/[schmitzm]/trunk/src/skrueger/geotools/StyledLayerUtil.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/StyledLayerUtil.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1228 by alfonx, Wed Nov 3 20:44:16 2010 UTC revision 1273 by alfonx, Mon Nov 15 16:22:47 2010 UTC
# Line 45  import java.io.FileWriter; Line 45  import java.io.FileWriter;
45  import java.net.URL;  import java.net.URL;
46  import java.text.DecimalFormat;  import java.text.DecimalFormat;
47  import java.util.ArrayList;  import java.util.ArrayList;
48    import java.util.Collections;
49  import java.util.List;  import java.util.List;
50  import java.util.Map;  import java.util.Map;
51  import java.util.Set;  import java.util.Set;
# Line 84  import org.opengis.feature.simple.Simple Line 85  import org.opengis.feature.simple.Simple
85  import org.opengis.feature.type.AttributeDescriptor;  import org.opengis.feature.type.AttributeDescriptor;
86  import org.opengis.feature.type.GeometryDescriptor;  import org.opengis.feature.type.GeometryDescriptor;
87  import org.opengis.feature.type.Name;  import org.opengis.feature.type.Name;
88    import org.opengis.filter.FilterFactory2;
89  import org.opengis.parameter.GeneralParameterValue;  import org.opengis.parameter.GeneralParameterValue;
90    
91    import schmitzm.geotools.FilterUtil;
92  import schmitzm.geotools.JTSUtil;  import schmitzm.geotools.JTSUtil;
93  import schmitzm.geotools.feature.FeatureUtil;  import schmitzm.geotools.feature.FeatureUtil;
94  import schmitzm.geotools.styling.StylingUtil;  import schmitzm.geotools.styling.StylingUtil;
# Line 115  public class StyledLayerUtil { Line 118  public class StyledLayerUtil {
118          private static final SAXBuilder SAX_BUILDER = new SAXBuilder();          private static final SAXBuilder SAX_BUILDER = new SAXBuilder();
119          private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();          private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();
120    
121            /**
122             * Is appended to the name of a rule, this rule shall not be shown in the
123             * legend
124             */
125            public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND";
126    
127          /** URL for Atlas XML schema */          /** URL for Atlas XML schema */
128          public static final String AMLURI = "http://www.wikisquare.de/AtlasML";          public static final String AMLURI = "http://www.wikisquare.de/AtlasML";
129          /** Name of the XML Element for the attribute meta data map */          /** Name of the XML Element for the attribute meta data map */
# Line 127  public class StyledLayerUtil { Line 136  public class StyledLayerUtil {
136          public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem";          public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem";
137          /** Name of the XML Element for a translation */          /** Name of the XML Element for a translation */
138          public static final String ELEM_NAME_TRANSLATION = "translation";          public static final String ELEM_NAME_TRANSLATION = "translation";
139            private static FilterFactory2 ff = FilterUtil.FILTER_FAC2;
140    
141          /**          /**
142           * Creates a Geotools {@link MapLayer} from an object. If the object is a           * Creates a Geotools {@link MapLayer} from an object. If the object is a
# Line 925  public class StyledLayerUtil { Line 935  public class StyledLayerUtil {
935          }          }
936    
937          /**          /**
          * *If appended to the name of a rule, this rule shall not be shown in the  
          * legend  
          */  
         public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND";  
   
         /**  
938           * Creates a {@link JPanel} that shows a legend for a list of           * Creates a {@link JPanel} that shows a legend for a list of
939           * {@link FeatureTypeStyle}s and a targeted featureType           * {@link FeatureTypeStyle}s and a targeted featureType
940           *           *
941           * @param style           * @param style
942           *            The Style to presented in this legend           *            The Style to presented in this legend
943           * @param featureType           * @param featureType
944           *            If this a legend for Point, Polygon or Line?           *            If this a legend for Point, Polygon or Line? Or ANY or NONE?
945           *           *
946           * @author <a href="mailto:[email protected]">Stefan Alfons Tzeggai</a>           * @author <a href="mailto:[email protected]">Stefan Alfons Tzeggai</a>
947           */           */
948          public static JPanel createLegendSwingPanel(Style style,          public static JPanel createLegendSwingPanel(Style style,
949                          final SimpleFeatureType featureType, final int iconWidth,                          final SimpleFeatureType featureType, final int iconWidth,
# Line 951  public class StyledLayerUtil { Line 955  public class StyledLayerUtil {
955                          return new JPanel();                          return new JPanel();
956                  }                  }
957    
                 final List<FeatureTypeStyle> list = style.featureTypeStyles();  
   
958                  final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]"));                  final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]"));
   
959                  if (style == null) {                  if (style == null) {
960                          // No Style => no legend                          // No Style => no legend
961                          return panel;                          return panel;
962                  }                  }
963    
964                  for (final FeatureTypeStyle ftStyle : list) {                  // Reversing the list, because a point that is painted above a polygon
965                    // should be higher in the list.
966                    final List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
967                    Collections.reverse(ftsList);
968                    for (final FeatureTypeStyle ftStyle : ftsList) {
969    
970                            // // Try to import the FeatureType into an AtlasStyler RuleList to
971                            // // determine whether this RL is actually disabled.
972                            // StylingUtil.sldToString(ftStyle).contains(RL_DISABLED_FILTER.toString())
973                            // return;
974    
975                          // One child-node for every rule                          // One child-node for every rule
976                          final List<Rule> rules = ftStyle.rules();                          final List<Rule> rules = ftStyle.rules();
# Line 968  public class StyledLayerUtil { Line 978  public class StyledLayerUtil {
978    
979                                  // Check if this RULE shall actually appear in the legend                                  // Check if this RULE shall actually appear in the legend
980                                  if (rule.getName() != null                                  if (rule.getName() != null
981                                                  && rule.getName().endsWith(HIDE_IN_LAYER_LEGEND_HINT))                                                  && rule.getName().contains(HIDE_IN_LAYER_LEGEND_HINT))
982                                          continue;                                          continue;
983    
984                                  /**                                  /**
# Line 1181  public class StyledLayerUtil { Line 1191  public class StyledLayerUtil {
1191                                          throw new RuntimeException("need a reader...");                                          throw new RuntimeException("need a reader...");
1192                                  //                                  //
1193    
1194                                  final GridCoverage2D cov = (GridCoverage2D) aReader                                  final GridCoverage2D cov = aReader
1195                                                  .read(new GeneralParameterValue[] { readGG });                                                  .read(new GeneralParameterValue[] { readGG });
1196                                  colorModel = cov.getRenderedImage().getColorModel();                                  colorModel = cov.getRenderedImage().getColorModel();
1197                          }                          }

Legend:
Removed from v.1228  
changed lines
  Added in v.1273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26