org.geomajas.geometry.Geometry.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(14.7k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.geomajas.geometry.Geometry.<init>()方法的一些代码示例,展示了Geometry.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.<init>()方法的具体详情如下:
包路径:org.geomajas.geometry.Geometry
类名称:Geometry
方法名:<init>

Geometry.<init>介绍

暂无

代码示例

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-javascript-api

/**
 * Create geometry.
 * 
 * @param geometryType
 *            geometry type
 * @param srid
 *            srid
 * @param precision
 *            precision
 */
@ExportConstructor
public static org.geomajas.geometry.Geometry constructor(String geometryType, int srid, int precision) {
  return new org.geomajas.geometry.Geometry(geometryType, srid, precision);
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private static void parseCollection(GeometryType type, Geometry geometry, JSONArray array) {
  Geometry[] geometries = new Geometry[array.size()];
  geometry.setGeometries(geometries);
  for (int i = 0; i < array.size(); i++) {
    switch (type) {
      case POINT:
        geometries[i] = new Geometry(Geometry.POINT, 0, 5);
        parseSimple(GeometryType.POINT, geometries[i], array.get(i).isArray());
        break;
      case LINEARRING:
        geometries[i] = new Geometry(Geometry.LINEAR_RING, 0, 5);
        parseSimple(GeometryType.LINEARRING, geometries[i], array.get(i).isArray());
        break;
      case LINESTRING:
        geometries[i] = new Geometry(Geometry.LINE_STRING, 0, 5);
        parseSimple(GeometryType.LINESTRING, geometries[i], array.get(i).isArray());
        break;
      case POLYGON:
        geometries[i] = new Geometry(Geometry.POLYGON, 0, 5);
        parseCollection(GeometryType.LINEARRING, geometries[i], array.get(i).isArray());
        break;
      default:
        break;
    }
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry point = new Geometry(Geometry.POINT, 0, -1);
  point.setCoordinates(new Coordinate[] { mapPresenter.getViewPort().getPosition() });
  // Now start editing it:
  editService.start(point);
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

/**
 * Search for features at a certain location.
 * 
 * @param location
 *            The location to check.
 * @param isShift
 *            Is the shift button pressed down?
 */
private void searchAtLocation(Coordinate location, boolean isShift) {
  Geometry point = new Geometry(Geometry.POINT, 0, -1);
  point.setCoordinates(new Coordinate[] { location });
  mapPresenter.getFeatureService().search(point, pixelsToUnits(pixelTolerance), QueryType.INTERSECTS,
      searchLayerType, -1, new SelectionCallback(isShift, false));
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("createBtn")
protected void onCreateButtonClicked(ClickEvent event) {
  // Create an empty point geometry. It has no coordinates yet. That is up to the user...
  Geometry line = new Geometry(Geometry.LINE_STRING, 0, -1);
  editService.start(line);
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_VERTEX, 0);
  editService.setEditingState(GeometryEditState.INSERTING);
  editService.setInsertIndex(index);
  // Et voila, the user may now click on the map...
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("createBtn")
protected void onCreateButtonClicked(ClickEvent event) {
  // Create an empty point geometry. It has no coordinate yet. That is up to the user...
  Geometry point = new Geometry(Geometry.POINT, 0, -1);
  editService.start(point);
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_VERTEX, 0);
  editService.setEditingState(GeometryEditState.INSERTING);
  editService.setInsertIndex(index);
  // Et voila, the use may now click on the map...
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-example-jar

@UiHandler("pathBtn")
public void onPathBtnClicked(ClickEvent event) {
  Geometry geometry = new Geometry(Geometry.POLYGON, 0, 0);
  Geometry shell = new Geometry(Geometry.LINEAR_RING, 0, 0);
  shell.setCoordinates(new Coordinate[] { new Coordinate(120, 160), new Coordinate(220, 160),
      new Coordinate(220, 260), new Coordinate(120, 260), new Coordinate(120, 160) });
  Geometry hole = new Geometry(Geometry.LINEAR_RING, 0, 0);
  hole.setCoordinates(new Coordinate[] { new Coordinate(140, 180), new Coordinate(190, 180),
      new Coordinate(190, 230), new Coordinate(140, 230), new Coordinate(140, 180) });
  geometry.setGeometries(new Geometry[] { shell, hole });
  Shape shape = (Shape) GeomajasImpl.getInstance().getGfxUtil().toShape(geometry);
  shape.setFillColor("#0066AA");
  shape.setFillOpacity(0.4);
  shape.setStrokeColor("#004499");
  container.add(shape);
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-server-extension

/**
 * Start splitting the given geometry.
 * 
 * @param geometry
 *            to be split
 */
public void start(Geometry geometry) {
  this.geometry = geometry;
  splitLine = new Geometry(Geometry.LINE_STRING, 0, 0);
  service.start(splitLine);
  service.setEditingState(GeometryEditState.INSERTING);
  service.setInsertIndex(service.getIndexService().create(GeometryIndexType.TYPE_VERTEX, 0));
  started = true;
  eventBus.fireEvent(new GeometrySplitStartEvent(geometry));
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("createBtn")
protected void onCreateButtonClicked(ClickEvent event) {
  // Create an empty point geometry. It has no coordinate yet. That is up to the user...
  Geometry point = new Geometry(Geometry.POLYGON, 0, -1);
  editService.start(point);
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon.
    GeometryIndex index = editService.addEmptyChild();
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
  // Et voila, the use may now click on the map...
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Now start editing it:
  editService.start(polygon);
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("createBtn")
protected void onCreateButtonClicked(ClickEvent event) {
  // Create an empty point geometry. It has no coordinate yet. That is up to the user...
  Geometry point = new Geometry(Geometry.POLYGON, 0, -1);
  editService.start(point);
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon.
    GeometryIndex index = editService.addEmptyChild();
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
  // Et voila, the use may now click on the map...
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Now start editing it:
  editService.start(polygon);
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private Geometry screenToWorld(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = screenToWorld(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = screenToWorld(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("createBtn")
protected void onCreateButtonClicked(ClickEvent event) {
  validationEventLayout.clear();
  // Create an empty point geometry. It has no coordinate yet. That is up to the user...
  Geometry point = new Geometry(Geometry.POLYGON, 0, -1);
  // Enable default validation
  editService.setDefaultValidation(true);
  editService.start(point);
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon.
    GeometryIndex index = editService.addEmptyChild();
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
  // Et voila, the use may now click on the map...
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private Geometry worldToScreen(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = worldToScreen(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = worldToScreen(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  validationEventLayout.clear();
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Enable default validation
  editService.setDefaultValidation(true);
  // Now start editing it:
  editService.start(polygon);
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

@Override
public void onUp(HumanInputEvent<?> event) {
  // Assure dragging or clicking started inside this widget
  if (dragging) {
    shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
    updateCircle(event);
    
    Geometry geometry = new Geometry(Geometry.POINT, 0, -1);
    Coordinate[] coordinates = new Coordinate[]{new Coordinate(circle.getUserX(), circle.getUserY())};
    geometry.setCoordinates(coordinates);
    ViewPort viewPort = mapPresenter.getViewPort();
    execute(viewPort.transform(geometry, RenderSpace.SCREEN, RenderSpace.WORLD), 
        circle.getRadius() / viewPort.getScale());
    stopDragging();
    dragging = false;
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

@Override
public void onUp(HumanInputEvent<?> event) {
  // Assure dragging or clicking started inside this widget
  if (dragging) {
    shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
    updateCircle(event);
    
    Geometry geometry = new Geometry(Geometry.POINT, 0, -1);
    Coordinate[] coordinates = new Coordinate[]{new Coordinate(circle.getUserX(), circle.getUserY())};
    geometry.setCoordinates(coordinates);
    ViewPort viewPort = mapPresenter.getViewPort();
    execute(viewPort.getTransformationService().transform(geometry, RenderSpace.SCREEN, RenderSpace.WORLD), 
        circle.getRadius() * viewPort.getResolution());
    stopDragging();
    dragging = false;
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry lineString = new Geometry(Geometry.LINE_STRING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  lineString.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1),
      new Coordinate(x2, y2), new Coordinate(x1, y2) });
  // Now start editing it:
  editService.start(lineString);
}

代码示例来源:origin: org.geomajas/geomajas-project-deskmanager-gwt

private void onEditingAddGeometry() {
  if (getGeometryStatus().equals(GeometryStatus.NONE)) {
    Geometry polygon = new Geometry(Geometry.POLYGON, 0, 0);
    editor.getEditService().start(polygon);
    try {
      GeometryIndex index = editor.getEditService().addEmptyChild();
      editor.getEditService().setInsertIndex(
          editor.getEditService().getIndexService()
              .addChildren(index, GeometryIndexType.TYPE_VERTEX, 0));
      editor.getEditService().setEditingState(GeometryEditState.INSERTING);
    } catch (GeometryOperationFailedException e) {
      editor.getEditService().stop();
      Window.alert(MESSAGES.securityGroupWarningExceptionDuringEditing(e.getMessage()));
    }
  } else {
    Window.alert(MESSAGES.securityGroupWarningOnlyOneGeometryAllowed());
  }
  updateEditingButtonEnabled();
}

相关文章