private void removeTempPoint() { if (tempPoint != null) { mapWidget.render(tempPoint, RenderGroup.VECTOR, RenderStatus.DELETE); tempPoint = null; } } }
protected void removeTempLine() { if (tempLine != null) { mapWidget.render(tempLine, RenderGroup.VECTOR, RenderStatus.DELETE); tempLine = null; } } }
@Override protected void removeTempLine() { if (tempPolygon != null) { mapWidget.render(tempPolygon, RenderGroup.VECTOR, RenderStatus.DELETE); tempPolygon = null; } super.removeTempLine(); } }
protected void updateTempLineAfterMove(MouseEvent<?> event) { if (tempLine == null) { updateTempLineAfterClick(); } if (currentLineStringCoordinates != null && currentLineStringCoordinates.length > 0) { Coordinate[] newCoords = new Coordinate[currentLineStringCoordinates.length + 1]; System.arraycopy(currentLineStringCoordinates, 0, newCoords, 0, currentLineStringCoordinates.length); newCoords[currentLineStringCoordinates.length] = getPanPosition(event); LineString lineString = geometry.getGeometryFactory().createLineString(newCoords); tempLine.setGeometry(lineString); mapWidget.render(tempLine, RenderGroup.VECTOR, RenderStatus.UPDATE); } }
private void createTempPoint() { tempPoint = new GfxGeometry("PointDrawController.updatePoint"); tempPoint.setStyle(drawStyle); tempPoint.setSymbolInfo(symbolStyle); Coordinate coords = getTransformer().worldToPan(geometry.getCoordinate()); Point point = (Point) geometry.getGeometryFactory().createPoint(coords); tempPoint.setGeometry(point); mapWidget.render(tempPoint, RenderGroup.VECTOR, RenderStatus.ALL); }
@Override protected void updateTempLineAfterMove(MouseEvent<?> event) { if (tempPolygon == null) { updateTempLineAfterClick(); } Polygon polygon = (Polygon) geometry; if (polygon != null && polygon.getCoordinates() != null && polygon.getCoordinates().length > 0) { LinearRing ring = geometry.getGeometryFactory().createLinearRing(polygon.getCoordinates()); if (ring != null && geometry.getCoordinates().length > 0) { Coordinate[] coordinates = ring.getCoordinates(); Coordinate firstCoordinate = coordinates[0]; Coordinate lastCoordinate = coordinates[coordinates.length - 2]; LineString lineStringPan = geometry.getGeometryFactory().createLineString(new Coordinate[] { getTransformer().worldToPan(lastCoordinate), getPanPosition(event), getTransformer().worldToPan(firstCoordinate) }); tempLine.setGeometry(lineStringPan); mapWidget.render(tempLine, RenderGroup.VECTOR, RenderStatus.ALL); } } }
@Override protected void updateTempLineAfterClick() { if (tempPolygon == null) { tempPolygon = new GfxGeometry("LineStringEditController.updatePolygon"); tempLine = new GfxGeometry("LineStringEditController.updateLine"); } if (geometry.isValid()) { tempPolygon.setStyle(drawStyleGood); tempLine.setStyle(drawStyleGood); } else { tempPolygon.setStyle(drawStyleBad); tempLine.setStyle(drawStyleBad); } Coordinate[] worldCoords = geometry.getCoordinates() != null ? geometry.getCoordinates() : new Coordinate[0]; int length = worldCoords != null ? worldCoords.length : 0; // remove the connection line between last and first point if (length > 2 && worldCoords[0].equals(worldCoords[length - 1])) { length--; } Coordinate[] srCoords = new Coordinate[length]; for (int i = 0; i < srCoords.length; i++) { srCoords[i] = getTransformer().worldToPan(worldCoords[i]); } GeometryFactory geometryFactory = geometry.getGeometryFactory(); LinearRing linearRing = geometryFactory.createLinearRing(srCoords); Polygon polygon = geometryFactory.createPolygon(linearRing, null); tempPolygon.setGeometry(polygon); mapWidget.render(tempPolygon, RenderGroup.VECTOR, RenderStatus.UPDATE); }