# HG changeset patch # User Felix Wolfsteller # Date 1342550425 0 # Node ID 2a8919e0ed28709b46ad0f7e460119358f31723e # Parent f091f2f55f88e1d10d70ab6f763e6ea0df2482af Cosmetics, doc. flys-artifacts/trunk@5025 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Jul 17 18:40:25 2012 +0000 @@ -1,3 +1,32 @@ +2012-07-17 Felix Wolfsteller + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java, + src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java, + src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java, + src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java, + src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java, + src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java, + src/main/java/de/intevation/flys/collections/CollectionAttribute.java: + Cosmetics, doc. + +2012-07-17 Felix Wolfsteller + + Partial implementation of issue720 (bandwith for curves), in + longitudinal section ws only, no styling, integer-based. + + * doc/conf/default-themes.xml: Add bandwidth to fields of longitudinal + section facets. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java: Add bandwidth + theme parsing. + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java: + If bandwidth is set, add an area data series with datapoints + above/under the actual data points. + + * src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java: + Helper for adding points with offset. + 2012-07-17 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java: diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java Tue Jul 17 18:40:25 2012 +0000 @@ -23,12 +23,12 @@ import de.intevation.artifactdatabase.state.Settings; +/** Create attribute part of collection document. */ public class CollectionAttribute { private static final Logger logger = Logger.getLogger(CollectionAttribute.class); - protected ElementCreator ec; protected Map outputMap; diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Jul 17 18:40:25 2012 +0000 @@ -430,15 +430,18 @@ XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); StyledSeriesBuilder.addPoints(series, wkms); - XYSeries seriesDown = new StyledXYSeries(aandf.getFacetDescription()+"-",false, theme); - XYSeries seriesUp = new StyledXYSeries(aandf.getFacetDescription()+"+",false, theme); - StyledSeriesBuilder.addUpperBand(seriesUp, wkms, 5d); - StyledSeriesBuilder.addLowerBand(seriesDown, wkms, 5d); - addAxisSeries(series, YAXIS.W.idx, visible); + // If a "band around the curve shall be drawn, add according area. int bandWidth = ThemeUtil.parseBandWidth(theme); if (bandWidth > 0 ) { + XYSeries seriesDown = new StyledXYSeries( + "band " + aandf.getFacetDescription(), false, theme); + XYSeries seriesUp = new StyledXYSeries( + aandf.getFacetDescription()+"-", false, theme); + StyledSeriesBuilder.addUpperBand(seriesUp, wkms, 5d); + StyledSeriesBuilder.addLowerBand(seriesDown, wkms, 5d); + StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); area.addSeries(seriesUp); area.addSeries(seriesDown); @@ -446,7 +449,6 @@ addAreaSeries(area, YAXIS.W.idx, visible); } - if (needInvertAxis(wkms)) { setInverted(true); } diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java Tue Jul 17 18:40:25 2012 +0000 @@ -74,6 +74,13 @@ } } + + /** + * Add points to dataset with an offset (shift all points by given amount). + * @param series series to add data to. + * @param wkms WKms of which the Ws will be shifted. + * @param off the offset. + */ public static void addUpperBand(XYSeries series, WKms wkms, double off) { if (wkms == null) { return; @@ -86,10 +93,19 @@ } } + + /** + * Add points to dataset with an offset (shift all points 'down' by given + * amount). + * @param series series to add data to. + * @param wkms WKms of which the Ws will be shifted. + * @param off the offset. + */ public static void addLowerBand(XYSeries series, WKms wkms, double off) { addUpperBand(series, wkms, -off); } + /** * Add points to series (km to 1st dim, q to 2nd dim). * diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Tue Jul 17 18:40:25 2012 +0000 @@ -123,6 +123,7 @@ } + /** Get fill paint for the maximum indicators. */ public Paint getMaximumFillPaint(int series, int column) { Paint p = getItemPaint(series, column); @@ -142,6 +143,7 @@ } + /** Get fill paint for the minimum indicators. */ public Paint getMinimumFillPaint(int series, int column) { Paint p = getItemPaint(series, column); @@ -274,14 +276,17 @@ yy = transX1; } - // draw the item label if there is one... + // Draw the item label if there is one... if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); } // Draw label of line. - if (dataset instanceof XYSeriesCollection && isShowLineLabel(series) && isMinimumX (dataset, series, item)) { + if (dataset instanceof XYSeriesCollection + && isShowLineLabel(series) + && isMinimumX (dataset, series, item) + ) { XYSeries xYSeries = ((XYSeriesCollection) dataset).getSeries(series); String waterlevelLabel = (xYSeries instanceof HasLabel) ? ((HasLabel)xYSeries).getLabel() @@ -297,9 +302,11 @@ // Move to right until no collisions exist anymore Shape hotspot = TextUtilities.calculateRotatedStringBounds( - waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT, + waterlevelLabel, g2, (float)xx, (float)yy-3f, + TextAnchor.CENTER_LEFT, 0f, TextAnchor.CENTER_LEFT); - while (JFreeUtil.collides(hotspot, entities, CollisionFreeLineLabelEntity.class)) { + while (JFreeUtil.collides(hotspot, entities, + CollisionFreeLineLabelEntity.class)) { xx += 5f; hotspot = TextUtilities.calculateRotatedStringBounds( waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT, @@ -327,7 +334,7 @@ updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); - // add an entity for the item, but only if it falls within the data + // Add an entity for the item, but only if it falls within the data // area... if (entities != null && isPointInRect(dataArea, xx, yy)) { addEntity(entities, entityArea, dataset, series, item, xx, yy); @@ -343,6 +350,9 @@ } + /** + * Whether or not the minimum should be rendered with shape. + */ public boolean isMinimumShapeVisible(int series) { if (this.isMinimumShapeVisible.size() <= series) { return false; @@ -352,11 +362,17 @@ } + /** + * Sets whether or not the maximum should be rendered with shape. + */ public void setIsMaximumShapeVisible(int series, boolean isVisible) { this.isMaximumShapeVisible.setBoolean(series, isVisible); } + /** + * Whether or not the maximum should be rendered with shape. + */ public boolean isMaximumShapeVisible(int series) { if (this.isMaximumShapeVisible.size() <= series) { return false; @@ -380,6 +396,7 @@ this.showLineLabel.setBoolean(series, showLineLabel); } + /** Whether or not a label should be shown for series. */ public boolean isShowLineLabelBG(int series) { if (this.showLineLabelBG.size() <= series) { @@ -389,6 +406,7 @@ return showLineLabelBG.getBoolean(series); } + public void setShowLineLabelBG(int series, boolean doShow) { this.showLineLabelBG.setBoolean(series, doShow); } diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java Tue Jul 17 18:40:25 2012 +0000 @@ -502,7 +502,7 @@ * The renderer can do nothing if it chooses. * * @param g2 the graphics device. - * @param dataArea the area inside the axes. + * @param dataArea the (visible) area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to @@ -532,6 +532,10 @@ return 2; } + + /** + * Adds x/y data to series. + */ private static final void addSeries( DefaultXYDataset ds, Comparable key, @@ -830,6 +834,7 @@ } } + /** * Draws the visual representation of a single data item. * diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java Tue Jul 17 18:40:25 2012 +0000 @@ -58,6 +58,8 @@ /** * Applies line color, size and type attributes to renderer, also * whether to draw lines and/or points. + * @param renderer Renderer to apply theme to. + * @return \param renderer */ public StableXYDifferenceRenderer applyTheme( StableXYDifferenceRenderer renderer @@ -117,14 +119,13 @@ renderer.setDrawOutline(show); } + protected void applyShowLine(StableXYDifferenceRenderer renderer) { boolean show = ThemeUtil.parseShowLine(theme); renderer.setShapesVisible(show); } - /** - * - */ + protected void applyOutlineColor(StableXYDifferenceRenderer renderer) { Color c = ThemeUtil.parseLineColorField(theme); renderer.setOutlinePaint(c); diff -r f091f2f55f88 -r 2a8919e0ed28 flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue Jul 17 18:31:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue Jul 17 18:40:25 2012 +0000 @@ -134,6 +134,7 @@ public final static String XPATH_WSPLGEN_FIELDS = "/theme[@name='WSPLGEN']/field"; + /** XPATH to bandwidth field. */ public final static String XPATH_BANDWIDTH = "/theme/field[@name='bandwidth']/@default"; @@ -191,12 +192,17 @@ } + /** + * Parse band width, defaulting to 0. + * @param theme the theme. + */ public static int parseBandWidth(Document theme) { String bandWidth = XMLUtils.xpathString(theme, XPATH_BANDWIDTH, null); return parseInteger(bandWidth, 0); } + public static int parsePointWidth(Document theme) { String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null);