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

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


  // Constructor:
  // -------------------------------------------------------------------------

  public PointDrawController(MapWidget mapWidget, AbstractFreeDrawingController parent) {
    super(mapWidget, parent);
    factory = new GeometryFactory(mapWidget.getMapModel().getSrid(), mapWidget.getMapModel().getPrecision());
    geometry = factory.createPoint(new Coordinate());
    drawStyle = new ShapeStyle("#FF7F00", 0.3f, "#FF7F00", 1, 2);
    symbolStyle = new SymbolInfo();
    CircleInfo c = new CircleInfo();
    symbolStyle.setCircle(c);
View Full Code Here


  // Constructor:
  // -------------------------------------------------------------------------

  public PolygonDrawController(MapWidget mapWidget, AbstractFreeDrawingController parent) {
    super(mapWidget, parent);
    factory = new GeometryFactory(mapWidget.getMapModel().getSrid(), mapWidget.getMapModel().getPrecision());
    geometry = factory.createPolygon(null, null);
  }
View Full Code Here

    IButton button3 = new IButton(I18nProvider.getSampleMessages().renderingDrawPolygon());
    button3.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group2);
        GeometryFactory factory = map.getMapModel().getGeometryFactory();
        LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(110, 10),
            new Coordinate(210, 10), new Coordinate(210, 110), new Coordinate(110, 110),
            new Coordinate(110, 10) });
        LinearRing hole = factory.createLinearRing(new Coordinate[] { new Coordinate(140, 40),
            new Coordinate(170, 40), new Coordinate(170, 70), new Coordinate(140, 70),
            new Coordinate(140, 40) });
        Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });
        ShapeStyle style = new ShapeStyle("#9933EE", 0.5f, "#9900FF", 1, 2);
        map.getVectorContext().drawPolygon(group2, "Polygon", polygon, style);
      }
    });
    button3.setWidth100();
View Full Code Here

    worldImage.setBounds(new Bbox(-2000000, -2000000, 4000000, 4000000)); // Mercator coordinates
    worldImage.setStyle(new PictureStyle(0.8));

    // And some geometries
    final GfxGeometry worldGeometry = new GfxGeometry("MultiPolygonInWorldSpace");
    final GeometryFactory gf = new GeometryFactory(map.getMapModel().getSrid(), map.getMapModel().getPrecision());
    Polygon p1 = gf.createPolygon(gf.createLinearRing(new Bbox(10000000d, 1000d, 1000000d, 1000000d)), null);
    Polygon p2 = gf.createPolygon(gf.createLinearRing(new Bbox(12000000d, 1000d, 500000d, 500000d)), null);
    MultiPolygon mp = gf.createMultiPolygon(new Polygon[] {p1, p2});
    worldGeometry.setStyle(new ShapeStyle("#FF0000", 0.5f, "#FF0000", 1.0f, 2));
    worldGeometry.setGeometry(mp);

    final GfxGeometry worldGeometry2 = new GfxGeometry("MultiPointInWorldSpace");
    SymbolInfo si = new SymbolInfo();
    CircleInfo ci = new CircleInfo();
    ci.setR(8.0f);
    si.setCircle(ci);
    Point pt1 = gf.createPoint(new Coordinate(6000000, -5000000));
    Point pt2 = gf.createPoint(new Coordinate(8000000, -5000000));
    Point pt3 = gf.createPoint(new Coordinate(7000000, -7000000));
    worldGeometry2.setStyle(new ShapeStyle("#0000FF", 0.3f, "#0000FF", 1.0f, 2));
    worldGeometry2.setGeometry(gf.createMultiPoint(new Point[] {pt1, pt2, pt3}));
    worldGeometry2.setSymbolInfo(si);

    button2.addClickHandler(new ClickHandler() {

      // Draw an image and some geometries in world space:
View Full Code Here

   *            The parent drawing controller, or null if there is none.
   */
  protected AbstractFreeDrawingController(MapWidget mapWidget, AbstractFreeDrawingController parent) {
    super(mapWidget);
    this.parent = parent;
    factory = new GeometryFactory(mapWidget.getMapModel().getSrid(), mapWidget.getMapModel().getPrecision());
    geometry = null;
    // TODO Auto-generated constructor stub
  }
View Full Code Here

  private HandlerManager handlerManager;

  public FeatureEditor(MapModel mapModel) {
    this.mapModel = mapModel;
    factory = new GeometryFactory(mapModel.getSrid(), mapModel.getPrecision());
    handlerManager = new HandlerManager(this);
  }
View Full Code Here

  // -------------------------------------------------------------------------
  // Constructor
  // -------------------------------------------------------------------------

  public RemoveRingOperationTest() {
    GeometryFactory gwtFactory = new GeometryFactory(SRID, PRECISION);
    LinearRing exteriorRing = gwtFactory.createLinearRing(new Coordinate[] {new Coordinate(0.0, 0.0),
        new Coordinate(20.0, 0.0), new Coordinate(20.0, 20.0), new Coordinate(0.0, 20.0)});
    LinearRing interiorRing1 = gwtFactory.createLinearRing(new Coordinate[] {new Coordinate(12.0, 12.0),
        new Coordinate(14.0, 12.0), new Coordinate(14.0, 18.0), new Coordinate(12.0, 18.0)});
    LinearRing interiorRing2 = gwtFactory.createLinearRing(new Coordinate[] {new Coordinate(16.0, 12.0),
        new Coordinate(18.0, 12.0), new Coordinate(18.0, 18.0), new Coordinate(16.0, 18.0)});

    polygon = gwtFactory.createPolygon(exteriorRing, new LinearRing[] {interiorRing1, interiorRing2});
  }
View Full Code Here

   */
  public static org.geomajas.gwt.client.spatial.geometry.Geometry toGwt(Geometry geometry) {
    if (geometry == null) {
      return null;
    }
    GeometryFactory factory = new GeometryFactory(geometry.getSrid(), geometry.getPrecision());
    org.geomajas.gwt.client.spatial.geometry.Geometry gwt = null;

    String geometryType = geometry.getGeometryType();
    if (Geometry.POINT.equals(geometryType)) {
      gwt = factory.createPoint(geometry.getCoordinates()[0]);
    } else if (Geometry.LINEAR_RING.equals(geometryType)) {
      gwt = factory.createLinearRing(geometry.getCoordinates());
    } else if (Geometry.LINE_STRING.equals(geometryType)) {
      gwt = factory.createLineString(geometry.getCoordinates());
    } else if (Geometry.POLYGON.equals(geometryType)) {
      LinearRing exteriorRing = (LinearRing) toGwt(geometry.getGeometries()[0]);
      LinearRing[] interiorRings = new LinearRing[geometry.getGeometries().length - 1];
      for (int i = 0; i < interiorRings.length; i++) {
        interiorRings[i] = (LinearRing) toGwt(geometry.getGeometries()[i + 1]);
      }
      gwt = factory.createPolygon(exteriorRing, interiorRings);
    } else if (Geometry.MULTI_POINT.equals(geometryType)) {
      Point[] points = new Point[geometry.getGeometries().length];
      gwt = factory.createMultiPoint((Point[]) convertGeometries(geometry, points));
    } else if (Geometry.MULTI_LINE_STRING.equals(geometryType)) {
      LineString[] lineStrings = new LineString[geometry.getGeometries().length];
      gwt = factory.createMultiLineString((LineString[]) convertGeometries(geometry, lineStrings));
    } else if (Geometry.MULTI_POLYGON.equals(geometryType)) {
      Polygon[] polygons = new Polygon[geometry.getGeometries().length];
      gwt = factory.createMultiPolygon((Polygon[]) convertGeometries(geometry, polygons));
    }

    return gwt;
  }
View Full Code Here

  public GeometryFactory getGeometryFactory() {
    if (null == geometryFactory) {
      if (0 == srid) {
        throw new IllegalArgumentException("srid needs to be set on MapModel to obtain GeometryFactory");
      }
      geometryFactory = new GeometryFactory(srid, -1); // @todo precision is not yet implemented
    }
    return geometryFactory;
  }
View Full Code Here

    menu = getContextMenu();
    mapWidget.setContextMenu(menu);

    if (maxBoundsDisplayed) {
      VectorLayer layer = getFeatureTransaction().getLayer();
      GeometryFactory factory = mapWidget.getMapModel().getGeometryFactory();
      LinearRing hole = factory.createLinearRing(new Bbox(layer.getLayerInfo().getMaxExtent()));
      LinearRing shell = factory.createLinearRing(mapWidget.getMapModel().getMapView().getMaxBounds());
      Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });

      maxExtent = new GfxGeometry("maxExtent");
      maxExtent.setGeometry(polygon);
      maxExtent.setStyle(new ShapeStyle("#000000", .6f, "#990000", 1, 2));
      mapWidget.registerWorldPaintable(maxExtent);
View Full Code Here

TOP

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

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.