/[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

trunk/src/skrueger/geotools/StyledLayerUtil.java revision 224 by alfonx, Tue Jul 14 15:57:19 2009 UTC branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java revision 517 by alfonx, Thu Nov 12 10:12:39 2009 UTC
# Line 1  Line 1 
1  package skrueger.geotools;  /*******************************************************************************
2     * Copyright (c) 2009 Martin O. J. Schmitz.
3  import java.io.File;   *
4  import java.io.FileNotFoundException;   * This file is part of the SCHMITZM library - a collection of utility
5  import java.io.FileWriter;   * classes based on Java 1.6, focusing (not only) on Java Swing
6  import java.net.URL;   * and the Geotools library.
7  import java.text.DecimalFormat;   *
8  import java.util.HashMap;   * The SCHMITZM project is hosted at:
9  import java.util.List;   * http://wald.intevation.org/projects/schmitzm/
10  import java.util.Map;   *
11  import java.util.SortedMap;   * This program is free software; you can redistribute it and/or
12  import java.util.TreeMap;   * modify it under the terms of the GNU Lesser General Public License
13     * as published by the Free Software Foundation; either version 3
14  import org.apache.log4j.Logger;   * of the License, or (at your option) any later version.
15  import org.geotools.coverage.grid.GridCoverage2D;   *
16  import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;   * This program is distributed in the hope that it will be useful,
17  import org.geotools.feature.FeatureCollection;   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  import org.geotools.map.DefaultMapLayer;   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  import org.geotools.map.MapLayer;   * GNU General Public License for more details.
20  import org.geotools.styling.ColorMap;   *
21  import org.geotools.styling.ColorMapEntry;   * You should have received a copy of the GNU Lesser General Public License (license.txt)
22  import org.geotools.styling.RasterSymbolizer;   * along with this program; if not, write to the Free Software
23  import org.geotools.styling.Style;   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24  import org.jdom.Document;   * or try this link: http://www.gnu.org/licenses/lgpl.html
25  import org.jdom.Element;   *
26  import org.jdom.input.SAXBuilder;   * Contributors:
27  import org.jdom.output.XMLOutputter;   *     Martin O. J. Schmitz - initial API and implementation
28     *     Stefan A. Krüger - additional utility classes
29  import schmitzm.geotools.styling.StylingUtil;   ******************************************************************************/
30  import schmitzm.io.IOUtil;  package skrueger.geotools;
31  import schmitzm.lang.LangUtil;  
32  import schmitzm.swing.SwingUtil;  import java.awt.Color;
33  import skrueger.AttributeMetaData;  import java.awt.Dimension;
34  import skrueger.RasterLegendData;  import java.awt.Graphics2D;
35  import skrueger.i8n.Translation;  import java.awt.Rectangle;
36    import java.awt.geom.AffineTransform;
37  /**  import java.awt.image.BufferedImage;
38   * This class provides static helper methods for dealing with  import java.awt.image.ColorModel;
39   * {@link StyledLayerInterface} stuff.  import java.awt.image.ComponentColorModel;
40   * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)  import java.awt.image.DataBuffer;
41   * @version 1.0  import java.io.File;
42   */  import java.io.FileNotFoundException;
43  public class StyledLayerUtil {  import java.io.FileWriter;
44    private static final Logger LOGGER = Logger.getLogger(StyledLayerUtil.class.getName());  import java.net.URL;
45    private static final SAXBuilder SAX_BUILDER = new SAXBuilder();  import java.text.DecimalFormat;
46    private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();  import java.util.List;
47    import java.util.Map;
48    /** URL for Atlas XML schema */  
49    public static final String AMLURI = "http://www.wikisquare.de/AtlasML";  import javax.swing.BorderFactory;
50    /** Name of the XML Element for the attribute meta data map */  import javax.swing.ImageIcon;
51    public static final String ELEM_NAME_AMD = "attributeMetaData";  import javax.swing.JComponent;
52    /** Name of the XML Element for the raster legend data */  import javax.swing.JLabel;
53    public static final String ELEM_NAME_RLD = "rasterLegendData";  
54    /** Name of the XML Element for an attribute meta data map entry */  import net.miginfocom.swing.MigLayout;
55    public static final String ELEM_NAME_ATTRIBUTE = "dataAttribute";  
56    /** Name of the XML Element for an raster legend data entry */  import org.apache.log4j.Logger;
57    public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem";  import org.geotools.coverage.grid.GeneralGridEnvelope;
58    /** Name of the XML Element for a translation */  import org.geotools.coverage.grid.GridCoverage2D;
59    public static final String ELEM_NAME_TRANSLATION = "translation";  import org.geotools.coverage.grid.GridGeometry2D;
60    import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
61    /**  import org.geotools.coverage.grid.io.AbstractGridFormat;
62     * Creates a Geotools {@link MapLayer} from an object. If the object is a  import org.geotools.feature.FeatureCollection;
63     * {@link StyledLayerInterface} then its sytle is used. In case of direct  import org.geotools.feature.NameImpl;
64     * Geotools objects ({@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},  import org.geotools.geometry.jts.ReferencedEnvelope;
65     * {@link FeatureCollection}) a default style is generated.  import org.geotools.map.DefaultMapLayer;
66     * @param object an Object  import org.geotools.map.MapLayer;
67     * @exception Exception if {@code null} is given as object or an error occurs during layer creation  import org.geotools.parameter.Parameter;
68     */  import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
69    public static MapLayer createMapLayer(Object object) throws Exception {  import org.geotools.styling.ColorMap;
70      return createMapLayer(object,null);  import org.geotools.styling.ColorMapEntry;
71    }  import org.geotools.styling.FeatureTypeStyle;
72    import org.geotools.styling.RasterSymbolizer;
73    /**  import org.geotools.styling.Rule;
74     * Creates a Geotools {@link MapLayer} from an object. If the object is a  import org.geotools.styling.Style;
75     * {@link StyledLayerInterface} then its sytle is used. In case of direct  import org.jdom.Document;
76     * Geotools objects ({@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},  import org.jdom.Element;
77     * {@link FeatureCollection}) a default style is generated.  import org.jdom.input.SAXBuilder;
78     * @param object an Object  import org.jdom.output.XMLOutputter;
79     * @param forcedStyle (SLD-)Style to force for the object  import org.opengis.feature.simple.SimpleFeature;
80     * @exception Exception if {@code null} is given as object or an error occurs during layer creation  import org.opengis.feature.simple.SimpleFeatureType;
81     */  import org.opengis.feature.type.Name;
82    public static MapLayer createMapLayer(Object object, Style forcedStyle) throws Exception {  import org.opengis.parameter.GeneralParameterValue;
83      MapLayer layer     = null;  
84      Style    style     = null;  import schmitzm.geotools.JTSUtil;
85      if ( object instanceof StyledLayerInterface ) {  import schmitzm.geotools.feature.FeatureUtil;
86        style =  ((StyledLayerInterface<?>)object).getStyle();  import schmitzm.geotools.styling.StylingUtil;
87        object = ((StyledLayerInterface<?>)object).getGeoObject();  import schmitzm.io.IOUtil;
88      }  import schmitzm.lang.LangUtil;
89      if ( forcedStyle != null )  import schmitzm.swing.JPanel;
90        style = forcedStyle;  import schmitzm.swing.SwingUtil;
91      if ( style == null )  import skrueger.AttributeMetadata;
92        style = StylingUtil.createDefaultStyle(object);  import skrueger.RasterLegendData;
93    import skrueger.i8n.Translation;
94      if (object instanceof GridCoverage2D)  
95        layer = new DefaultMapLayer( (GridCoverage2D) object, style);  /**
96      if (object instanceof AbstractGridCoverage2DReader)   * This class provides static helper methods for dealing with
97        layer = new DefaultMapLayer( (AbstractGridCoverage2DReader) object, style);   * {@link StyledLayerInterface} stuff.
98      if (object instanceof FeatureCollection)   *
99        layer = new DefaultMapLayer( (FeatureCollection) object, style);   * @author <a href="mailto:[email protected]">Martin Schmitz</a>
100     *         (University of Bonn/Germany)
101      if ( layer == null )   * @version 1.0
102        throw new Exception("Can not create MapLayer from "+(object == null ? "null" : object.getClass()));   */
103    public class StyledLayerUtil {
104      return layer;          private static final Logger LOGGER = Logger.getLogger(StyledLayerUtil.class
105    }                          .getName());
106            private static final SAXBuilder SAX_BUILDER = new SAXBuilder();
107    /**          private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();
108     * Creates an default instance of {@link StyledLayerInterface} for a Geotools  
109     * object ({@link GridCoverage2D}, {@link FeatureCollection}) with a default          /** URL for Atlas XML schema */
110     * style.          public static final String AMLURI = "http://www.wikisquare.de/AtlasML";
111     * @param object an Object          /** Name of the XML Element for the attribute meta data map */
112     * @param title  title for the object          public static final String ELEM_NAME_AMD = "attributeMetaData";
113     * @exception UnsupportedOperationException if {@code null} is given as object or an error occurs during creation          /** Name of the XML Element for the raster legend data */
114     */          public static final String ELEM_NAME_RLD = "rasterLegendData";
115    public static StyledLayerInterface<?> createStyledLayer(Object object, String title) {          /** Name of the XML Element for an attribute meta data map entry */
116       return createStyledLayer(object, title, null);          public static final String ELEM_NAME_ATTRIBUTE = "dataAttribute";
117    }          /** Name of the XML Element for an raster legend data entry */
118            public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem";
119    /**          /** Name of the XML Element for a translation */
120     * Creates an default instance of {@link StyledLayerInterface} for a Geotools          public static final String ELEM_NAME_TRANSLATION = "translation";
121     * object ({@link GridCoverage2D}, {@link FeatureCollection}) with a given  
122     * style.          /**
123     * @param object an Object           * Creates a Geotools {@link MapLayer} from an object. If the object is a
124     * @param title  title for the object           * {@link StyledLayerInterface} then its sytle is used. In case of direct
125     * @param style  style and meta data for the object           * Geotools objects ({@link GridCoverage2D},
126     * @exception UnsupportedOperationException if {@code null} is given as object or an error occurs during creation           * {@link AbstractGridCoverage2DReader}, {@link FeatureCollection}) a
127     */           * default style is generated.
128    public static StyledLayerInterface<?> createStyledLayer(Object object, String title, StyledLayerStyle style) {           *
129      StyledLayerInterface<?> styledLayer = null;           * @param object
130             *            an Object
131      String id = (title != null) ? title : "defaultID";           * @exception Exception
132             *                if {@code null} is given as object or an error occurs
133      if ( object instanceof GridCoverage2D )           *                during layer creation
134        styledLayer = new StyledGridCoverage(           */
135            (GridCoverage2D)object,          public static MapLayer createMapLayer(final Object object) throws Exception {
136            id,                  return createMapLayer(object, null);
137            title,          }
138            style  
139        );          /**
140      else if ( object instanceof AbstractGridCoverage2DReader )           * Creates a Geotools {@link MapLayer} from an object. If the object is a
141             styledLayer = new StyledGridCoverageReader(           * {@link StyledLayerInterface} then its sytle is used. In case of direct
142                 (AbstractGridCoverage2DReader)object,           * Geotools objects ({@link GridCoverage2D},
143                 id,           * {@link AbstractGridCoverage2DReader}, {@link FeatureCollection}) a
144                 title,           * default style is generated.
145                 style           *
146             );           * @param object
147      else if ( object instanceof FeatureCollection )           *            an Object
148        styledLayer = new StyledFeatureCollection(           * @param forcedStyle
149            (FeatureCollection)object,           *            (SLD-)Style to force for the object
150            id,           * @exception Exception
151            title,           *                if {@code null} is given as object or an error occurs
152            style           *                during layer creation
153        );           */
154                public static MapLayer createMapLayer(Object object, final Style forcedStyle)
155      if ( styledLayer == null )                          throws Exception {
156        throw new UnsupportedOperationException("Can not create StyledLayerInterface object from "+(object == null ? "null" : object.getClass()));                  MapLayer layer = null;
157                    Style style = null;
158      return styledLayer;                  if (object instanceof StyledLayerInterface) {
159    }                          style = ((StyledLayerInterface<?>) object).getStyle();
160                            object = ((StyledLayerInterface<?>) object).getGeoObject();
161    /**                  }
162     * Return only the visible or invisible entries of an AttributeMetaData-Map.                  if (forcedStyle != null)
163     * @param amdMap AttributeMetaData-Map                          style = forcedStyle;
164     * @param visible indicated whether the visible or invisible entries are                  if (style == null)
165     *                returned                          style = StylingUtil.createDefaultStyle(object);
166     */  
167    public static SortedMap<Integer,AttributeMetaData> getVisibleAttributeMetaData(Map<Integer,AttributeMetaData> amdMap, boolean visible) {                  if (object instanceof GridCoverage2D)
168      SortedMap<Integer,AttributeMetaData> filteredMap = new TreeMap<Integer,AttributeMetaData>();                          layer = new DefaultMapLayer((GridCoverage2D) object, style);
169      for (AttributeMetaData amd : amdMap.values())                  if (object instanceof AbstractGridCoverage2DReader)
170        if ( amd.isVisible() )                          layer = new DefaultMapLayer((AbstractGridCoverage2DReader) object,
171          filteredMap.put(amd.getColIdx(), amd);                                          style);
172                        if (object instanceof FeatureCollection)
173      return filteredMap;                          layer = new DefaultMapLayer((FeatureCollection) object, style);
174    }  
175                      if (layer == null)
176                              throw new Exception("Can not create MapLayer from "
177    /**                                          + (object == null ? "null" : object.getClass()));
178     * Parses a {@link AttributeMetaData} object from an JDOM-{@link Element}.  
179     * This method works like {@link AMLImport#parseDataAttribute(org.w3c.dom.Node},                  return layer;
180     * but for JDOM.          }
181     * @param element {@link Element} to parse  
182     */          /**
183    public static AttributeMetaData parseAttributeMetaData(final Element element) {           * Creates an default instance of {@link StyledLayerInterface} for a
184      final Integer col = Integer.valueOf(element.getAttributeValue("col"));           * Geotools object ({@link GridCoverage2D}, {@link FeatureCollection}) with
185      final Boolean visible = Boolean.valueOf(element.getAttributeValue("visible"));           * a default style.
186      final String unit = element.getAttributeValue("unit");           *
187             * @param object
188      Translation name = new Translation();           *            an Object
189      Translation desc = new Translation();           * @param title
190      for (final Element childElement : (List<Element>)element.getChildren()) {           *            title for the object
191        if (childElement.getName() == null)           * @exception UnsupportedOperationException
192          continue;           *                if {@code null} is given as object or an error occurs
193             *                during creation
194        if (childElement.getName().equals("name"))           */
195          name = parseTranslation(childElement);          public static StyledLayerInterface<?> createStyledLayer(
196        else if (childElement.getName().equals("desc"))                          final Object object, final String title) {
197          desc = parseTranslation(childElement);                  return createStyledLayer(object, title, null);
198      }          }
199      return new AttributeMetaData(col, visible, name, desc, unit);  
200    }          /**
201             * Creates an default instance of {@link StyledLayerInterface} for a
202    /**           * Geotools object ({@link GridCoverage2D}, {@link FeatureCollection}) with
203     * Parses a {@link AttributeMetaData} map from an JDOM-{@link Element}           * a given style.
204     * with {@code <attribute>}-childs.           *
205     * @param element {@link Element} to parse           * @param object
206     */           *            an Object
207    public static Map<Integer,AttributeMetaData> parseAttributeMetaDataMap(final Element element) {           * @param title
208      HashMap<Integer,AttributeMetaData> metaData = new HashMap<Integer,AttributeMetaData>();           *            title for the object
209      List<Element> attributesElements = element.getChildren( ELEM_NAME_ATTRIBUTE );           * @param style
210      for (Element attibuteElement : attributesElements)           *            style and meta data for the object
211      {           * @exception UnsupportedOperationException
212        AttributeMetaData attrMetaData = parseAttributeMetaData( attibuteElement );           *                if {@code null} is given as object or an error occurs
213        metaData.put( attrMetaData.getColIdx(), attrMetaData );           *                during creation
214      }           */
215      return metaData;          public static StyledLayerInterface<?> createStyledLayer(
216    }                          final Object object, final String title,
217                            final StyledLayerStyle style) {
218    /**                  StyledLayerInterface<?> styledLayer = null;
219     * Loads a {@link AttributeMetaData} object from an URL.  
220     * @param documentUrl {@link URL} to parse                  final String id = (title != null) ? title : "defaultID";
221     * @see #parseAttributeMetaData(Element)  
222     */                  if (object instanceof GridCoverage2D)
223    public static Map<Integer,AttributeMetaData> loadAttributeMetaDataMap(final URL documentUrl) throws Exception {                          styledLayer = new StyledGridCoverage((GridCoverage2D) object, id,
224      Document document = SAX_BUILDER.build(documentUrl);                                          title, style);
225      return parseAttributeMetaDataMap( document.getRootElement() );                  else if (object instanceof AbstractGridCoverage2DReader)
226    }                          styledLayer = new StyledGridCoverageReader(
227                                            (AbstractGridCoverage2DReader) object, id, title, style);
228    /**                  else if (object instanceof FeatureCollection)
229     * Creates an JDOM {@link Element} for the given {@link AttributeMetaData}                          styledLayer = new StyledFeatureCollection(
230     * object.                                          (FeatureCollection) object, id, title, style);
231     * @param amd meta data for one attribute  
232     */                  if (styledLayer == null)
233    public static Element createAttributeMetaDataElement(final AttributeMetaData amd) {                          throw new UnsupportedOperationException(
234      final Element element = new Element( ELEM_NAME_ATTRIBUTE , AMLURI);                                          "Can not create StyledLayerInterface object from "
235      element.setAttribute("col", String.valueOf( amd.getColIdx() ) );                                                          + (object == null ? "null" : object.getClass()));
236      element.setAttribute("visible", String.valueOf( amd.isVisible() ) );  
237      element.setAttribute("unit", amd.getUnit() );                  return styledLayer;
238      // Creating a aml:name tag...          }
239      element.addContent( createTranslationElement("name", amd.getTitle()) );  
240      // Creating a aml:desc tag...          /**
241      element.addContent( createTranslationElement("desc", amd.getDesc()) );           * Return only the visible or invisible entries of an AttributeMetaData-Map.
242      return element;           *
243    }           * @param amdMap
244             *            AttributeMetaData-Map
245    /**           * @param visible
246     * Creates an JDOM {@link Element} for the given {@link AttributeMetaData}           *            indicated whether the visible or invisible entries are
247     * map.           *            returned
248     * @param amdMap map of attribute meta data           */
249     */          public static AttributeMetadataMap getVisibleAttributeMetaData(
250    public static Element createAttributeMetaDataMapElement(final Map<Integer,AttributeMetaData> amdMap) {                          final AttributeMetadataMap amdMap, final boolean visible) {
251      final Element element = new Element( ELEM_NAME_AMD , AMLURI);  
252      for (AttributeMetaData amd : amdMap.values())                  final AttributeMetadataMap filteredMap = new AttributeMetadataMap();
253        element.addContent( createAttributeMetaDataElement( amd ) );                  for (final AttributeMetadata amd : amdMap.values())
254      return element;                          if (amd.isVisible() == visible)
255    }                                  filteredMap.put(amd.getName(), amd);
256    
257    /**                  return filteredMap;
258     * Saves a {@link AttributeMetaData AttributeMetaData-Map} to an URL.          }
259     * @param amdMap map of {@link AttributeMetaData}  
260     * @param documentUrl {@link URL} to store the XML          /**
261     */           * Parses a {@link AttributeMetadata} object from an JDOM-{@link Element}.
262    public static void saveAttributeMetaDataMap(final Map<Integer,AttributeMetaData> amdMap, final URL documentUrl) throws Exception {           * This method works like {@link
263      // Create XML-Document           * AMLImport#parseDataAttribute(org.w3c.dom.Node}, but for JDOM.
264      final FileWriter out = new FileWriter( new File(documentUrl.toURI()) );           *
265      XML_OUTPUTTER.output(           * @param element
266        createAttributeMetaDataMapElement(amdMap),           *            {@link Element} to parse
267        out           */
268      );          public static AttributeMetadata parseAttributeMetaData(final Element element) {
269      out.flush();                  final String namespace = String.valueOf(element
270      out.close();                                  .getAttributeValue("namespace"));
271    }                  final String localname = String.valueOf(element
272                                    .getAttributeValue("localname"));
273                    final Name aName = new NameImpl(namespace, localname);
274                    final Boolean visible = Boolean.valueOf(element
275    /**                                  .getAttributeValue("visible"));
276     * Parses a {@link RasterLegendData} object from an JDOM-{@link Element}.                  final String unit = element.getAttributeValue("unit");
277     * This method works like {@link AMLImport#parseRasterLegendData(org.w3c.dom.Node},  
278     * but for JDOM.                  Translation name = new Translation();
279     * @param element {@link Element} to parse                  Translation desc = new Translation();
280     */                  for (final Element childElement : (List<Element>) element.getChildren()) {
281    public static RasterLegendData parseRasterLegendData(Element element) {                          if (childElement.getName() == null)
282                                    continue;
283      final boolean paintGaps = Boolean.valueOf( element.getAttributeValue("paintGaps") );  
284                            if (childElement.getName().equals("name"))
285      RasterLegendData rld = new RasterLegendData(paintGaps);                                  name = parseTranslation(childElement);
286                            else if (childElement.getName().equals("desc"))
287      for ( Element childElement : (List<Element>)element.getChildren() ) {                                  desc = parseTranslation(childElement);
288        final String name = childElement.getName();                  }
289        // Cancel if it's an attribute                  return new AttributeMetadata(aName, visible, name, desc, unit);
290        if ( childElement.getChildren().size() == 0 )          }
291          continue;  
292            /**
293        if (name.equals( ELEM_NAME_RASTERLEGEND )) {           * Parses a {@link AttributeMetadata} map from an JDOM-{@link Element} with
294          final String valueAttr = childElement.getAttributeValue("value");           * {@code <attribute>}-childs.
295          if ( valueAttr == null )           *
296            throw new UnsupportedOperationException("Attribute 'value' missing for definition of <"+ELEM_NAME_RASTERLEGEND+">");           * @param element
297          final double value = Double.valueOf(valueAttr);           *            {@link Element} to parse
298             */
299          // first and only item should be the label          public static AttributeMetadataMap parseAttributeMetaDataMap(
300          final Element labelElement = childElement.getChild("label");                          final Element element) {
301          // id label element is missing, the translation is searched directly                  final AttributeMetadataMap metaData = new AttributeMetadataMap();
302          // as childs of the rasterLegendItem element                  final List<Element> attributesElements = element
303          Translation label = parseTranslation( labelElement != null ? labelElement : childElement );                                  .getChildren(ELEM_NAME_ATTRIBUTE);
304          rld.put(value, label);                  for (final Element attibuteElement : attributesElements) {
305        }                          final AttributeMetadata attrMetaData = parseAttributeMetaData(attibuteElement);
306      }                          metaData.put(attrMetaData.getName(), attrMetaData);
307                    }
308      return rld;                  return metaData;
309    }          }
310    
311    /**          /**
312     * Loads a {@link RasterLegendData} object from an URL.           * Loads a {@link AttributeMetadata} object from an URL.
313     * @param documentUrl {@link URL} to parse           *
314     * @see #parseAttributeMetaData(Element)           * @param documentUrl
315     */           *            {@link URL} to parse
316    public static RasterLegendData loadRasterLegendData(final URL documentUrl) throws Exception {           * @see #parseAttributeMetaData(Element)
317      Document document = SAX_BUILDER.build(documentUrl);           */
318      return parseRasterLegendData( document.getRootElement() );          public static AttributeMetadataMap loadAttributeMetaDataMap(
319    }                          final URL documentUrl) throws Exception {
320                    final Document document = SAX_BUILDER.build(documentUrl);
321   /**                  return parseAttributeMetaDataMap(document.getRootElement());
322     * Creates an JDOM {@link Element} for the given {@link RasterLegendData}          }
323     * map.  
324     * @param rld raster legend data          /**
325     */           * Creates an JDOM {@link Element} for the given {@link AttributeMetadata}
326    public static Element createRasterLegendDataElement(final RasterLegendData rld) {           * object.
327      final Element element = new Element( ELEM_NAME_RLD , AMLURI);           *
328      element.setAttribute("paintGaps", rld.isPaintGaps().toString());           * @param amd
329      for (Double key : rld.getSortedKeys()) {           *            meta data for one attribute
330        Element item = new Element( ELEM_NAME_RASTERLEGEND, AMLURI);           */
331        item.setAttribute("value", key.toString());          public static Element createAttributeMetaDataElement(
332        item.addContent( createTranslationElement("label", rld.get(key)) );                          final AttributeMetadata amd) {
333        element.addContent(item);                  final Element element = new Element(ELEM_NAME_ATTRIBUTE, AMLURI);
334      }                  element.setAttribute("namespace", String.valueOf(amd.getName()
335      return element;                                  .getNamespaceURI()));
336    }                  element.setAttribute("localname", String.valueOf(amd.getLocalName()));
337                    element.setAttribute("visible", String.valueOf(amd.isVisible()));
338    /**                  element.setAttribute("unit", amd.getUnit());
339     * Creates {@link RasterLegendData} from a {@link ColorMap}.                  // Creating a aml:name tag...
340     * @param colorMap  a color map                  element.addContent(createTranslationElement("name", amd.getTitle()));
341     * @param paintGaps indicated whether gaps are painted between the legend items                  // Creating a aml:desc tag...
342     * @param digits    number of digits the grid value classes (and legend) are                  element.addContent(createTranslationElement("desc", amd.getDesc()));
343     *                  rounded to (null means no round; >= 0 means digits after comma;                  return element;
344     *                  < 0 means digits before comma)    */          }
345    public static RasterLegendData generateRasterLegendData(ColorMap colorMap, boolean paintGaps, Integer digits) {  
346      DecimalFormat    decFormat = digits != null ? new DecimalFormat( SwingUtil.getNumberFormatPattern(digits) ) : null;          /**
347      RasterLegendData rld       = new RasterLegendData(paintGaps);           * Creates an JDOM {@link Element} for the given {@link AttributeMetadata}
348      for (ColorMapEntry cme : colorMap.getColorMapEntries())           * map.
349      {           *
350        double value = StylingUtil.getQuantityFromColorMapEntry(cme);           * @param amdMap
351        String label = cme.getLabel();           *            map of attribute meta data
352        // if no label is set (e.g. quantitative style),           */
353        // use the value as label          public static Element createAttributeMetaDataMapElement(
354        if ( label == null || label.equals("") )                          final AttributeMetadataMap amdMap) {
355          if ( digits == null )                  final Element element = new Element(ELEM_NAME_AMD, AMLURI);
356            label = String.valueOf(value);                  for (final AttributeMetadata amd : amdMap.values())
357          else                          element.addContent(createAttributeMetaDataElement(amd));
358            label = decFormat.format( LangUtil.round(value, digits) );                  return element;
359        rld.put( value, new Translation("   "+label) );          }
360      }  
361      return rld;          /**
362    }           * Saves a {@link AttributeMetadata AttributeMetaData-Map} to an URL.
363             *
364    /**           * @param amdMap
365     * Creates {@link RasterLegendData} from the {@link ColorMap} of a style.           *            map of {@link AttributeMetadata}
366     * @param style     a raster style (must contain a  {@link RasterSymbolizer})           * @param documentUrl
367     * @param paintGaps indicated whether gaps are painted between the legend items           *            {@link URL} to store the XML
368     * @param digits    number of digits the grid value classes (and legend) are           */
369     *                  rounded to (null means no round; >= 0 means digits after comma;          public static void saveAttributeMetaDataMap(
370     *                  < 0 means digits before comma)    */                          final AttributeMetadataMap amdMap, final URL documentUrl)
371    public static RasterLegendData generateRasterLegendData(Style style, boolean paintGaps, Integer digits) {                          throws Exception {
372      ColorMap colorMap = StylingUtil.getColorMapFromStyle(style);                  // Create XML-Document
373      if ( colorMap == null)                  final FileWriter out = new FileWriter(new File(documentUrl.toURI()));
374        throw new IllegalArgumentException("Color map can not be determined from style!");                  XML_OUTPUTTER.output(createAttributeMetaDataMapElement(amdMap), out);
375      return generateRasterLegendData(colorMap, paintGaps, digits);                  out.flush();
376    }                  out.close();
377            }
378    /**  
379     * Saves a {@link RasterLegendData} to an URL.          /**
380     * @param rld raster legend data           * Parses a {@link RasterLegendData} object from an JDOM-{@link Element}.
381     * @param documentUrl {@link URL} to store the XML           * This method works like {@link
382     */           * AMLImport#parseRasterLegendData(org.w3c.dom.Node}, but for JDOM.
383    public static void saveRasterLegendData(final RasterLegendData rld, final URL documentUrl) throws Exception {           *
384      // Create XML-Document           * @param element
385      final FileWriter out = new FileWriter( new File(documentUrl.toURI()) );           *            {@link Element} to parse
386      XML_OUTPUTTER.output(           */
387        createRasterLegendDataElement(rld),          public static RasterLegendData parseRasterLegendData(final Element element) {
388        out  
389      );                  final boolean paintGaps = Boolean.valueOf(element
390      out.flush();                                  .getAttributeValue("paintGaps"));
391      out.close();  
392    }                  final RasterLegendData rld = new RasterLegendData(paintGaps);
393    
394    /**                  for (final Element childElement : (List<Element>) element.getChildren()) {
395     * Parses a {@link Translation} object from an JDOM-{@link Element}.                          final String name = childElement.getName();
396     * This method works like {@link AMLImport#parseTranslation(org.w3c.dom.Node},                          // Cancel if it's an attribute
397     * but for JDOM.                          if (childElement.getChildren().size() == 0)
398     * @param element {@link Element} to parse                                  continue;
399     */  
400    public final static Translation parseTranslation(final Element element) {                          if (name.equals(ELEM_NAME_RASTERLEGEND)) {
401      Translation trans = new Translation();                                  final String valueAttr = childElement
402                                                    .getAttributeValue("value");
403      if (element == null)                                  if (valueAttr == null)
404       return trans;                                          throw new UnsupportedOperationException(
405                                                            "Attribute 'value' missing for definition of <"
406      for (final Element translationElement : (List<Element>)element.getChildren()) {                                                                          + ELEM_NAME_RASTERLEGEND + ">");
407        final String name = translationElement.getName();                                  final double value = Double.valueOf(valueAttr);
408        if (name == null)  
409          continue;                                  // first and only item should be the label
410                                    final Element labelElement = childElement.getChild("label");
411        // lang attribute                                  // id label element is missing, the translation is searched
412        String lang = translationElement.getAttributeValue("lang");                                  // directly
413        // set the default, if no language code is set                                  // as childs of the rasterLegendItem element
414        if ( lang == null )                                  final Translation label = parseTranslation(labelElement != null ? labelElement
415          lang = Translation.DEFAULT_KEY;                                                  : childElement);
416                                    rld.put(value, label);
417        final String translationText = translationElement.getValue();                          }
418        if (translationText == null)                  }
419          trans.put(lang, "");  
420        else                  return rld;
421          trans.put(lang, translationText);          }
422      }  
423            /**
424      // if no <translation> is given, the value of the node should           * Loads a {@link RasterLegendData} object from an URL.
425      // be used as a default translation           *
426      if (trans.size() == 0)           * @param documentUrl
427        trans.put( Translation.DEFAULT_KEY, element.getValue() );           *            {@link URL} to parse
428      //     trans = new Translation( ((List<Element>)element.getChildren()).get(0).getValue() );           * @see #parseAttributeMetaData(Element)
429             */
430      return trans;          public static RasterLegendData loadRasterLegendData(final URL documentUrl)
431    }                          throws Exception {
432                    final Document document = SAX_BUILDER.build(documentUrl);
433    /**                  return parseRasterLegendData(document.getRootElement());
434     * Creates an JDOM {@link Element} for the given {@link Translation}.          }
435     * @param tagname Name of the Element  
436     * @param translation Translation to store in the Element          /**
437     */           * Creates an JDOM {@link Element} for the given {@link RasterLegendData}
438    public final static Element createTranslationElement(String tagname, Translation translation) {           * map.
439      Element element = new Element(tagname, AMLURI);           *
440      if ( translation == null )           * @param rld
441        throw new UnsupportedOperationException("Translation element can not be created from null!");           *            raster legend data
442             */
443      // If only a default translation is set, the <translation lang="..">..</tranlation>          public static Element createRasterLegendDataElement(
444      // part is not used                          final RasterLegendData rld) {
445      if (translation.keySet().size() == 1 && translation.get(Translation.DEFAULT_KEY) != null) {                  final Element element = new Element(ELEM_NAME_RLD, AMLURI);
446        element.addContent( translation.get(Translation.DEFAULT_KEY) );                  element.setAttribute("paintGaps", rld.isPaintGaps().toString());
447        return element;                  for (final Double key : rld.getSortedKeys()) {
448      }                          final Element item = new Element(ELEM_NAME_RASTERLEGEND, AMLURI);
449                            item.setAttribute("value", key.toString());
450      // add a <translation lang="..">..</tranlation> part to the element for                          item.addContent(createTranslationElement("label", rld.get(key)));
451      // all languages                          element.addContent(item);
452      for (String lang : translation.keySet()) {                  }
453        Element translationElement = new Element( ELEM_NAME_TRANSLATION , AMLURI);                  return element;
454        translationElement.setAttribute("lang", lang);          }
455        String translationString = translation.get(lang);  
456        if (translationString == null)          /**
457         translationString = "";           * Creates {@link RasterLegendData} from a {@link ColorMap}.
458        translationElement.addContent( translationString );           *
459        element.addContent(translationElement);           * @param colorMap
460      }           *            a color map
461             * @param paintGaps
462      return element;           *            indicated whether gaps are painted between the legend items
463    }           * @param digits
464             *            number of digits the grid value classes (and legend) are
465             *            rounded to (null means no round; >= 0 means digits after
466    /**           *            comma; < 0 means digits before comma)
467     * Sets a style to {@link StyledLayerInterface}.           */
468     * @param styledObject a styled object          public static RasterLegendData generateRasterLegendData(
469     * @param style a Style                          final ColorMap colorMap, final boolean paintGaps,
470     */                          final Integer digits) {
471    public static void setStyledLayerStyle(StyledLayerInterface styledObject, StyledLayerStyle<?> style) {                  final DecimalFormat decFormat = digits != null ? new DecimalFormat(
472      // set SLD style                                  SwingUtil.getNumberFormatPattern(digits)) : null;
473      styledObject.setStyle( style.getGeoObjectStyle() );                  final RasterLegendData rld = new RasterLegendData(paintGaps);
474      // set meta data                  for (final ColorMapEntry cme : colorMap.getColorMapEntries()) {
475      if ( styledObject        instanceof StyledGridCoverageInterface &&                          final double value = StylingUtil.getQuantityFromColorMapEntry(cme);
476           (style.getMetaData() instanceof RasterLegendData || style.getMetaData() == null) ) {                          String label = cme.getLabel();
477        RasterLegendData sourceRld = (RasterLegendData)style.getMetaData();                          // if no label is set (e.g. quantitative style),
478        RasterLegendData destRld = ((StyledGridCoverageInterface)styledObject).getLegendMetaData();                          // use the value as label
479        if ( destRld != null && sourceRld != null ) {                          if (label == null || label.equals(""))
480          destRld.setPaintGaps(sourceRld.isPaintGaps());                                  if (digits == null)
481          destRld.clear();                                          label = String.valueOf(value);
482          destRld.putAll( sourceRld );                                  else
483        }                                          label = decFormat.format(LangUtil.round(value, digits));
484        return;                          rld.put(value, new Translation("   " + label));
485      }                  }
486      if ( styledObject        instanceof StyledFeatureCollectionInterface &&                  return rld;
487           (style.getMetaData() instanceof Map || style.getMetaData() == null) ) {          }
488        Map<Integer, AttributeMetaData> sourceAmd = (Map<Integer, AttributeMetaData>)style.getMetaData();  
489        Map<Integer, AttributeMetaData> destAmd   = ((StyledFeatureCollectionInterface)styledObject).getAttributeMetaDataMap();          /**
490        if ( destAmd != null && sourceAmd != null ) {           * Creates {@link RasterLegendData} from the {@link ColorMap} of a style.
491          destAmd.clear();           *
492          destAmd.putAll( sourceAmd );           * @param style
493        }           *            a raster style (must contain a {@link RasterSymbolizer})
494        return;           * @param paintGaps
495      }           *            indicated whether gaps are painted between the legend items
496             * @param digits
497      throw new UnsupportedOperationException("Style is not compatible to object: " +           *            number of digits the grid value classes (and legend) are
498                                              (style.getMetaData() == null ? null : style.getMetaData().getClass().getSimpleName()) +           *            rounded to (null means no round; >= 0 means digits after
499                                              " <-> " +           *            comma; < 0 means digits before comma)
500                                              (styledObject == null ? null : styledObject.getClass().getSimpleName()));           */
501    }          public static RasterLegendData generateRasterLegendData(final Style style,
502                            final boolean paintGaps, final Integer digits) {
503    /**                  final ColorMap colorMap = StylingUtil.getColorMapFromStyle(style);
504     * Returns the style a {@link StyledLayerInterface} as a {@link StyledLayerStyle}.                  if (colorMap == null)
505     * @param styledObject a styled object                          throw new IllegalArgumentException(
506     * @return {@code StyledLayerStyle<RasterLegendData>} for {@link StyledGridCoverageInterface}                                          "Color map can not be determined from style!");
507     *         or {@code StyledLayerStyle<Map<Integer,AttributeMetaData>>} for                  return generateRasterLegendData(colorMap, paintGaps, digits);
508     *         {@link StyledFeatureCollectionInterface}          }
509     */  
510    public static StyledLayerStyle<?> getStyledLayerStyle(StyledLayerInterface styledObject) {          /**
511      if ( styledObject instanceof StyledGridCoverageInterface )           * Saves a {@link RasterLegendData} to an URL.
512        return getStyledLayerStyle( (StyledGridCoverageInterface)styledObject );           *
513      if ( styledObject instanceof StyledFeatureCollectionInterface )           * @param rld
514        return getStyledLayerStyle( (StyledFeatureCollectionInterface)styledObject );           *            raster legend data
515      throw new UnsupportedOperationException("Unknown type of StyledLayerInterface: "+(styledObject == null ? null : styledObject.getClass().getSimpleName()));           * @param documentUrl
516    }           *            {@link URL} to store the XML
517             */
518    /**          public static void saveRasterLegendData(final RasterLegendData rld,
519     * Returns the style and raster meta data of a {@link StyledGridCoverageInterface}                          final URL documentUrl) throws Exception {
520     * as a {@link StyledLayerStyle}.                  // Create XML-Document
521     * @param styledGC a styled grid coverage                  final FileWriter out = new FileWriter(new File(documentUrl.toURI()));
522     */                  XML_OUTPUTTER.output(createRasterLegendDataElement(rld), out);
523    public static StyledLayerStyle<RasterLegendData> getStyledLayerStyle(StyledGridCoverageInterface styledGC) {                  out.flush();
524      return new StyledLayerStyle<RasterLegendData>(                  out.close();
525        styledGC.getStyle(),          }
526        styledGC.getLegendMetaData()  
527      );          /**
528    }           * Parses a {@link Translation} object from an JDOM-{@link Element}. This
529             * method works like {@link AMLImport#parseTranslation(org.w3c.dom.Node},
530    /**           * but for JDOM.
531     * Returns the style and attribute meta data of a {@link StyledFeatureCollectionInterface}           *
532     * as a {@link StyledLayerStyle}.           * @param element
533     * @param styledFC a styled feature collection           *            {@link Element} to parse
534     */           */
535    public static StyledLayerStyle<Map<Integer,AttributeMetaData>> getStyledLayerStyle(StyledFeatureCollectionInterface styledFC) {          public final static Translation parseTranslation(final Element element) {
536      return new StyledLayerStyle<Map<Integer,AttributeMetaData>>(                  final Translation trans = new Translation();
537        styledFC.getStyle(),  
538        styledFC.getAttributeMetaDataMap()                  if (element == null)
539      );                          return trans;
540    }  
541                    for (final Element translationElement : (List<Element>) element
542    /**                                  .getChildren()) {
543     * Loads a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData Raster-LegendData}                          final String name = translationElement.getName();
544     * for a given geo-object (raster) source. The SLD file must be present. A missing                          if (name == null)
545     * raster legend-data file is tolerated.                                  continue;
546     * @param geoObjectURL URL of the (already read) raster object  
547     * @param sldExt file extention for the SLD file                          // lang attribute
548     * @param rldExt file extention for the raster legend-data file                          String lang = translationElement.getAttributeValue("lang");
549     * @return {@code null} in case of any error                          // set the default, if no language code is set
550     */                          if (lang == null)
551    public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(URL geoObjectURL, String sldExt, String rldExt) {                                  lang = Translation.DEFAULT_KEY;
552      RasterLegendData metaData = null;  
553      Style sldStyle = null;                          final String translationText = translationElement.getValue();
554      try {                          if (translationText == null)
555        Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(geoObjectURL, sldExt));                                  trans.put(lang, "");
556        // SLD must be present                          else
557        if ( styles == null || styles.length == 0 )                                  trans.put(lang, translationText);
558          return null;                  }
559        sldStyle = styles[0];  
560      }                  // if no <translation> is given, the value of the node should
561      catch (Exception err) {                  // be used as a default translation
562        // SLD must be present                  if (trans.size() == 0)
563        LangUtil.logDebugError(LOGGER,err);                          trans.put(Translation.DEFAULT_KEY, element.getValue());
564        return null;                  // trans = new Translation(
565      }                  // ((List<Element>)element.getChildren()).get(0).getValue() );
566    
567      try {                  return trans;
568        metaData = StyledLayerUtil.loadRasterLegendData( IOUtil.changeUrlExt(geoObjectURL,rldExt) );          }
569      } catch (FileNotFoundException err) {  
570        // ignore missing raster legend data          /**
571      } catch (Exception err) {           * Creates an JDOM {@link Element} for the given {@link Translation}.
572        // any other error during legend data creation leads to error           *
573        LangUtil.logDebugError(LOGGER,err);           * @param tagname
574        return null;           *            Name of the Element
575      }           * @param translation
576      return new StyledLayerStyle<RasterLegendData>(sldStyle, metaData);           *            Translation to store in the Element
577    }           */
578            public final static Element createTranslationElement(final String tagname,
579    /**                          final Translation translation) {
580     * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and                  final Element element = new Element(tagname, AMLURI);
581     * {@linkplain RasterLegendData Raster-LegendData} from a {@code .rld} file                  if (translation == null)
582     * for a given geo-object (raster) source. The SLD file must be present. A missing                          throw new UnsupportedOperationException(
583     * raster legend-data file is tolerated.                                          "Translation element can not be created from null!");
584     * @param geoObjectURL URL of the (already read) raster object  
585     * @param sldExt file extention for the SLD file                  // If only a default translation is set, the <translation
586     * @param rldExt file extention for the raster legend-data file                  // lang="..">..</tranlation>
587     * @return {@code null} in case of any error                  // part is not used
588     */                  if (translation.keySet().size() == 1
589    public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(URL geoObjectURL) {                                  && translation.get(Translation.DEFAULT_KEY) != null) {
590      return loadStyledRasterStyle(geoObjectURL, "sld", "rld");                          element.addContent(translation.get(Translation.DEFAULT_KEY));
591    }                          return element;
592                    }
593    /**  
594     * Loads a {@linkplain Style SLD-Style} and a {@linkplain AttributeMetaData AttributeMetaData-Map}                  // add a <translation lang="..">..</tranlation> part to the element for
595     * for a given geo-object (feature) source. The SLD file must be present. A missing                  // all languages
596     * attribute meta-data file is tolerated.                  for (final String lang : translation.keySet()) {
597     * @param geoObjectURL URL of the (already read) feature object                          final Element translationElement = new Element(
598     * @param sldExt file extention for the SLD file                                          ELEM_NAME_TRANSLATION, AMLURI);
599     * @param rldExt file extention for the raster legend-data file                          translationElement.setAttribute("lang", lang);
600     * @return {@code null} in case of any error                          String translationString = translation.get(lang);
601     */                          if (translationString == null)
602    public static StyledLayerStyle<Map<Integer,AttributeMetaData>> loadStyledFeatureStyle(URL geoObjectURL, String sldExt, String rldExt) {                                  translationString = "";
603      Map<Integer,AttributeMetaData> metaData = null;                          translationElement.addContent(translationString);
604      Style                          sldStyle = null;                          element.addContent(translationElement);
605      try {                  }
606        Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(geoObjectURL, sldExt));  
607        // SLD must be present                  return element;
608        if ( styles == null || styles.length == 0 )          }
609          return null;  
610        sldStyle = styles[0];          /**
611      } catch (Exception err) {           * Sets a style to {@link StyledLayerInterface}.
612        // SLD must be present           *
613        LangUtil.logDebugError(LOGGER,err);           * @param styledObject
614        return null;           *            a styled object
615      }           * @param style
616             *            a Style
617      try {           */
618        metaData = StyledLayerUtil.loadAttributeMetaDataMap( IOUtil.changeUrlExt(geoObjectURL,rldExt) );          public static void setStyledLayerStyle(
619      } catch (FileNotFoundException err) {                          final StyledLayerInterface styledObject,
620        // ignore missing attribute meta data                          final StyledLayerStyle<?> style) {
621      } catch (Exception err) {                  // set SLD style
622        // any other error during meta data creation leads to error                  styledObject.setStyle(style.getGeoObjectStyle());
623        LangUtil.logDebugError(LOGGER,err);                  // set meta data
624        return null;                  if (styledObject instanceof StyledGridCoverageInterface
625      }                                  && (style.getMetaData() instanceof RasterLegendData || style
626                                                    .getMetaData() == null)) {
627      return new StyledLayerStyle<Map<Integer,AttributeMetaData>>(sldStyle, metaData);                          final RasterLegendData sourceRld = (RasterLegendData) style
628    }                                          .getMetaData();
629                            final RasterLegendData destRld = ((StyledGridCoverageInterface) styledObject)
630    /**                                          .getLegendMetaData();
631     * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and                          if (destRld != null && sourceRld != null) {
632     * {@linkplain AttributeMetaData AttributeMetaData-Map} from a {@code .amd} file                                  destRld.setPaintGaps(sourceRld.isPaintGaps());
633     * for a given geo-object (feature) source. The SLD file must be present. A missing                                  destRld.clear();
634     * attribute meta-data file is tolerated.                                  destRld.putAll(sourceRld);
635     * @param geoObjectURL URL of the (already read) feature object                          }
636     * @param sldExt file extention for the SLD file                          return;
637     * @param rldExt file extention for the raster legend-data file                  }
638     * @return {@code null} in case of any error                  if (styledObject instanceof StyledFeatureCollectionInterface
639     */                                  && (style.getMetaData() instanceof Map || style.getMetaData() == null)) {
640    public static StyledLayerStyle<Map<Integer,AttributeMetaData>> loadStyledFeatureStyle(URL geoObjectURL) {                          final AttributeMetadataMap sourceAmd = (AttributeMetadataMap) style
641      return loadStyledFeatureStyle(geoObjectURL, "sld", "amd");                                          .getMetaData();
642    }                          final AttributeMetadataMap destAmd = ((StyledFeatureCollectionInterface) styledObject)
643                                            .getAttributeMetaDataMap();
644    /**                          if (destAmd != null && sourceAmd != null) {
645     * Stores a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData Raster-LegendData}                                  destAmd.clear();
646     * for a given geo-object (raster) source.                                  destAmd.putAll(sourceAmd);
647     * @param style  style to save                          }
648     * @param geoObjectURL URL of the raster object                          return;
649     * @param sldExt file extention for the SLD file                  }
650     * @param mdExt file extention for the meta-data file  
651     */                  throw new UnsupportedOperationException(
652    public static <T> void saveStyledLayerStyle(StyledLayerStyle<T> style, URL geoObjectURL, String sldExt, String mdExt) throws Exception {                                  "Style is not compatible to object: "
653      // Store the SLD                                                  + (style.getMetaData() == null ? null : style
654      Style sldStyle = style.getGeoObjectStyle();                                                                  .getMetaData().getClass().getSimpleName())
655      if ( sldStyle != null ) {                                                  + " <-> "
656        StylingUtil.saveStyleToSLD(                                                  + (styledObject == null ? null : styledObject
657           sldStyle,                                                                  .getClass().getSimpleName()));
658           IOUtil.changeFileExt(          }
659                new File(geoObjectURL.toURI()),  
660                sldExt          /**
661           )           * Returns the style a {@link StyledLayerInterface} as a
662        );           * {@link StyledLayerStyle}.
663      }           *
664             * @param styledObject
665      // Store the meta data           *            a styled object
666      T metaData = style.getMetaData();           * @return {@code StyledLayerStyle<RasterLegendData>} for
667      if ( metaData != null ) {           *         {@link StyledGridCoverageInterface} or {@code
668        if ( metaData instanceof RasterLegendData ) {           *         StyledLayerStyle<Map<Integer,AttributeMetaData>>} for
669          saveRasterLegendData(           *         {@link StyledFeatureCollectionInterface}
670              (RasterLegendData)metaData,           */
671              IOUtil.changeUrlExt(geoObjectURL,mdExt)          public static StyledLayerStyle<?> getStyledLayerStyle(
672          );                          final StyledLayerInterface styledObject) {
673  //      } else if ( metaData instanceof Map<Integer,AttributeMetaData> ) { // LEIDER NICHT KOMPILIERBAR!!                  if (styledObject instanceof StyledGridCoverageInterface)
674        } else if ( metaData instanceof Map ) {                          return getStyledLayerStyle((StyledGridCoverageInterface) styledObject);
675          saveAttributeMetaDataMap(                  if (styledObject instanceof StyledFeatureCollectionInterface)
676              (Map<Integer,AttributeMetaData>)metaData,                          return getStyledLayerStyle((StyledFeatureCollectionInterface) styledObject);
677              IOUtil.changeUrlExt(geoObjectURL,mdExt)                  throw new UnsupportedOperationException(
678          );                                  "Unknown type of StyledLayerInterface: "
679        } else                                                  + (styledObject == null ? null : styledObject
680          throw new UnsupportedOperationException("Export for meta data not yet supported: "+metaData.getClass().getSimpleName());                                                                  .getClass().getSimpleName()));
681      }          }
682    }  
683            /**
684    /**           * Returns the style and raster meta data of a
685     * Stores the {@linkplain Style SLD-Style} to a {@code .sld} file and           * {@link StyledGridCoverageInterface} as a {@link StyledLayerStyle}.
686     * the meta data ({@link RasterLegendData} or {@link AttributeMetaData})           *
687     * to a {@code .rld} or {@code .amd} file.           * @param styledGC
688     * for a given geo-object source.           *            a styled grid coverage
689     * @param style  style to save           */
690     * @param geoObjectURL URL of the (already read) raster object          public static StyledLayerStyle<RasterLegendData> getStyledLayerStyle(
691     */                          final StyledGridCoverageInterface styledGC) {
692    public static void saveStyledLayerStyle(StyledLayerStyle<?> style, URL geoObjectURL) throws Exception {                  return new StyledLayerStyle<RasterLegendData>(styledGC.getStyle(),
693      if ( style.getMetaData() instanceof RasterLegendData )                                  styledGC.getLegendMetaData());
694        saveStyledLayerStyle(style,geoObjectURL, "sld", "rld");          }
695      else  
696        saveStyledLayerStyle(style,geoObjectURL, "sld", "amd");          /**
697    }           * Returns the style and attribute meta data of a
698             * {@link StyledFeatureCollectionInterface} as a {@link StyledLayerStyle}.
699  }           *
700             * @param styledFC
701             *            a styled feature collection
702             */
703            public static StyledLayerStyle<AttributeMetadataMap> getStyledLayerStyle(
704                            final StyledFeatureCollectionInterface styledFC) {
705                    return new StyledLayerStyle<AttributeMetadataMap>(styledFC.getStyle(),
706                                    styledFC.getAttributeMetaDataMap());
707            }
708    
709            /**
710             * Loads a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData
711             * Raster-LegendData} for a given geo-object (raster) source. The SLD file
712             * must be present. A missing raster legend-data file is tolerated.
713             *
714             * @param geoObjectURL
715             *            URL of the (already read) raster object
716             * @param sldExt
717             *            file extention for the SLD file
718             * @param rldExt
719             *            file extention for the raster legend-data file
720             * @return {@code null} in case of any error
721             */
722            public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(
723                            final URL geoObjectURL, final String sldExt, final String rldExt) {
724                    RasterLegendData metaData = null;
725                    Style sldStyle = null;
726                    try {
727                            final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(
728                                            geoObjectURL, sldExt));
729                            // SLD must be present
730                            if (styles == null || styles.length == 0)
731                                    return null;
732                            sldStyle = styles[0];
733                    } catch (final Exception err) {
734                            // SLD must be present
735                            LangUtil.logDebugError(LOGGER, err);
736                            return null;
737                    }
738    
739                    try {
740                            metaData = StyledLayerUtil.loadRasterLegendData(IOUtil
741                                            .changeUrlExt(geoObjectURL, rldExt));
742                    } catch (final FileNotFoundException err) {
743                            // ignore missing raster legend data
744                    } catch (final Exception err) {
745                            // any other error during legend data creation leads to error
746                            LangUtil.logDebugError(LOGGER, err);
747                            return null;
748                    }
749                    return new StyledLayerStyle<RasterLegendData>(sldStyle, metaData);
750            }
751    
752            /**
753             * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and
754             * {@linkplain RasterLegendData Raster-LegendData} from a {@code .rld} file
755             * for a given geo-object (raster) source. The SLD file must be present. A
756             * missing raster legend-data file is tolerated.
757             *
758             * @param geoObjectURL
759             *            URL of the (already read) raster object
760             * @param sldExt
761             *            file extention for the SLD file
762             * @param rldExt
763             *            file extention for the raster legend-data file
764             * @return {@code null} in case of any error
765             */
766            public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(
767                            final URL geoObjectURL) {
768                    return loadStyledRasterStyle(geoObjectURL, "sld", "rld");
769            }
770    
771            /**
772             * Loads a {@linkplain Style SLD-Style} and a {@linkplain AttributeMetadata
773             * AttributeMetaData-Map} for a given geo-object (feature) source. The SLD
774             * file must be present. A missing attribute meta-data file is tolerated.
775             *
776             * @param geoObjectURL
777             *            URL of the (already read) feature object
778             * @param sldExt
779             *            file extention for the SLD file
780             * @param rldExt
781             *            file extention for the raster legend-data file
782             * @return {@code null} in case of any error
783             */
784            public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(
785                            final URL geoObjectURL, final String sldExt, final String rldExt) {
786                    AttributeMetadataMap metaData = null;
787                    Style sldStyle = null;
788                    try {
789                            final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(
790                                            geoObjectURL, sldExt));
791                            // SLD must be present
792                            if (styles == null || styles.length == 0)
793                                    return null;
794                            sldStyle = styles[0];
795                    } catch (final Exception err) {
796                            // SLD must be present
797                            LangUtil.logDebugError(LOGGER, err);
798                            return null;
799                    }
800    
801                    try {
802                            metaData = StyledLayerUtil.loadAttributeMetaDataMap(IOUtil
803                                            .changeUrlExt(geoObjectURL, rldExt));
804                    } catch (final FileNotFoundException err) {
805                            // ignore missing attribute meta data
806                    } catch (final Exception err) {
807                            // any other error during meta data creation leads to error
808                            LangUtil.logDebugError(LOGGER, err);
809                            return null;
810                    }
811    
812                    return new StyledLayerStyle<AttributeMetadataMap>(sldStyle, metaData);
813            }
814    
815            /**
816             * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and
817             * {@linkplain AttributeMetadata AttributeMetaData-Map} from a {@code .amd}
818             * file for a given geo-object (feature) source. The SLD file must be
819             * present. A missing attribute meta-data file is tolerated.
820             *
821             * @param geoObjectURL
822             *            URL of the (already read) feature object
823             * @param sldExt
824             *            file extention for the SLD file
825             * @param rldExt
826             *            file extention for the raster legend-data file
827             * @return {@code null} in case of any error
828             */
829            public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(
830                            final URL geoObjectURL) {
831                    return loadStyledFeatureStyle(geoObjectURL, "sld", "amd");
832            }
833    
834            /**
835             * Stores a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData
836             * Raster-LegendData} for a given geo-object (raster) source.
837             *
838             * @param style
839             *            style to save
840             * @param geoObjectURL
841             *            URL of the raster object
842             * @param sldExt
843             *            file extention for the SLD file
844             * @param mdExt
845             *            file extention for the meta-data file
846             */
847            public static <T> void saveStyledLayerStyle(
848                            final StyledLayerStyle<T> style, final URL geoObjectURL,
849                            final String sldExt, final String mdExt) throws Exception {
850                    // Store the SLD
851                    final Style sldStyle = style.getGeoObjectStyle();
852                    if (sldStyle != null) {
853                            StylingUtil.saveStyleToSLD(sldStyle, IOUtil.changeFileExt(new File(
854                                            geoObjectURL.toURI()), sldExt));
855                    }
856    
857                    // Store the meta data
858                    final T metaData = style.getMetaData();
859                    if (metaData != null) {
860                            if (metaData instanceof RasterLegendData) {
861                                    saveRasterLegendData((RasterLegendData) metaData, IOUtil
862                                                    .changeUrlExt(geoObjectURL, mdExt));
863                                    // } else if ( metaData instanceof
864                                    // Map<Integer,AttributeMetaData> ) { // LEIDER NICHT
865                                    // KOMPILIERBAR!!
866                            } else if (metaData instanceof Map) {
867                                    saveAttributeMetaDataMap((AttributeMetadataMap) metaData,
868                                                    IOUtil.changeUrlExt(geoObjectURL, mdExt));
869                            } else
870                                    throw new UnsupportedOperationException(
871                                                    "Export for meta data not yet supported: "
872                                                                    + metaData.getClass().getSimpleName());
873                    }
874            }
875    
876            /**
877             * Stores the {@linkplain Style SLD-Style} to a {@code .sld} file and the
878             * meta data ({@link RasterLegendData} or {@link AttributeMetadata}) to a
879             * {@code .rld} or {@code .amd} file. for a given geo-object source.
880             *
881             * @param style
882             *            style to save
883             * @param geoObjectURL
884             *            URL of the (already read) raster object
885             */
886            public static void saveStyledLayerStyle(final StyledLayerStyle<?> style,
887                            final URL geoObjectURL) throws Exception {
888                    if (style.getMetaData() instanceof RasterLegendData)
889                            saveStyledLayerStyle(style, geoObjectURL, "sld", "rld");
890                    else
891                            saveStyledLayerStyle(style, geoObjectURL, "sld", "amd");
892            }
893    
894            /**
895             * Creates a {@link JPanel} that shows a legend for a list of
896             * {@link FeatureTypeStyle}s and a targeted featureType
897             *
898             * @param featureType
899             *            If this a legend for Point, Polygon or Line?
900             * @param list
901             *            The Styles to presented in this legend
902             *
903             * @author <a href="mailto:[email protected]">Stefan Alfons
904             *         Kr&uuml;ger</a>
905             */
906            public static JPanel createLegendPanel(Style style,
907                            final SimpleFeatureType featureType, final int iconWidth,
908                            final int iconHeight) {
909    
910                    final List<FeatureTypeStyle> list = style.featureTypeStyles();
911    
912                    final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]"));
913    
914                    if (style == null) {
915                            // No Style => no legend
916                            return panel;
917                    }
918    
919                    for (final FeatureTypeStyle ftStyle : list) {
920    
921                            // One child-node for every rule
922                            final List<Rule> rules = ftStyle.rules();
923                            for (final Rule rule : rules) {
924    
925                                    /**
926                                     * Let's not create a hbox for Rules that only contain
927                                     * TextSymbolizers
928                                     */
929                                    if (StylingUtil.getTextSymbolizers(rule.getSymbolizers())
930                                                    .size() == rule.getSymbolizers().length)
931                                            continue;
932    
933                                    final BufferedImage imageForRule = LegendIconFeatureRenderer
934                                                    .getInstance().createImageForRule(rule, featureType,
935                                                                    new Dimension(iconWidth, iconHeight));
936    
937                                    final ImageIcon legendIcon = new ImageIcon(imageForRule);
938    
939                                    final JLabel iconLabel = new JLabel(legendIcon);
940                                    panel.add(iconLabel, "sgx1");
941                                    // hbox.setAlignmentX(0f);
942                                    // hbox.add(iconLabel);
943                                    // hbox.add(Box.createHorizontalStrut(3));
944    
945                                    final Translation labelT = new Translation();
946                                    labelT.fromOneLine(rule.getDescription().getTitle());
947                                    final JLabel classTitleLabel = new JLabel(labelT.toString());
948    
949                                    panel.add(classTitleLabel, "sgx2");
950                                    classTitleLabel.setLabelFor(iconLabel);
951                            }
952                    }
953    
954                    return panel;
955            }
956    
957            /**
958             * Creates a {@link JComponent} that contains a legend for a given
959             * rasterLayer and a given {@link Style}.
960             *
961             * @param style
962             *            if <code>null</code>, the default {@link Style} is extracetd
963             *            from the {@link StyledRasterInterface}
964             */
965            public static JPanel createLegendPanel(
966                            final StyledRasterInterface<?> styledRaster, Style style,
967                            final int iconWidth, final int iconHeight) {
968    
969                    // If no style is given, we use the default style for this layer
970                    if (style == null)
971                            style = styledRaster.getStyle();
972    
973                    /**
974                     * Determine whether a Style is responsible for the coloring
975                     */
976                    ColorModel colorModel = null;
977                    if (!isStyleable(styledRaster)
978                                    || (isStyleable(styledRaster) && style == null)) {
979                            colorModel = getColorModel(styledRaster);
980                    }
981    
982                    final RasterLegendData rasterLegendData = styledRaster
983                                    .getLegendMetaData();
984                    final List<Double> legendRasterValues = rasterLegendData
985                                    .getSortedKeys();
986                    final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData
987                                    .createSampleRasters();
988    
989                    final JPanel panel = new JPanel(new MigLayout("wrap 2"));
990    
991                    for (final Double rValue : legendRasterValues) {
992    
993                            // final Dimension ICON_SIZE = new Dimension(iconWidth,
994                            // new JLabel().getFontMetrics(new JLabel().getFont())
995                            // .getHeight() > 5 ? new JLabel().getFontMetrics(
996                            // new JLabel().getFont()).getHeight() : iconHeight);
997    
998                            // ****************************************************************************
999                            // Create the actual icon
1000                            // ****************************************************************************
1001                            final BufferedImage buffImage = new BufferedImage(iconWidth,
1002                                            iconHeight, BufferedImage.TYPE_INT_ARGB);
1003    
1004                            final Graphics2D graphics = buffImage.createGraphics();
1005    
1006                            if (colorModel != null) {
1007                                    // The colors come from the ColorModel!
1008    
1009                                    try {
1010                                            Object inData = null;
1011                                            switch (colorModel.getTransferType()) {
1012                                            case DataBuffer.TYPE_BYTE:
1013                                                    inData = new byte[] { rValue.byteValue() };
1014                                                    break;
1015                                            case DataBuffer.TYPE_USHORT:
1016                                                    inData = new short[] { rValue.shortValue() };
1017                                                    break;
1018                                            case DataBuffer.TYPE_INT:
1019                                                    inData = new int[] { rValue.intValue() };
1020                                                    break;
1021                                            case DataBuffer.TYPE_SHORT:
1022                                                    inData = new short[] { rValue.shortValue() };
1023                                                    break;
1024                                            case DataBuffer.TYPE_FLOAT:
1025                                                    inData = new float[] { rValue.floatValue() };
1026                                                    break;
1027                                            case DataBuffer.TYPE_DOUBLE:
1028                                                    inData = new double[] { rValue.doubleValue() };
1029                                                    break;
1030                                            default:
1031                                                    inData = rValue.intValue();
1032                                            }
1033                                            final Color color = new Color(colorModel.getRGB(inData));
1034                                            graphics.setBackground(color);
1035                                            graphics.setColor(color);
1036                                            graphics.fillRect(0, 0, iconWidth, iconHeight);
1037                                    } catch (final Exception e) {
1038                                            LOGGER.info(
1039                                                            "Dann nehmen wir halt den GridCoverageRenderer", e);
1040                                            colorModel = null;
1041                                    }
1042                            } else {
1043                                    // The colors come from the Style
1044    
1045                                    /**
1046                                     * The coverage contains only one value of value rValue
1047                                     */
1048                                    final GridCoverage2D sampleCov = sampleRasters.get(rValue);
1049                                    GridCoverageRenderer renderer;
1050                                    try {
1051                                            renderer = new GridCoverageRenderer(sampleCov
1052                                                            .getCoordinateReferenceSystem(), JTSUtil
1053                                                            .createEnvelope(sampleCov.getEnvelope()),
1054                                                            new Rectangle(iconWidth, iconHeight),
1055                                                            (AffineTransform) null);
1056                                    } catch (final Exception e1) {
1057                                            throw new RuntimeException(
1058                                                            "Creating a GridCoverageRenderer failed:", e1);
1059                                    }
1060    
1061                                    /**
1062                                     * Iterate over all FeatureTypeStyles.
1063                                     */
1064                                    final List<RasterSymbolizer> rSymbols = StylingUtil
1065                                                    .getRasterSymbolizers(style);
1066    
1067                                    for (final RasterSymbolizer symbolizer : rSymbols) {
1068                                            try {
1069                                                    renderer.paint(graphics, sampleCov, symbolizer);
1070                                            } catch (final Exception ee) {
1071                                                    LOGGER.error("Unable to paint " + symbolizer
1072                                                                    + " into the legend image", ee);
1073                                            }
1074                                    }
1075                            }
1076    
1077                            final JLabel iconLabel = new JLabel(new ImageIcon(buffImage));
1078                            // hbox.setAlignmentX(0f);
1079                            panel.add(iconLabel, "sgx1");
1080                            // hbox.add(Box.createHorizontalStrut(3));
1081    
1082                            final Translation labelT = rasterLegendData.get(rValue);
1083                            final JLabel classTitleLabel = new JLabel(labelT.toString());
1084                            panel.add(classTitleLabel, "sgx2"
1085                                            + (rasterLegendData.getPaintGaps() ? ", gapy 0 3" : ""));
1086                            classTitleLabel.setLabelFor(iconLabel);
1087    
1088                            // box.add(hbox);
1089    
1090                            if (rasterLegendData.getPaintGaps()) {
1091                                    iconLabel
1092                                                    .setBorder(BorderFactory.createLineBorder(Color.black));
1093                            }
1094    
1095                    }
1096    
1097                    return panel;
1098            }
1099    
1100            /**
1101             * Extracts the {@link ColorModel} of any {@link StyledRasterInterface}. May
1102             * return <code>null</code> if the geoobject can not be accessed.
1103             */
1104            @SuppressWarnings("unchecked")
1105            public static ColorModel getColorModel(
1106                            final StyledRasterInterface<?> styledGrid) {
1107                    ColorModel colorModel = null;
1108                    try {
1109                            final Object geoObject = styledGrid.getGeoObject();
1110                            if (geoObject instanceof GridCoverage2D) {
1111                                    final GridCoverage2D cov = (GridCoverage2D) geoObject;
1112                                    colorModel = cov.getRenderedImage().getColorModel();
1113                            } else if (styledGrid instanceof StyledRasterPyramidInterface) {
1114    
1115                                    final Parameter readGG = new Parameter(
1116                                                    AbstractGridFormat.READ_GRIDGEOMETRY2D);
1117    
1118                                    final ReferencedEnvelope mapExtend = new org.geotools.geometry.jts.ReferencedEnvelope(
1119                                                    styledGrid.getEnvelope(), styledGrid.getCrs());
1120    
1121                                    readGG.setValue(new GridGeometry2D(new GeneralGridEnvelope(
1122                                                    new Rectangle(0, 0, 1, 1)), mapExtend));
1123    
1124                                    final FeatureCollection<SimpleFeatureType, SimpleFeature> rFc = (FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject;
1125    
1126                                    final AbstractGridCoverage2DReader aReader = (AbstractGridCoverage2DReader) FeatureUtil
1127                                                    .getWrappedGeoObject(rFc);
1128                                    final GridCoverage2D cov = (GridCoverage2D) aReader
1129                                                    .read(new GeneralParameterValue[] { readGG });
1130                                    colorModel = cov.getRenderedImage().getColorModel();
1131                            }
1132                    } catch (final Exception e) {
1133                            LOGGER.error("Error reading the colormodel from " + styledGrid, e);
1134                            return null;
1135                    }
1136                    return colorModel;
1137            }
1138    
1139            /**
1140             * @return <code>true</code> if a {@link RasterSymbolizer} can be applied
1141             *         and will have an effect. Some rasters (e.g. GeoTIFF) can come
1142             *         with their own {@link ColorModel} and will ignore any
1143             *         {@link RasterSymbolizer} = SLD.
1144             */
1145            public static boolean isStyleable(
1146                            final StyledRasterInterface<?> styledRaster) {
1147                    final ColorModel colorModel = getColorModel(styledRaster);
1148    
1149                    LOGGER.info("The colormodel of " + styledRaster.getTitle() + " is "
1150                                    + colorModel.getClass().getSimpleName());
1151    
1152                    if (colorModel == null)
1153                            return true;
1154                    if (colorModel instanceof ComponentColorModel)
1155                            return true;
1156                    return false;
1157            }
1158    
1159            /**
1160             * Set the given Style as the Style of the {@link MapLayer}, unless the
1161             * styles are the same (not comparing selection stuff). If the
1162             * {@link MapLayer}s {@link Style} is changed, the selection FTS is kept.<br/>
1163             * Remember {@link MapLayer#setStyle(Style)} triggers an event leading to a
1164             * repaint, so only use it when needed.
1165             *
1166             * @return <code>true</code> if the {@link MapLayer}'s {@link Style} has been changed.
1167             */
1168            public static boolean updateMapLayerStyleIfChangedAndKeepSelection(MapLayer mapLayer,
1169                            Style style2) {
1170    
1171                    Style mapLayerStyleCleaned = StylingUtil
1172                                                    .removeSelectionFeatureTypeStyle(mapLayer.getStyle());
1173                    
1174                    Style newStyleCleaned = StylingUtil.removeSelectionFeatureTypeStyle(style2);
1175                    
1176                    if (StylingUtil.isStyleDifferent(mapLayerStyleCleaned,
1177                                    newStyleCleaned)) {
1178                            
1179                            // They are different when compared without SELECTION FTS!
1180                            
1181                            // Now let's copy any SELECTION FTS to the now style
1182                            FeatureTypeStyle selectionFeatureTypeStyle = StylingUtil.getSelectionFeatureTypeStyle( mapLayer.getStyle() );
1183                            if (selectionFeatureTypeStyle != null) {
1184                                    newStyleCleaned.featureTypeStyles().add(selectionFeatureTypeStyle);
1185                                    // newStyleCleaned is not so clean anymore... We just alled a selcetion FTS
1186                            }  
1187                            
1188                            mapLayer.setStyle(newStyleCleaned);
1189                            
1190                            return true;
1191                            
1192                    } else return false;
1193            }
1194    
1195    }

Legend:
Removed from v.224  
changed lines
  Added in v.517

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26