Package org.geomajas.gwt.client.spatial.geometry

Examples of org.geomajas.gwt.client.spatial.geometry.Geometry


    addNewGeometry();
  }

  private void onUndo() {
    if (geometries.size() > 0) {
      Geometry geom = geometries.remove(geometries.size() - 1);
      redoGeoms.add(geom);
      btnRedo.setDisabled(false);
      updateView();
    }
    if (geometries.size() == 0) {
View Full Code Here


    }
  }

  private void onRedo() {
    if (redoGeoms.size() > 0) {
      Geometry geom = redoGeoms.remove(redoGeoms.size() - 1);
      geometries.add(geom);
      if (geometries.size() == 1) {
        btnUndo.setDisabled(false);
      }
      updateView();
View Full Code Here

    resetButtonState();
  }

  private void addNewGeometry() {
    if (drawController.getController() != null) {
      Geometry geom = drawController.getController().getGeometry();
      if (!geom.isEmpty()
          && geom.isValid()
          && !geometries.contains(geom)) {

        geometries.add(geom);
        if (geometries.size() == 1) {
          btnUndo.setDisabled(false);
View Full Code Here

                Feature feature = features.get(map.get(dto.getId()));
                if (incAttr) {
                  feature.setAttributes(dto.getAttributes());
                }
                if (incGeom) {
                  Geometry geometry = GeometryConverter.toGwt(dto.getGeometry());
                  feature.setGeometry(geometry);
                }
              }
            }
            callback.execute(features);
View Full Code Here

  public void paint(Paintable paintable, Object group, MapContext context) {
    if (paintable != null) {
      Feature feature = (Feature) paintable;
      WorldViewTransformer worldViewTransformer = feature.getLayer().getMapModel().getMapView()
          .getWorldViewTransformer();
      Geometry geometry = worldViewTransformer.worldToPan(feature.getGeometry());
      ShapeStyle style = createStyleForFeature(feature);
      PaintableGroup selectionGroup = feature.getLayer().getSelectionGroup();
      context.getVectorContext().drawGroup(selectionGroup, feature);
      String name = feature.getLayer().getId() + "-" + feature.getId();

      if (geometry instanceof LineString) {
        context.getVectorContext().drawLine(feature, name, (LineString) geometry, style);
      } else if (geometry instanceof MultiLineString) {
        MultiLineString m = (MultiLineString) geometry;
        for (int i = 0; i < m.getNumGeometries(); i++) {
          context.getVectorContext().drawLine(feature, name + "." + i, (LineString) m.getGeometryN(i), style);
        }
      } else if (geometry instanceof Polygon) {
        context.getVectorContext().drawPolygon(feature, name, (Polygon) geometry, style);
      } else if (geometry instanceof MultiPolygon) {
        MultiPolygon m = (MultiPolygon) geometry;
        for (int i = 0; i < m.getNumGeometries(); i++) {
          context.getVectorContext().drawPolygon(feature, name + "." + i, (Polygon) m.getGeometryN(i), style);
        }
      } else if (geometry instanceof Point) {
        if (hasImageSymbol(feature)) {
          context.getVectorContext().drawSymbol(feature, name, geometry.getCoordinate(), null,
              feature.getStyleId() + "-selection");
        } else {
          context.getVectorContext().drawSymbol(feature, name, geometry.getCoordinate(), style,
              feature.getStyleId());
        }
      } else if (geometry instanceof MultiPoint) {
        Coordinate[] coordinates = geometry.getCoordinates();
        if (hasImageSymbol(feature)) {
          for (int i = 0; i < coordinates.length; i++) {
            context.getVectorContext().drawSymbol(feature, name + "." + i, coordinates[i], null,
                feature.getStyleId() + "-selection");
          }
View Full Code Here

    if (features == null) {
      return;
    }
    context.getVectorContext().drawGroup(mapWidget.getGroup(RenderGroup.VECTOR), featureTransaction);
    for (int i = 0; i < features.length; i++) {
      Geometry geometry = mapWidget.getMapModel().getMapView().getWorldViewTransformer().worldToPan(
          features[i].getGeometry());
      context.getVectorContext().drawGroup(featureTransaction, features[i]);
      if (geometry instanceof Point) {
        paint(features[i], "featureTransaction.feature" + i, (Point) geometry, context.getVectorContext());
      } else if (geometry instanceof MultiPoint) {
View Full Code Here

   *            A MapContext object, responsible for actual drawing.
   */
  public void paint(Paintable paintable, Object group, MapContext context) {
    if (paintable != null) {
      GfxGeometry gfxGeometry = (GfxGeometry) paintable;
      Geometry geometry = gfxGeometry.getGeometry();
      ShapeStyle shapeStyle = gfxGeometry.getStyle();
      if (geometry instanceof LineString) {
        context.getVectorContext().drawLine(group, gfxGeometry.getId(), (LineString) geometry, shapeStyle);
      } else if (geometry instanceof MultiLineString) {
        MultiLineString m = (MultiLineString) geometry;
        String gfxId = gfxGeometry.getId();
        GraphicsContext gc = context.getVectorContext();
        for (int i = 0; i < m.getNumGeometries(); i++) {
          gc.drawLine(group, gfxId + "." + i, (LineString) m.getGeometryN(i), shapeStyle);
        }
      } else if (geometry instanceof Polygon) {
        context.getVectorContext().drawPolygon(group, gfxGeometry.getId(), (Polygon) geometry, shapeStyle);
      } else if (geometry instanceof MultiPolygon) {
        MultiPolygon m = (MultiPolygon) geometry;
        String gfxId = gfxGeometry.getId();
        GraphicsContext gc = context.getVectorContext();
        for (int i = 0; i < m.getNumGeometries(); i++) {
          gc.drawPolygon(group, gfxId + "." + i, (Polygon) m.getGeometryN(i), shapeStyle);
        }
      } else if (geometry instanceof Point) {
        context.getVectorContext().drawSymbolDefinition(group, gfxGeometry.getId() + ".def",
            gfxGeometry.getSymbolInfo(), shapeStyle, null);
        context.getVectorContext().drawSymbol(group, gfxGeometry.getId(), geometry.getCoordinate(), shapeStyle,
            gfxGeometry.getId() + ".def");
      } else if (geometry instanceof MultiPoint) {
        Coordinate[] coordinates = geometry.getCoordinates();
        String gfxId = gfxGeometry.getId();
        GraphicsContext gc = context.getVectorContext();
        String styleTypeDef = gfxGeometry.getId() + ".def";
        context.getVectorContext().drawSymbolDefinition(group, styleTypeDef, gfxGeometry.getSymbolInfo(),
            shapeStyle, null);
View Full Code Here

   * @param context
   *            The context to paint on.
   */
  public void deleteShape(Paintable paintable, Object group, MapContext context) {
    GfxGeometry gfxGeometry = (GfxGeometry) paintable;
    Geometry geom = gfxGeometry.getGeometry();
    if (geom instanceof Point || geom instanceof MultiPoint) {
      context.getVectorContext().deleteElement(group, gfxGeometry.getId() + ".def");
    }
    if (geom instanceof MultiPolygon || geom instanceof MultiLineString || geom instanceof MultiPoint) {
      GraphicsContext gc = context.getVectorContext();
      String gfxId = gfxGeometry.getId();
      for (int i = 0; i < geom.getNumGeometries(); i++) {
        gc.deleteElement(group, gfxId + "." + i);
      }
    } else {
      context.getVectorContext().deleteElement(group, gfxGeometry.getId());
    }
View Full Code Here

  protected void createTempLines(FeatureTransaction featureTransaction, MouseEvent<?> event) {
    if (featureTransaction.getNewFeatures() != null && featureTransaction.getNewFeatures().length > 0
        && tempLine1 == null) {
      Coordinate position = getPanPosition(event);
      Geometry geom = getGeometryIndex().getGeometry(featureTransaction);
      LineString lineString = geom.getGeometryFactory().createLineString(new Coordinate[] { position, position });
      tempLine1 = new GfxGeometry("LineStringEditController.updateLine1");
      tempLine1.setGeometry(lineString);
      tempLine1.setStyle(new ShapeStyle("#FFFFFF", 0, "#FF3322", 1, 1));
      mapWidget.render(tempLine1, RenderGroup.VECTOR, RenderStatus.ALL);
      tempLine2 = new GfxGeometry("LineStringEditController.updateLine2");
View Full Code Here

  public void execute(List<Feature> features) {
    List<Geometry> geometries = new ArrayList<Geometry>();

    for (Feature feature : features) {
      Geometry geometry = feature.getGeometry();
      // For multipolygons and multilinestrings, we calculate bounds intersection
      // for each partial geometry. This way we can send parts of the complex
      // geometries to the snapping list, and not always the entire geometry.(=faster)
      List<Geometry> currentGeometries = new ArrayList<Geometry>();
      if (geometry instanceof MultiLineString || geometry instanceof MultiPoint
          || geometry instanceof MultiPolygon) {
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          Geometry geometryN = geometry.getGeometryN(n);
          if (geometryN.getBounds().intersects(bounds)) {
            currentGeometries.add(geometryN);
          }
        }
      } else {
        if (geometry.getBounds().intersects(bounds)) {
View Full Code Here

TOP

Related Classes of org.geomajas.gwt.client.spatial.geometry.Geometry

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.