# HG changeset patch # User Ingo Weinzierl # Date 1324974127 0 # Node ID f9a972d375ba21e48d8d7a6766f5dce7a12189c3 # Parent c7f18fa0d6856ac3d610916a4e61a8061c94fa04 Use the user defined font size to set Y axes label fonts sizes. flys-artifacts/trunk@3543 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c7f18fa0d685 -r f9a972d375ba flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Dec 27 08:04:12 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Dec 27 08:22:07 2011 +0000 @@ -1,3 +1,17 @@ +2011-12-27 Ingo Weinzierl + + * src/main/java/de/intevation/flys/exports/AxisSection.java: Added method + getFontSize() to retrieve the font size for an axis. + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java: + Modified createYAxis(int): call super.createYAxis(int) and adjust + necessary settings - no Axis creation takes place here. + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Added + getXAxisLabelFontSize() and getYAxisLabelFontSize(int) to retrieve the + user defined font size for an axis. The getYAxisLabelFontSize() is used in + createYAxis(int) to set the font size for axes labels. + 2011-12-27 Ingo Weinzierl * src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java: diff -r c7f18fa0d685 -r f9a972d375ba flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java Tue Dec 27 08:04:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java Tue Dec 27 08:22:07 2011 +0000 @@ -88,6 +88,12 @@ } + public Integer getFontSize() { + IntegerAttribute attr = (IntegerAttribute) getAttribute(FONTSIZE_ATTR); + return attr != null ? (Integer) attr.getValue() : null; + } + + public void setFixed(boolean fixed) { Attribute attr = getAttribute(FIXATION_ATTR); if (attr == null) { diff -r c7f18fa0d685 -r f9a972d375ba flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Dec 27 08:04:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Dec 27 08:22:07 2011 +0000 @@ -232,10 +232,8 @@ */ @Override protected NumberAxis createYAxis(int index) { - Font labelFont = new Font("Tahoma", Font.BOLD, 14); - String label = getYAxisLabel(index); + NumberAxis axis = super.createYAxis(index); - NumberAxis axis = createNumberAxis(index, label); // "Q" Axis shall include 0. if (index == YAXIS.Q.idx) { axis.setAutoRangeIncludesZero(true); @@ -243,7 +241,7 @@ else { axis.setAutoRangeIncludesZero(false); } - axis.setLabelFont(labelFont); + return axis; } diff -r c7f18fa0d685 -r f9a972d375ba flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Dec 27 08:04:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Dec 27 08:22:07 2011 +0000 @@ -2,6 +2,7 @@ import java.awt.BasicStroke; import java.awt.Color; +import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.awt.TexturePaint; @@ -172,8 +173,10 @@ /** The max Y range to include all Y values of all series for each axis. */ protected Map yRanges; - public static final Color DEFAULT_GRID_COLOR = Color.GRAY; - public static final float DEFAULT_GRID_LINE_WIDTH = 0.3f; + public static final Color DEFAULT_GRID_COLOR = Color.GRAY; + public static final float DEFAULT_GRID_LINE_WIDTH = 0.3f; + public static final int DEFAULT_FONT_SIZE = 12; + public static final String DEFAULT_FONT_NAME = "Tahoma"; public XYChartGenerator() { @@ -270,7 +273,7 @@ fontSize = getLegendFontSize(chartSettings); } - return fontSize != null ? fontSize : 12; + return fontSize != null ? fontSize : DEFAULT_FONT_SIZE; } @@ -354,6 +357,48 @@ /** + * This method returns the font size for the X axis. If the font size is + * specified in ChartSettings (if chartSettings is set), this size is + * returned. Otherwise the default font size 12 is returned. + * + * @return the font size for the x axis. + */ + protected int getXAxisLabelFontSize() { + ChartSettings chartSettings = getChartSettings(); + if (chartSettings == null) { + return DEFAULT_FONT_SIZE; + } + + AxisSection as = chartSettings.getAxisSection("X"); + Integer fontSize = as.getFontSize(); + + return fontSize != null ? fontSize : DEFAULT_FONT_SIZE; + } + + + /** + * This method returns the font size for an Y axis. If the font size is + * specified in ChartSettings (if chartSettings is set), this size is + * returned. Otherwise the default font size 12 is returned. + * + * @return the font size for the x axis. + */ + protected int getYAxisFontSize(int pos) { + ChartSettings chartSettings = getChartSettings(); + if (chartSettings == null) { + return DEFAULT_FONT_SIZE; + } + + YAxisWalker walker = getYAxisWalker(); + + AxisSection as = chartSettings.getAxisSection(walker.getId(pos)); + Integer fontSize = as.getFontSize(); + + return fontSize != null ? fontSize : DEFAULT_FONT_SIZE; + } + + + /** * Generate chart. */ public void generate() @@ -631,11 +676,18 @@ protected NumberAxis createYAxis(int index) { YAxisWalker walker = getYAxisWalker(); + Font labelFont = new Font( + DEFAULT_FONT_NAME, + Font.BOLD, + getYAxisFontSize(index)); + IdentifiableNumberAxis axis = new IdentifiableNumberAxis( walker.getId(index), getYAxisLabel(index)); axis.setAutoRangeIncludesZero(false); + axis.setLabelFont(labelFont); + return axis; }