Mercurial > dive4elements > river
changeset 2183:a79d5cd26083
Render labels of manual points in a very primitive manner.
flys-artifacts/trunk@3787 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 27 Jan 2012 11:01:13 +0000 |
parents | 5ff481ab24a1 |
children | fc86fcfe503e |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java |
diffstat | 4 files changed, 47 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 <felix.wolfsteller@intevation.de> + + 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 <felix.wolfsteller@intevation.de> + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + 2012-01-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> Refactored class hierachy to integrate model for W~W:
--- 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<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); + 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); } }
--- 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); }
--- 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<XYTextAnnotation> textAnnotations; + /** Annotations at axis. */ protected List<StickyAxisAnnotation> axisTextAnnotations; + /** Areas at axis. */ protected List<HYKFactory.Zone> boxes; + /** Styling information. */ protected Document theme; + /** Chart-legend information. */ protected String label; @@ -70,6 +74,11 @@ return axisTextAnnotations; } + public void setTextAnnotations(List<XYTextAnnotation> annotations) { + this.textAnnotations = annotations; + } + + /** Set the "other" Text Annotations. */ public List<XYTextAnnotation> getTextAnnotations() { return textAnnotations; }