Package org.geomajas.configuration

Examples of org.geomajas.configuration.FeatureStyleInfo


    factory = new GeometryFactory();
  }

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTileImpl tile = (InternalTileImpl) object;
    FeatureStyleInfo bgStyle = labelStyle.getBackgroundStyle();

    document.writeElement("vml:group", asChild);
    document.writeId("labels." + tile.getCode().toString());
    document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
    document.writeAttribute("style", "WIDTH: " + coordWidth + "; HEIGHT: " + coordHeight);

    // the shapetype
    document.writeElement("vml:shapetype", true);
    document.writeAttribute("id", "labels." + tile.getCode().toString() + ".style");
    document.writeAttribute("style", "WIDTH: 100%; HEIGHT: 100%");
    document.writeAttribute("style", "VISIBILITY: hidden");
    document.writeAttribute("filled", "f");
    document.writeAttribute("stroked", "f");
    document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
    // up to shapetype
    document.closeElement();

    for (InternalFeature f : tile.getFeatures()) {
      InternalFeatureImpl feature = (InternalFeatureImpl) f;
      Coordinate pos = geoService.calcDefaultLabelPosition(feature);
      if (pos == null) {
        continue;
      }
      com.vividsolutions.jts.geom.Point p = factory.createPoint(pos);
      com.vividsolutions.jts.geom.Point labelPos;
      try {
        labelPos = (com.vividsolutions.jts.geom.Point) transformer.transform(p);
        String labelString = feature.getLabel();

        // If the attribute has no value, continue with the next:
        if (labelString == null || labelString.length() == 0) {
          document.closeElement();
          continue;
        }

        // Calculate label width, left and top:
        Rectangle2D textBox = textService.getStringBounds(labelString, labelStyle.getFontStyle());
        int boxWidth = (int) textBox.getWidth() + 8; // TODO: check why not wide enough !!!
        int boxHeight = (int) textBox.getHeight() + 2;
        int left = ((int) labelPos.getX()) - boxWidth / 2;
        int top = ((int) labelPos.getY()) - boxHeight / 2;

        // Group for an individual label (vml:group):
        document.writeElement("vml:group", true);
        document.writeAttribute("style", "LEFT: " + left + "px; TOP: " + top + "px; WIDTH: " + boxWidth
            + "px; HEIGHT: " + boxHeight + "px; position:absolute;");
        document.writeAttribute("coordsize", boxWidth + " " + boxHeight);

        // First we draw the rectangle:
        document.writeElement("vml:rect", true);
        document.writeAttribute("id", feature.getId() + ".label");
        document.writeAttribute("style", "WIDTH: " + boxWidth + "px; HEIGHT: " + boxHeight + "px;");
        document.writeAttribute("fillcolor", bgStyle.getFillColor());
        document.writeAttribute("strokecolor", bgStyle.getStrokeColor());
        document.writeAttribute("strokeweight", bgStyle.getStrokeWidth());

        // Rect-fill element:
        document.writeElement("vml:fill", true);
        document.writeAttribute("opacity", Float.toString(bgStyle.getFillOpacity()));
        document.closeElement();

        // Rect-stroke element:
        document.writeElement("vml:stroke", true);
        document.writeAttribute("opacity", Float.toString(bgStyle.getStrokeOpacity()));
        document.closeElement();

        // Then the label-text:
        document.writeElement("vml:textbox", true);
        document.writeAttribute("id", feature.getId() + ".text");
View Full Code Here


    int height = (int) rectInfo.getH();
    int left = (int) coordinate.x - width / 2;
    int top = (int) coordinate.y - height / 2;
    document.writeAttribute("style", "WIDTH: " + width + "px; HEIGHT: " + height + "px;TOP: " + top + "px; LEFT: "
        + left + "px;");
    FeatureStyleInfo style = feature.getStyleInfo();
    document.writeAttribute("fillcolor", style.getFillColor());
    document.writeAttribute("strokecolor", style.getStrokeColor());
    document.writeAttribute("strokeweight", style.getStrokeWidth());

    // Rect-fill element:
    document.writeElement("vml:fill", true);
    document.writeAttribute("opacity", Float.toString(style.getFillOpacity()));
    document.closeElement();

    // Rect-stroke element:
    document.writeElement("vml:stroke", true);
    document.writeAttribute("opacity", Float.toString(style.getStrokeOpacity()));
    document.closeElement();

    // Rect element
    document.closeElement();
  }
View Full Code Here

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTile tile = (InternalTile) object;
    String style = null;
    for (InternalFeature feature : tile.getFeatures()) {
      FeatureStyleInfo featureStyle = feature.getStyleInfo();
      if (null != featureStyle) {
        String nextStyle = Integer.toString(featureStyle.getIndex());
        if (style == null || !style.equals(nextStyle)) {
          if (style != null) {
            document.closeElement();
            document.writeElement("vml:group", false);
            document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
            document.writeAttribute("style", "WIDTH: " + coordWidth + "; HEIGHT: " + coordHeight);
          } else {
            document.writeElement("vml:group", true);
            document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
            document.writeAttribute("style", "WIDTH: " + coordWidth + "; HEIGHT: " + coordHeight);
          }
          style = nextStyle;

          VectorLayerInfo layerInfo = feature.getLayer().getLayerInfo();
          if (layerInfo.getLayerType() != LayerType.POINT &&
              layerInfo.getLayerType() != LayerType.MULTIPOINT) {

            // the shapetype
            document.writeElement("vml:shapetype", true);
            document.writeAttribute("id", featureStyle.getStyleId());
            document.writeAttribute("style", "WIDTH: 100%; HEIGHT: 100%");
            document.writeAttribute("style", "VISIBILITY: hidden");
            document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
            document.writeAttribute("fillcolor", featureStyle.getFillColor());
            document.writeAttribute("strokecolor", featureStyle.getStrokeColor());
            document.writeAttribute("strokeweight", featureStyle.getStrokeWidth() + "px");

            // Tile-fill element:
            document.writeElement("vml:fill", true);
            document.writeAttribute("opacity", Float.toString(featureStyle.getFillOpacity()));
            document.closeElement();

            // Tile-stroke element:
            document.writeElement("vml:stroke", true);
            document.writeAttribute("opacity", Float.toString(featureStyle.getStrokeOpacity()));
            document.closeElement();

            // up to style group
            document.closeElement();
          }
View Full Code Here

  /**
   * The default constructor. Creates an invisible style, with the default ID. Try to avoid this.
   */
  public StyleFilterImpl() {
    this.filter = Filter.INCLUDE;
    FeatureStyleInfo style = new FeatureStyleInfo();
    style.setFillColor("#FFFFFF");
    style.setFillOpacity(0);
    style.setStrokeColor("#FFFFFF");
    style.setStrokeOpacity(0);
    style.setIndex(FeatureStyleInfo.DEFAULT_STYLE_INDEX);
    style.setName("invisible-style");
    style.setFormula("");
    style.setStyleId("default??");
  }
View Full Code Here

    InternalTile tile = (InternalTile) object;
    document.writeElement("g", true);
    document.writeId("features." + tile.getCode().toString());
    String style = null;
    for (InternalFeature feature : tile.getFeatures()) {
      FeatureStyleInfo featureStyle = feature.getStyleInfo();
      if (null != featureStyle) {
        String nextStyle = Integer.toString(featureStyle.getIndex());
        if (style == null || !style.equals(nextStyle)) {
          if (style != null) {
            document.closeElement();
            document.writeElement("g", false);
          } else {
View Full Code Here

    this.factory = new GeometryFactory();
  }

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTile tile = (InternalTile) object;
    FeatureStyleInfo bgStyle = labelStyle.getBackgroundStyle();
    document.writeElement("g", asChild);
    document.writeId("labels." + tile.getCode().toString());
    for (InternalFeature feature : tile.getFeatures()) {
      Coordinate pos = geoService.calcDefaultLabelPosition(feature);
      if (null != pos) {
View Full Code Here

        vectorRasterizingInfo.setStyle(layerInfo.getNamedStyleInfo());
        if (vectorLayer.getSelectedFeatures().size() > 0) {
          Set<String> selectedFeatures = vectorLayer.getSelectedFeatures();
          vectorRasterizingInfo.setSelectedFeatureIds(selectedFeatures.toArray(new String[selectedFeatures
              .size()]));
          FeatureStyleInfo selectStyle = null;
          switch (layerInfo.getLayerType()) {
            case GEOMETRY:
              break;
            case LINESTRING:
            case MULTILINESTRING:
              selectStyle = mapInfo.getLineSelectStyle();
              break;
            case MULTIPOINT:
            case POINT:
              selectStyle = mapInfo.getPointSelectStyle();
              break;
            case MULTIPOLYGON:
            case POLYGON:
              selectStyle = mapInfo.getPolygonSelectStyle();
              break;
          }
          selectStyle.applyDefaults();
          vectorRasterizingInfo.setSelectionStyle(selectStyle);
        }
        layerInfo.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, vectorRasterizingInfo);
      } else if (layer instanceof RasterLayer) {
        RasterLayerRasterizingInfo rasterInfo = new RasterLayerRasterizingInfo();
        ClientRasterLayerInfo layerInfo = (ClientRasterLayerInfo) layer.getLayerInfo();
        rasterInfo.setShowing(layer.isShowing());
        rasterInfo.setCssStyle(layerInfo.getStyle());
        layerInfo.getWidgetInfo().put(RasterLayerRasterizingInfo.WIDGET_KEY, rasterInfo);
      }
    }
    mapRasterizingInfo.getExtraLayers().clear();
    for (WorldPaintable worldPaintable : map.getWorldPaintables().values()) {
      if (worldPaintable instanceof GfxGeometry) {
        ClientGeometryLayerInfo layer = new ClientGeometryLayerInfo();
        GfxGeometry geometry = (GfxGeometry) worldPaintable;
        layer.getGeometries().add(GeometryConverter.toDto((Geometry) geometry.getOriginalLocation()));
        FeatureStyleInfo style = new FeatureStyleInfo();
        style.setFillColor(geometry.getStyle().getFillColor());
        style.setFillOpacity(geometry.getStyle().getFillOpacity());
        style.setStrokeColor(geometry.getStyle().getStrokeColor());
        style.setStrokeOpacity(geometry.getStyle().getStrokeOpacity());
        style.setStrokeWidth((int) geometry.getStyle().getStrokeWidth());
        style.applyDefaults();
        layer.setStyle(style);
        layer.setLayerType(geometry.getGeometry().getLayerType());
        layer.setLabel(geometry.getId());
        layer.setId(geometry.getId());
        mapRasterizingInfo.getExtraLayers().add(layer);
View Full Code Here

      NamedStyleInfo nsi = vl.getLayerInfo().getNamedStyleInfo(styleName);
      if (null == nsi) {
        throw new AdvancedviewsException(AdvancedviewsException.NO_SUCH_NAMEDSTYLE, styleName);
      }

      FeatureStyleInfo fsi = null;
      for (FeatureStyleInfo tmp : nsi.getFeatureStyles()) {
        if (featureStyleId.equals(tmp.getStyleId())) {
          fsi = tmp;
          break;
        }
View Full Code Here

    }
    return rect;
  }

  private void drawFeature(PdfContext context, InternalFeature f) {
    FeatureStyleInfo style = f.getStyleInfo();

    // Color, transparency, dash
    Color fillColor = context.getColor(style.getFillColor(), style.getFillOpacity());
    Color strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity());
    float[] dashArray = context.getDashArray(style.getDashArray());

    // check if the feature is selected
    ClientMapInfo map = configurationService.getMapInfo(getMap().getMapId(), getMap().getApplicationId());
    if (selectedFeatures.contains(f.getId())) {
      if (f.getGeometry() instanceof MultiPolygon || f.getGeometry() instanceof Polygon) {
        style = mergeStyle(style, map.getPolygonSelectStyle());
        fillColor = context.getColor(style.getFillColor(), style.getFillOpacity());
        strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity());
      } else if (f.getGeometry() instanceof MultiLineString || f.getGeometry() instanceof LineString) {
        style = mergeStyle(style, map.getLineSelectStyle());
        strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity());
      } else if (f.getGeometry() instanceof MultiPoint || f.getGeometry() instanceof Point) {
        style = mergeStyle(style, map.getPointSelectStyle());
        strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity());
      }
    }

    float lineWidth = style.getStrokeWidth();

    SymbolInfo symbol = null;
    if (f.getGeometry() instanceof MultiPoint || f.getGeometry() instanceof Point) {
      symbol = style.getSymbol();
    }
    // transform to user space
    f.getGeometry().apply(new MapToUserFilter());
    // notify geometry change !!!
    f.getGeometry().geometryChanged();
View Full Code Here

    // now draw
    context.drawGeometry(f.getGeometry(), symbol, fillColor, strokeColor, lineWidth, dashArray, getSize());
  }

  private FeatureStyleInfo mergeStyle(FeatureStyleInfo base, FeatureStyleInfo extension) {
    FeatureStyleInfo merged = new FeatureStyleInfo();
    merged.setDashArray(extension.getDashArray() != null ? extension.getDashArray() : base.getDashArray());
    merged.setFillColor(extension.getFillColor() != null ? extension.getFillColor() : base.getFillColor());
    merged.setFillOpacity(extension.getFillOpacity() != -1 ? extension.getFillOpacity() : base.getFillOpacity());
    merged.setStrokeColor(extension.getStrokeColor() != null ? extension.getStrokeColor() : base.getStrokeColor());
    merged.setStrokeOpacity(extension.getStrokeOpacity() != -1 ? extension.getStrokeOpacity() : base
        .getStrokeOpacity());
    merged.setSymbol(extension.getSymbol() != null ? extension.getSymbol() : base.getSymbol());
    merged.setStrokeWidth(extension.getStrokeWidth() != -1 ? extension.getStrokeWidth() : base.getStrokeWidth());
    return merged;
  }
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.FeatureStyleInfo

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.