Package org.geotools.styling

Examples of org.geotools.styling.ColorMapEntryImpl


              //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


            Color fromColor = new Color(
                Integer.parseInt(colorRules[i][0]),
                Integer.parseInt(colorRules[i][1]),
                Integer.parseInt(colorRules[i][2]));

            ColorMapEntryImpl cme = new ColorMapEntryImpl();
            cme.setColor((Expression) builder.literal(fromColor)
                .build());
            cme.setQuantity((Expression) builder.literal(from)
                .build());
            cm.addColorMapEntry(cme);
          }
          ColorMapEntryImpl cme = new ColorMapEntryImpl();
          cme.setColor((Expression) builder.literal(toColor).build());
          cme.setQuantity((Expression) builder.literal(to).build());
          cm.addColorMapEntry(cme);

        } catch (NumberFormatException e) {
          SLDPlugin.log(e.getMessage(), e);
          continue;
        }
      }

    } else {
      /*
       * in this case we have also the values for the range defined and
       * the color rule has to be "v1 r1 g1 b1 v2 r2 g2 b2".
       */
      if (colorRules[0].length != 8) {
        throw new IOException(
            "The colortable can have records of 3 or 8 columns. Check your colortables."); //$NON-NLS-1$
      }

      for (int i = 0; i < colorRules.length; i++) {
        try {
          double to = Double.parseDouble(colorRules[i][4]);
          Color toColor = new Color(
              Integer.parseInt(colorRules[i][5]),
              Integer.parseInt(colorRules[i][6]),
              Integer.parseInt(colorRules[i][7]));
          if (i == 0) {
            double from = Double.parseDouble(colorRules[i][0]);
            Color fromColor = new Color(
                Integer.parseInt(colorRules[i][1]),
                Integer.parseInt(colorRules[i][2]),
                Integer.parseInt(colorRules[i][3]));

            ColorMapEntryImpl cme = new ColorMapEntryImpl();
            cme.setColor((Expression) builder.literal(fromColor)
                .build());
            cme.setQuantity((Expression) builder.literal(from)
                .build());
            cm.addColorMapEntry(cme);
          }
          ColorMapEntryImpl cme = new ColorMapEntryImpl();
          cme.setColor((Expression) builder.literal(toColor).build());
          cme.setQuantity((Expression) builder.literal(to).build());
          cm.addColorMapEntry(cme);
        } catch (NumberFormatException e) {
          SLDPlugin.log(e.getMessage(), e);
          continue;
        }
View Full Code Here

        private ColorMapEntry getColorMapEntry(double value) {
            return getColorMapEntry(value, Double.NaN);
        }

        private ColorMapEntry getColorMapEntry(double min, double range) {
            ColorMapEntry entry = new ColorMapEntryImpl();
            entry.setOpacity(filterFactory.literal(opacity));
            entry.setColor(filterFactory.literal(toHexColor(color)));
            entry.setQuantity(filterFactory.literal(min + (Double.isNaN(range) ? 0 : (percentage*range))));
            return entry;
        }
View Full Code Here

TOP

Related Classes of org.geotools.styling.ColorMapEntryImpl

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.