|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectskrueger.geotools.StyledLayerUtil
public class StyledLayerUtil
This class provides static helper methods for dealing with
StyledLayerInterface
stuff.
Field Summary | |
---|---|
static String |
AMLURI
URL for Atlas XML schema |
static String |
ELEM_NAME_AMD
Name of the XML Element for the attribute meta data map |
static String |
ELEM_NAME_ATTRIBUTE
Name of the XML Element for an attribute meta data map entry |
static String |
ELEM_NAME_RASTERLEGEND
Name of the XML Element for an raster legend data entry |
static String |
ELEM_NAME_RLD
Name of the XML Element for the raster legend data |
static String |
ELEM_NAME_TRANSLATION
Name of the XML Element for a translation |
Constructor Summary | |
---|---|
StyledLayerUtil()
|
Method Summary | ||
---|---|---|
static void |
addEmptyStringToAllTextualAttributes(AttributeMetadataMap attributeMetaDataMap,
SimpleFeatureType schema)
Checks every attribute name in the AttributeMetadataMap for its
binding type. |
|
static void |
checkAttribMetaData(AttributeMetadataMap attributeMetaDataMap,
SimpleFeatureType schema)
After loading an atlas, the AttribteMetaData contains whatever is written in the XML. |
|
static Element |
createAttributeMetaDataElement(AttributeMetadata amd)
Creates an JDOM Element for the given AttributeMetadata
object. |
|
static Element |
createAttributeMetaDataMapElement(AttributeMetadataMap amdMap)
Creates an JDOM Element for the given AttributeMetadata
map. |
|
static JPanel |
createLegendPanel(StyledRasterInterface<?> styledRaster,
Style style,
int iconWidth,
int iconHeight)
Creates a JComponent that contains a legend for a given
rasterLayer and a given Style . |
|
static JPanel |
createLegendPanel(Style style,
SimpleFeatureType featureType,
int iconWidth,
int iconHeight)
Creates a JPanel that shows a legend for a list of
FeatureTypeStyle s and a targeted featureType |
|
static MapLayer |
createMapLayer(Object object)
Creates a Geotools MapLayer from an object. |
|
static MapLayer |
createMapLayer(Object object,
Style forcedStyle)
Creates a Geotools MapLayer from an object. |
|
static Element |
createRasterLegendDataElement(RasterLegendData rld)
Creates an JDOM Element for the given RasterLegendData
map. |
|
static StyledLayerInterface<?> |
createStyledLayer(Object object,
String title)
Creates an default instance of StyledLayerInterface for a
Geotools object (GridCoverage2D , FeatureCollection ) with
a default style. |
|
static StyledLayerInterface<?> |
createStyledLayer(Object object,
String title,
StyledLayerStyle style)
Creates an default instance of StyledLayerInterface for a
Geotools object (GridCoverage2D , FeatureCollection ) with
a given style. |
|
static Element |
createTranslationElement(String tagname,
Translation translation)
Creates an JDOM Element for the given Translation . |
|
static RasterLegendData |
generateRasterLegendData(ColorMap colorMap,
boolean paintGaps,
Integer digits)
Creates RasterLegendData from a ColorMap . |
|
static RasterLegendData |
generateRasterLegendData(Style style,
boolean paintGaps,
Integer digits)
Creates RasterLegendData from the ColorMap of a style. |
|
static ColorModel |
getColorModel(StyledRasterInterface<?> styledGrid)
Extracts the ColorModel of any StyledRasterInterface . |
|
static StyledLayerStyle<AttributeMetadataMap> |
getStyledLayerStyle(StyledFeatureCollectionInterface styledFC)
Returns the style and attribute meta data of a StyledFeatureCollectionInterface as a StyledLayerStyle . |
|
static StyledLayerStyle<RasterLegendData> |
getStyledLayerStyle(StyledGridCoverageInterface styledGC)
Returns the style and raster meta data of a StyledGridCoverageInterface as a StyledLayerStyle . |
|
static StyledLayerStyle<?> |
getStyledLayerStyle(StyledLayerInterface styledObject)
Returns the style a StyledLayerInterface as a
StyledLayerStyle . |
|
static AttributeMetadataMap |
getVisibleAttributeMetaData(AttributeMetadataMap amdMap,
boolean visible)
Return only the visible or invisible entries of an AttributeMetaData-Map. |
|
static boolean |
isStyleable(StyledRasterInterface<?> styledRaster)
|
|
static AttributeMetadataMap |
loadAttributeMetaDataMap(URL documentUrl)
Loads a AttributeMetadata object from an URL. |
|
static RasterLegendData |
loadRasterLegendData(URL documentUrl)
Loads a RasterLegendData object from an URL. |
|
static StyledLayerStyle<AttributeMetadataMap> |
loadStyledFeatureStyle(URL geoObjectURL)
Loads a SLD-Style from a .sld file and
AttributeMetaData-Map from a .amd
file for a given geo-object (feature) source. |
|
static StyledLayerStyle<AttributeMetadataMap> |
loadStyledFeatureStyle(URL geoObjectURL,
String sldExt,
String rldExt)
Loads a SLD-Style and a AttributeMetaData-Map for a given geo-object (feature) source. |
|
static StyledLayerStyle<RasterLegendData> |
loadStyledRasterStyle(URL geoObjectURL)
Loads a SLD-Style from a .sld file and
Raster-LegendData from a .rld file
for a given geo-object (raster) source. |
|
static StyledLayerStyle<RasterLegendData> |
loadStyledRasterStyle(URL geoObjectURL,
String sldExt,
String rldExt)
Loads a SLD-Style and Raster-LegendData for a given geo-object (raster) source. |
|
static AttributeMetadata |
parseAttributeMetaData(Element element)
Parses a AttributeMetadata object from an JDOM-Element . |
|
static AttributeMetadataMap |
parseAttributeMetaDataMap(Element element)
Parses a AttributeMetadata map from an JDOM-Element with
<attribute> -childs. |
|
static RasterLegendData |
parseRasterLegendData(Element element)
Parses a RasterLegendData object from an JDOM-Element . |
|
static Translation |
parseTranslation(Element element)
Parses a Translation object from an JDOM-Element . |
|
static void |
saveAttributeMetaDataMap(AttributeMetadataMap amdMap,
URL documentUrl)
Saves a AttributeMetaData-Map to an URL. |
|
static void |
saveRasterLegendData(RasterLegendData rld,
URL documentUrl)
Saves a RasterLegendData to an URL. |
|
static void |
saveStyledLayerStyle(StyledLayerStyle<?> style,
URL geoObjectURL)
Stores the SLD-Style to a .sld file and the
meta data (RasterLegendData or AttributeMetadata ) to a
.rld or .amd file. for a given geo-object source. |
|
static
|
saveStyledLayerStyle(StyledLayerStyle<T> style,
URL geoObjectURL,
String sldExt,
String mdExt)
Stores a SLD-Style and Raster-LegendData for a given geo-object (raster) source. |
|
static void |
setStyledLayerStyle(StyledLayerInterface styledObject,
StyledLayerStyle<?> style)
Sets a style to StyledLayerInterface . |
|
static boolean |
updateMapLayerStyleIfChangedAndKeepSelection(MapLayer mapLayer,
Style style2)
Set the given Style as the Style of the MapLayer , unless the
styles are the same (not comparing selection stuff). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String AMLURI
public static final String ELEM_NAME_AMD
public static final String ELEM_NAME_RLD
public static final String ELEM_NAME_ATTRIBUTE
public static final String ELEM_NAME_RASTERLEGEND
public static final String ELEM_NAME_TRANSLATION
Constructor Detail |
---|
public StyledLayerUtil()
Method Detail |
---|
public static MapLayer createMapLayer(Object object) throws Exception
MapLayer
from an object. If the object is a
StyledLayerInterface
then its sytle is used. In case of direct
Geotools objects (GridCoverage2D
,
AbstractGridCoverage2DReader
, FeatureCollection
) a
default style is generated.
object
- an Object
Exception
- if null
is given as object or an error occurs
during layer creationpublic static MapLayer createMapLayer(Object object, Style forcedStyle) throws Exception
MapLayer
from an object. If the object is a
StyledLayerInterface
then its sytle is used. In case of direct
Geotools objects (GridCoverage2D
,
AbstractGridCoverage2DReader
, FeatureCollection
) a
default style is generated.
object
- an ObjectforcedStyle
- (SLD-)Style to force for the object
Exception
- if null
is given as object or an error occurs
during layer creationpublic static StyledLayerInterface<?> createStyledLayer(Object object, String title)
StyledLayerInterface
for a
Geotools object (GridCoverage2D
, FeatureCollection
) with
a default style.
object
- an Objecttitle
- title for the object
UnsupportedOperationException
- if null
is given as object or an error occurs
during creationpublic static StyledLayerInterface<?> createStyledLayer(Object object, String title, StyledLayerStyle style)
StyledLayerInterface
for a
Geotools object (GridCoverage2D
, FeatureCollection
) with
a given style.
object
- an Objecttitle
- title for the objectstyle
- style and meta data for the object
UnsupportedOperationException
- if null
is given as object or an error occurs
during creationpublic static AttributeMetadataMap getVisibleAttributeMetaData(AttributeMetadataMap amdMap, boolean visible)
amdMap
- AttributeMetaData-Mapvisible
- indicated whether the visible or invisible entries are
returned
TODO replace with
AttributeMetadataMap.sortedValuesVisibleOnly()
public static AttributeMetadata parseAttributeMetaData(Element element)
AttributeMetadata
object from an JDOM-Element
.
This method works like AMLImport#parseDataAttribute(org.w3c.dom.Node
, but for JDOM.
TODO 20.11.2009, SK: There are some new attribute weight, functiona,
functionX and nodata in AttributeMetaData that should be parsed/exported
too. but this method is only used by ISDSS, which is not supporting that
stuff anyways.
element
- Element
to parsepublic static AttributeMetadataMap parseAttributeMetaDataMap(Element element)
AttributeMetadata
map from an JDOM-Element
with
<attribute>
-childs.
element
- Element
to parse
TODO Since GP 1.3 the AttributeMetadata
class has more
attributes which are not used by Xulu/ISDSS. GP
exports/imports the AMD via AMLExporter and AMLImporter
classes. (SK, 3.2.2010) *public static AttributeMetadataMap loadAttributeMetaDataMap(URL documentUrl) throws Exception
AttributeMetadata
object from an URL.
documentUrl
- URL
to parse
Exception
parseAttributeMetaData(Element)
public static Element createAttributeMetaDataElement(AttributeMetadata amd)
Element
for the given AttributeMetadata
object.
amd
- meta data for one attribute
TODO Since GP 1.3 the AttributeMetadata
class has more
attributes which are not used by Xulu/ISDSS. GP
exports/imports the AMD via AMLExporter and AMLImporter
classes. (SK, 3.2.2010)public static Element createAttributeMetaDataMapElement(AttributeMetadataMap amdMap)
Element
for the given AttributeMetadata
map.
amdMap
- map of attribute meta datapublic static void saveAttributeMetaDataMap(AttributeMetadataMap amdMap, URL documentUrl) throws Exception
AttributeMetaData-Map
to an URL.
amdMap
- map of AttributeMetadata
documentUrl
- URL
to store the XML
Exception
public static RasterLegendData parseRasterLegendData(Element element)
RasterLegendData
object from an JDOM-Element
.
This method works like AMLImport#parseRasterLegendData(org.w3c.dom.Node
, but for JDOM.
element
- Element
to parsepublic static RasterLegendData loadRasterLegendData(URL documentUrl) throws Exception
RasterLegendData
object from an URL.
documentUrl
- URL
to parse
Exception
parseAttributeMetaData(Element)
public static Element createRasterLegendDataElement(RasterLegendData rld)
Element
for the given RasterLegendData
map.
rld
- raster legend datapublic static RasterLegendData generateRasterLegendData(ColorMap colorMap, boolean paintGaps, Integer digits)
RasterLegendData
from a ColorMap
.
colorMap
- a color mappaintGaps
- indicated whether gaps are painted between the legend itemsdigits
- number of digits the grid value classes (and legend) are
rounded to (null means no round; >= 0 means digits after
comma; < 0 means digits before comma)public static RasterLegendData generateRasterLegendData(Style style, boolean paintGaps, Integer digits)
RasterLegendData
from the ColorMap
of a style.
style
- a raster style (must contain a RasterSymbolizer
)paintGaps
- indicated whether gaps are painted between the legend itemsdigits
- number of digits the grid value classes (and legend) are
rounded to (null means no round; >= 0 means digits after
comma; < 0 means digits before comma)public static void saveRasterLegendData(RasterLegendData rld, URL documentUrl) throws Exception
RasterLegendData
to an URL.
rld
- raster legend datadocumentUrl
- URL
to store the XML
Exception
public static final Translation parseTranslation(Element element)
Translation
object from an JDOM-Element
. This
method works like AMLImport#parseTranslation(org.w3c.dom.Node
,
but for JDOM.
element
- Element
to parsepublic static final Element createTranslationElement(String tagname, Translation translation)
Element
for the given Translation
.
tagname
- Name of the Elementtranslation
- Translation to store in the Elementpublic static void setStyledLayerStyle(StyledLayerInterface styledObject, StyledLayerStyle<?> style)
StyledLayerInterface
.
styledObject
- a styled objectstyle
- a Stylepublic static StyledLayerStyle<?> getStyledLayerStyle(StyledLayerInterface styledObject)
StyledLayerInterface
as a
StyledLayerStyle
.
styledObject
- a styled object
StyledLayerStyle<RasterLegendData>
for
StyledGridCoverageInterface
or StyledLayerStyle<Map<Integer,AttributeMetaData>>
for
StyledFeatureCollectionInterface
public static StyledLayerStyle<RasterLegendData> getStyledLayerStyle(StyledGridCoverageInterface styledGC)
StyledGridCoverageInterface
as a StyledLayerStyle
.
styledGC
- a styled grid coveragepublic static StyledLayerStyle<AttributeMetadataMap> getStyledLayerStyle(StyledFeatureCollectionInterface styledFC)
StyledFeatureCollectionInterface
as a StyledLayerStyle
.
styledFC
- a styled feature collectionpublic static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(URL geoObjectURL, String sldExt, String rldExt)
geoObjectURL
- URL of the (already read) raster objectsldExt
- file extention for the SLD filerldExt
- file extention for the raster legend-data file
null
in case of any errorpublic static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(URL geoObjectURL)
.sld
file and
Raster-LegendData from a .rld
file
for a given geo-object (raster) source. The SLD file must be present. A
missing raster legend-data file is tolerated.
geoObjectURL
- URL of the (already read) raster objectsldExt
- file extention for the SLD filerldExt
- file extention for the raster legend-data file
null
in case of any errorpublic static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(URL geoObjectURL, String sldExt, String rldExt)
geoObjectURL
- URL of the (already read) feature objectsldExt
- file extention for the SLD filerldExt
- file extention for the raster legend-data file
null
in case of any errorpublic static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(URL geoObjectURL)
.sld
file and
AttributeMetaData-Map from a .amd
file for a given geo-object (feature) source. The SLD file must be
present. A missing attribute meta-data file is tolerated.
geoObjectURL
- URL of the (already read) feature objectsldExt
- file extention for the SLD filerldExt
- file extention for the raster legend-data file
null
in case of any errorpublic static <T> void saveStyledLayerStyle(StyledLayerStyle<T> style, URL geoObjectURL, String sldExt, String mdExt) throws Exception
style
- style to savegeoObjectURL
- URL of the raster objectsldExt
- file extention for the SLD filemdExt
- file extention for the meta-data file
Exception
public static void saveStyledLayerStyle(StyledLayerStyle<?> style, URL geoObjectURL) throws Exception
.sld
file and the
meta data (RasterLegendData
or AttributeMetadata
) to a
.rld
or .amd
file. for a given geo-object source.
style
- style to savegeoObjectURL
- URL of the (already read) raster object
Exception
public static JPanel createLegendPanel(Style style, SimpleFeatureType featureType, int iconWidth, int iconHeight)
JPanel
that shows a legend for a list of
FeatureTypeStyle
s and a targeted featureType
featureType
- If this a legend for Point, Polygon or Line?list
- The Styles to presented in this legendpublic static JPanel createLegendPanel(StyledRasterInterface<?> styledRaster, Style style, int iconWidth, int iconHeight)
JComponent
that contains a legend for a given
rasterLayer and a given Style
.
style
- if null
, the default Style
is extracetd
from the StyledRasterInterface
public static ColorModel getColorModel(StyledRasterInterface<?> styledGrid)
ColorModel
of any StyledRasterInterface
. May
return null
if the geoobject can not be accessed.
public static boolean isStyleable(StyledRasterInterface<?> styledRaster)
true
if a RasterSymbolizer
can be applied
and will have an effect. Some rasters (e.g. GeoTIFF) can come
with their own ColorModel
and will ignore any
RasterSymbolizer
= SLD.public static boolean updateMapLayerStyleIfChangedAndKeepSelection(MapLayer mapLayer, Style style2)
MapLayer
, unless the
styles are the same (not comparing selection stuff). If the
MapLayer
s Style
is changed, the selection FTS is kept.MapLayer#setStyle(Style)
triggers an event leading to a
repaint, so only use it when needed.
true
if the MapLayer
's Style
has
been changed.public static void checkAttribMetaData(AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema)
public static void addEmptyStringToAllTextualAttributes(AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema)
AttributeMetadataMap
for its
binding type. It the type is textual, add the mrpty string as a NODATA
value.
attributeMetaDataMap
- schema
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |