Package org.geotools.filter.expression

Examples of org.geotools.filter.expression.ExpressionBuilder


  private ColorMap parseRulesValuesList(final String[][] colorRules)
      throws IOException {

    ColorMap cm = new ColorMapImpl();
    ExpressionBuilder builder = new ExpressionBuilder();
    if (colorRules[0].length == 3) {
      if (dataMin == null && dataMax == null) {
        minMaxJob.schedule();
        try {
          minMaxJob.join();
        } catch (InterruptedException e) {
          SLDPlugin.log(e.getMessage(), e);
          return null;
        }
      }
      /*
       * the colorrules are without values, so we ramp through them over
       * the range.
       */
      if (dataMin == null) {
        dataMin = -100.0;
      }
      if (dataMax == null) {
        dataMax = 5000.0;
      }

      // calculate the color increment
      float rinc = (float) (dataMax - dataMin)
          / (float) (colorRules.length - 1);

      for (int i = 0; i < colorRules.length - 1; i++) {
        try {
          double to = dataMin + ((i + 1) * rinc);
          Color toColor = new Color(
              Integer.parseInt(colorRules[i + 1][0]),
              Integer.parseInt(colorRules[i + 1][1]),
              Integer.parseInt(colorRules[i + 1][2]));
          if (i == 0) {
            double from = dataMin + (i * rinc);
            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


        assertNotNull(b.reset().build());
    }

    @Test
    public void expression() {
        ExpressionBuilder b = new ExpressionBuilder();
        assertNotNull(b.build());
        assertNull(b.unset().build());
        assertEquals(Expression.NIL, b.reset().build());
        assertNotNull(b.reset().literal(1).build());

        assertEquals(b.unset().literal(1).build(), b.reset().literal(1).build());
    }
View Full Code Here

TOP

Related Classes of org.geotools.filter.expression.ExpressionBuilder

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.