Package org.geotools.styling

Examples of org.geotools.styling.ColorMapEntry


                            .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);
View Full Code Here


  private static List<LegendEntry> createRampEntries(ColorMap colorMap, final Dimension imageSize){
    List<LegendEntry> lentries = new ArrayList<LegendEntry>();
    final ColorMapEntry[] entries = colorMap.getColorMapEntries();
    boolean first = true;
    for (int i = 1; i < entries.length; i += 1){
      final ColorMapEntry entry = entries[i];
      final ColorMapEntry prevEntry = entries[i-1];
     
      if (isNoData(prevEntry)){
        //skip no data entries in legend
        continue;
      }
     
      ImageDescriptor dd = null;
      int idx = -1;
      if (first){
        idx = 0;
      }else if (i > entries.length - 2){
        idx = 2;
      }
      final int index = idx;
     
      first = false;
      dd = new ImageDescriptor() {
        @Override
        public ImageData getImageData() {

          Display display = PlatformUI.getWorkbench().getDisplay();

          Image swtImage = new Image(display, imageSize.width,
              imageSize.height);
          GC gc = new GC(swtImage);
          gc.setAntialias(SWT.ON);

          org.eclipse.swt.graphics.Color c1 = getColor(display,
              entry.getColor());
          org.eclipse.swt.graphics.Color c2 = getColor(display,
              prevEntry.getColor());

          gc.setAlpha(getAlpha(entry.getOpacity()));
          gc.setBackground(c1);
          gc.setForeground(c2);
          gc.fillGradientRectangle(1, 0, imageSize.width-2,
              imageSize.height, true);

          gc.setAlpha(150);
          gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
          gc.drawLine(0, 0, 0, imageSize.height);
          gc.drawLine(imageSize.width-1, 0, imageSize.width-1, imageSize.height);
                  if (index == 0){
                    gc.drawLine(0, 0, imageSize.width-1, 0)
                  }else if (index == 2){
                    gc.drawLine(0, imageSize.height - 1, imageSize.width-1, imageSize.height - 1);
                  }
                 
          c1.dispose();
          c2.dispose();

          ImageData clone = (ImageData) swtImage.getImageData()
              .clone();
          swtImage.dispose();

          return clone;
        }
      };
     
           
      String[] text = null;
      String q1 = entry.getQuantity().evaluate(null, String.class);
      String q2 = prevEntry.getQuantity().evaluate(null, String.class);

      String l1 = entry.getLabel();
      String l2 = prevEntry.getLabel();
      if (i <= entries.length - 3){
        if (l2 == null){
          text = new String[]{q2};
        }else{
          text = new String[]{l2 + " (" + q2 + ")"}; //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

   */
  private static List<LegendEntry> createIntervalEntries(ColorMap colorMap, final Dimension imageSize){
    List<LegendEntry> lentries = new ArrayList<LegendEntry>();
    final ColorMapEntry[] entries = colorMap.getColorMapEntries();
    for (int i = 0; i < entries.length; i ++){
      ColorMapEntry prevEntry = null;
      if (i > 0){
        prevEntry = entries[i-1];
      }
      final ColorMapEntry entry = entries[i];
     
      if (isNoData(entry)){
        //skip no data entries in legend
        continue;
      }
     
      ImageDescriptor dd = null;
         dd = new ImageDescriptor() {
          @Override
                public ImageData getImageData() {
                                 
                    Display display =PlatformUI.getWorkbench().getDisplay();
                   
                    Image swtImage = new Image(display, imageSize.width, imageSize.height);
                    GC gc = new GC(swtImage);
                    gc.setAntialias(SWT.ON);
                   
                    org.eclipse.swt.graphics.Color c = getColor(display, entry.getColor());
                   
                    gc.setAlpha(getAlpha(entry.getOpacity()));
                    gc.setBackground( c );
                    gc.fillRectangle( 1, 1, imageSize.width-2, imageSize.height-2);
                    c.dispose();
                   
                    gc.setAlpha(150);
                    gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
                    gc.drawRectangle(1, 1, imageSize.width - 2, imageSize.height-2);
                   
                    ImageData clone = (ImageData) swtImage.getImageData().clone();               
                    swtImage.dispose();
                   
                    return clone;
                }
            };
            String text = null;
           
            String q1 = entry.getQuantity().evaluate(null, String.class);
            String l1 = entry.getLabel();
           
            if (prevEntry == null){
              text = "< " + q1; //$NON-NLS-1$
              if (l1 != null){
                text = l1 + " (" + text + ")"; //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

  private static List<LegendEntry> createValuesEntries(ColorMap colorMap, final Dimension imageSize){
    List<LegendEntry> lentries = new ArrayList<LegendEntry>();
   
    final ColorMapEntry[] entries = colorMap.getColorMapEntries();
    for (int i = 0; i < entries.length; i ++){
      final ColorMapEntry entry = entries[i]
     
      if (isNoData(entry)){
        //skip no data entries in legend
        continue;
      }
     
      ImageDescriptor dd = null;
         dd = new ImageDescriptor() {
          @Override
                public ImageData getImageData() {
                    Display display =PlatformUI.getWorkbench().getDisplay();
                   
                    Image swtImage = new Image(display, imageSize.width, imageSize.height);
                    GC gc = new GC(swtImage);
                    gc.setAntialias(SWT.ON);
                    org.eclipse.swt.graphics.Color c = getColor(display, entry.getColor());

                    gc.setAlpha(getAlpha(entry.getOpacity()));
                    gc.setBackground( c );
                    gc.fillRectangle( 1, 1, imageSize.width-2, imageSize.height-2);
                   
                    gc.setAlpha(150);
                    gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
                    gc.drawRectangle(1, 1, imageSize.width - 2, imageSize.height-2);
                   
                    c.dispose();
                   
                    ImageData clone = (ImageData) swtImage.getImageData().clone();               
                    swtImage.dispose();
                   
                    return clone;
                }
            };
           
            String text = null;
            String q1 = entry.getQuantity().evaluate(null, String.class);
            String l1 = entry.getLabel();
           text = q1;
            if (l1 != null){
              text = l1 + " (" + q1 + ")"; //$NON-NLS-1$ //$NON-NLS-2$
            }
            LegendEntry le = new LegendEntry(text, dd);
View Full Code Here

            if (cm != null && getCurrentSelection() != null){
              //flip colors
              if (reverseColors){
                ColorMap reverse = new ColorMapImpl();
                for (int i = 0; i < cm.getColorMapEntries().length; i ++){
                  ColorMapEntry entry = cm.getColorMapEntries()[i];
                  ColorMapEntry clone = new ColorMapEntryImpl();
                  clone.setColor(cm.getColorMapEntry(cm.getColorMapEntries().length - 1 - i).getColor());
                  clone.setLabel(entry.getLabel());
                  clone.setQuantity(entry.getQuantity());
                  clone.setOpacity(entry.getOpacity());
                  reverse.addColorMapEntry(clone);
                 
                }
                cm = reverse;
              }
View Full Code Here

    ColorMapImpl colorMap = new ColorMapImpl();
    colorMap.setType(ColorMapImpl.TYPE_VALUES);

    for (ColorEntry c : colors){
      ColorMapEntryBuilder cme = new ColorMapEntryBuilder();
      ColorMapEntry e = cme.color(c.getColor()).opacity(c.getOpacity()).quantity(formatter.formatNumber(c.getValue())).build();
      if (c.getLabel() != null && !c.getLabel().trim().isEmpty()){
        e.setLabel(c.getLabel());
      }
      colorMap.addColorMapEntry(e);
    }
    return colorMap;
   
View Full Code Here

   
    List<ColorMapEntry> entries = new ArrayList<ColorMapEntry>();
    for (int i = 0; i < colors.size(); i ++){
      ColorEntry c1 = colors.get(i);
      ColorMapEntryBuilder cme = new ColorMapEntryBuilder();
      ColorMapEntry e = cme.color(c1.getColor()).opacity(c1.getOpacity()).quantity(formatter.formatNumber(c1.getValue())).build();
      if (c1.getLabel() != null && !c1.getLabel().trim().isEmpty()){
        e.setLabel(c1.getLabel());
      }
      entries.add(e);
    }
    ColorMapEntry[] sorted = entries.toArray(new ColorMapEntry[0]);
    SingleBandEditorPage.sortEntries(sorted);
View Full Code Here

    colorMap.setType(ColorMapImpl.TYPE_RAMP);
   
    for (int i = 0; i < colors.size(); i ++){
      ColorEntry c1 = colors.get(i);     
      ColorMapEntryBuilder cme = new ColorMapEntryBuilder();
      ColorMapEntry e = cme.color(c1.getColor()).opacity(c1.getOpacity()).quantity(formatter.formatNumber(c1.getValue())).build();
      if (c1.getLabel() != null && !c1.getLabel().trim().isEmpty()){
        e.setLabel(c1.getLabel());
      }
      colorMap.addColorMapEntry(e);
     
    }
    return colorMap;
View Full Code Here

            final HAlign hAlign, final VAlign vAling, final Color bkgColor,
            final double bkgOpacity, final String text, final Dimension requestedDimension,
            final Font labelFont, final Color labelFontColor, final boolean fontAntiAliasing,
            final Color borderColor) {

        final ColorMapEntry currentCME = cMapEntries.get(0);
        Color color = LegendUtils.color(currentCME);
        final double opacity = LegendUtils.getOpacity(currentCME);
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (255 * opacity));
        super.add(new SimpleColorManager(color, opacity, requestedDimension, borderColor));

        final String label = currentCME.getLabel();
        final double quantity = LegendUtils.getQuantity(currentCME);
        final String symbol = " = ";
        String rule = Double.toString(quantity) + " " + symbol + " x";

        super.add(new TextManager(rule, vAling, hAlign, bkgColor, requestedDimension, labelFont,
View Full Code Here

            final HAlign hAlign, final VAlign vAling, final Color bkgColor,
            final double bkgOpacity, final String text, final Dimension requestedDimension,
            final Font labelFont, final Color labelFontColor, final boolean fontAntiAliasing,
            final Color borderColor) {

        final ColorMapEntry previousCME = mapEntries.get(0);
        final ColorMapEntry currentCME = mapEntries.get(1);
        boolean leftEdge;
        if (previousCME == null)
            leftEdge = true;
        else
            leftEdge = false;

        Color previousColor;
        if (!leftEdge) {
            previousColor = LegendUtils.color(previousCME);
            final double opacity = LegendUtils.getOpacity(previousCME);
            previousColor = new Color(previousColor.getRed(), previousColor.getGreen(),
                    previousColor.getBlue(), (int) (255 * opacity + 0.5));
        } else
            previousColor = null;

        Color color = LegendUtils.color(currentCME);
        double opacity = LegendUtils.getOpacity(currentCME);
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (255 * opacity));
        super.add(new GradientColorManager(color, opacity, previousColor, requestedDimension,
                borderColor));

        String label = currentCME.getLabel();
        double quantity = LegendUtils.getQuantity(currentCME);

        String symbol = leftEdge ? " > " : " = ";
        String rule = leftEdge ? Double.toString(quantity) + " " + symbol + " x" : Double
                .toString(quantity)
View Full Code Here

TOP

Related Classes of org.geotools.styling.ColorMapEntry

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.