示例#1
0
 /** Creates a new PointSymbolizer object. */
 public PointSymbolizer() {
   super(null, "org.deegree.graphics.displayelements.PointDisplayElement");
   Stroke stroke = new Stroke();
   Fill fill = new Fill();
   Mark mark = new Mark("square", stroke, fill);
   graphic = StyleFactory.createGraphic(null, mark, 1, 5, 0);
 }
示例#2
0
  @SuppressWarnings("unchecked")
  private static Style createStyle(SimpleFeatureSource source, String fieldName) throws Exception {

    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    Function colourFn = ff.function("colorlookup", ff.literal(source), ff.property(fieldName));

    Stroke stroke =
        styleFactory.createStroke(
            colourFn,
            ff.literal(1.0f), // line
            // width
            ff.literal(1.0f)); // opacity

    Fill fill = styleFactory.createFill(colourFn, ff.literal(1.0f)); // opacity

    Class<?> geomClass = source.getSchema().getGeometryDescriptor().getType().getBinding();
    Symbolizer sym = null;
    Geometries geomType = Geometries.getForBinding((Class<? extends Geometry>) geomClass);

    switch (geomType) {
      case POLYGON:
      case MULTIPOLYGON:
        sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);
        break;

      case LINESTRING:
      case MULTILINESTRING:
        sym = styleFactory.createLineSymbolizer(stroke, null);
        break;

      case POINT:
      case MULTIPOINT:
        Graphic gr = styleFactory.createDefaultGraphic();
        gr.graphicalSymbols().clear();
        Mark mark = styleFactory.getCircleMark();
        mark.setFill(fill);
        mark.setStroke(stroke);
        gr.graphicalSymbols().add(mark);
        gr.setSize(ff.literal(10.0f));
        sym = styleFactory.createPointSymbolizer(gr, null);
        break;

      default:
        throw new IllegalArgumentException("Unsupported geometry type");
    }

    Style style = SLD.wrapSymbolizers(sym);

    return style;
  }
示例#3
0
  /**
   * Obtains the subset definition object from the environment for a given table.
   *
   * @param env execution environment
   * @param tlabel table parameter label
   * @param styleFactory factory which can examine the environment for plotting style information
   */
  private SubsetDef[] getSubsetDefinitions(
      Environment env, String tlabel, StyleFactory styleFactory) throws TaskException {

    /* Work out which parameter suffixes are being used to identify
     * different subsets for the table with parameter suffix tlabel.
     * This is done by finding all the parameters which start
     * "subset"+tlabel and pulling off their suffixes.  These suffixes
     * are then applied to other parameter stems for obtaining other
     * per-subset parameter values. */
    String[] paramNames = env.getNames();
    String stPrefix = SUBSET_PREFIX + tlabel;
    String[] subLabels = getSuffixes(paramNames, stPrefix);
    Arrays.sort(subLabels);
    int nset = subLabels.length;

    /* If there are no subsets for this table, consider it the same as
     * a single subset with inclusion of all points. */
    if (nset == 0) {
      Parameter nameParam = createSubsetNameParameter(tlabel);
      nameParam.setDefault(tlabel);
      String name = nameParam.stringValue(env);
      return new SubsetDef[] {
        new SubsetDef(tlabel, "true", name, styleFactory.getStyle(env, tlabel)),
      };
    }

    /* If there is at least one subset, gather the information required
     * to construct a SubsetDef object describing its characteristics. */
    else {
      SubsetDef[] sdefs = new SubsetDef[nset];
      for (int is = 0; is < nset; is++) {
        String stLabel = tlabel + subLabels[is];
        String expr = createSubsetExpressionParameter(stLabel).stringValue(env);
        Parameter nameParam = createSubsetNameParameter(stLabel);
        nameParam.setDefault(expr);
        String name = nameParam.stringValue(env);
        sdefs[is] = new SubsetDef(stLabel, expr, name, styleFactory.getStyle(env, stLabel));
      }
      return sdefs;
    }
  }