# HG changeset patch # User Felix Wolfsteller # Date 1327662073 0 # Node ID a79d5cd26083ab9bc1df2e2c4cceb9541efa2068 # Parent 5ff481ab24a1694d372d1589c6e637eb47a859e7 Render labels of manual points in a very primitive manner. flys-artifacts/trunk@3787 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5ff481ab24a1 -r a79d5cd26083 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jan 27 10:45:34 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jan 27 11:01:13 2012 +0000 @@ -1,3 +1,20 @@ +2012-01-27 Felix Wolfsteller + + Blindly render Text of manual points if it does not collide with + other text. + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java, + src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Handle TextAnnotations, create some for manual points. + + * src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java: + Added setter for TextAnnotations, documentation. + +2012-01-27 Felix Wolfsteller + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + 2012-01-27 Sascha L. Teichmann Refactored class hierachy to integrate model for W~W: diff -r 5ff481ab24a1 -r a79d5cd26083 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Fri Jan 27 10:45:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Fri Jan 27 11:01:13 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.exports; +import java.util.ArrayList; +import java.util.List; import org.apache.log4j.Logger; @@ -12,6 +14,8 @@ import org.w3c.dom.Document; +import org.jfree.chart.annotations.XYTextAnnotation; + import de.intevation.artifactdatabase.state.ArtifactAndFacet; import de.intevation.artifactdatabase.state.Facet; @@ -22,6 +26,7 @@ import de.intevation.flys.artifacts.model.WKms; import de.intevation.flys.artifacts.model.WQKms; +import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; import de.intevation.flys.jfree.FLYSAnnotation; import de.intevation.flys.jfree.StyledAreaSeriesCollection; import de.intevation.flys.jfree.StyledXYSeries; @@ -632,20 +637,29 @@ ) { XYSeries series = new StyledXYSeries(seriesName, theme); + // Add text annotations for single points. + List xy = new ArrayList(); + try { JSONArray points = new JSONArray((String) o); for (int i = 0; i < points.length(); i++) { JSONArray array = points.getJSONArray(i); - double x = array.getDouble(0); - double y = array.getDouble(1); + double x = array.getDouble(0); + double y = array.getDouble(1); + String name = array.getString(2); //logger.debug(" x " + x + " y " + y ); series.add(x, y, false); + xy.add(new CollisionFreeXYTextAnnotation(name, x, y)); } } catch(JSONException e){ logger.error("Could not decode json."); } + + FLYSAnnotation annotations = new FLYSAnnotation(seriesName, null, null, theme); + annotations.setTextAnnotations(xy); + doAnnotations(annotations, null, theme, visible); addAxisSeries(series, YAXIS.W.idx, visible); } } diff -r 5ff481ab24a1 -r a79d5cd26083 flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Jan 27 10:45:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Jan 27 11:01:13 2012 +0000 @@ -1182,9 +1182,9 @@ addStickyAnnotation(sta, plot, area, lineStyle, textStyle); } - // The not yet implemented other Text Annotations. + // Other Text Annotations. for (XYTextAnnotation ta: fa.getTextAnnotations()) { - // TODO implement, one we have textannotations + plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND); } // Hyks. @@ -1460,7 +1460,8 @@ // Add all annotations to our annotation pool. annotations.setTheme(theme); - annotations.setLabel(facet.getDescription()); + if (facet != null) + annotations.setLabel(facet.getDescription()); addAnnotations(annotations, visible); } diff -r 5ff481ab24a1 -r a79d5cd26083 flys-artifacts/src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java Fri Jan 27 10:45:34 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java Fri Jan 27 11:01:13 2012 +0000 @@ -17,15 +17,19 @@ */ public class FLYSAnnotation { - // TODO this will likely be used, soon. + /* 'Other' Text Annotations. */ protected List textAnnotations; + /** Annotations at axis. */ protected List axisTextAnnotations; + /** Areas at axis. */ protected List boxes; + /** Styling information. */ protected Document theme; + /** Chart-legend information. */ protected String label; @@ -70,6 +74,11 @@ return axisTextAnnotations; } + public void setTextAnnotations(List annotations) { + this.textAnnotations = annotations; + } + + /** Set the "other" Text Annotations. */ public List getTextAnnotations() { return textAnnotations; }