Skip to content

Commit

Permalink
Merge pull request #267 from softwaremagico/265-show-competitor-numer…
Browse files Browse the repository at this point in the history
…ical-order-on-classification-pdf

Added order
  • Loading branch information
softwaremagico authored Nov 17, 2023
2 parents ebfe92f + e7f8125 commit 104e36b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager)
[![Time](https://img.shields.io/badge/development-519h-blueviolet.svg)]()
[![Time](https://img.shields.io/badge/development-519.5h-blueviolet.svg)]()

[![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]()
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

import java.awt.Color;
import java.awt.*;

public abstract class ParentList extends PdfDocument {

protected static final float MIN_HEADER_HIGH = 50f;
protected static final int FOOTER_BORDER = 0;
protected static final int HEADER_BORDER = 0;
protected static final int CELL_BORDER = 0;
Expand Down Expand Up @@ -269,7 +271,6 @@ public void createContent(Document document, PdfWriter writer) throws EmptyPdfBo
PdfTheme.HEADER_FONT_SIZE);
createFooterRow(document, mainTable, document.getPageSize().getWidth(), document.getPageSize().getHeight(), writer, PdfTheme.getBasicFont(),
PdfTheme.FOOTER_FONT_SIZE);
createRowSeparator(mainTable);
createBodyRows(document, mainTable, document.getPageSize().getWidth(), document.getPageSize().getHeight(), writer, PdfTheme.getBasicFont(),
PdfTheme.FONT_SIZE);
createRowSeparator(mainTable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public PdfController(MessageSource messageSource, RoleController roleController,
}

public CompetitorsScoreList generateCompetitorsScoreList(Locale locale, TournamentDTO tournament, List<ScoreOfCompetitorDTO> competitorTopTen) {
return new CompetitorsScoreList(messageSource, locale, tournament, competitorTopTen);
return new CompetitorsScoreList(messageSource, locale, tournament, competitorTopTen, true);
}

public TeamsScoreList generateTeamsScoreList(Locale locale, TournamentDTO tournament, List<ScoreOfTeamDTO> teamsTopTen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import com.softwaremagico.kt.pdf.PdfTheme;

public class FooterEvent extends PdfPageEventHelper {
private static final int BOTTOM_MARGIN = 20;
private static final int BOTTOM_MARGIN = 0;

/**
* Adds a footer to every page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@
* Creates a sheet with the competitors ranking depending on the performance on the tournament.
*/
public class CompetitorsScoreList extends ParentList {

private static final float[] TABLE_WIDTH = {0.50f, 0.20f, 0.20f, 0.20f};
private static final float[] TABLE_WIDTH_WITH_CLASSIFICATION = {0.10f, 0.50f, 0.20f, 0.20f, 0.20f};
private final List<ScoreOfCompetitorDTO> competitorTopTen;
private final TournamentDTO tournament;
private final MessageSource messageSource;
private final Locale locale;

public CompetitorsScoreList(MessageSource messageSource, Locale locale, TournamentDTO tournament, List<ScoreOfCompetitorDTO> competitorTopTen) {
private final boolean showClassificationOrder;

public CompetitorsScoreList(MessageSource messageSource, Locale locale, TournamentDTO tournament, List<ScoreOfCompetitorDTO> competitorTopTen,
boolean showClassificationOrder) {
this.tournament = tournament;
this.competitorTopTen = competitorTopTen;
this.messageSource = messageSource;
this.locale = locale;
this.showClassificationOrder = showClassificationOrder;
}

@Override
Expand All @@ -78,13 +84,17 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setColspan(getTableWidths().length);
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

@Override
public void createBodyRows(Document document, PdfPTable mainTable, float width, float height, PdfWriter writer,
BaseFont font, int fontSize) {

if (showClassificationOrder) {
mainTable.addCell(getCell("", PdfTheme.getBasicFont(), 0, Element.ALIGN_CENTER, Font.BOLD));
}
mainTable.addCell(getCell(messageSource.getMessage("classification.competitors.competitor.name", null, locale),
PdfTheme.getBasicFont(), 0, Element.ALIGN_CENTER, Font.BOLD));
mainTable.addCell(getCell(messageSource.getMessage("classification.competitors.duels.won", null, locale),
Expand All @@ -94,7 +104,12 @@ public void createBodyRows(Document document, PdfPTable mainTable, float width,
mainTable.addCell(getCell(messageSource.getMessage("classification.competitors.fights", null, locale),
PdfTheme.getBasicFont(), 0, Element.ALIGN_CENTER, Font.BOLD));

int counter = 1;
for (final ScoreOfCompetitorDTO scoreOfCompetitor : competitorTopTen) {
if (showClassificationOrder) {
mainTable.addCell(getCell(String.valueOf(counter), PdfTheme.getHandwrittenFont(), 1, Element.ALIGN_LEFT));
counter++;
}
mainTable.addCell(getCell(NameUtils.getLastnameName(scoreOfCompetitor.getCompetitor()), PdfTheme.getHandwrittenFont(), 1, Element.ALIGN_CENTER));
mainTable.addCell(getCell(scoreOfCompetitor.getWonDuels() + (scoreOfCompetitor.getUntieDuels() > 0 ? "*" : "") + "/"
+ scoreOfCompetitor.getDrawDuels(), PdfTheme.getHandwrittenFont(), 1, Element.ALIGN_CENTER));
Expand All @@ -112,6 +127,9 @@ public void createFooterRow(Document document, PdfPTable mainTable, float width,

@Override
public float[] getTableWidths() {
if (showClassificationOrder) {
return TABLE_WIDTH_WITH_CLASSIFICATION;
}
return TABLE_WIDTH;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setColspan(getTableWidths().length);
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public void createHeaderRow(Document document, PdfPTable mainTable, float width,
cell.setColspan(getTableWidths().length);
cell.setBorderWidth(HEADER_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setMinimumHeight(MIN_HEADER_HIGH);
mainTable.addCell(cell);
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/views/club-list/club-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class ClubListComponent extends RbacBasedComponent implements OnInit {

showAllElements(): void {
this.clubService.getAll().subscribe((clubs: Club[]): void => {
clubs.sort((a: Club, b: Club) => a.name.localeCompare(b.name));
this.basicTableData.dataSource.data = clubs;
});
}
Expand Down

0 comments on commit 104e36b

Please sign in to comment.