Package org.geotools.styling

Examples of org.geotools.styling.SelectedChannelType


    // the RasterSymbolizer Helper
    rsh = new RasterSymbolizerHelper(gc, null);

    final RasterSymbolizer rsb_1 = sldBuilder.createRasterSymbolizer();
    final ChannelSelection chSel = new ChannelSelectionImpl();
    final SelectedChannelType chTypeGray = new SelectedChannelTypeImpl();
    final ContrastEnhancement cntEnh = new ContrastEnhancementImpl();

    //this will convert to byte!!!
    cntEnh.setMethod(ContrastMethod.HISTOGRAM);
    chTypeGray.setChannelName("1");
    chTypeGray.setContrastEnhancement(cntEnh);
    chSel.setGrayChannel(chTypeGray);
    rsb_1.setChannelSelection(chSel);
   
    // visit the RasterSymbolizer
    rsh.visit(rsb_1);
View Full Code Here


    // the RasterSymbolizer Helper
    rsh = new RasterSymbolizerHelper(gc, null);

    final RasterSymbolizer rsb_1 = sldBuilder.createRasterSymbolizer();
    final ChannelSelection chSel = new ChannelSelectionImpl();
    final SelectedChannelType chTypeGray = new SelectedChannelTypeImpl();
    chTypeGray.setChannelName("1");
    chSel.setGrayChannel(chTypeGray);
    rsb_1.setChannelSelection(chSel);
    rsb_1.setOpacity(sldBuilder.literalExpression(1.0));
    final ColorMap cm = sldBuilder.createColorMap(
        new String[] { // labels
View Full Code Here

    final RootNode chainSource = new RootNode(source, getHints());
    final BandMergeNode subChainSink = new BandMergeNode(getHints());
    //anchoring the chain for later disposal
    setSink(subChainSink);
    final SelectedChannelType[] rgb=cs.getRGBChannels();
    final SelectedChannelType gray=cs.getGrayChannel();
    // both of them are set?
    if((rgb!=null&&rgb[0]!=null&&rgb[1]!=null&&rgb[2]!=null)&&(gray!=null))
      throw new IllegalArgumentException(Errors.format(
          ErrorKeys.ILLEGAL_ARGUMENT_$1, "Both gray and rgb channel selection are valid!"));
    final SelectedChannelType[] sc = gray==null?rgb:new SelectedChannelType[]{gray};
   
    // If we do not really select any bands from the original coverage, we try to entirely skip this operation
    // this means that either we have to select 1 real band, or we have to select 3 real bands
    // Notice that we also try to be as resilient as possible since
    if (sc != null && ((sc.length ==1 &&sc[0]!=null)||(sc.length ==3 &&sc[0]!=null&&sc[1]!=null&&sc[2]!=null))) {
      // //
      //
      // Note that we can either select 1 (GRAY) or 3 (RGB) bands.
      //
      // //
      if (sc.length != 3 && sc.length != 1)
        throw new IllegalArgumentException(Errors.format(
            ErrorKeys.BAD_BAND_NUMBER_$1, Integer.valueOf(sc.length)));
      for (int i = 0; i < sc.length; i++) {

        // get the channel element
        final SelectedChannelType channel = sc[i];
        if(LOGGER.isLoggable(Level.FINE))
            LOGGER.fine("Channel "+i+" was "+ channel.getChannelName());
 
        // //
        //
        // BAND SELECTION
       
        //
        // //
        final BandSelectionNode bandSelectionNode = new BandSelectionNode();
        bandSelectionNode.addSource(chainSource);
        bandSelectionNode.visit(channel);

        // //
        //
        // CONTRAST ENHANCEMENT
        //
        // //
        final ContrastEnhancementNode contrastenhancementNode = new ContrastEnhancementNode();
        contrastenhancementNode.addSource(bandSelectionNode);
        bandSelectionNode.addSink(contrastenhancementNode);
        contrastenhancementNode.visit(channel != null ? channel.getContrastEnhancement() : null);

        // //
        //
        // BAND MERGE
        //
View Full Code Here

     *
     * @return a new Style instance to render the image in greyscale
     */
    private Style createGreyscaleStyle(int band) {
        ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
        SelectedChannelType sct = sf.createSelectedChannelType(String.valueOf(band), ce);

        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        ChannelSelection sel = sf.channelSelection(sct);
        sym.setChannelSelection(sel);

View Full Code Here

    public SelectedChannelType build() {
        if (unset) {
            return null;
        }
        SelectedChannelType selectedChannelType = sf.selectedChannelType(channelName,
                contrastEnhancement.build());
        return selectedChannelType;
    }
View Full Code Here

    protected SelectedChannelType copy(SelectedChannelType selectedChannelType) {
        if( selectedChannelType == null ) return null;
       
        ContrastEnhancement enhancement = copy( selectedChannelType.getContrastEnhancement() );
        String name = selectedChannelType.getChannelName();
        SelectedChannelType copy = sf.createSelectedChannelType( name, enhancement);
       
        return copy;
    }
View Full Code Here

    }

    public void visit(ChannelSelection cs) {
        //get the channels
        final SelectedChannelType sct[] = copy(cs.getSelectedChannels());
        final ChannelSelection copy = sf.createChannelSelection(sct);
        if (STRICT && !copy.equals(cs)) {
            throw new IllegalStateException("Was unable to duplicate provided ChannelSelection:" + cs);
        }
        pages.push(copy);
View Full Code Here

            throw new IllegalStateException("Was unable to duplicate provided OverlapBehavior:" + ob);
        }
    }

    public void visit(SelectedChannelType sct) {
        final SelectedChannelType copy = sf.createSelectedChannelType(sct.getChannelName(), copy(sct.getContrastEnhancement()));
        if (STRICT && !copy.equals(sct)) {
            throw new IllegalStateException("Was unable to duplicate provided SelectedChannelType:" + sct);
        }
        pages.push(copy);
    }
View Full Code Here

        Element contrast = document.createElementNS(SLD.NAMESPACE, "ContrastEnhancement");

        document.getDocumentElement().appendChild(name);
        document.getDocumentElement().appendChild(contrast);

        SelectedChannelType channelType = (SelectedChannelType) parse();
        assertNotNull(channelType);
        assertNotNull(channelType.getChannelName());
        assertEquals(channelType.getChannelName(), "SomeName");

        assertNotNull(channelType.getContrastEnhancement());
    }
View Full Code Here

    return symbol;
  }

  /** Internal parse method - made protected for unit testing */
  protected SelectedChannelType parseSelectedChannel(Node root) {
    SelectedChannelType symbol = new SelectedChannelTypeImpl();

    NodeList children = root.getChildNodes();
    final int length = children.getLength();
    for (int i = 0; i < length; i++) {
      Node child = children.item(i);

      if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
        continue;
      }
      String childName = child.getLocalName();

      if (childName == null) {
        childName = child.getNodeName();
      } else if (childName.equalsIgnoreCase("SourceChannelName")) {
        if (child.getFirstChild() != null
            && child.getFirstChild().getNodeType() == Node.TEXT_NODE)
          symbol.setChannelName(getFirstChildValue(child));
      } else if (childName.equalsIgnoreCase("ContrastEnhancement")) {
        symbol.setContrastEnhancement(parseContrastEnhancement(child));

        /*
         * try { if (child.getFirstChild() != null &&
         * child.getFirstChild().getNodeType() == Node.TEXT_NODE)
         * symbol.setContrastEnhancement((Expression) ExpressionBuilder
View Full Code Here

TOP

Related Classes of org.geotools.styling.SelectedChannelType

Copyright © 2018 www.massapicom. 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.