[Schmitzm-commits] r1967 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 25 17:45:57 CEST 2012


Author: alfonx
Date: 2012-04-25 17:45:57 +0200 (Wed, 25 Apr 2012)
New Revision: 1967

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
Log:
https://trac.wikisquare.de/gp/ticket/65 (Beim ?\195?\182ffnen der Legende
einer Karte werden alle Styles aufgelistet, nicht die f?\195?\188r die
zoomstufe relevanten)

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:50:39 UTC (rev 1966)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2012-04-25 15:45:57 UTC (rev 1967)
@@ -1002,11 +1002,13 @@
 	 *            <code>null</code> of a Scale Denominator to determine whether
 	 *            a Rule is actually visible in that scale.
 	 * 
-	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
+	 * @param amds
+	 *            <code>null</code> oder eine Liste von Attribut-Informationen
 	 */
 	public static JPanel createLegendSwingPanel(Style style,
 			final SimpleFeatureType featureType, final int iconWidth,
-			final int iconHeight, Double scaleDenominator) {
+			final int iconHeight, Double scaleDenominator,
+			AttributeMetadataMap<AttributeMetadataInterface> amds) {
 
 		if (featureType == null) {
 			ExceptionDialog.show(new IllegalStateException(
@@ -1089,24 +1091,26 @@
 					{
 						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() ?
+
+						int chartLegendIconSize = 80; // pointSymbolizer.getGraphic().getSize().toString()
+														// ?
 						final BufferedImage chartImage = LegendIconFeatureRenderer
 								.getInstance().createImageForSymbolizer(
-										fixSymbolizer, ftpoint,
-										new Dimension(chartLegendIconSize, chartLegendIconSize));
+										fixSymbolizer,
+										ftpoint,
+										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");
 					}
@@ -1114,6 +1118,18 @@
 					// Create a label for every attribute used..
 					for (String attName : cg.getAttributes()) {
 
+						// Schauen, ob es eine übersetzung für den
+						// Spaltennamen/Attributnamen gibt
+						String attLabel = attName;
+
+						if (amds != null && amds.get(attName) != null) {
+							if (amds.get(attName).getTitle() != null) {
+								// Übersetzung zur aktuiellen Sprache
+								attLabel = amds.get(attName).getTitle()
+										.toString();
+							}
+						}
+
 						final BufferedImage imageChartData = new BufferedImage(
 								iconWidth, (int) (iconHeight * 0.8),
 								BufferedImage.TYPE_INT_ARGB);
@@ -1122,7 +1138,7 @@
 						g2.fillRect(0, 0, iconWidth, (int) (iconHeight * 0.8));
 						g2.dispose();
 
-						addRowToPanel(panel, imageChartData, attName);
+						addRowToPanel(panel, imageChartData, attLabel);
 					}
 
 				} else {
@@ -1135,6 +1151,7 @@
 							.getInstance().createImageForRule(rule,
 									featureType,
 									new Dimension(iconWidth, iconHeight));
+
 					String descriptionTitle = GTUtil.descriptionTitle(rule
 							.getDescription());
 
@@ -1825,6 +1842,9 @@
 	public static boolean hasScalechangeAnyEffect(Style style,
 			double oldScaleDenominator, double newScaleDenominator) {
 
+		if (oldScaleDenominator == 0 || newScaleDenominator == 0)
+			return true;
+
 		for (FeatureTypeStyle fts : style.featureTypeStyles()) {
 			for (Rule r : fts.rules()) {
 				double minScale = r.getMinScaleDenominator();



More information about the Schmitzm-commits mailing list