[Schmitzm-commits] r1535 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 22 11:24:50 CET 2011
Author: alfonx
Date: 2011-03-22 11:24:49 +0100 (Tue, 22 Mar 2011)
New Revision: 1535
Modified:
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/AbstractStyledLayer.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledFS.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverage.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverageReader.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerInterface.java
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
Log:
AtlasStyler Stand-alone now allows to import and style GeoTiff and ArcASCII ... mainly untested
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/AbstractStyledLayer.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/AbstractStyledLayer.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/AbstractStyledLayer.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -29,6 +29,8 @@
******************************************************************************/
package de.schmitzm.geotools.styling;
+import java.io.File;
+
import javax.swing.ImageIcon;
import org.apache.log4j.Logger;
@@ -42,241 +44,305 @@
/**
* This class is a default implementation of {@link StyledLayerInterface}.
- * {@link StyledLayerInterface#dispose()} and {@link StyledLayerInterface#uncache()}
- * must be implemented by the sub class. This class only implements the "hold"
- * of an geo object of type {@code <E>}.
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * {@link StyledLayerInterface#dispose()} and
+ * {@link StyledLayerInterface#uncache()} must be implemented by the sub class.
+ * This class only implements the "hold" of an geo object of type {@code <E>}.
+ *
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ * (University of Bonn/Germany)
* @version 1.0
*/
public abstract class AbstractStyledLayer<E> implements StyledLayerInterface<E> {
- /** Logger for warning- and error messages. */
- protected Logger LOGGER = LangUtil.createLogger(this);
+ /** Logger for warning- and error messages. */
+ protected Logger LOGGER = LangUtil.createLogger(this);
- /** Holds the unique ID of the geo object. */
- protected String id = null;
- /** Holds a short (language-specific) description of the geo object. */
- protected Translation title = null;
- /** Holds a long (language-specific) description of the geo object. */
- protected Translation desc = null;
- /** Holds the (language-specific) keywords to describe the geo object. */
- protected Translation keywords = null;
- /** Holds an icon to represent the geo object */
- protected ImageIcon icon = null;
- /** Holds the geo object represeneted by the map */
- protected E geoObject = null;
- /** Holds the CRS of the geo object */
- protected CoordinateReferenceSystem crs = null;
- /** Holds the bounds of the geo object */
- protected Envelope envelope = null;
- /** Holds the display style for the geo object */
- protected Style style = null;
+ /** Holds the unique ID of the geo object. */
+ protected String id = null;
+ /** Holds a short (language-specific) description of the geo object. */
+ protected Translation title = null;
+ /** Holds a long (language-specific) description of the geo object. */
+ protected Translation desc = null;
+ /** Holds the (language-specific) keywords to describe the geo object. */
+ protected Translation keywords = null;
+ /** Holds an icon to represent the geo object */
+ protected ImageIcon icon = null;
+ /** Holds the geo object represeneted by the map */
+ protected E geoObject = null;
+ /** Holds the CRS of the geo object */
+ protected CoordinateReferenceSystem crs = null;
+ /** Holds the bounds of the geo object */
+ protected Envelope envelope = null;
+ /** Holds the display style for the geo object */
+ protected Style style = null;
- /**
- * Creates a language specific styled layer.
- * @param geoObject the geo object
- * @param envelope the bounds of the geo object
- * @param crs the CRS of the geo object
- * @param id a unique ID for the geo object
- * @param title a (language-specific) short description
- * @param desc a (language-specific) long description
- * @param keywords (language-specific) keywords for the geo objects
- * @param style a display style
- * @param icon an icon for the object
- * @exception IllegalArgumentException if {@code null} is given as ID or
- * geo object
- */
- public AbstractStyledLayer(E geoObject, Envelope envelope, CoordinateReferenceSystem crs, String id, Translation title, Translation desc, Translation keywords, Style style, ImageIcon icon) {
- if ( id == null )
- throw new IllegalArgumentException("ID is not allowed to be null!");
- if ( geoObject == null )
- throw new IllegalArgumentException("The GeoObject is not allowed to be null!");
- this.id = id;
- this.geoObject = geoObject;
- this.crs = crs;
- this.envelope = envelope;
- setTitle( title );
- setDesc( desc );
- setKeywords( keywords );
- setStyle( style );
- setImageIcon( icon );
- }
+ private File sldFile;
- /**
- * Creates a non-translated styled layer.
- * @param geoObject the geo object
- * @param envelope the bounds of the geo object
- * @param crs the CRS of the geo object
- * @param id a unique ID for the geo object
- * @param title a short description
- * @param desc a long description
- * @param keywords keywords for the geo objects
- * @param style a display style
- * @param icon an icon for the object
- * @exception IllegalArgumentException if {@code null} is given as ID
- */
- public AbstractStyledLayer(E geoObject, Envelope envelope, CoordinateReferenceSystem crs, String id, String title, String desc, String keywords, Style style, ImageIcon icon ) {
- this(geoObject, envelope, crs, id, (Translation)null, null, null, style, icon);
- setTitle( title );
- setDesc( desc );
- setKeywords( keywords );
- }
+ /**
+ * Creates a language specific styled layer.
+ *
+ * @param geoObject
+ * the geo object
+ * @param envelope
+ * the bounds of the geo object
+ * @param crs
+ * the CRS of the geo object
+ * @param id
+ * a unique ID for the geo object
+ * @param title
+ * a (language-specific) short description
+ * @param desc
+ * a (language-specific) long description
+ * @param keywords
+ * (language-specific) keywords for the geo objects
+ * @param style
+ * a display style
+ * @param icon
+ * an icon for the object
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID or geo object
+ */
+ public AbstractStyledLayer(E geoObject, Envelope envelope,
+ CoordinateReferenceSystem crs, String id, Translation title,
+ Translation desc, Translation keywords, Style style, ImageIcon icon) {
+ if (id == null)
+ throw new IllegalArgumentException("ID is not allowed to be null!");
+ if (geoObject == null)
+ throw new IllegalArgumentException(
+ "The GeoObject is not allowed to be null!");
+ this.id = id;
+ this.geoObject = geoObject;
+ this.crs = crs;
+ this.envelope = envelope;
+ setTitle(title);
+ setDesc(desc);
+ setKeywords(keywords);
+ setStyle(style);
+ setImageIcon(icon);
+ }
- /**
- * Returns a ID for the geo object. The ID should be unique in a map ob
- * {@linkplain StyledLayerInterface styled layer objects}
- */
- public String getId() {
- return id;
- }
+ /**
+ * Creates a non-translated styled layer.
+ *
+ * @param geoObject
+ * the geo object
+ * @param envelope
+ * the bounds of the geo object
+ * @param crs
+ * the CRS of the geo object
+ * @param id
+ * a unique ID for the geo object
+ * @param title
+ * a short description
+ * @param desc
+ * a long description
+ * @param keywords
+ * keywords for the geo objects
+ * @param style
+ * a display style
+ * @param icon
+ * an icon for the object
+ * @exception IllegalArgumentException
+ * if {@code null} is given as ID
+ */
+ public AbstractStyledLayer(E geoObject, Envelope envelope,
+ CoordinateReferenceSystem crs, String id, String title,
+ String desc, String keywords, Style style, ImageIcon icon) {
+ this(geoObject, envelope, crs, id, (Translation) null, null, null,
+ style, icon);
+ setTitle(title);
+ setDesc(desc);
+ setKeywords(keywords);
+ }
- /**
- * Returns a short (language-specific) description of the geo object.
- */
- public Translation getTitle() {
- return title;
- }
+ /**
+ * Returns a ID for the geo object. The ID should be unique in a map ob
+ * {@linkplain StyledLayerInterface styled layer objects}
+ */
+ public String getId() {
+ return id;
+ }
- /**
- * Sets a short (language-specific) description of the geo object.
- * If {@code title} is {@code null} an untranslated default title is set, so
- * {@link #getTitle()} never returns {@code null}.
- * @param title new description for the geo object
- */
- public void setTitle(Translation title) {
- this.title = (title != null) ? title : new Translation("untitled");
- }
+ /**
+ * Returns a short (language-specific) description of the geo object.
+ */
+ public Translation getTitle() {
+ return title;
+ }
- /**
- * Sets a short (non-translated) description of the geo object.
- * If {@code title} is {@code null} an untranslated default title is set, so
- * {@link #getTitle()} never returns {@code null}.
- * @param title new description for the geo object
- */
- public void setTitle(String title) {
- setTitle( title != null ? new Translation(title): (Translation)null );
- }
+ /**
+ * Sets a short (language-specific) description of the geo object. If
+ * {@code title} is {@code null} an untranslated default title is set, so
+ * {@link #getTitle()} never returns {@code null}.
+ *
+ * @param title
+ * new description for the geo object
+ */
+ public void setTitle(Translation title) {
+ this.title = (title != null) ? title : new Translation("untitled");
+ }
- /**
- * Returns a long (language-specific) description of the object.
- */
- public Translation getDesc() {
- return desc;
- }
+ /**
+ * Sets a short (non-translated) description of the geo object. If
+ * {@code title} is {@code null} an untranslated default title is set, so
+ * {@link #getTitle()} never returns {@code null}.
+ *
+ * @param title
+ * new description for the geo object
+ */
+ public void setTitle(String title) {
+ setTitle(title != null ? new Translation(title) : (Translation) null);
+ }
- /**
- * Sets a long (language-specific) description of the object.
- * If {@code desc} is {@code null} an (untranslated) empty description is set, so
- * {@link #getDesc()} never returns {@code null}.
- * @param desc new description for the geo object
- */
- public void setDesc(Translation desc) {
- this.desc = (desc != null) ? desc : new Translation("");
- }
+ /**
+ * Returns a long (language-specific) description of the object.
+ */
+ public Translation getDesc() {
+ return desc;
+ }
- /**
- * Sets a long (non-translated) description of the object.
- * If {@code desc} is {@code null} an (untranslated) empty description is set, so
- * {@link #getDesc()} never returns {@code null}.
- * @param desc new description for the geo object
- */
- public void setDesc(String desc) {
- setDesc( desc != null ? new Translation(desc) : (Translation)null);
- }
+ /**
+ * Sets a long (language-specific) description of the object. If
+ * {@code desc} is {@code null} an (untranslated) empty description is set,
+ * so {@link #getDesc()} never returns {@code null}.
+ *
+ * @param desc
+ * new description for the geo object
+ */
+ public void setDesc(Translation desc) {
+ this.desc = (desc != null) ? desc : new Translation("");
+ }
- /**
- * Returns a (language-specific) key word sequence for the geo object.
- */
- public Translation getKeywords() {
- return keywords;
- }
+ /**
+ * Sets a long (non-translated) description of the object. If {@code desc}
+ * is {@code null} an (untranslated) empty description is set, so
+ * {@link #getDesc()} never returns {@code null}.
+ *
+ * @param desc
+ * new description for the geo object
+ */
+ public void setDesc(String desc) {
+ setDesc(desc != null ? new Translation(desc) : (Translation) null);
+ }
- /**
- * Sets a (language-specific) key word sequence for the geo object.
- * If {@code keywords} is {@code null} an (untranslated) empty string is set, so
- * {@link #getKeywords()} never returns {@code null}.
- * @param keywords Keywords
- */
- public void setKeywords(Translation keywords) {
- this.keywords = (keywords != null) ? keywords : new Translation("");
- }
+ /**
+ * Returns a (language-specific) key word sequence for the geo object.
+ */
+ public Translation getKeywords() {
+ return keywords;
+ }
- /**
- * Sets a (non-translated) key word sequence for the geo object.
- * If {@code keywords} is {@code null} an (untranslated) empty string is set, so
- * {@link #getKeywords()} never returns {@code null}.
- * @param keywords Keywords
- */
- public void setKeywords(String keywords) {
- setKeywords( keywords != null ? new Translation(keywords) : (Translation)null);
- }
+ /**
+ * Sets a (language-specific) key word sequence for the geo object. If
+ * {@code keywords} is {@code null} an (untranslated) empty string is set,
+ * so {@link #getKeywords()} never returns {@code null}.
+ *
+ * @param keywords
+ * Keywords
+ */
+ public void setKeywords(Translation keywords) {
+ this.keywords = (keywords != null) ? keywords : new Translation("");
+ }
- /**
- * Returns the geo object representet in the map. Sub classes must override
- * this method to implement "late loading" on first call.
- * @return {@link #geoObject}
- */
- public E getGeoObject() {
- return geoObject;
- }
+ /**
+ * Sets a (non-translated) key word sequence for the geo object. If
+ * {@code keywords} is {@code null} an (untranslated) empty string is set,
+ * so {@link #getKeywords()} never returns {@code null}.
+ *
+ * @param keywords
+ * Keywords
+ */
+ public void setKeywords(String keywords) {
+ setKeywords(keywords != null ? new Translation(keywords)
+ : (Translation) null);
+ }
- /**
- * Returns the bounds of the geo object.
- */
- public Envelope getEnvelope() {
- return envelope;
- }
+ /**
+ * Returns the geo object representet in the map. Sub classes must override
+ * this method to implement "late loading" on first call.
+ *
+ * @return {@link #geoObject}
+ */
+ public E getGeoObject() {
+ return geoObject;
+ }
- /**
- * Returns the {@link CoordinateReferenceSystem} of the geo object.
- */
- public CoordinateReferenceSystem getCrs() {
- return crs;
- }
+ /**
+ * Returns the bounds of the geo object.
+ */
+ public Envelope getEnvelope() {
+ return envelope;
+ }
- /**
- * Returns {@link #crs CoordinateReferenceSystem.toString()}. This method
- * can be overriden to create a "nicer" description.
- */
- public String getCRSString() {
- return crs.toString();
- }
+ /**
+ * Returns the {@link CoordinateReferenceSystem} of the geo object.
+ */
+ public CoordinateReferenceSystem getCrs() {
+ return crs;
+ }
- /**
- * Returns an icon, which represents the geo object.
- */
- public ImageIcon getImageIcon() {
- return null;
- }
+ /**
+ * Returns {@link #crs CoordinateReferenceSystem.toString()}. This method
+ * can be overriden to create a "nicer" description.
+ */
+ public String getCRSString() {
+ return crs.toString();
+ }
- /**
- * Sets an icon, which represents the geo object.
- * @param icon an icon
- */
- public void setImageIcon(ImageIcon icon) {
- this.icon = icon;
- }
+ /**
+ * Returns an icon, which represents the geo object.
+ */
+ public ImageIcon getImageIcon() {
+ return null;
+ }
- /**
- * Returns the display style for the geo object.
- */
- public Style getStyle() {
- return style;
- }
+ /**
+ * Sets an icon, which represents the geo object.
+ *
+ * @param icon
+ * an icon
+ */
+ public void setImageIcon(ImageIcon icon) {
+ this.icon = icon;
+ }
- /**
- * Sets the display style for the geo object.
- * If {@code style} is {@code null} an default style is set, so
- * {@link #getStyle()} never returns {@code null}.
- * @see #createDefaultStyle()
- */
- public void setStyle(Style style) {
- this.style = (style != null) ? style : createDefaultStyle();
- }
+ /**
+ * Returns the display style for the geo object.
+ */
+ public Style getStyle() {
+ return style;
+ }
- /**
- * Creates a default style for the geo object. This style is used whenever
- * the style is set to {@code null}.
- * @see #setStyle(Style)
- */
- protected abstract Style createDefaultStyle();
+ /**
+ * Sets the display style for the geo object. If {@code style} is
+ * {@code null} an default style is set, so {@link #getStyle()} never
+ * returns {@code null}.
+ *
+ * @see #createDefaultStyle()
+ */
+ public void setStyle(Style style) {
+ this.style = (style != null) ? style : createDefaultStyle();
+ }
+
+ /**
+ * Creates a default style for the geo object. This style is used whenever
+ * the style is set to {@code null}.
+ *
+ * @see #setStyle(Style)
+ */
+ protected abstract Style createDefaultStyle();
+
+ /**
+ * Optinally set a File to Store the SLD in
+ */
+ public void setSldFile(File sldFile) {
+ this.sldFile = sldFile;
+ }
+
+ /**
+ * Get <code>null</code> or the File wherethe SLD has been read from
+ */
+ public File getSldFile() {
+ return sldFile;
+ }
+
}
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledFS.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledFS.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledFS.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -364,26 +364,6 @@
return getGeoObject().getSchema();
}
- /**
- * Tries to load a style from the file denoted in {@link #getSldFile()}. If
- * the file doesn't exits, return <code>null</code>;
- *
- * @return <code>true</code> is style was loaded
- */
- public boolean loadStyle() {
- if (getSldFile() == null)
- return false;
-
- try {
- Style[] loadSLD = StylingUtil.loadSLD(getSldFile());
- setStyle(loadSLD[0]);
- return true;
- } catch (Exception e) {
- return false;
- }
-
- }
-
public void setTitle(String title) {
setTitle(new Translation(title));
}
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverage.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverage.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverage.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -338,5 +338,4 @@
public void setNodataValue(Double nodataValue) {
this.nodataValue = nodataValue;
}
-
}
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverageReader.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverageReader.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledGridCoverageReader.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -29,12 +29,14 @@
******************************************************************************/
package de.schmitzm.geotools.styling;
+import java.io.File;
import java.net.URL;
import javax.swing.ImageIcon;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
+import org.geotools.data.FeatureSource;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.styling.Style;
@@ -57,8 +59,31 @@
AbstractStyledLayer<AbstractGridCoverage2DReader> implements
StyledGridCoverageReaderInterface {
private Double nodataValue;
+ private File sldFile;
+ /**
+ * @return The {@link File} where the SLD was loaded from or
+ * <code>null</code> if there didn't exist a {@link File}.
+ *
+ * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
+ */
@Override
+ public File getSldFile() {
+ return sldFile;
+ }
+
+ /**
+ * Associates this .sld with the {@link FeatureSource}, but does not
+ * automatically load the file. It must not even exist.
+ *
+ * @param sldFile
+ */
+ @Override
+ public void setSldFile(File sldFile) {
+ this.sldFile = sldFile;
+ }
+
+ @Override
public ReferencedEnvelope getReferencedEnvelope() {
return new ReferencedEnvelope(getEnvelope(), getCrs());
}
@@ -70,7 +95,6 @@
/** Holds the meta data for displaying a legend. */
protected RasterLegendData legendData = null;
- private Double nodataValue2;
/**
* Creates a styled grid with language-specific informations.
@@ -275,6 +299,9 @@
* Returns the meta data needed for displaying a legend.
*/
public RasterLegendData getLegendMetaData() {
+ if (legendData == null)
+ return StyledLayerUtil.generateRasterLegendData(getStyle(), false,
+ null);
return legendData;
}
@@ -287,8 +314,9 @@
* legend meta data
*/
public void setLegendMetaData(RasterLegendData legendData) {
- this.legendData = (legendData != null) ? legendData
- : new RasterLegendData(false);
+ // this.legendData = (legendData != null) ? legendData
+ // : new RasterLegendData(false);
+ this.legendData = legendData;
}
/**
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerInterface.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerInterface.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerInterface.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -29,6 +29,7 @@
******************************************************************************/
package de.schmitzm.geotools.styling;
+import java.io.File;
import java.net.URL;
import javax.swing.ImageIcon;
@@ -88,13 +89,13 @@
* <ul>
* <li>layer list only depends on {@link StyledLayerInterface}</li>
* <li>methods returning {@link Translation} must not return {@code null}</li>
- * <li>methods returning {@link AttributeMetadataInterface}-Map must not return {@code
- * null}</li>
- * <li>static helper method to get a new {@link AttributeMetadataImpl}-map with the
- * visible attributes only</li>
- * <li>static helper method to create a "default" {@link AttributeMetadataImpl}-map
- * for a {@link FeatureCollection} with all attributes visible and without real
- * translations, but the attribute name as description.</li>
+ * <li>methods returning {@link AttributeMetadataInterface}-Map must not return
+ * {@code null}</li>
+ * <li>static helper method to get a new {@link AttributeMetadataImpl}-map with
+ * the visible attributes only</li>
+ * <li>static helper method to create a "default" {@link AttributeMetadataImpl}
+ * -map for a {@link FeatureCollection} with all attributes visible and without
+ * real translations, but the attribute name as description.</li>
* </ul>
*/
public interface StyledLayerInterface<E> {
@@ -123,7 +124,6 @@
*/
public ReferencedEnvelope getReferencedEnvelope();
-
/**
* @return return an ImageIcon - <code>null</code> is valid and no icon or a
* default icon will then be shown
@@ -151,7 +151,7 @@
* @return null or an {@link URL}
*/
public URL getInfoURL();
-
+
/**
* Should be called when this Object is not needed anymore.
*/
@@ -165,5 +165,17 @@
* reread on next call of getGeoObject()
*/
public void uncache();
-// public String getLegendHtml();
+
+ // public String getLegendHtml();
+
+ /**
+ * Optinally set a File to Store the SLD in
+ */
+ public void setSldFile(File sldFile);
+
+ /**
+ * Get <code>null</code> or the File wherethe SLD has been read from
+ */
+ public File getSldFile();
+
}
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java 2011-03-21 14:12:45 UTC (rev 1534)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java 2011-03-22 10:24:49 UTC (rev 1535)
@@ -122,7 +122,28 @@
private static final SAXBuilder SAX_BUILDER = new SAXBuilder();
private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();
+ final public static String DONT_IMPORT_MARKER_STRING = "DONTIMPORT";
+
/**
+ * Tries to load a style from the file denoted in {@link #getSldFile()}. If
+ * the file doesn't exits, return <code>null</code>;
+ *
+ * @return <code>true</code> is style was loaded
+ */
+ public static boolean loadStyle(StyledLayerInterface<?> styledLayer) {
+ if (styledLayer.getSldFile() == null)
+ return false;
+
+ try {
+ Style[] loadSLD = StylingUtil.loadSLD(styledLayer.getSldFile());
+ styledLayer.setStyle(loadSLD[0]);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
* Is appended to the name of a rule, this rule shall not be shown in the
* legend
*/
@@ -1121,6 +1142,9 @@
if (I18NUtil.isEmpty(labelT))
continue;
+ if (labelT.toString().startsWith(DONT_IMPORT_MARKER_STRING))
+ continue;
+
// final Dimension ICON_SIZE = new Dimension(iconWidth,
// new JLabel().getFontMetrics(new JLabel().getFont())
// .getHeight() > 5 ? new JLabel().getFontMetrics(
More information about the Schmitzm-commits
mailing list