[Schmitzm-commits] r1844 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Jan 29 22:59:48 CET 2012
Author: alfonx
Date: 2012-01-29 22:59:46 +0100 (Sun, 29 Jan 2012)
New Revision: 1844
Modified:
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
Log:
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java 2012-01-29 19:11:08 UTC (rev 1843)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java 2012-01-29 21:59:46 UTC (rev 1844)
@@ -63,7 +63,9 @@
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.geotools.brewer.color.BrewerPalette;
+import org.geotools.brewer.color.ColorBrewer;
import org.geotools.brewer.color.PaletteSuitability;
+import org.geotools.brewer.color.PaletteType;
import org.geotools.brewer.color.SampleScheme;
import org.geotools.coverage.AbstractCoverage;
import org.geotools.coverage.Category;
@@ -157,8 +159,7 @@
/**
* Diese Klasse enthaelt Hilfsfunktionen zum GeoTools-Styling
*
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
- * (University of Bonn/Germany)
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*
* @version 1.1
@@ -183,40 +184,35 @@
}
/** Standard-Instanz einer {@link StyleFactory} */
- public static final StyleFactory STYLE_FACTORY = CommonFactoryFinder
- .getStyleFactory(GeoTools.getDefaultHints());
+ public static final StyleFactory STYLE_FACTORY = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
/** Standard-Instanz eines {@link StyleBuilder}. */
- public static final StyleBuilder STYLE_BUILDER = new StyleBuilder(
- STYLE_FACTORY);
+ public static final StyleBuilder STYLE_BUILDER = new StyleBuilder(STYLE_FACTORY);
public static final FilterFactory2 ff = FeatureUtil.FILTER_FACTORY2;
/** A Filter to mark a {@link TextSymbolizer} class as disabled **/
- public final static PropertyIsEqualTo LABEL_CLASS_DISABLED_FILTER = ff
- .equals(ff.literal("LABEL_CLASS_DISABLED"), ff.literal("YES"));
+ public final static PropertyIsEqualTo LABEL_CLASS_DISABLED_FILTER = ff.equals(ff.literal("LABEL_CLASS_DISABLED"),
+ ff.literal("YES"));
/** A Filter to mark a {@link TextSymbolizer} class as enabled **/
- public final static PropertyIsEqualTo LABEL_CLASS_ENABLED_FILTER = ff
- .equals(ff.literal("LABEL_CLASS_ENABLED"),
- ff.literal("LABEL_CLASS_ENABLED"));
+ public final static PropertyIsEqualTo LABEL_CLASS_ENABLED_FILTER = ff.equals(ff.literal("LABEL_CLASS_ENABLED"),
+ ff.literal("LABEL_CLASS_ENABLED"));
- public static final DuplicatingStyleVisitor DUPLICATINGSTYLEVISITOR = new DuplicatingStyleVisitor(
- STYLE_FACTORY);
+ public static final DuplicatingStyleVisitor DUPLICATINGSTYLEVISITOR = new DuplicatingStyleVisitor(STYLE_FACTORY);
// ** Do not change the value, it is needed to recognize SLD **//
static final String ALL_LABEL_CLASSES_ENABLED = "ALL_LABEL_CLASSES_ENABLED";
/**
- * A Filter to mark that one class/rule has been disabled. Sorry,
- * AtlasStyler specifc, but used in Sl #createLegendSwing method
+ * A Filter to mark that one class/rule has been disabled. Sorry, AtlasStyler specifc, but used in Sl
+ * #createLegendSwing method
**/
- public static final PropertyIsEqualTo RL_DISABLED_FILTER = ff.equals(
- ff.literal("ALL_LABEL_CLASSES_DISABLED"), ff.literal("YES"));
+ public static final PropertyIsEqualTo RL_DISABLED_FILTER = ff.equals(ff.literal("ALL_LABEL_CLASSES_DISABLED"),
+ ff.literal("YES"));
/**
* A Filter to mark that one class/rule is enabled
**/
- public static final PropertyIsEqualTo RL_ENABLED_FILTER = ff.equals(
- ff.literal(ALL_LABEL_CLASSES_ENABLED),
+ public static final PropertyIsEqualTo RL_ENABLED_FILTER = ff.equals(ff.literal(ALL_LABEL_CLASSES_ENABLED),
ff.literal(ALL_LABEL_CLASSES_ENABLED));
// ** Do not change the value, it is needed to recognize SLD **//
@@ -225,8 +221,7 @@
/**
* A Filter to mark that one class/rule is enabled
**/
- public static final PropertyIsEqualTo RL_FILTER_APPLIED_FILTER = ff.equals(
- ff.literal(RL_FILTER_APPLIED_STR),
+ public static final PropertyIsEqualTo RL_FILTER_APPLIED_FILTER = ff.equals(ff.literal(RL_FILTER_APPLIED_STR),
ff.literal(RL_FILTER_APPLIED_STR));
/**
@@ -237,17 +232,14 @@
}
/**
- * RegEx Patter to read palette information from gdalinfo output, for images
- * wir <code>RGB</code>, @see {@link #parseColormapToSld(URL)} @see
- * {@link #parseColormapToSld(File)}
+ * RegEx Patter to read palette information from gdalinfo output, for images wir <code>RGB</code>, @see
+ * {@link #parseColormapToSld(URL)} @see {@link #parseColormapToSld(File)}
**/
- public static final Pattern GDALINFO_COLORMAP_RGB = Pattern
- .compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+).*$");
+ public static final Pattern GDALINFO_COLORMAP_RGB = Pattern.compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+).*$");
/**
- * RegEx Patter to read palette information from gdalinfo output, for images
- * wir <code>RGBA</code> @see {@link #parseColormapToSld(URL)} @see
- * {@link #parseColormapToSld(File)}
+ * RegEx Patter to read palette information from gdalinfo output, for images wir <code>RGBA</code> @see
+ * {@link #parseColormapToSld(URL)} @see {@link #parseColormapToSld(File)}
**/
public static final Pattern GDALINFO_COLORMAP_RGBA = Pattern
.compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+),(\\d+).*$");
@@ -259,40 +251,32 @@
static final Literal size3 = FeatureUtil.FILTER_FACTORY2.literal(3);
static final Graphic SELECTION_GRAPHIC1 = STYLE_FACTORY.createGraphic(
- new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("square"), null,
- STYLE_FACTORY.createFill(STYLE_BUILDER
- .colorExpression(Color.WHITE)), size1, zeroLit) },
- new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
- .literal(1), size1, zeroLit);
+ new ExternalGraphic[0],
+ new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("square"), null,
+ STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.WHITE)), size1, zeroLit) },
+ new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
static final Graphic SELECTION_GRAPHIC2 = STYLE_FACTORY.createGraphic(
- new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
- STYLE_FACTORY.createFill(STYLE_BUILDER
- .colorExpression(Color.BLACK)), size2, zeroLit) },
- new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
- .literal(1), size2, zeroLit);
- static final Graphic SELECTION_GRAPHIC3 = STYLE_FACTORY.createGraphic(
- new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
- STYLE_FACTORY.createFill(STYLE_BUILDER
- .colorExpression(Color.YELLOW.brighter())), size3,
- zeroLit) }, new org.geotools.styling.Symbol[0],
- FeatureUtil.FILTER_FACTORY2.literal(1), size3, zeroLit);
+ new ExternalGraphic[0],
+ new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+ STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.BLACK)), size2, zeroLit) },
+ new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size2, zeroLit);
+ static final Graphic SELECTION_GRAPHIC3 = STYLE_FACTORY
+ .createGraphic(new ExternalGraphic[0],
+ new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+ STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.YELLOW.brighter())), size3,
+ zeroLit) }, new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1),
+ size3, zeroLit);
static final Graphic BLINK_GRAPHIC1 = STYLE_FACTORY.createGraphic(
- new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
- STYLE_FACTORY.createFill(STYLE_BUILDER
- .colorExpression(Color.WHITE)), size0, halfLit) },
- new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
- .literal(1), size0, zeroLit);
+ new ExternalGraphic[0],
+ new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+ STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.WHITE)), size0, halfLit) },
+ new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size0, zeroLit);
private static final FilterFactory FILTER_FACTORY = FeatureUtil.FILTER_FACTORY;
/**
- * THis string is set as the Name of the Rules that describe selected
- * features
+ * THis string is set as the Name of the Rules that describe selected features
**/
public static final String SELECTION_RULE_ID = "SelectionRule";
@@ -302,31 +286,28 @@
private static final String OPTIMIZED_COMMENT = "<!-- This SLD has been exported in an 'optimized' version. This version potentially renders faster, but AtlasStyler will not be able to load it correctly.-->";
/**
- * Unless {@link ColorMap} is not sorted automatically, this method calls
- * {@link #sortColorMap(ColorMap)} after inserting the color map entry.
+ * Unless {@link ColorMap} is not sorted automatically, this method calls {@link #sortColorMap(ColorMap)} after
+ * inserting the color map entry.
*
* @param colorMap
* the color map to extend
* @param colorMapEntry
* the new entry
*/
- public static ColorMap addColorMapEntryAndSort(ColorMap colorMap,
- ColorMapEntry colorMapEntry) {
+ public static ColorMap addColorMapEntryAndSort(ColorMap colorMap, ColorMapEntry colorMapEntry) {
colorMap.addColorMapEntry(colorMapEntry);
return sortColorMap(colorMap);
}
/**
- * Applies general properties (color map type and extended colors) to a
- * {@link ColorMap}.
+ * Applies general properties (color map type and extended colors) to a {@link ColorMap}.
*
* @param sourceColorMap
* color map the properties are taken from
* @param destColormap
* color map the properties are set
*/
- public static void applyColorMapProperties(ColorMap sourceColorMap,
- ColorMap destColormap) {
+ public static void applyColorMapProperties(ColorMap sourceColorMap, ColorMap destColormap) {
if (sourceColorMap == null || destColormap == null)
return;
destColormap.setExtendedColors(sourceColorMap.getExtendedColors());
@@ -334,8 +315,7 @@
}
/**
- * Removes all label information from the {@link ColorMapEntry}s of the
- * given {@link ColorMap}
+ * Removes all label information from the {@link ColorMapEntry}s of the given {@link ColorMap}
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
@@ -386,8 +366,7 @@
/**
* Kopiert eine {@link ColorMap}.
*
- * @return <code>null</code> wenn die uebergebene ColorMap <code>null</code>
- * ist
+ * @return <code>null</code> wenn die uebergebene ColorMap <code>null</code> ist
*/
public static ColorMap cloneColorMap(ColorMap colorMap) {
// MS: Leider kommt der DuplicatingStyleVisitor nicht damit klar, dass
@@ -414,8 +393,7 @@
/**
* Kopiert einen {@link ColorMapEntry}.
*
- * @return <code>null</code> wenn der uebergebene ColorMapEntry
- * <code>null</code> ist
+ * @return <code>null</code> wenn der uebergebene ColorMapEntry <code>null</code> ist
*
* TODO doppelt mit copy( ColorMapEntry? )
*/
@@ -423,24 +401,20 @@
if (colorMapEntry == null)
return null;
- return createColorMapEntry(colorMapEntry.getLabel(),
- getQuantityFromColorMapEntry(colorMapEntry),
- getColorFromColorMapEntry(colorMapEntry),
- getOpacityFromColorMapEntry(colorMapEntry));
+ return createColorMapEntry(colorMapEntry.getLabel(), getQuantityFromColorMapEntry(colorMapEntry),
+ getColorFromColorMapEntry(colorMapEntry), getOpacityFromColorMapEntry(colorMapEntry));
}
/**
- * Prueft, ob zwei {@link ColorMapEntry}-Instanzen gleich sind. Dies ist der
- * Fall, wenn ihnen der gleiche Wert, die gleiche Farbe, die gleiche
- * Transparenz und das gleiche Label zugeordnet ist.
+ * Prueft, ob zwei {@link ColorMapEntry}-Instanzen gleich sind. Dies ist der Fall, wenn ihnen der gleiche Wert, die
+ * gleiche Farbe, die gleiche Transparenz und das gleiche Label zugeordnet ist.
*
* @param cme1
* ein Farbpaletten-Eintrag
* @param cme2
* ein anderer Farbpaletten-Eintrag
*/
- public static boolean colorMapEntriesEqual(ColorMapEntry cme1,
- ColorMapEntry cme2) {
+ public static boolean colorMapEntriesEqual(ColorMapEntry cme1, ColorMapEntry cme2) {
if (cme1 == null ^ cme2 == null)
return false;
if (cme1 == cme2)
@@ -458,8 +432,7 @@
// Wert auf Gleichheit testen
Double quan1 = getQuantityFromColorMapEntry(cme1);
Double quan2 = getQuantityFromColorMapEntry(cme2);
- if (quan1 == null ^ quan2 == null || quan1 != null
- && !quan1.equals(quan2))
+ if (quan1 == null ^ quan2 == null || quan1 != null && !quan1.equals(quan2))
return false;
// Transparenz auf Gleichheit testen
Double op1 = getOpacityFromColorMapEntry(cme1);
@@ -473,8 +446,7 @@
/**
* Kopiert einen {@link ColorMapEntry}.
*
- * @return <code>null</code> wenn der uebergebene ColorMapEntry
- * <code>null</code> ist
+ * @return <code>null</code> wenn der uebergebene ColorMapEntry <code>null</code> ist
*/
public static ColorMapEntry copy(ColorMapEntry colorMapEntry) {
DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
@@ -516,9 +488,8 @@
}
/**
- * Since GT2.6, the AttributeNames are case sensitive. Also the raster
- * Styles need GeometryProperty set to "geom" to work. This method checks
- * all referenced AttributeNames.
+ * Since GT2.6, the AttributeNames are case sensitive. Also the raster Styles need GeometryProperty set to "geom" to
+ * work. This method checks all referenced AttributeNames.
*
* @param Schema
* may be <code>null</code>, e.g. for raster layers
@@ -530,17 +501,15 @@
}
/**
- * Since GT2.6, the AttributeNames are case sensitive. Also the raster
- * Styles need GeometryProperty set to "geom" to work. This method checks
- * all referenced AttributeNames and checks them against the schema.
+ * Since GT2.6, the AttributeNames are case sensitive. Also the raster Styles need GeometryProperty set to "geom" to
+ * work. This method checks all referenced AttributeNames and checks them against the schema.
*
* @param Schema
* may be <code>null</code>, e.g. for raster layers
*
* TODO Rename to correctStye
*/
- public static Style correctPropertyNames(Style style,
- final SimpleFeatureType schema) {
+ public static Style correctPropertyNames(Style style, final SimpleFeatureType schema) {
DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor() {
@Override
@@ -562,9 +531,8 @@
} else if (expression instanceof PropertyName) {
PropertyName pName = (PropertyName) expression;
- Name correctedName = FeatureUtil
- .findBestMatchingAttributeFallBackFirst(schema,
- pName.getPropertyName());
+ Name correctedName = FeatureUtil.findBestMatchingAttributeFallBackFirst(schema,
+ pName.getPropertyName());
return ff.property(correctedName);
}
@@ -579,8 +547,7 @@
divFilter.setExpression2(copy(divFilter.getExpression2()));
} else if (filter instanceof IsNullImpl) {
IsNullImpl isNullFilter = (IsNullImpl) filter;
- isNullFilter.setExpression1(copy(isNullFilter
- .getExpression1()));
+ isNullFilter.setExpression1(copy(isNullFilter.getExpression1()));
} else if (filter instanceof NotImpl) {
NotImpl notFilter = (NotImpl) filter;
List<Filter> children = notFilter.getChildren();
@@ -613,8 +580,7 @@
// TODO noch viel mehr faelle!!
if (filter instanceof IsBetweenImpl) {
IsBetweenImpl isbetween = (IsBetweenImpl) filter;
- isbetween
- .setExpression(copy(isbetween.getExpression()));
+ isbetween.setExpression(copy(isbetween.getExpression()));
}
}
@@ -671,8 +637,8 @@
}
/**
- * @return A {@link FeatureTypeStyle} that can be used style the given
- * geoObject during a blink or highlight process.
+ * @return A {@link FeatureTypeStyle} that can be used style the given geoObject during a blink or highlight
+ * process.
*/
public static FeatureTypeStyle createBlinkFeatureTypeStyle(Object geoObject) {
if (geoObject instanceof GridCoverage2D
@@ -708,65 +674,52 @@
case NONE:
default:
- throw new IllegalArgumentException(
- "Provide a suitable GeometryForm object, NONE not allowed");
+ throw new IllegalArgumentException("Provide a suitable GeometryForm object, NONE not allowed");
}
- return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, Double.NaN,
- Double.NaN);
+ return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, Double.NaN, Double.NaN);
}
- private static Symbolizer[] createBlinkFeatureTypeStyleLine(
- Symbolizer[] symbolizers) {
+ private static Symbolizer[] createBlinkFeatureTypeStyleLine(Symbolizer[] symbolizers) {
LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(Color.red, 6.);
symbolizers = LangUtil.extendArray(symbolizers, ls);
- LineSymbolizer ls2 = STYLE_BUILDER
- .createLineSymbolizer(Color.black, 4.);
+ LineSymbolizer ls2 = STYLE_BUILDER.createLineSymbolizer(Color.black, 4.);
symbolizers = LangUtil.extendArray(symbolizers, ls2);
- LineSymbolizer ls3 = STYLE_BUILDER
- .createLineSymbolizer(Color.white, 2.);
+ LineSymbolizer ls3 = STYLE_BUILDER.createLineSymbolizer(Color.white, 2.);
symbolizers = LangUtil.extendArray(symbolizers, ls3);
return symbolizers;
}
- private static Symbolizer[] createBlinkFeatureTypeStylePolygon(
- Symbolizer[] symbolizers) {
- PolygonSymbolizer pol1 = STYLE_BUILDER.createPolygonSymbolizer(
- STYLE_BUILDER.createStroke(Color.red, 4), null);
+ private static Symbolizer[] createBlinkFeatureTypeStylePolygon(Symbolizer[] symbolizers) {
+ PolygonSymbolizer pol1 = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(Color.red, 4), null);
symbolizers = LangUtil.extendArray(symbolizers, pol1);
- PolygonSymbolizer pol2 = STYLE_BUILDER.createPolygonSymbolizer(
- STYLE_BUILDER.createStroke(Color.black, 2),
+ PolygonSymbolizer pol2 = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(Color.black, 2),
STYLE_BUILDER.createFill(Color.WHITE, .5));
symbolizers = LangUtil.extendArray(symbolizers, pol2);
return symbolizers;
}
- private static Symbolizer[] createBlinkFeatureTypeStylePoint(
- Symbolizer[] symbolizers) {
+ private static Symbolizer[] createBlinkFeatureTypeStylePoint(Symbolizer[] symbolizers) {
Graphic bg2;
Literal size0 = FeatureUtil.FILTER_FACTORY2.literal(26);
Literal size1 = FeatureUtil.FILTER_FACTORY2.literal(28);
- Graphic bg1 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
- new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("circle"),
- STYLE_BUILDER.createStroke(Color.red, 2.), null, size1,
- halfLit) }, new org.geotools.styling.Symbol[0],
- FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
+ Graphic bg1 = STYLE_FACTORY.createGraphic(
+ new ExternalGraphic[0],
+ new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"),
+ STYLE_BUILDER.createStroke(Color.red, 2.), null, size1, halfLit) },
+ new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
PointSymbolizer ps1 = STYLE_FACTORY.createPointSymbolizer();
ps1.setGraphic(bg1);
symbolizers = LangUtil.extendArray(symbolizers, ps1);
- bg2 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
- new Mark[] { STYLE_FACTORY.createMark(
- FeatureUtil.FILTER_FACTORY2.literal("circle"),
- STYLE_BUILDER.createStroke(Color.black, 2.),
- STYLE_BUILDER.createFill(Color.WHITE, 0.3), size0,
- halfLit) }, new org.geotools.styling.Symbol[0],
+ bg2 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+ FeatureUtil.FILTER_FACTORY2.literal("circle"), STYLE_BUILDER.createStroke(Color.black, 2.),
+ STYLE_BUILDER.createFill(Color.WHITE, 0.3), size0, halfLit) }, new org.geotools.styling.Symbol[0],
FeatureUtil.FILTER_FACTORY2.literal(1), size0, zeroLit);
PointSymbolizer ps2 = STYLE_FACTORY.createPointSymbolizer();
@@ -777,13 +730,11 @@
}
/**
- * Creates a new {@link BrewerPalette} with only one scheme (which includes
- * all colors). The suitablity of the palette is set to "unknown" for all
- * viewer types.
+ * Creates a new {@link BrewerPalette} with only one scheme (which includes all colors). The suitablity of the
+ * palette is set to "unknown" for all viewer types.
*
* @param name
- * name for the palette (also the description is set to this
- * value)
+ * name for the palette (also the description is set to this value)
* @param colors
* colors for the palette
*/
@@ -796,13 +747,10 @@
// set suitability to UNKNOWN for all viewers
PaletteSuitability suitability = new PaletteSuitability();
try {
- suitability.setSuitability(colors.length, new String[] { "?", "?",
- "?", "?", "?", "?" });
+ suitability.setSuitability(colors.length, new String[] { "?", "?", "?", "?", "?", "?" });
palette.setPaletteSuitability(suitability);
} catch (IOException e) {
- LOGGER.error(
- "Unabel to PaletteSuitability.setSuitablility for colors.length="
- + colors, e);
+ LOGGER.error("Unabel to PaletteSuitability.setSuitablility for colors.length=" + colors, e);
}
// Create the trivial scheme for the palette (requested colors equals
@@ -835,8 +783,7 @@
* @param opacity
* Transparenz fuer die Farbe des Farbpaletten-Eintrag
*/
- public static ColorMapEntry createColorMapEntry(String label,
- Double quantity, Color color, double opacity) {
+ public static ColorMapEntry createColorMapEntry(String label, Double quantity, Color color, double opacity) {
ColorMapEntry newEntry = STYLE_FACTORY.createColorMapEntry();
try {
newEntry.setLabel(label);
@@ -850,28 +797,23 @@
}
/**
- * Erstellt einen Default-Style fuer die Klassen/Interfaces:
- * StyledFeaturesInterface, GridCoverage2D, FeatureCollection, FeatureSource
- * und GeometryAttributeType.
+ * Erstellt einen Default-Style fuer die Klassen/Interfaces: StyledFeaturesInterface, GridCoverage2D,
+ * FeatureCollection, FeatureSource und GeometryAttributeType.
*
* @param object
- * {@link GridCoverage2D},
- * {@link org.geotools.coverage.grid.io.AbstractGridCoverage2DReader}
- * oder {@link FeatureCollection}
+ * {@link GridCoverage2D}, {@link org.geotools.coverage.grid.io.AbstractGridCoverage2DReader} oder
+ * {@link FeatureCollection}
* @return {@code null} falls kein Style generiert werden kann
*
- * @Deprectated Use FeatureUtil.createDefaultStyle and
- * FeatureUtil.getGeometryForm
+ * @Deprectated Use FeatureUtil.createDefaultStyle and FeatureUtil.getGeometryForm
*/
public static Style createDefaultStyle(Object object) {
if (object instanceof StyledFeaturesInterface)
- return FeatureUtil
- .createDefaultStyle(((StyledFeaturesInterface<?>) object)
- .getSchema().getGeometryDescriptor());
+ return FeatureUtil.createDefaultStyle(((StyledFeaturesInterface<?>) object).getSchema()
+ .getGeometryDescriptor());
- if (object instanceof GridCoverage2D
- || object instanceof AbstractGridCoverage2DReader
+ if (object instanceof GridCoverage2D || object instanceof AbstractGridCoverage2DReader
|| object instanceof StyledRasterInterface)
return GridUtil.createDefaultStyle();
@@ -880,18 +822,15 @@
}
if (object instanceof FeatureCollection)
- return FeatureUtil
- .createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
+ return FeatureUtil.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
if (object instanceof FeatureSource)
- return FeatureUtil.createDefaultStyle(((FeatureSource) object)
- .getSchema().getGeometryDescriptor());
+ return FeatureUtil.createDefaultStyle(((FeatureSource) object).getSchema().getGeometryDescriptor());
if (object instanceof GeometryDescriptor)
return FeatureUtil.createDefaultStyle((GeometryDescriptor) object);
- LOGGER.warn("createDefaultStyle could not handle " + object
- + " and returned an empty (invalid) Style");
+ LOGGER.warn("createDefaultStyle could not handle " + object + " and returned an empty (invalid) Style");
return STYLE_BUILDER.createStyle();
}
@@ -901,19 +840,15 @@
* @param name
* Name fuer die {@link GridSampleDimension}
* @param colorMap
- * fuer jeden Eintrag der {@link ColorMap} wird eine
- * {@link Category} erzeugt
+ * fuer jeden Eintrag der {@link ColorMap} wird eine {@link Category} erzeugt
* @param noDataValues
- * Werte fuer die zusaetzliche {@link Category Categorys}
- * erstellt werden, welche die transparent dargestellt werden
- * (wenn {@code null} wird keine zusaetzliche {@link Category}
- * erstellt)
+ * Werte fuer die zusaetzliche {@link Category Categorys} erstellt werden, welche die transparent
+ * dargestellt werden (wenn {@code null} wird keine zusaetzliche {@link Category} erstellt)
* @param unit
- * Einheit der Werte in der {@link GridSampleDimension} (kann
- * {@code null} sein)
+ * Einheit der Werte in der {@link GridSampleDimension} (kann {@code null} sein)
*/
- public static GridSampleDimension createDiscreteGridSampleDimension(
- String name, ColorMap colorMap, double[] noDataValues, Unit<?> unit) {
+ public static GridSampleDimension createDiscreteGridSampleDimension(String name, ColorMap colorMap,
+ double[] noDataValues, Unit<?> unit) {
if (colorMap.getColorMapEntries().length == 0)
return null;
@@ -936,10 +871,11 @@
if (label == null)
label = "";
categories.put(intValue, new Category(label, new Color[] { color },
- // New by Stefan Tzeggai 12.9.11: GT8 Migration
-// new NumberRange(intValue, intValue), new NumberRange<Integer>(
-// intValue, intValue)));
- new NumberRange<Integer>(Integer.class, intValue, intValue), new NumberRange<Integer>(Integer.class,intValue, intValue)));
+ // New by Stefan Tzeggai 12.9.11: GT8 Migration
+ // new NumberRange(intValue, intValue), new NumberRange<Integer>(
+ // intValue, intValue)));
+ new NumberRange<Integer>(Integer.class, intValue, intValue), new NumberRange<Integer>(
+ Integer.class, intValue, intValue)));
}
// If NoData-Value is set, create an additional Category
@@ -957,20 +893,18 @@
// double higherEnd = colorMapMax + 10000*colorMapRange;
final int lowerStart = Integer.MIN_VALUE;
final int higherEnd = Integer.MAX_VALUE;
-
+
// New by Stefan Tzeggai 12.9.11: GT8 Migration
- categories.put(colorMapMax + 10, new Category("_autoNoData1_",
- new Color[] { new Color(0, 0, 0, 0) }, new NumberRange<Integer>(Integer.class,
- colorMapMax + 1, colorMapMax + 2), new NumberRange<Integer>(Integer.class,
- colorMapMax + 1, higherEnd)));
-// new Color[] { new Color(0, 0, 0, 0) }, new NumberRange(
-// colorMapMax + 1, colorMapMax + 2), new NumberRange(
-// colorMapMax + 1, higherEnd)));
+ categories.put(colorMapMax + 10, new Category("_autoNoData1_", new Color[] { new Color(0, 0, 0, 0) },
+ new NumberRange<Integer>(Integer.class, colorMapMax + 1, colorMapMax + 2), new NumberRange<Integer>(
+ Integer.class, colorMapMax + 1, higherEnd)));
+ // new Color[] { new Color(0, 0, 0, 0) }, new NumberRange(
+ // colorMapMax + 1, colorMapMax + 2), new NumberRange(
+ // colorMapMax + 1, higherEnd)));
if (colorMapMin < colorMapMax)
- categories.put(colorMapMin - 10, new Category("_autoNoData2_",
- new Color[] { new Color(0, 0, 0, 0) },
- // new NumberRange(colorMapMin-2, colorMapMin-1), //
- // logischer, aber klappt nicht!?
+ categories.put(colorMapMin - 10, new Category("_autoNoData2_", new Color[] { new Color(0, 0, 0, 0) },
+ // new NumberRange(colorMapMin-2, colorMapMin-1), //
+ // logischer, aber klappt nicht!?
NumberRange.create(colorMapMax + 3, colorMapMax + 4),
// new NumberRange(colorMapMax + 3, colorMapMax + 4),
NumberRange.create(lowerStart, colorMapMin - 1)
@@ -978,8 +912,8 @@
));
// Create the GridSampleDimension
- GridSampleDimension gsd = new GridSampleDimension(name, categories
- .values().toArray(new Category[0]), unit).geophysics(true);
+ GridSampleDimension gsd = new GridSampleDimension(name, categories.values().toArray(new Category[0]), unit)
+ .geophysics(true);
for (Category c : gsd.getCategories())
LOGGER.debug(c.toString());
@@ -988,8 +922,7 @@
}
/**
- * Erzeugt eine {@link Category} fuer die NoData-Werte transparent
- * dargestellt werden.
+ * Erzeugt eine {@link Category} fuer die NoData-Werte transparent dargestellt werden.
*
* @param geoValue
* Geo-Wert, der NoData repraesentiert
@@ -999,8 +932,7 @@
}
/**
- * Erzeugt eine {@link Category} fuer die NoData-Werte transparent
- * dargestellt werden.
+ * Erzeugt eine {@link Category} fuer die NoData-Werte transparent dargestellt werden.
*
* @param value
* Sample-Wert der Category
@@ -1008,51 +940,39 @@
* Geo-Wert, der NoData repraesentiert
*/
public static Category createNoDataCategory(int value, double geoValue) {
- return new Category(
- Vocabulary.formatInternational(VocabularyKeys.NODATA),
+ return new Category(Vocabulary.formatInternational(VocabularyKeys.NODATA),
// New by Stefan Tzeggai 12.9.11: GT8 Migration
- new Color[] { new Color(0, 0, 0, 0) }, new NumberRange<Integer>(Integer.class, value,
- value), new NumberRange<Double>(Double.class, geoValue, geoValue));
+ new Color[] { new Color(0, 0, 0, 0) }, new NumberRange<Integer>(Integer.class, value, value),
+ new NumberRange<Double>(Double.class, geoValue, geoValue));
}
/**
* @param geoObject
- * the {@link GeometryForm} the selection style shall be created
- * for.
+ * the {@link GeometryForm} the selection style shall be created for.
* @param type
- * define the look of the selection style by choosing a constant
- * from {@link SelectionStylesTypes}
+ * define the look of the selection style by choosing a constant from {@link SelectionStylesTypes}
*
- * @return a {@link Style} that is suitable to identify features of the
- * given type as selected items.
+ * @return a {@link Style} that is suitable to identify features of the given type as selected items.
*/
- public static FeatureTypeStyle createSelectionFTStyle(
- GeometryForm geometryForm, SelectionStylesTypes type) {
- Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm,
- type);
+ public static FeatureTypeStyle createSelectionFTStyle(GeometryForm geometryForm, SelectionStylesTypes type) {
+ Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
- return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, 0.0,
- Double.POSITIVE_INFINITY);
+ return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, 0.0, Double.POSITIVE_INFINITY);
}
/**
* @param geoObject
- * {@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},
- * {@link FeatureCollection}, {@link GeometryAttributeType} or
- * {@link FeatureSource}
+ * {@link GridCoverage2D}, {@link AbstractGridCoverage2DReader}, {@link FeatureCollection},
+ * {@link GeometryAttributeType} or {@link FeatureSource}
*
* @param type
- * define the look of the selection style by choosing a constant
- * from {@link SelectionStylesTypes}
+ * define the look of the selection style by choosing a constant from {@link SelectionStylesTypes}
*
- * @return a {@link Style} that is suitable to identify features of the
- * given type as selected items.
+ * @return a {@link Style} that is suitable to identify features of the given type as selected items.
*/
- public static FeatureTypeStyle createSelectionFTStyle(Object geoObject,
- SelectionStylesTypes type) {
+ public static FeatureTypeStyle createSelectionFTStyle(Object geoObject, SelectionStylesTypes type) {
- if (geoObject instanceof AbstractCoverage
- || geoObject instanceof AbstractGridCoverage2DReader) {
+ if (geoObject instanceof AbstractCoverage || geoObject instanceof AbstractGridCoverage2DReader) {
// Wenn irgendwann mal selection für raster möglich ist, dann hier
// einen schöneren style erstellen.
return GridUtil.createDefaultStyle().featureTypeStyles().get(0);
@@ -1078,8 +998,7 @@
* @param selectionIds
* @return
*/
- public static Rule createSelectionRule(GeometryForm geometryForm,
- String idPropertyName, List<String> selectionIds,
+ public static Rule createSelectionRule(GeometryForm geometryForm, String idPropertyName, List<String> selectionIds,
SelectionStylesTypes type) {
if (idPropertyName == null)
@@ -1098,8 +1017,7 @@
if (selectionIds.size() > 0) {
for (String id : selectionIds) {
PropertyIsEqualTo equal = FilterUtil.FILTER_FAC2.equals(
- FilterUtil.FILTER_FAC2.property(idPropertyName),
- FilterUtil.FILTER_FAC2.literal(id));
+ FilterUtil.FILTER_FAC2.property(idPropertyName), FilterUtil.FILTER_FAC2.literal(id));
equals.add(equal);
}
rule.setFilter(FilterUtil.FILTER_FAC2.or(equals));
@@ -1109,16 +1027,14 @@
}
// Symboizers
- Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm,
- type);
+ Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
rule.symbolizers().addAll(Arrays.asList(symbolizers));
return rule;
}
- public static Style createSelectionStyle(Object geoObject,
- SelectionStylesTypes type) {
+ public static Style createSelectionStyle(Object geoObject, SelectionStylesTypes type) {
FeatureTypeStyle fts = createSelectionFTStyle(geoObject, type);
Style style = STYLE_FACTORY.createStyle();
style.featureTypeStyles().clear();
@@ -1127,8 +1043,7 @@
}
- public static Symbolizer[] createSelectionSymbolizers(
- GeometryForm geometryForm, SelectionStylesTypes type) {
+ public static Symbolizer[] createSelectionSymbolizers(GeometryForm geometryForm, SelectionStylesTypes type) {
Symbolizer[] symbolizers = new Symbolizer[0];
double size = 15.;
@@ -1147,8 +1062,7 @@
break;
case POLYGON:
- symbolizers = addSelectionSymbolizersPolygon(type, symbolizers,
- size);
+ symbolizers = addSelectionSymbolizersPolygon(type, symbolizers, size);
break;
case LINE:
@@ -1156,8 +1070,7 @@
break;
case ANY:
- symbolizers = addSelectionSymbolizersPolygon(type, symbolizers,
- size);
+ symbolizers = addSelectionSymbolizersPolygon(type, symbolizers, size);
symbolizers = addSelectionSymbolizersPoint(symbolizers);
// symbolizers = addSelectionSymbolizersLine(symbolizers);
break;
@@ -1169,19 +1082,17 @@
return symbolizers;
}
- private static Symbolizer[] addSelectionSymbolizersLine(
- Symbolizer[] symbolizers) {
+ private static Symbolizer[] addSelectionSymbolizersLine(Symbolizer[] symbolizers) {
LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(Color.red, 3.);
symbolizers = LangUtil.extendArray(symbolizers, ls);
- LineSymbolizer ls2 = STYLE_BUILDER
- .createLineSymbolizer(Color.white, 1.);
+ LineSymbolizer ls2 = STYLE_BUILDER.createLineSymbolizer(Color.white, 1.);
symbolizers = LangUtil.extendArray(symbolizers, ls2);
return symbolizers;
}
- private static Symbolizer[] addSelectionSymbolizersPolygon(
- SelectionStylesTypes type, Symbolizer[] symbolizers, double size) {
+ private static Symbolizer[] addSelectionSymbolizersPolygon(SelectionStylesTypes type, Symbolizer[] symbolizers,
+ double size) {
String markShapeName = "";
if (type == SelectionStylesTypes.LeftTop2RightBottom_lines
|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_smallgaps
@@ -1203,8 +1114,7 @@
Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
fillMark.setStroke(STYLE_BUILDER.createStroke(Color.red, 3.));
- Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
- fillMark, null);
+ Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, fillMark, null);
fillGraphic.setSize(FILTER_FACTORY.literal(size));
@@ -1212,39 +1122,33 @@
fill.setGraphicFill(fillGraphic);
}
- PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
- outline, fill);
+ PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(outline, fill);
symbolizers = LangUtil.extendArray(symbolizers, polS0);
}
{ // White
- Stroke outline = STYLE_BUILDER.createStroke(
- Color.yellow.brighter(), 1);
+ Stroke outline = STYLE_BUILDER.createStroke(Color.yellow.brighter(), 1);
Fill fill = null;
if (type != SelectionStylesTypes.Outline_only) {
Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
- fillMark.setStroke(STYLE_BUILDER.createStroke(
- Color.yellow.brighter(), 1.));
- Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
- fillMark, null);
+ fillMark.setStroke(STYLE_BUILDER.createStroke(Color.yellow.brighter(), 1.));
+ Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, fillMark, null);
fillGraphic.setSize(FILTER_FACTORY.literal(size));
fill = STYLE_BUILDER.createFill();
fill.setGraphicFill(fillGraphic);
}
- PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
- outline, fill);
+ PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(outline, fill);
// polS0.setGeometry(offsetFunction);
symbolizers = LangUtil.extendArray(symbolizers, polS0);
}
return symbolizers;
}
- private static Symbolizer[] addSelectionSymbolizersPoint(
- Symbolizer[] symbolizers) {
+ private static Symbolizer[] addSelectionSymbolizersPoint(Symbolizer[] symbolizers) {
PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer();
ps.setGraphic(SELECTION_GRAPHIC1);
symbolizers = LangUtil.extendArray(symbolizers, ps);
@@ -1260,18 +1164,16 @@
}
/**
- * Creates a {@link Style} for a {@link Grid} layer from a {@link ColorMap}
- * Title will be set to {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
+ * Creates a {@link Style} for a {@link Grid} layer from a {@link ColorMap} Title will be set to
+ * {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
*
* @param colorMap
* If null, then defaultStyle for Grid will be used
* @param name
- * The name to give to the Style. null will result in name
- * {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
+ * The name to give to the Style. null will result in name {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
*
- * @return Always a Style that you can apply to a {@link GridCoverage}.
- * Style has name {@link GridUtil#DEFAULT_RASTER_STYLE_NAME} if no
- * colormap was provided.
+ * @return Always a Style that you can apply to a {@link GridCoverage}. Style has name
+ * {@link GridUtil#DEFAULT_RASTER_STYLE_NAME} if no colormap was provided.
*
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
@@ -1286,23 +1188,19 @@
* @param colorMap
* If null, then defaultStyle for Grid will be used
* @param name
- * The name to give to the Style. null will result in name=
- * {@link GridUtil#UNNAMED_RASTER_STYLE_NAME} or
+ * The name to give to the Style. null will result in name= {@link GridUtil#UNNAMED_RASTER_STYLE_NAME} or
* GridUtil#DEFAULT_RASTER_STYLE_NAME} (if no colorMap is given).
*
* @param title
* The Title to give to the Style. null will result in title=
- * {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE} or
- * {@link GridUtil#DEFAULT_RASTER_STYLE_TITLE} (if no colorMap is
- * given)
+ * {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE} or {@link GridUtil#DEFAULT_RASTER_STYLE_TITLE} (if no
+ * colorMap is given)
*
- * @return Always a {@link Style} that you can be applyed to a
- * {@link GridCoverage}.
+ * @return Always a {@link Style} that you can be applyed to a {@link GridCoverage}.
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static Style createStyleFromColorMap(ColorMap colorMap, String name,
- String title) {
+ public static Style createStyleFromColorMap(ColorMap colorMap, String name, String title) {
if (colorMap == null)
return GridUtil.createDefaultStyle();
@@ -1330,8 +1228,7 @@
RuleImpl ruleImpl = new RuleImpl(symbolizers) {
};
Rule[] rules = { ruleImpl };
- FeatureTypeStyleImpl featureTypeStyleImpl = new FeatureTypeStyleImpl(
- rules) {
+ FeatureTypeStyleImpl featureTypeStyleImpl = new FeatureTypeStyleImpl(rules) {
};
Style style = STYLE_FACTORY.createStyle();
@@ -1342,8 +1239,7 @@
}
/**
- * Erzeugt einen {@link Style} aus einem {@linkplain Element JDOM-Element},
- * des eine SLD-Definition enthaelt
+ * Erzeugt einen {@link Style} aus einem {@linkplain Element JDOM-Element}, des eine SLD-Definition enthaelt
*
* @param element
* Element mit SLD-Definition
@@ -1366,8 +1262,7 @@
}
}
- public static Style createStyleSimple(Object geoObject, Color color,
- Color color2) {
+ public static Style createStyleSimple(Object geoObject, Color color, Color color2) {
if (geoObject instanceof GridCoverage2D
|| geoObject instanceof org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) {
// Wenn irgendwann mal selection für raster möglich ist, dann hier
@@ -1390,14 +1285,12 @@
break;
case POLYGON:
- PolygonSymbolizer polS = STYLE_BUILDER.createPolygonSymbolizer(
- STYLE_BUILDER.createStroke(color2),
+ PolygonSymbolizer polS = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(color2),
STYLE_BUILDER.createFill(color));
symbolizers = LangUtil.extendArray(symbolizers, polS);
case LINE:
- LineSymbolizer ls = STYLE_BUILDER
- .createLineSymbolizer(STYLE_BUILDER.createStroke(color));
+ LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(STYLE_BUILDER.createStroke(color));
symbolizers = LangUtil.extendArray(symbolizers, ls);
break;
@@ -1405,8 +1298,7 @@
// In case of ANY, create a Style with polygon and point
// symbolizers.
- polS = STYLE_BUILDER.createPolygonSymbolizer(
- STYLE_BUILDER.createStroke(color2),
+ polS = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(color2),
STYLE_BUILDER.createFill(color));
ps = createPointSymbolizer(color, color2);
@@ -1419,77 +1311,63 @@
}
style.featureTypeStyles().get(0).rules().clear();
- style.featureTypeStyles().get(0).rules()
- .add(STYLE_FACTORY.createRule());
+ style.featureTypeStyles().get(0).rules().add(STYLE_FACTORY.createRule());
style.featureTypeStyles().get(0).rules().get(0).symbolizers().clear();
- style.featureTypeStyles().get(0).rules().get(0).symbolizers()
- .addAll(Arrays.asList(symbolizers));
+ style.featureTypeStyles().get(0).rules().get(0).symbolizers().addAll(Arrays.asList(symbolizers));
return style;
}
- private static PointSymbolizer createPointSymbolizer(Color color,
- Color color2) {
- PointSymbolizer ps = STYLE_BUILDER.createPointSymbolizer(STYLE_BUILDER
- .createGraphic(null, STYLE_BUILDER.createMark("circle"), null));
- ps.getGraphic().getMarks()[0].setFill(STYLE_BUILDER.createFill(color,
- 0.5));
-
-// ps.getGraphic().getMarks()[0].setSize(STYLE_BUILDER
-// .literalExpression(8.));
-
+ private static PointSymbolizer createPointSymbolizer(Color color, Color color2) {
+ PointSymbolizer ps = STYLE_BUILDER.createPointSymbolizer(STYLE_BUILDER.createGraphic(null,
+ STYLE_BUILDER.createMark("circle"), null));
+ ps.getGraphic().getMarks()[0].setFill(STYLE_BUILDER.createFill(color, 0.5));
+
+ // ps.getGraphic().getMarks()[0].setSize(STYLE_BUILDER
+ // .literalExpression(8.));
+
ps.getGraphic().setSize(STYLE_BUILDER.literalExpression(8.));
- ps.getGraphic().getMarks()[0].setStroke(STYLE_BUILDER
- .createStroke(color2));
+ ps.getGraphic().getMarks()[0].setStroke(STYLE_BUILDER.createStroke(color2));
return ps;
}
/**
- * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator
- * enthalten. Dadurch können Elemente für manche Zoom-Stufen deaktiviert
- * werden.
+ * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator enthalten. Dadurch können Elemente für
+ * manche Zoom-Stufen deaktiviert werden.
*
- * Kommentar: "Sichtbarkeit" bezieht es nicht darauf, ob die Elemente auf
- * dem Kartenausschnitt sichtbar sind, sondern um die SLD Regeln, welche das
- * SimpleFeature evt. nur Scalenabhängig zeichnen.<br/>
- * SK 19.6.2009:Bei einem {@link PolygonSymbolizer} zählt nicht der Rand,
- * sondern nur ob eine Füllung vorhanden ist! Man kann dann zwar leider
- * nicht auf ein Rand eines Polygons ohne Fill klicken, aber dafür kann man
- * durch die ungefüllte Fläche klicken.
+ * Kommentar: "Sichtbarkeit" bezieht es nicht darauf, ob die Elemente auf dem Kartenausschnitt sichtbar sind,
+ * sondern um die SLD Regeln, welche das SimpleFeature evt. nur Scalenabhängig zeichnen.<br/>
+ * SK 19.6.2009:Bei einem {@link PolygonSymbolizer} zählt nicht der Rand, sondern nur ob eine Füllung vorhanden ist!
+ * Man kann dann zwar leider nicht auf ein Rand eines Polygons ohne Fill klicken, aber dafür kann man durch die
+ * ungefüllte Fläche klicken.
*
* @param fc
- * Die zu filternde FeatureCollection. Diese wird nicht
- * verändert.
+ * Die zu filternde FeatureCollection. Diese wird nicht verändert.
* @param style
- * Der Style, mit dem die Features gerendert werden (z.b.
- * layer.getStyle() )
+ * Der Style, mit dem die Features gerendert werden (z.b. layer.getStyle() )
*
* @param scaleDenominator
- * Der aktuelle ScaleDenomitor für den die Sichtbarkeit ermittelt
- * wird.
+ * Der aktuelle ScaleDenomitor für den die Sichtbarkeit ermittelt wird.
*
* @see RendererUtilities.calculateOGCScale
*
- * @return Eine FeatureCollection in welcher nur die Features enthalten
- * sind, welche bei aktuellen Scale mit dem übergebenen Style
- * gerendert werden.
+ * @return Eine FeatureCollection in welcher nur die Features enthalten sind, welche bei aktuellen Scale mit dem
+ * übergebenen Style gerendert werden.
*
* TODO Was ist mit raster?!
*
- * TODO Das sollte man besser machen: Zuerst die FIlter der
- * sichtbaren regeln raussuchen, und dann direkt am anfang damitmit
- * mitfiltern...
+ * TODO Das sollte man besser machen: Zuerst die FIlter der sichtbaren regeln raussuchen, und dann direkt am
+ * anfang damitmit mitfiltern...
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
public static MemoryFeatureCollection filterSLDVisibleOnly(
- final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
- final Style style, final Double scaleDenominator) {
+ final FeatureCollection<SimpleFeatureType, SimpleFeature> fc, final Style style,
+ final Double scaleDenominator) {
// Eine im Speicher gehaltene FeatureCollection der sichtbaren
- final MemoryFeatureCollection fcVisible = new MemoryFeatureCollection(
- fc.getSchema());
+ final MemoryFeatureCollection fcVisible = new MemoryFeatureCollection(fc.getSchema());
// Prüfen aller Features in der Collection
final Iterator<SimpleFeature> fcIt = fc.iterator();
@@ -1503,22 +1381,18 @@
// Leave out FTSs that are selection related
if (fts.getName() != null
- && fts.getName()
- .equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
+ && fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
continue;
final List<Rule> rules = fts.rules();
for (final Rule rule : rules) {
- final double maxScaleDenominator = rule
- .getMaxScaleDenominator();
- final double minScaleDenominator = rule
- .getMinScaleDenominator();
+ final double maxScaleDenominator = rule.getMaxScaleDenominator();
+ final double minScaleDenominator = rule.getMinScaleDenominator();
// 1. Check: Trifft die Rule auf den aktuellen Scale der
// JMapPane?
- if ((minScaleDenominator > scaleDenominator)
- || (scaleDenominator > maxScaleDenominator)) {
+ if ((minScaleDenominator > scaleDenominator) || (scaleDenominator > maxScaleDenominator)) {
continue;
}
@@ -1537,25 +1411,21 @@
boolean passt = false;
for (final Symbolizer symb : rule.getSymbolizers()) {
- final Geometry geom = (Geometry) feature
- .getDefaultGeometry();
+ final Geometry geom = (Geometry) feature.getDefaultGeometry();
- if ((geom instanceof MultiPoint)
- || (geom instanceof com.vividsolutions.jts.geom.Point)) {
+ if ((geom instanceof MultiPoint) || (geom instanceof com.vividsolutions.jts.geom.Point)) {
if (symb instanceof PointSymbolizer) {
if (((PointSymbolizer) symb).getGraphic() != null)
passt = true;
break;
}
- } else if ((geom instanceof MultiLineString)
- || (geom instanceof LineString)) {
+ } else if ((geom instanceof MultiLineString) || (geom instanceof LineString)) {
if (symb instanceof LineSymbolizer) {
if (((LineSymbolizer) symb).getStroke() != null)
passt = true;
break;
}
- } else if ((geom instanceof MultiPolygon)
- || (geom instanceof Polygon)) {
+ } else if ((geom instanceof MultiPolygon) || (geom instanceof Polygon)) {
if (symb instanceof PolygonSymbolizer) {
if (((PolygonSymbolizer) symb).getFill() != null)
@@ -1588,22 +1458,16 @@
} catch (final java.lang.IllegalStateException e) {
LOGGER.error("Iterating over the features", e);
/**
- * SK: 14.Apri 2009. It happened a few time to that fcIt.hasNext
- * suddenly threw an exception for the "africa countries.shp":
- * Exception in thread "AWT-EventQueue-0"
- * java.lang.IllegalStateException: ShapeType changed illegally from
- * Polygon to Undefined at org.geotools.
- * data.shapefile.shp.ShapefileReader.nextRecord(ShapefileReader
- * .java:452) at org.geotools.data.shapefile.indexed.
- * IndexedShapefileDataStore$Reader
+ * SK: 14.Apri 2009. It happened a few time to that fcIt.hasNext suddenly threw an exception for the
+ * "africa countries.shp": Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: ShapeType
+ * changed illegally from Polygon to Undefined at org.geotools.
+ * data.shapefile.shp.ShapefileReader.nextRecord(ShapefileReader .java:452) at
+ * org.geotools.data.shapefile.indexed. IndexedShapefileDataStore$Reader
* .next(IndexedShapefileDataStore.java:1272) at
- * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:92)
- * at org .geotools.data.FilteringFeatureReader.hasNext(
- * FilteringFeatureReader .java:125) at
- * org.geotools.data.store.FeatureReaderIterator.hasNext(
- * FeatureReaderIterator.java:44) at
- * schmitzm.geotools.feature.FeatureUtil
- * .filterSLDVisibleOnly(FeatureUtil.java:216) *
+ * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:92) at org
+ * .geotools.data.FilteringFeatureReader.hasNext( FilteringFeatureReader .java:125) at
+ * org.geotools.data.store.FeatureReaderIterator.hasNext( FeatureReaderIterator.java:44) at
+ * schmitzm.geotools.feature.FeatureUtil .filterSLDVisibleOnly(FeatureUtil.java:216) *
*
*/
}
@@ -1615,50 +1479,40 @@
}
/**
- * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator
- * enthalten. Dadurch können Elemente für manche Zoom-Stufen deaktiviert
- * werden.
+ * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator enthalten. Dadurch können Elemente für
+ * manche Zoom-Stufen deaktiviert werden.
*
* @param fc
- * Die zu filternde FeatureCollection. Diese wird nicht
- * verändert.
+ * Die zu filternde FeatureCollection. Diese wird nicht verändert.
* @param style
- * Der Style, mit dem die Features gerendert werden (z.b.
- * layer.getStyle() )
+ * Der Style, mit dem die Features gerendert werden (z.b. layer.getStyle() )
*
- * @return Eine FeatureCollection in welcher nur die Features enthalten
- * sind, welche bei aktuellen Scale mit dem übergebenen Style
- * gerendert werden.
+ * @return Eine FeatureCollection in welcher nur die Features enthalten sind, welche bei aktuellen Scale mit dem
+ * übergebenen Style gerendert werden.
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
public static FeatureCollection<SimpleFeatureType, SimpleFeature> filterSLDVisibleOnly(
- final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
- final Style style, XMapPane xMapPane) {
+ final FeatureCollection<SimpleFeatureType, SimpleFeature> fc, final Style style, XMapPane xMapPane) {
if (xMapPane == null || style == null)
return new EmptyFeatureCollection(fc.getSchema());
// Der "scaleDenominator" der aktuellen JMapPane
- Double scaleDenominator = RendererUtilities.calculateOGCScale(
- new ReferencedEnvelope(xMapPane.getMapArea(), xMapPane
- .getMapContext().getCoordinateReferenceSystem()),
- xMapPane.getBounds().width, null);
+ Double scaleDenominator = RendererUtilities.calculateOGCScale(new ReferencedEnvelope(xMapPane.getMapArea(),
+ xMapPane.getMapContext().getCoordinateReferenceSystem()), xMapPane.getBounds().width, null);
return filterSLDVisibleOnly(fc, style, scaleDenominator);
}
/**
- * Ermittelt fuer einen Wert den {@link ColorMapEntry} aus einer
- * {@link ColorMap}.
+ * Ermittelt fuer einen Wert den {@link ColorMapEntry} aus einer {@link ColorMap}.
*
* @param value
* Wert
- * @return {@code null}, wenn in der {@link ColorMap} kein expliziter
- * Eintrag fuer den Wert hinterlegt ist
+ * @return {@code null}, wenn in der {@link ColorMap} kein expliziter Eintrag fuer den Wert hinterlegt ist
*/
- public static ColorMapEntry findColorMapEntry(ColorMap colorMap,
- double value) {
+ public static ColorMapEntry findColorMapEntry(ColorMap colorMap, double value) {
for (ColorMapEntry entry : colorMap.getColorMapEntries())
if (value == getQuantityFromColorMapEntry(entry))
return entry;
@@ -1672,8 +1526,7 @@
* Farbpaletten-Eintrag
*/
public static Color getColorFromColorMapEntry(ColorMapEntry entry) {
- if (entry == null || entry.getColor() == null
- || entry.getColor().evaluate(null) == null)
+ if (entry == null || entry.getColor() == null || entry.getColor().evaluate(null) == null)
return null;
// // Transparenz
@@ -1708,14 +1561,11 @@
}
/**
- * Liefert die Farbpalette zu einem Style, wenn der Style aus einem
- * {@link RasterSymbolizer} erzeugt wurde.
+ * Liefert die Farbpalette zu einem Style, wenn der Style aus einem {@link RasterSymbolizer} erzeugt wurde.
*
* @param style
- * Style Wenn <code>null</code>, dann wird style auf
- * {@link GridUtil}.createDefaultStyle() gesetzt
- * @return <code>null</code> wenn der Style nicht auf einem
- * {@link RasterSymbolizer} basiert.
+ * Style Wenn <code>null</code>, dann wird style auf {@link GridUtil}.createDefaultStyle() gesetzt
+ * @return <code>null</code> wenn der Style nicht auf einem {@link RasterSymbolizer} basiert.
*/
public static ColorMap getColorMapFromStyle(final Style style) {
final List<ColorMap> colorMapsFromStyle = getColorMapsFromStyle(style);
@@ -1727,12 +1577,10 @@
}
/**
- * Liefert alle Farbpaletten aus einem Style, wenn irgendo
- * {@link RasterSymbolizer} enthalten sind.
+ * Liefert alle Farbpaletten aus einem Style, wenn irgendo {@link RasterSymbolizer} enthalten sind.
*
* @param style
- * Style Wenn <code>null</code>, dann wird style auf
- * {@link GridUtil}.createDefaultStyle() gesetzt
+ * Style Wenn <code>null</code>, dann wird style auf {@link GridUtil}.createDefaultStyle() gesetzt
* @return Leere Liste wenn keine RasterSymbolizer enthalten ist.
*/
public static List<ColorMap> getColorMapsFromStyle(Style style) {
@@ -1762,8 +1610,7 @@
*/
public static int getColorMapType(String typeStr) {
if (typeStr == null)
- throw new IllegalArgumentException("Unknown color map type: "
- + typeStr);
+ throw new IllegalArgumentException("Unknown color map type: " + typeStr);
typeStr = typeStr.trim().toLowerCase();
if (typeStr.equals("ramp") || typeStr.equals("type_ramp"))
@@ -1807,14 +1654,11 @@
</code>
*
- * Returns the first attribute found in the label expression of the given
- * {@link TextSymbolizer}. If non is found for some reason, the method tries
- * to return the first attribute from the schema. We expect the layer to
- * have some attributes, because otherwise AS shouldn't even create the
- * LabellingTab.
+ * Returns the first attribute found in the label expression of the given {@link TextSymbolizer}. If non is found
+ * for some reason, the method tries to return the first attribute from the schema. We expect the layer to have some
+ * attributes, because otherwise AS shouldn't even create the LabellingTab.
*/
- public static PropertyName getFirstPropertyName(final SimpleFeatureType ft,
- final TextSymbolizer textSymbolizer) {
+ public static PropertyName getFirstPropertyName(final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
final Expression labelExpression = textSymbolizer.getLabel();
try {
if (labelExpression instanceof PropertyName) {
@@ -1822,8 +1666,7 @@
return (PropertyName) labelExpression;
} else if (labelExpression instanceof Function) {
final Function filterExpression = (Function) labelExpression;
- final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(
- ft);
+ final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(ft);
attExVid.visit(filterExpression, null);
@@ -1838,8 +1681,8 @@
prop1 = attributeNames[0];
} else {
- if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression
- .toString().indexOf(attributeNames[1])) {
+ if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression.toString().indexOf(
+ attributeNames[1])) {
prop1 = attributeNames[0];
// prop2 = attributeNames[1];
} else {
@@ -1856,13 +1699,11 @@
}
// TODO this is not rockhard.. could NPE
- return FilterUtil.FILTER_FAC2.property(ft.getAttributeDescriptors()
- .get(1).getLocalName());
+ return FilterUtil.FILTER_FAC2.property(ft.getAttributeDescriptors().get(1).getLocalName());
}
/**
- * @return the {@link Color} used in the {@link Graphic} or null, if an
- * {@link ExternalGraphic} is used.
+ * @return the {@link Color} used in the {@link Graphic} or null, if an {@link ExternalGraphic} is used.
*
* @param graphic
* If <code>null</code> returns <code>null</code>
@@ -1910,8 +1751,7 @@
}
/**
- * Super smart metod ;-) Needs to be extended to look at the graphic width
- * and Geometry type.
+ * Super smart metod ;-) Needs to be extended to look at the graphic width and Geometry type.
*
* @param geometryDescriptor
* @param avgNn
@@ -1922,8 +1762,7 @@
}
/**
- * Super smart metod ;-) Needs to be extended to look at the graphic width
- * and Geometry type.
+ * Super smart metod ;-) Needs to be extended to look at the graphic width and Geometry type.
*
* @param geometryDescriptor
* @param avgNn
@@ -1984,9 +1823,7 @@
return 1.0;
Object exprValue = expression.evaluate(null);
- return (exprValue instanceof String) ? Double
- .valueOf((String) exprValue) : ((Number) exprValue)
- .doubleValue();
+ return (exprValue instanceof String) ? Double.valueOf((String) exprValue) : ((Number) exprValue).doubleValue();
}
/**
@@ -2051,15 +1888,12 @@
return null;
Object exprValue = expression.evaluate(null);
- return (exprValue instanceof String) ? Double
- .valueOf((String) exprValue) : ((Number) exprValue)
- .doubleValue();
+ return (exprValue instanceof String) ? Double.valueOf((String) exprValue) : ((Number) exprValue).doubleValue();
}
/**
- * Returns all {@link RasterSymbolizer} that are contained in a
- * {@link Style}. {@link RasterSymbolizer} from {@link FeatureTypeStyle}s
- * that are selection related are ignored.
+ * Returns all {@link RasterSymbolizer} that are contained in a {@link Style}. {@link RasterSymbolizer} from
+ * {@link FeatureTypeStyle}s that are selection related are ignored.
*/
public static List<RasterSymbolizer> getRasterSymbolizers(Style style) {
final List<RasterSymbolizer> rsList = new ArrayList<RasterSymbolizer>();
@@ -2070,12 +1904,10 @@
return rsList;
}
- public static void getRasterSymbolizers(
- final List<RasterSymbolizer> rsList, FeatureTypeStyle fts) {
+ public static void getRasterSymbolizers(final List<RasterSymbolizer> rsList, FeatureTypeStyle fts) {
// Leave out FTSs that are selection related
if (fts.getName() != null
- && fts.getName()
- .equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
+ && fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
return;
for (Rule r : fts.rules()) {
@@ -2091,11 +1923,10 @@
* Geopublisher allows to use one or two attributes for labeling, like
*
*
- * Returns the second attribute found in the label expression of the given
- * {@link TextSymbolizer} or <code>null</code>.
+ * Returns the second attribute found in the label expression of the given {@link TextSymbolizer} or
+ * <code>null</code>.
*/
- public static PropertyName getSecondPropertyName(
- final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
+ public static PropertyName getSecondPropertyName(final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
try {
final Expression labelExpression = textSymbolizer.getLabel();
@@ -2104,8 +1935,7 @@
return null;
} else if (labelExpression instanceof Function) {
final Function filterExpression = (Function) labelExpression;
- final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(
- ft);
+ final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(ft);
attExVid.visit(filterExpression, null);
@@ -2114,8 +1944,8 @@
return null;
String prop2 = null;
- if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression
- .toString().indexOf(attributeNames[1])) {
+ if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression.toString().indexOf(
+ attributeNames[1])) {
prop2 = attributeNames[1];
} else {
prop2 = attributeNames[0];
@@ -2133,13 +1963,12 @@
}
/**
- * Returns <code>null</code> or any {@link FeatureTypeStyle} contained in
- * the given {@link Style} that is SELECTION related.
+ * Returns <code>null</code> or any {@link FeatureTypeStyle} contained in the given {@link Style} that is SELECTION
+ * related.
*
* @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
*/
- public static FeatureTypeStyle getSelectionFeatureTypeStyle(
- final Style style) {
+ public static FeatureTypeStyle getSelectionFeatureTypeStyle(final Style style) {
if (style == null)
return null;
@@ -2150,8 +1979,7 @@
FeatureTypeStyle fts = style.featureTypeStyles().get(ii);
if (fts.getName() != null
- && fts.getName()
- .equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
+ && fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
return style.featureTypeStyles().get(ii);
}
}
@@ -2253,16 +2081,15 @@
/**
* @param style
- * A {@link Style} to search for the first {@link TextSymbolizer}
- * that will be used for the given {@link SimpleFeature}.
+ * A {@link Style} to search for the first {@link TextSymbolizer} that will be used for the given
+ * {@link SimpleFeature}.
*
* @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
*
- * @return <code>null</code> or the first {@link TextSymbolizer} found in
- * the style that applies to the {@link SimpleFeature}.
+ * @return <code>null</code> or the first {@link TextSymbolizer} found in the style that applies to the
+ * {@link SimpleFeature}.
*/
- public static TextSymbolizer getTextSymbolizer(final Style style,
- final SimpleFeature f) {
+ public static TextSymbolizer getTextSymbolizer(final Style style, final SimpleFeature f) {
if (f == null)
return null;
try {
@@ -2297,14 +2124,12 @@
/**
* @param style
- * A {@link Style} to search for all {@link TextSymbolizer}s . No
- * guarantee, that any one of them will ever be used for any
- * feature (think about filters).
+ * A {@link Style} to search for all {@link TextSymbolizer}s . No guarantee, that any one of them will
+ * ever be used for any feature (think about filters).
*
* @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
*
- * @return {@link List} or all {@link TextSymbolizer}s found in the
- * {@link Style}.
+ * @return {@link List} or all {@link TextSymbolizer}s found in the {@link Style}.
*/
public static List<TextSymbolizer> getTextSymbolizers(final Style style) {
List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
@@ -2328,17 +2153,14 @@
/**
* @param symbolizers
- * List of Symbolizers to search for all {@link TextSymbolizer}s
- * . No guarantee, that any one of them will ever be used for any
- * feature (think about filters).
+ * List of Symbolizers to search for all {@link TextSymbolizer}s . No guarantee, that any one of them
+ * will ever be used for any feature (think about filters).
*
* @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
*
- * @return {@link List} or all {@link TextSymbolizer}s found in the given
- * symbolizers.
+ * @return {@link List} or all {@link TextSymbolizer}s found in the given symbolizers.
*/
- public static List<TextSymbolizer> getTextSymbolizers(
- Symbolizer[] symbolizers) {
+ public static List<TextSymbolizer> getTextSymbolizers(Symbolizer[] symbolizers) {
List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
try {
if (symbolizers != null) {
@@ -2360,17 +2182,14 @@
/**
* @param style
- * A {@link Style} to search for all {@link TextSymbolizer}s . No
- * guarantee, that any one of them will ever be used for any
- * feature (think about filters).
+ * A {@link Style} to search for all {@link TextSymbolizer}s . No guarantee, that any one of them will
+ * ever be used for any feature (think about filters).
*
* @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
*
- * @return {@link List} or all {@link TextSymbolizer}s found in the
- * {@link Style}.
+ * @return {@link List} or all {@link TextSymbolizer}s found in the {@link Style}.
*/
- public static List<TextSymbolizer> getVisibleTextSymbolizers(
- final Style style) {
+ public static List<TextSymbolizer> getVisibleTextSymbolizers(final Style style) {
List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
try {
if (style != null) {
@@ -2383,9 +2202,8 @@
/*
* We are comparing it to AsUtil.alwaysfalsefilter
*
- * public static final PropertyIsEqualTo
- * allwaysFalseFilter = ff2.equals(ff2
- * .literal("1"), ff2.literal("2"));
+ * public static final PropertyIsEqualTo allwaysFalseFilter = ff2.equals(ff2 .literal("1"),
+ * ff2.literal("2"));
*/
try {
@@ -2393,20 +2211,14 @@
if (f instanceof And) {
And and = (And) f;
if (and.getChildren() != null) {
- Filter candidateF = and.getChildren()
- .get(0);
+ Filter candidateF = and.getChildren().get(0);
if (candidateF instanceof PropertyIsEqualTo) {
final PropertyIsEqualTo compare = (PropertyIsEqualTo) candidateF;
if (compare.getExpression1() instanceof Literal
&& compare.getExpression2() instanceof Literal) {
- Literal test1 = (Literal) compare
- .getExpression1();
- Literal test2 = (Literal) compare
- .getExpression2();
- if (test1.toString()
- .equals("1")
- && test2.toString()
- .equals("2")) {
+ Literal test1 = (Literal) compare.getExpression1();
+ Literal test2 = (Literal) compare.getExpression2();
+ if (test1.toString().equals("1") && test2.toString().equals("2")) {
// This TextSymbolizer is
// disabled using
// ASUtil.allwaysFalseFilter
@@ -2420,9 +2232,7 @@
}
}
} catch (Exception e) {
- LOGGER.debug(
- "Checking for textSymbolizer allwaysFalseFilter",
- e);
+ LOGGER.debug("Checking for textSymbolizer allwaysFalseFilter", e);
}
}
@@ -2446,8 +2256,7 @@
* The first {@link Style}
* @param style2file
* A {@link File} pointing to the second {@link Style}
- * @return <code>true</code> is they are different, ignoring any XML
- * fomatting.
+ * @return <code>true</code> is they are different, ignoring any XML fomatting.
*/
public static boolean isStyleDifferent(Style style1, File style2file) {
try {
@@ -2479,8 +2288,7 @@
* The first {@link Style}
* @param style2
* The second {@link Style} to compare to
- * @return <code>true</code> is they are different, ignoring any XML
- * fomatting.
+ * @return <code>true</code> is they are different, ignoring any XML fomatting.
*/
public static boolean isStyleDifferent(Style style1, Style style2) {
try {
@@ -2491,8 +2299,8 @@
return !style1string.equals(style2string);
} catch (Exception e) {
- LOGGER.debug("Compating styles " + style1 + " and " + style2
- + " failed. So we assume they are different.", e);
+ LOGGER.debug("Compating styles " + style1 + " and " + style2 + " failed. So we assume they are different.",
+ e);
return true;
}
@@ -2526,8 +2334,7 @@
* @param inputStream
* {@link InputStream} to read the SLD from
*
- * @return An {@link Array} of {@link Style}s, can be length==0. null if
- * file not exists
+ * @return An {@link Array} of {@link Style}s, can be length==0. null if file not exists
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
@@ -2535,14 +2342,11 @@
Style[] styles = null;
try {
- SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- inputStream);
+ SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
styles = stylereader.readXML();
return styles;
} catch (Exception e) {
- LOGGER.warn(
- " ... no styles recognized. Return 'new Style[] { null }' ",
- e);
+ LOGGER.warn(" ... no styles recognized. Return 'new Style[] { null }' ", e);
return new Style[] { null };
}
@@ -2554,8 +2358,8 @@
* @param url
* {@link URL} to read the SLD from
*
- * @return An {@link Array} of {@link Style}s, can be length==0 if no
- * UserStyles in SLD file. null if file not exists
+ * @return An {@link Array} of {@link Style}s, can be length==0 if no UserStyles in SLD file. null if file not
+ * exists
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
@@ -2571,18 +2375,14 @@
}
}
- public static StyledLayerDescriptor loadStyledLayerDescriptor(
- InputStream inputStream) {
+ public static StyledLayerDescriptor loadStyledLayerDescriptor(InputStream inputStream) {
StyledLayerDescriptor sld = null;
try {
- SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- inputStream);
+ SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
sld = stylereader.parseSLD();
return sld;
} catch (Exception e) {
- LOGGER.warn(
- " ... no StyledLayerDescriptor recognized. Returning null ",
- e);
+ LOGGER.warn(" ... no StyledLayerDescriptor recognized. Returning null ", e);
return sld;
}
}
@@ -2590,27 +2390,22 @@
public static StyledLayerDescriptor loadStyledLayerDescriptor(Reader reader) {
StyledLayerDescriptor sld = null;
try {
- SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- reader);
+ SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, reader);
sld = stylereader.parseSLD();
return sld;
} catch (Exception e) {
- LOGGER.warn(
- " ... no StyledLayerDescriptor recognized. Returning null ",
- e);
+ LOGGER.warn(" ... no StyledLayerDescriptor recognized. Returning null ", e);
return sld;
}
}
- static public ColorMap parseColormapToSld(File colormapFile)
- throws IOException {
+ static public ColorMap parseColormapToSld(File colormapFile) throws IOException {
return parseColormapToSld(DataUtilities.fileToURL(colormapFile));
}
/**
- * Creates a Geotools Colormap containing all the Color Palette definitions
- * defined in the File. The File may have different formats. Supported
- * formats are<br/>
+ * Creates a Geotools Colormap containing all the Color Palette definitions defined in the File. The File may have
+ * different formats. Supported formats are<br/>
* <ul>
* <li>gdalinfo output</li>
* </ul>
@@ -2620,9 +2415,7 @@
*
* TODO Stefan Tzeggai Support gdal xml.aux format!
*
- * @see http
- * ://osgeo-org.1803224.n2.nabble.com/gdal-dev-Color-palette-file-for
- * -use-in-rgb2pct-td4493744.html
+ * @see http ://osgeo-org.1803224.n2.nabble.com/gdal-dev-Color-palette-file-for -use-in-rgb2pct-td4493744.html
*/
static public ColorMap parseColormapToSld(URL url) throws IOException {
@@ -2641,66 +2434,56 @@
Matcher matcher = GDALINFO_COLORMAP_RGBA.matcher(line);
if (matcher.find()) {
- Color color = new Color(Integer.valueOf(matcher.group(2)),
- Integer.valueOf(matcher.group(3)),
- Integer.valueOf(matcher.group(4)),
- Integer.valueOf(matcher.group(5)));
+ Color color = new Color(Integer.valueOf(matcher.group(2)), Integer.valueOf(matcher.group(3)),
+ Integer.valueOf(matcher.group(4)), Integer.valueOf(matcher.group(5)));
// Arrays verlängern
labels = LangUtil.extendArray(labels, "");
colors = LangUtil.extendArray(colors, color);
- quantities = LangUtil.extendArray(quantities,
- Double.valueOf(matcher.group(1)));
+ quantities = LangUtil.extendArray(quantities, Double.valueOf(matcher.group(1)));
// Zur nächsten Zeile springen
continue;
}
} catch (Exception e) {
- LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '"
- + line + "'. Skipped.", e);
+ LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '" + line + "'. Skipped.", e);
}
try {
Matcher matcher = GDALINFO_COLORMAP_RGB.matcher(line);
if (matcher.find()) {
- Color color = new Color(Integer.valueOf(matcher.group(2)),
- Integer.valueOf(matcher.group(3)),
+ Color color = new Color(Integer.valueOf(matcher.group(2)), Integer.valueOf(matcher.group(3)),
Integer.valueOf(matcher.group(4)));
// Arrays verlängern
labels = LangUtil.extendArray(labels, "");
colors = LangUtil.extendArray(colors, color);
- quantities = LangUtil.extendArray(quantities,
- Double.valueOf(matcher.group(1)));
+ quantities = LangUtil.extendArray(quantities, Double.valueOf(matcher.group(1)));
// Zur nächsten Zeile springen
continue;
}
} catch (Exception e) {
- LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '"
- + line + "'. Skipped.", e);
+ LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '" + line + "'. Skipped.", e);
}
}
int type = ColorMap.TYPE_VALUES;
- ColorMap createColorMap = STYLE_BUILDER.createColorMap(labels,
- quantities, colors, type);
+ ColorMap createColorMap = STYLE_BUILDER.createColorMap(labels, quantities, colors, type);
return createColorMap;
}
/**
- * Unless {@link ColorMap} has no methods to remove an entry this method
- * creates a new {@link ColorMap} with the identical entries except the one
- * to remove.
+ * Unless {@link ColorMap} has no methods to remove an entry this method creates a new {@link ColorMap} with the
+ * identical entries except the one to remove.
*
* @param colorMap
* the color map to remove entries from
* @param colorMapEntry
* the entry to remove
*/
- public static ColorMap removeColorMapEntry(ColorMap colorMap,
- ColorMapEntry colorMapEntry) {
+ public static ColorMap removeColorMapEntry(ColorMap colorMap, ColorMapEntry colorMapEntry) {
ColorMap newColorMap = new ColorMapImpl();
applyColorMapProperties(colorMap, newColorMap);
@@ -2713,9 +2496,8 @@
}
/**
- * Unless {@link ColorMap} has no methods to remove an entry this method
- * creates a new {@link ColorMap} with the identical entries except the one
- * to remove.
+ * Unless {@link ColorMap} has no methods to remove an entry this method creates a new {@link ColorMap} with the
+ * identical entries except the one to remove.
*
* @param colorMap
* the color map to remove entries from
@@ -2735,8 +2517,8 @@
}
/**
- * Creates a copy of the given {@link Style}, removing any
- * {@link FeatureTypeStyle}s that are only SELECTION related.
+ * Creates a copy of the given {@link Style}, removing any {@link FeatureTypeStyle}s that are only SELECTION
+ * related.
*
* @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
*/
@@ -2753,8 +2535,7 @@
FeatureTypeStyle fts = style.featureTypeStyles().get(ii);
if (fts.getName() != null
- && fts.getName()
- .equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
+ && fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
cleanStyle.featureTypeStyles().remove(ii);
break;
}
@@ -2770,13 +2551,11 @@
* @param oldColor
* @param newColor
*/
- public static void replaceFillColor(Fill fill, Color oldColor,
- Color newColor) {
+ public static void replaceFillColor(Fill fill, Color oldColor, Color newColor) {
if (fill == null)
return;
- if ((fill.getColor() != null)
- && (getColorFromExpression(fill.getColor()).equals(oldColor)))
+ if ((fill.getColor() != null) && (getColorFromExpression(fill.getColor()).equals(oldColor)))
fill.setColor(STYLE_BUILDER.colorExpression(newColor));
replaceGraphicColor(fill.getGraphicFill(), oldColor, newColor);
@@ -2792,8 +2571,7 @@
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static void replaceGraphicColor(Graphic graphic, Color oldColor,
- Color newColor) {
+ public static void replaceGraphicColor(Graphic graphic, Color oldColor, Color newColor) {
if (graphic == null)
return;
@@ -2815,8 +2593,7 @@
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static void replaceLineSymbolizerColor(LineSymbolizer ps,
- Color oldColor, Color newColor) {
+ public static void replaceLineSymbolizerColor(LineSymbolizer ps, Color oldColor, Color newColor) {
if (ps == null)
return;
@@ -2828,8 +2605,7 @@
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static void replacePointSymbolizerColor(PointSymbolizer ps,
- Color oldColor, Color newColor) {
+ public static void replacePointSymbolizerColor(PointSymbolizer ps, Color oldColor, Color newColor) {
if (ps == null)
return;
@@ -2844,8 +2620,7 @@
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
* @param ps
*/
- public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps,
- Color oldColor, Color newColor) {
+ public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps, Color oldColor, Color newColor) {
replaceFillColor(ps.getFill(), oldColor, newColor);
replaceStrokeColor(ps.getStroke(), oldColor, newColor);
}
@@ -2857,14 +2632,11 @@
* @param oldColor
* @param newColor
*/
- public static void replaceStrokeColor(Stroke stroke, Color oldColor,
- Color newColor) {
+ public static void replaceStrokeColor(Stroke stroke, Color oldColor, Color newColor) {
if (stroke == null)
return;
- if ((stroke.getColor() != null)
- && (StylingUtil.getColorFromExpression(stroke.getColor())
- .equals(oldColor)))
+ if ((stroke.getColor() != null) && (StylingUtil.getColorFromExpression(stroke.getColor()).equals(oldColor)))
stroke.setColor(StylingUtil.STYLE_BUILDER.colorExpression(newColor));
replaceGraphicColor(stroke.getGraphicFill(), oldColor, newColor);
@@ -2878,8 +2650,7 @@
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static void replaceSymbolizerColor(Symbolizer symb, Color oldColor,
- Color newColor) {
+ public static void replaceSymbolizerColor(Symbolizer symb, Color oldColor, Color newColor) {
if (symb == null)
return;
@@ -2903,59 +2674,47 @@
final static Parser parser = new Parser(SLD_CONFIGURATION);
/**
- * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a
- * FeatureTypeStyle for selection is used, it is automatically removed. This
- * method also checks, whether the style is actually differing from any
- * existing style in the {@link File}. If there is no difference, the file
- * is not saved again (that is more svn friendly).<br/>
+ * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a FeatureTypeStyle for selection is used, it
+ * is automatically removed. This method also checks, whether the style is actually differing from any existing
+ * style in the {@link File}. If there is no difference, the file is not saved again (that is more svn friendly).<br/>
* All text ist converted to UTF-8.
*
* @param origStyle
- * {@link Style} to save. Any selectino related FeatureTypeStyle
- * will be removed.
+ * {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*
- * @return <code>true</code> if the file was really written.
- * <code>false</code> means, that the existing file already
- * contained the same content and was not touched.
+ * @return <code>true</code> if the file was really written. <code>false</code> means, that the existing file
+ * already contained the same content and was not touched.
* @throws IOException
*/
- public static final boolean saveStyleToSld(Style origStyle, File exportFile)
- throws IOException {
+ public static final boolean saveStyleToSld(Style origStyle, File exportFile) throws IOException {
return saveStyleToSld(origStyle, exportFile, false, null);
}
/**
- * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a
- * FeatureTypeStyle for selection is used, it is automatically removed. This
- * method also checks, whether the style is actually differing from any
- * existing style in the {@link File}. If there is no difference, the file
- * is not saved again (that is more svn friendly).<br/>
+ * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a FeatureTypeStyle for selection is used, it
+ * is automatically removed. This method also checks, whether the style is actually differing from any existing
+ * style in the {@link File}. If there is no difference, the file is not saved again (that is more svn friendly).<br/>
* All text ist converted to UTF-8.
*
* @param origStyle
- * {@link Style} to save. Any selectino related FeatureTypeStyle
- * will be removed.
+ * {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
*
* @param optimized
- * If <code>true</code> any redundant information (typically used
- * by AtlasStyler for GUI state and internal information) is
- * thrown away.
+ * If <code>true</code> any redundant information (typically used by AtlasStyler for GUI state and
+ * internal information) is thrown away.
*
* @param title
- * when using optimized, a new title may be defined the the
- * {@link Style} or <code>null</code>.
+ * when using optimized, a new title may be defined the the {@link Style} or <code>null</code>.
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
*
- * @return <code>true</code> if the file was really written.
- * <code>false</code> means, that the existing file already
- * contained the same content and was not touched.
+ * @return <code>true</code> if the file was really written. <code>false</code> means, that the existing file
+ * already contained the same content and was not touched.
* @throws IOException
*/
- public static final boolean saveStyleToSld(Style origStyle,
- File exportFile, boolean optimized, String title)
+ public static final boolean saveStyleToSld(Style origStyle, File exportFile, boolean optimized, String title)
throws IOException {
try {
@@ -2984,8 +2743,7 @@
String string = nativeWritten.getBuffer().toString();
if (optimized) {
- string = string.replaceFirst("\\<sld", OPTIMIZED_COMMENT
- + "\n<sld");
+ string = string.replaceFirst("\\<sld", OPTIMIZED_COMMENT + "\n<sld");
}
IOUtils.write(string, output, "UTF-8");
} finally {
@@ -2994,18 +2752,15 @@
}
LOGGER.debug("Validating stored file " + exportFile + "... ");
- List<Exception> validateSld = validateSld(new FileInputStream(
- exportFile));
+ List<Exception> validateSld = validateSld(new FileInputStream(exportFile));
if (validateSld.size() > 0) {
- LOGGER.error(exportFile + " is not valid SLD: "
- + validateSld.size() + " exceptions");
+ LOGGER.error(exportFile + " is not valid SLD: " + validateSld.size() + " exceptions");
}
for (Exception e : validateSld) {
LOGGER.warn(exportFile + " " + e.getLocalizedMessage(), e);
}
} catch (TransformerException te) {
- LOGGER.warn("TransformerException while saving Style to SLD file "
- + exportFile, te);
+ LOGGER.warn("TransformerException while saving Style to SLD file " + exportFile, te);
return false;
}
return true;
@@ -3030,8 +2785,8 @@
}
for (Name ftsName : ftsRules.keySet()) {
- oStyle.featureTypeStyles().add(
- STYLE_BUILDER.createFeatureTypeStyle(ftsName.toString(),
+ oStyle.featureTypeStyles()
+ .add(STYLE_BUILDER.createFeatureTypeStyle(ftsName.toString(),
ftsRules.get(ftsName).toArray(new Rule[0])));
}
@@ -3056,12 +2811,12 @@
}
/**
- * @return a Simplified filter, free of any filters used as markers by
- * AtlasStyler.
+ * @return a Simplified filter, free of any filters used as markers by AtlasStyler.
*/
public static Filter simpliyfyFilter(Filter f) {
- if (f == null) return Filter.INCLUDE;
+ if (f == null)
+ return Filter.INCLUDE;
if (f instanceof AndImpl) {
AndImpl and = (AndImpl) f;
@@ -3137,9 +2892,7 @@
try {
is.close();
} catch (IOException e1) {
- LOGGER.error(
- "Closing the InputStream after the Seriouse Exception failed",
- e1);
+ LOGGER.error("Closing the InputStream after the Seriouse Exception failed", e1);
}
return el;
}
@@ -3148,38 +2901,32 @@
}
/**
- * True if the given XMl coming from the {@link InputStream} is validates
- * against SLD 1.0
+ * True if the given XMl coming from the {@link InputStream} is validates against SLD 1.0
*/
public static boolean validates(InputStream is) {
return validateSld(is).size() == 0;
}
/**
- * Exports the {@link Style} to OGC SLD. If a FeatureTypeStyle for selection
- * is used, it is automatically removed.
+ * Exports the {@link Style} to OGC SLD. If a FeatureTypeStyle for selection is used, it is automatically removed.
*
* @param exportStyle
- * {@link Style} to save. Any selectino related FeatureTypeStyle
- * will be removed.
+ * {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
*
* @param optimized
- * If <code>true</code> any redundant information (typically used
- * by AtlasStyler for GUI state and internal information) is
- * thrown away.
+ * If <code>true</code> any redundant information (typically used by AtlasStyler for GUI state and
+ * internal information) is thrown away.
*
* @param title
- * when using optimized, a new title may be defined the the
- * {@link Style} or <code>null</code>.
+ * when using optimized, a new title may be defined the the {@link Style} or <code>null</code>.
*
*
*
* @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
* @throws TransformerException
*/
- public static final void saveStyleToSLD(Style exportStyle,
- OutputStream exportStream, boolean optimized, String title)
- throws TransformerException {
+ public static final void saveStyleToSLD(Style exportStyle, OutputStream exportStream, boolean optimized,
+ String title) throws TransformerException {
exportStyle = removeSelectionFeatureTypeStyle(exportStyle);
@@ -3204,9 +2951,8 @@
}
/**
- * AtlasStyler has a fixed system that allows to use one or two label
- * attributes. If two are used, the are seperated by ": ". This mehtod stes
- * one or two ProperybaName fields.
+ * AtlasStyler has a fixed system that allows to use one or two label attributes. If two are used, the are seperated
+ * by ": ". This mehtod stes one or two ProperybaName fields.
*
* @param symbolizer
* the {@link TextSymbolizer} to call setLabel(Expression) on.
@@ -3215,17 +2961,13 @@
* @param literalLabelField2
* may be <code>null</code>
*/
- public static void setDoublePropertyName(final TextSymbolizer symbolizer,
- final PropertyName literalLabelField1,
+ public static void setDoublePropertyName(final TextSymbolizer symbolizer, final PropertyName literalLabelField1,
final PropertyName literalLabelField2) {
- if (literalLabelField2 != null
- && !literalLabelField2.getPropertyName().isEmpty()
+ if (literalLabelField2 != null && !literalLabelField2.getPropertyName().isEmpty()
&& !literalLabelField2.toString().equalsIgnoreCase("-")) {
final Literal trenner = FilterUtil.FILTER_FAC2.literal(": ");
- final Function f3 = FilterUtil.FILTER_FAC2.function("strConcat",
- trenner, literalLabelField2);
- final Function bothExpression = FilterUtil.FILTER_FAC2.function(
- "strConcat", literalLabelField1, f3);
+ final Function f3 = FilterUtil.FILTER_FAC2.function("strConcat", trenner, literalLabelField2);
+ final Function bothExpression = FilterUtil.FILTER_FAC2.function("strConcat", literalLabelField1, f3);
LOGGER.debug("Extended label expression is now: " + bothExpression);
symbolizer.setLabel(bothExpression);
} else {
@@ -3241,8 +2983,7 @@
* @param opacity
* Transparenzwert
*/
- public static void setOpacityForColorMapEntry(ColorMapEntry entry,
- double opacity) {
+ public static void setOpacityForColorMapEntry(ColorMapEntry entry, double opacity) {
if (entry != null)
entry.setOpacity(STYLE_BUILDER.literalExpression(opacity));
}
@@ -3255,8 +2996,7 @@
* @param quantity
* neuer Wert
*/
- public static void setQuantityForColorMapEntry(ColorMapEntry entry,
- double quantity) {
+ public static void setQuantityForColorMapEntry(ColorMapEntry entry, double quantity) {
if (entry != null)
entry.setQuantity(STYLE_BUILDER.literalExpression(quantity));
}
@@ -3294,8 +3034,7 @@
}
/**
- * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to
- * XML.
+ * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to XML.
*
* @throws TransformerException
*/
@@ -3303,8 +3042,7 @@
return SLDTRANSFORMER.transform(sld);
}
- public static boolean validates(FeatureTypeStyle fts) throws IOException,
- TransformerException {
+ public static boolean validates(FeatureTypeStyle fts) throws IOException, TransformerException {
// Bytestream not file!
Style s = STYLE_BUILDER.createStyle();
s.featureTypeStyles().add(fts);
@@ -3322,8 +3060,7 @@
}
}
- public static boolean isStyleDifferent(FeatureTypeStyle fts1,
- FeatureTypeStyle fts2) {
+ public static boolean isStyleDifferent(FeatureTypeStyle fts1, FeatureTypeStyle fts2) {
Style style1 = STYLE_BUILDER.createStyle();
style1.featureTypeStyles().add(fts1);
@@ -3338,20 +3075,17 @@
return xml;
}
- public static void correctGeometryPropertyname(
- final SimpleFeatureType schema, Symbolizer sym) {
+ public static void correctGeometryPropertyname(final SimpleFeatureType schema, Symbolizer sym) {
String newGpn = sym.getGeometryPropertyName();
if (schema != null) {
// If we have a schema,
- GeometryDescriptor geometryDescriptor = schema
- .getGeometryDescriptor();
+ GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
if (geometryDescriptor != null)
newGpn = geometryDescriptor.getName().toString();
if (newGpn != null) {
- NameImpl found = FeatureUtil.findBestMatchingAttribute(schema,
- newGpn);
+ NameImpl found = FeatureUtil.findBestMatchingAttribute(schema, newGpn);
if (found != null)
newGpn = found.getLocalPart();
else
@@ -3364,8 +3098,7 @@
}
/***************************************************************************
- * Copies all Values from one {@link TextSymbolizer} to another
- * {@link TextSymbolizer}
+ * Copies all Values from one {@link TextSymbolizer} to another {@link TextSymbolizer}
*
* @param from
* {@link TextSymbolizer} source
@@ -3375,8 +3108,7 @@
* @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public static void copyAllValues(final TextSymbolizer from,
- final TextSymbolizer to) {
+ public static void copyAllValues(final TextSymbolizer from, final TextSymbolizer to) {
to.setLabel(from.getLabel());
to.setPriority(from.getPriority());
@@ -3384,14 +3116,52 @@
final FilterFactory2 ff2 = FeatureUtil.FILTER_FACTORY2;
- to.getFonts()[0].setFontFamily(ff2.literal(from.getFonts()[0]
- .getFontFamily().toString()));
- to.getFonts()[0].setFontSize(ff2.literal(from.getFonts()[0]
- .getFontSize().toString()));
- to.getFonts()[0].setFontWeight(ff2.literal(from.getFonts()[0]
- .getFontWeight().toString()));
- to.getFonts()[0].setFontStyle(ff2.literal(from.getFonts()[0]
- .getFontStyle().toString()));
+ to.getFonts()[0].setFontFamily(ff2.literal(from.getFonts()[0].getFontFamily().toString()));
+ to.getFonts()[0].setFontSize(ff2.literal(from.getFonts()[0].getFontSize().toString()));
+ to.getFonts()[0].setFontWeight(ff2.literal(from.getFonts()[0].getFontWeight().toString()));
+ to.getFonts()[0].setFontStyle(ff2.literal(from.getFonts()[0].getFontStyle().toString()));
}
+ /**
+ * Liefert für einen namen eine Plalette
+ */
+ public static BrewerPalette getBrewerPaletteByName(String name) {
+ if (name == null)
+ return null;
+ for (BrewerPalette bp : getBrewerPalettes(true)) {
+ if (bp.getName().equalsIgnoreCase(name))
+ return bp;
+ }
+ return null;
+ }
+
+ /**
+ * Liefert eine Liste aller verfügbaren Colorbrewer Paletten
+ *
+ * @return
+ */
+ public static BrewerPalette[] getBrewerPalettes(boolean distinctValues) {
+ BrewerPalette[] palettes = new BrewerPalette[] {};
+ // This code only the paletes usefull for unique values.
+ final PaletteType paletteTypeUnique = new PaletteType(false, true);
+ final PaletteType paletteTypeRanged = new PaletteType(true, false);
+ try {
+ ColorBrewer brewer1, brewer2;
+ brewer1 = ColorBrewer.instance(paletteTypeUnique);
+ brewer2 = ColorBrewer.instance(paletteTypeRanged);
+ BrewerPalette[] palettes1 = brewer1.getPalettes(paletteTypeUnique);
+ BrewerPalette[] palettes2 = brewer2.getPalettes(paletteTypeRanged);
+
+ if (distinctValues) {
+ palettes = LangUtil.extendArray(palettes1, palettes2);
+ } else
+ palettes = LangUtil.extendArray(palettes2, palettes1);
+ } catch (IOException e) {
+ LOGGER.error("Error loading palettes", e);
+ palettes = ColorBrewer.instance().getPalettes();
+ }
+
+ return palettes;
+ }
+
}
More information about the Schmitzm-commits
mailing list