Examples of RasterSymbolizer


Examples of org.geotools.styling.RasterSymbolizer

                // System.out.println("BANDS: " + numBands);
                // // return false;
                // }

                StyleBuilder sB = new StyleBuilder(sf);
                RasterSymbolizer rasterSym = sf.createRasterSymbolizer();

                ColorMap colorMap = sf.createColorMap();
                ArrayList<CoverageRule> rulesList = colorRulesEditor.getRulesList();
                for( int i = 0; i < rulesList.size(); i++ ) {
                    CoverageRule coverageRule = rulesList.get(i);
                    if (!coverageRule.isActive()) {
                        continue;
                    }
                    Color fromColor = coverageRule.getFromColor();
                    Color toColor = coverageRule.getToColor();
                    double[] values = coverageRule.getFromToValues();
                    double opacity = coverageRule.getOpacity();

                    Expression fromColorExpr = sB.colorExpression(new java.awt.Color(fromColor.getRed(), fromColor.getGreen(),
                            fromColor.getBlue(), 255));
                    Expression toColorExpr = sB.colorExpression(new java.awt.Color(toColor.getRed(), toColor.getGreen(), toColor
                            .getBlue(), 255));
                    Expression fromExpr = sB.literalExpression(values[0]);
                    Expression toExpr = sB.literalExpression(values[1]);
                    Expression opacityExpr = sB.literalExpression(opacity);

                    ColorMapEntry entry = sf.createColorMapEntry();
                    entry.setQuantity(fromExpr);
                    entry.setColor(fromColorExpr);
                    entry.setOpacity(opacityExpr);
                    colorMap.addColorMapEntry(entry);

                    entry = sf.createColorMapEntry();
                    entry.setQuantity(toExpr);
                    entry.setOpacity(opacityExpr);
                    entry.setColor(toColorExpr);
                    colorMap.addColorMapEntry(entry);
                }

                rasterSym.setColorMap(colorMap);

                /*
                 * set global transparency for the map
                 */
                rasterSym.setOpacity(sB.literalExpression(colorRulesEditor.getAlphaVAlue() / 100.0));

                Style newStyle = SLD.wrapSymbolizers(rasterSym);
                Layer selLayer = getSelectedLayer();
                newStyle.setName(selLayer.getName());

View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

        TextSymbolizer symbolizer = styleBuilder.createTextSymbolizer();
        return symbolizer;
    }

    protected static RasterSymbolizer createRasterSymbolizer() {
        RasterSymbolizer symbolizer = styleBuilder.createRasterSymbolizer();
        return symbolizer;
    }
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

    public Style createDefaultStyle() {

        StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
        StyleBuilder styleBuilder = new StyleBuilder(styleFactory);

        RasterSymbolizer rasterSymbolizer = styleFactory.createRasterSymbolizer();
        Rule rule = styleFactory.createRule();
        rule.setSymbolizers(new Symbolizer[]{rasterSymbolizer});

        Style style = styleBuilder.createStyle();
        SLDContentManager sldContentManager = new SLDContentManager(styleBuilder, style);
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

            // look up the preference for caching tiles on-disk or in
            // memory and use the proper tilerange for that.
            TileRange range = createTileRange(wmtSource, renderJob, tileList);

            // create an empty raster symbolizer for rendering
            RasterSymbolizer style = styleBuilder.createRasterSymbolizer();

            // setup how much each tile is worth for the monitor work %
            int tileCount = range.getTileCount();
            int tileWorth = (tileCount / 100) * tileCount;

 
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

     * @param sym
     */
    public void set( RasterSymbolizer sym2 ) {
        listen(false); // don't sync when setting up
        try {
            RasterSymbolizer sym = sym2;

            if (sym == null) {
                this.opacity = 1.0;
            }else{
                this.opacity = SLD.rasterOpacity(sym);
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

     * @return as simple style to use in default cases.
     */
    public static Style createRasterStyle( String typeName ) {
        StyleBuilder sb = new StyleBuilder();
        Style rasterstyle = sb.createStyle();
        RasterSymbolizer raster = sb.createRasterSymbolizer();

        rasterstyle.addFeatureTypeStyle(sb.createFeatureTypeStyle(raster));
        rasterstyle.getFeatureTypeStyles()[0].setFeatureTypeName(SLDs.GENERIC_FEATURE_TYPENAME);
        return rasterstyle;
    }
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

   * panel.
   *
   * @throws Exception
   */
  private void updateStyle() throws Exception{
        RasterSymbolizer rasterSym = sf.createRasterSymbolizer();
              
        ColorMap colorMap = getCurrentSelection().getColorMap();
        rasterSym.setColorMap(colorMap);

        Style newStyle = SLD.wrapSymbolizers(rasterSym);
        newStyle.setName(((Layer)getSelectedLayer()).getName() );
        StyleBlackboard styleBlackboard = getSelectedLayer().getStyleBlackboard();

View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

    }
    colorRules = new PredefinedColorRules(getGridCoverageReader(), this.noDataValues);
   
    Style style = (Style) l.getStyleBlackboard().get(SLDContent.ID);
   
    RasterSymbolizer symbolizer = SLD.rasterSymbolizer(style);
    if (symbolizer == null || symbolizer.getColorMap() == null){
      //no symbolizer
     
    }else{
      ColorMap cm = symbolizer.getColorMap();
      for (IColorMapTypePanel pnl : stylePanels){
        if (pnl.canSupport(cm.getType())){
          pnl.init(cm);
          cmbThemingStyle.setSelection(new StructuredSelection(pnl));
          cmbThemingStyle.getControl().notifyListeners(SWT.Selection, new Event());
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

                  final double currentScale = currentContext.getViewportModel().getScaleDenominator();               
                  double minScale = rule.getMinScaleDenominator();
                  double maxScale = rule.getMaxScaleDenominator();
                  if (minScale <= currentScale && currentScale <= maxScale ) {
                      final GridCoverageRenderer paint = new GridCoverageRenderer( destinationCRS, envelope, screenSize,worldToScreen,hints );
                      final RasterSymbolizer rasterSymbolizer = SLD.rasterSymbolizer(style);

                      // check if there is a color to mask
                      Object maskColor = getContext().getLayer().getStyleBlackboard().getString("raster-color-mask"); //$NON-NLS-1$                     
                        if (maskColor instanceof String) {
                            // create a color mask
                            String[] colorSplit = ((String) maskColor).split(":"); //$NON-NLS-1$
                            Color color = new Color(Integer.parseInt(colorSplit[0]), Integer.parseInt(colorSplit[1]),
                                    Integer.parseInt(colorSplit[2]));
                            RenderedImage image = coverage.getRenderedImage();
                            ImageWorker iw = new ImageWorker(image);
                            iw.makeColorTransparent(color);
                            image = iw.getRenderedImage();
                            GridCoverageFactory gcF = CoverageFactoryFinder.getGridCoverageFactory(null);
                            coverage = gcF.create(coverage.getName(), image, coverage.getCoordinateReferenceSystem(), coverage
                                    .getGridGeometry().getGridToCRS(), coverage.getSampleDimensions(), null, null);
                        }
                 
                      //setState( RENDERING );
                      paint.paint( graphics, coverage, rasterSymbolizer );                       
                      setState( DONE );
                  }
                 
              } catch(Exception e) {
                  final GridCoverageRenderer paint = new GridCoverageRenderer( destinationCRS, envelope, screenSize,worldToScreen,hints );
                  RasterSymbolizer rasterSymbolizer = CommonFactoryFinder.getStyleFactory(null).createRasterSymbolizer();
                 
                  //setState( RENDERING );
                  paint.paint( graphics, coverage, rasterSymbolizer );
                    setState( DONE );
              }
View Full Code Here

Examples of org.geotools.styling.RasterSymbolizer

        GridCoverage coverage;
        try {
            coverage = getContext().getGeoResource().resolve(GridCoverage.class, null);

            RasterSymbolizer rasterSymbolizer;

            StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
            rasterSymbolizer = factory.createRasterSymbolizer();

            renderer.paint(graphics, (GridCoverage2D) coverage, rasterSymbolizer);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.