Search in sources :

Example 6 with RasterSymbolizer

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;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 7 with RasterSymbolizer

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;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 8 with RasterSymbolizer

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);
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 9 with RasterSymbolizer

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);
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) IOException(java.io.IOException)

Example 10 with RasterSymbolizer

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;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ServiceException(org.geoserver.platform.ServiceException) SchemaException(org.geotools.feature.SchemaException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) IllegalAttributeException(org.opengis.feature.IllegalAttributeException) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) LiteShape2(org.geotools.geometry.jts.LiteShape2) LinearRing(com.vividsolutions.jts.geom.LinearRing) Polygon(com.vividsolutions.jts.geom.Polygon)

Aggregations

RasterSymbolizer (org.geotools.styling.RasterSymbolizer)29 Test (org.junit.Test)12 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)10 Rule (org.geotools.styling.Rule)10 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)10 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)9 Style (org.geotools.styling.Style)9 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)7 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)7 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)7 ChannelSelection (org.geotools.styling.ChannelSelection)7 LineSymbolizer (org.geotools.styling.LineSymbolizer)7 PointSymbolizer (org.geotools.styling.PointSymbolizer)7 NamedLayer (org.geotools.styling.NamedLayer)6 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)6 Symbolizer (org.geotools.styling.Symbolizer)6 Box (javax.swing.Box)5 FilterFactory (org.opengis.filter.FilterFactory)5 MalformedURLException (java.net.MalformedURLException)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4