use of org.geotools.styling.RasterSymbolizer in project sldeditor by robward-scisys.
the class DefaultSymbols method createNewRaster.
/**
* Creates the new raster symbol.
*
* @return the styled layer descriptor
*/
public static StyledLayerDescriptor createNewRaster() {
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
sld.addStyledLayer(namedLayer);
Style style = styleFactory.createStyle();
namedLayer.addStyle(style);
List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
ftsList.add(fts);
Rule rule = styleFactory.createRule();
fts.rules().add(rule);
RasterSymbolizer raster = createDefaultRasterSymbolizer();
rule.symbolizers().add(raster);
return sld;
}
use of org.geotools.styling.RasterSymbolizer in project sldeditor by robward-scisys.
the class NewRasterSLD method create.
/**
* Creates the symbol.
*
* @return the styled layer descriptor
*/
/* (non-Javadoc)
* @see com.sldeditor.create.NewSLDInterface#create()
*/
@Override
public StyledLayerDescriptor create() {
StyledLayerDescriptor sld = getStyleFactory().createStyledLayerDescriptor();
NamedLayer namedLayer = getStyleFactory().createNamedLayer();
sld.addStyledLayer(namedLayer);
Style style = getStyleFactory().createStyle();
namedLayer.addStyle(style);
List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
FeatureTypeStyle fts = getStyleFactory().createFeatureTypeStyle();
ftsList.add(fts);
Rule rule = getStyleFactory().createRule();
fts.rules().add(rule);
RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
rule.symbolizers().add(raster);
return sld;
}
use of org.geotools.styling.RasterSymbolizer in project sldeditor by robward-scisys.
the class RuleRenderVisitor method visit.
/* (non-Javadoc)
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.RasterSymbolizer)
*/
// CHECKSTYLE:OFF
public void visit(RasterSymbolizer raster) {
// CHECKSTYLE:ON
RasterSymbolizer copy = sf.createRasterSymbolizer();
copy.setChannelSelection(copy(raster.getChannelSelection()));
copy.setColorMap(copy(raster.getColorMap()));
copy.setContrastEnhancement(copy(raster.getContrastEnhancement()));
copy.setGeometry(copy(raster.getGeometry()));
copy.setUnitOfMeasure(raster.getUnitOfMeasure());
copy.setImageOutline(copy(raster.getImageOutline()));
copy.setOpacity(copy(raster.getOpacity()));
copy.setOverlap(copy(raster.getOverlap()));
copy.setShadedRelief(copy(raster.getShadedRelief()));
if (STRICT && !copy.equals(raster)) {
throw new IllegalStateException("Was unable to duplicate provided raster:" + raster);
}
pages.push(copy);
}
use of org.geotools.styling.RasterSymbolizer in project sldeditor by robward-scisys.
the class RasterReader method createRGBStyle.
/**
* Creates the rgb style.
*
* @param reader the reader
* @param raster the raster
* @return the style
*/
private Style createRGBStyle(AbstractGridCoverage2DReader reader, WritableRaster raster) {
RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
GridCoverage2D cov = null;
try {
cov = reader.read(null);
} catch (IOException giveUp) {
throw new RuntimeException(giveUp);
}
// We need at least three bands to create an RGB style
int numBands = cov.getNumSampleDimensions();
if (numBands < 3) {
createRGBImageSymbol(sym, cov, raster);
} else {
createRGBChannelSymbol(sym, cov, numBands);
}
return SLD.wrapSymbolizers(sym);
}
use of org.geotools.styling.RasterSymbolizer in project sldeditor by robward-scisys.
the class SLDEditorBufferedImageLegendGraphicBuilder method getSampleShape.
/**
* Returns a <code>java.awt.Shape</code> appropiate to render a legend graphic given the
* symbolizer type and the legend dimensions.
*
* @param symbolizer the Symbolizer for whose type a sample shape will be created
* @param legendWidth the requested width, in output units, of the legend graphic
* @param legendHeight the requested height, in output units, of the legend graphic
*
* @return an appropiate Line2D, Rectangle2D or LiteShape(Point) for the symbolizer, wether it
* is a LineSymbolizer, a PolygonSymbolizer, or a Point ot Text Symbolizer
*
* @throws IllegalArgumentException if an unknown symbolizer impl was passed in.
*/
private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth, int legendHeight) {
LiteShape2 sampleShape;
final float hpad = (legendWidth * LegendUtils.hpaddingFactor);
final float vpad = (legendHeight * LegendUtils.vpaddingFactor);
if (symbolizer instanceof LineSymbolizer) {
Coordinate[] coords = { new Coordinate(hpad, legendHeight - vpad - 1), new Coordinate(legendWidth - hpad - 1, vpad) };
LineString geom = geomFac.createLineString(coords);
try {
this.sampleLine = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleLine = null;
}
sampleShape = this.sampleLine;
} else if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof RasterSymbolizer)) {
final float w = legendWidth - (2 * hpad) - 1;
final float h = legendHeight - (2 * vpad) - 1;
Coordinate[] coords = { new Coordinate(hpad, vpad), new Coordinate(hpad, vpad + h), new Coordinate(hpad + w, vpad + h), new Coordinate(hpad + w, vpad), new Coordinate(hpad, vpad) };
LinearRing shell = geomFac.createLinearRing(coords);
Polygon geom = geomFac.createPolygon(shell, null);
try {
this.sampleRect = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleRect = null;
}
sampleShape = this.sampleRect;
} else if (symbolizer instanceof PointSymbolizer || symbolizer instanceof TextSymbolizer) {
Coordinate coord = new Coordinate(legendWidth / 2, legendHeight / 2);
try {
this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
} catch (Exception e) {
this.samplePoint = null;
}
sampleShape = this.samplePoint;
} else {
throw new IllegalArgumentException("Unknown symbolizer: " + symbolizer);
}
return sampleShape;
}
Aggregations