GanttChartXLabelBarRenderer.javaprojectforge-business/src/main/java/org/projectforge/business/gantt/GanttChartXLabelBarRenderer.java contenant le code Java pour la couche du diagramme de Gantt.Paquetage : org.projectforge.business.gantt
Classes : GanttChartXLabelBarRenderer
Méthodes (7) : init, getScale, draw, showNonWorkingDays, match, getXValue, getFromToDays
Champs (6) : MIN_PIXEL_PER_UNIT, showNonWorkingDays, fromDate, toDate, diagramWidth, style
Importations : 11 paquetages
package org.projectforge.business.gantt;
import org.projectforge.export.SVGColor;
import org.projectforge.export.SVGHelper;
import org.projectforge.framework.calendar.Holidays;
import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext;
import org.projectforge.framework.time.DateTimeFormatter;
import org.projectforge.framework.time.PFDateTime;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.time.LocalDate;
import java.time.Month;
import java.util.Date;
public class GanttChartXLabelBarRenderer
{
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(GanttChartXLabelBarRenderer.class);
private static final double MIN_PIXEL_PER_UNIT = 10.0;
private static final int[] QUARTER_SCALES = { 1, 2, 4, 8, 12};
private static final int[] MONTH_SCALES = { 1, 2, 3, 6, 12, 24, 36, 48, 60};
private static final int[] SCALES = { 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000};
GanttXUnit labelUnit;
int labelScale;
// Graduations avec étiquettes
GanttXUnit ticksUnit;
int ticksScale;
// Petites graduations
GanttXUnit ticksUnit2;
int ticksScale2;
GanttXUnit gridUnit;
int gridScale;
String label;
private boolean showNonWorkingDays;
private LocalDate fromDate;
private LocalDate toDate;
int fromToDays = -1;
private double diagramWidth;
private GanttChartStyle style;
public GanttChartXLabelBarRenderer(final LocalDate fromDate, final LocalDate toDate, final double diagramWidth, final GanttChartStyle style)
{
this.fromDate = fromDate;
this.toDate = toDate;
this.diagramWidth = diagramWidth;
this.style = style;
this.gridScale = style.getXGridScale();
init();
}
private void init()
{
final int numberOfDays = getFromToDays(); // Initialise fromToDays.
final double numberOfWeeks = 0.25 * numberOfDays;
final double numberOfMonths = 0.033 * numberOfDays;
final double numberOfQuarters = numberOfMonths / 3;
if (this.style.getXUnit() == GanttXUnit.AUTO) {
if (diagramWidth / numberOfDays > MIN_PIXEL_PER_UNIT) {
labelUnit = GanttXUnit.DAY;
ticksUnit = GanttXUnit.DAY;
ticksUnit2 = GanttXUnit.DAY;
} else if (diagramWidth / numberOfWeeks > MIN_PIXEL_PER_UNIT) {
labelUnit = GanttXUnit.WEEK;
ticksUnit = GanttXUnit.WEEK;
ticksUnit2 = GanttXUnit.DAY;
} else if (diagramWidth / numberOfMonths > MIN_PIXEL_PER_UNIT) {
labelUnit = GanttXUnit.MONTH;
ticksUnit = GanttXUnit.MONTH;
ticksUnit2 = GanttXUnit.WEEK;
} else {
labelUnit = GanttXUnit.QUARTER;
ticksUnit = GanttXUnit.MONTH;
ticksUnit2 = GanttXUnit.WEEK;
}
}
this.gridUnit = ticksUnit;
double numberOfUnits;
if (labelUnit == GanttXUnit.DAY) {
numberOfUnits = (double) numberOfDays;
} else if (labelUnit == GanttXUnit.WEEK) {
numberOfUnits = numberOfWeeks;
} else if (labelUnit == GanttXUnit.MONTH) {
numberOfUnits = numberOfMonths;
} else {
numberOfUnits = numberOfQuarters;
}
labelScale = style.getXLabelsScale();
ticksScale = style.getXTicksScale();
ticksScale2 = style.getXTicksScale2();
if (labelUnit == GanttXUnit.QUARTER) {
if (labelScale < 0) {
if (style.isRelativeTimeValues()) {
// Les nombres nécessitent moins d'espace que les étiquettes de trimestre (03/2010)
labelScale = getScale(numberOfQuarters, 50, labelUnit);
} else {
labelScale = getScale(numberOfQuarters, 100, labelUnit);
}
}
if (ticksScale < 0) {
// ... (tronqué, 358 lignes au total)
868d6abb7 2025 -> 2026 63081666f En-têtes des fichiers sources : 2024 -> 2025. b6092df09 Copyright 2023 -> 2024 ab45d51fa Copyright 2001-2022 -> 2001-2023. 5f7ef41b8 Copyright 2021 -> 2022