Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2152:2336927cb096
Add basic (text) styling for HYKS.
flys-artifacts/trunk@3734 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 20 Jan 2012 08:38:50 +0000 |
parents | c5d24e0587ce |
children | c68f4f227c09 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Jan 20 08:35:03 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Jan 20 08:38:50 2012 +0000 @@ -1029,9 +1029,11 @@ plot.setFixedLegendItems(old); } + /** * Get "lowest" Y Value for first axis. This value is exactly at the * border of the plot. + * @return lowest value on first 'y'-axis. */ protected double getLowestYValue(XYPlot plot) { ValueAxis yaxis = plot.getRangeAxis(0); @@ -1045,6 +1047,7 @@ /** * Get "lowest" Y Value for first axis. This value is exactly at the * border of the plot. + * @return highest value on first 'y'-axis. */ protected double getUppestYValue(XYPlot plot) { ValueAxis yaxis = plot.getRangeAxis(0); @@ -1090,19 +1093,32 @@ return; } + // Paints for the boxes/lines. Stroke basicStroke = new BasicStroke(1.0f); Paint linePaint = new Color(255,0,0,60); Paint fillPaint = new Color(0,255,0,60); Paint tranPaint = new Color(0,0,0,0); + // Pre-calculated positions on y axis. double fillPercent = 0.03; double low = getLowestYValue(plot); double up = getUppestYValue(plot); double upb = low + (up - low) * fillPercent; double upt = low + (up - low) * fillPercent/2.0d; + for (FLYSAnnotation fa: annotations) { + // Access text styling, if any. + Document theme = fa.getTheme(); + ThemeAccess.TextStyle textStyle = null; + if (theme != null) { + ThemeAccess themeAccess = new ThemeAccess(theme); + textStyle = themeAccess.parseTextStyle(); + } + + // For each zone, create a box to fill with color, a box to draw + // the lines and a text to display the type. for (HYKFactory.Zone zone: fa.getBoxes()) { fillPaint = colorForHYKZone(zone.getName()); @@ -1111,10 +1127,12 @@ XYBoxAnnotation boxB = new XYBoxAnnotation(zone.getFrom(), low, zone.getTo(), up, basicStroke, fillPaint, tranPaint); - // TODO style text XYTextAnnotation tex = new XYTextAnnotation(zone.getName(), zone.getFrom() + (zone.getTo() - zone.getFrom()) / 2.0d, upt); + if (textStyle != null) { + textStyle.apply(tex); + } plot.getRenderer().addAnnotation(boxA); plot.getRenderer().addAnnotation(boxB); @@ -1123,6 +1141,7 @@ } } + /** * Adjusts the axes of a plot. This method sets the <i>labelFont</i> of the * X axis.