[Schmitzm-commits] r1966 - in trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling: . chartsymbols
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Apr 25 16:50:39 CEST 2012
Author: alfonx
Date: 2012-04-25 16:50:39 +0200 (Wed, 25 Apr 2012)
New Revision: 1966
Modified:
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java
Log:
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java 2012-04-25 14:07:58 UTC (rev 1965)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java 2012-04-25 14:50:39 UTC (rev 1966)
@@ -1087,22 +1087,31 @@
pointSymbolizer.getGraphic());
{
- // One bigger Icon to span over both columns
Symbolizer fixSymbolizer = ChartGraphic
.getFixDataLegendSymbolizer(pointSymbolizer);
+
+ // TODO https://trac.wikisquare.de/gp/ticket/79
+ fixSymbolizer = ChartGraphic
+ .addLegendLabels(fixSymbolizer);
+
SimpleFeatureType ftpoint = FeatureUtil
.createFeatureType(Point.class);
+
+ int chartLegendIconSize = 80; // pointSymbolizer.getGraphic().getSize().toString() ?
final BufferedImage chartImage = LegendIconFeatureRenderer
.getInstance().createImageForSymbolizer(
fixSymbolizer, ftpoint,
- new Dimension(80, 80));
+ new Dimension(chartLegendIconSize, chartLegendIconSize));
final JLabel iconLabel = new JLabel(new ImageIcon(
chartImage));
+
+ // One bigger Icon to span over both columns
panel.add(iconLabel, "span 2");
}
+ // Create a label for every attribute used..
for (String attName : cg.getAttributes()) {
final BufferedImage imageChartData = new BufferedImage(
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java 2012-04-25 14:07:58 UTC (rev 1965)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java 2012-04-25 14:50:39 UTC (rev 1966)
@@ -511,4 +511,51 @@
private Integer imageWidth;
private Integer imageHeight;
+
+ /**
+ * The Chart-URL is extendend to show a number on the Y-Axis or X-Axis
+ * (depending whether the chart is Horizontal or Vertical)
+ *
+ * https://trac.wikisquare.de/gp/ticket/79
+ */
+ public static Symbolizer addLegendLabels(Symbolizer symbolizer) {
+
+ DuplicatingStyleVisitor visitor = new DuplicatingStyleVisitor() {
+ @Override
+ protected ExternalGraphic copy(ExternalGraphic eg) {
+ // https://trac.wikisquare.de/gp/ticket/79
+
+ String url2;
+ try {
+ url2 = eg.getLocation().toString();
+
+ // chxt=x,y,r,x
+ // chxl=0:|0|55|110|
+
+ // TODO Bei vertical und horizontal anders, TODO Nur bei
+ // BAR?!
+ // url2 += "&chxt=x";
+ // Label an Axis style:
+ url2 += "&chxs=0,ff0000,12,1,lt";
+ // Which Axis to show
+ url2 += "&chxt=y";
+ url2 += "&chdlp=t|t";
+ // Which Labels to show:
+ url2 += "&chxl=0:|0|20|111|";
+ url2 += "&chma=30,30,30,30";
+
+ ExternalGraphic externalGraphic2 = StylingUtil.STYLE_BUILDER
+ .createExternalGraphic(url2, eg.getFormat());
+
+ return externalGraphic2;
+ } catch (Exception e) {
+ Logger.getLogger(ChartGraphicPreviewFixStyleVisitor.class)
+ .error(e, e);
+ return eg;
+ }
+ }
+ };
+ symbolizer.accept(visitor);
+ return (Symbolizer) visitor.getCopy();
+ }
}
More information about the Schmitzm-commits
mailing list