private void updateGeometryOnMap() { if (worldPaintable == null) { worldPaintable = new GfxGeometry(GeometricSearchCreator.IDENTIFIER + "_SELECTION_GEOMETRY"); worldPaintable.setStyle(selectionStyle); } else { mapWidget.unregisterWorldPaintable(worldPaintable); } if (searchGeometry != null) { worldPaintable.setGeometry(searchGeometry); mapWidget.registerWorldPaintable(worldPaintable); } } }
/** * Default constructor. */ public GroupDetail() { groupGeometry = new GfxGeometry(GROUP_GEOM_ID); groupGeometry.setStyle(new ShapeStyle("#EEEE00", 0.5f, "#EEEE00", 0.8f, 2)); driver.initialize(this); }
public void onMapModelChanged(MapModelChangedEvent event) { try { Rectangle bg = new Rectangle("background"); bg.setBounds(new Bbox(0, 0, 4000000, 4000000)); bg.setStyle(new ShapeStyle("#FFFFFF", 1f, "#FFFFFF", 1f, 2)); map.registerWorldPaintable(bg); Rectangle rect = new Rectangle("my rect"); rect.setBounds(new Bbox(0, 0, 1000000, 1000000)); rect.setStyle(createStyle("#FF0000")); map.registerWorldPaintable(rect); Circle circle = new Circle("my circle"); circle.setPosition(new Coordinate(1500000, 1500000)); circle.setRadius(500000f); circle.setStyle(createStyle("#00FF00")); map.registerWorldPaintable(circle); GfxGeometry triangle = new GfxGeometry("triangle"); Geometry geom; geom = WktService .toGeometry("POLYGON ((2000000 2000000, 3000000 2000000,3000000 3000000,2000000 2000000))"); triangle.setGeometry(GeometryConverter.toGwt(geom)); triangle.setStyle(createStyle("#FFFF00")); map.registerWorldPaintable(triangle); Image image = new Image("osgeo"); image.setHref("http://live.osgeo.org/_images/logo-geomajas.png"); image.setBounds(new Bbox(0, 2000000, 1000000, 1000000)); image.setStyle(new PictureStyle(0.7)); map.registerWorldPaintable(image); Text text = new Text("my text", "Hello world", new Coordinate(2000000, 2000000), new FontStyle( "#00FFF0", 50, "Verdana", "bold", "italic"));
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); }
private void setGeometryOfCurrentGroup(Geometry geometryOfCurrentGroup) { territoryMap.unregisterWorldPaintable(groupGeometry); this.geometryOfCurrentGroup = geometryOfCurrentGroup; groupGeometry.setGeometry(GeometryConverter.toGwt(geometryOfCurrentGroup)); updateEditingButtonEnabled(); territoryMap.registerWorldPaintable(groupGeometry); }
@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); }
protected void updateTempLineAfterClick() { if (tempLine == null) { tempLine = new GfxGeometry("LineStringDrawController.updateLine"); tempLine.setStyle(drawStyle); } Coordinate[] srCoords = new Coordinate[geometry.getCoordinates().length]; Coordinate[] worldCoords = geometry.getCoordinates(); for (int i = 0; i < srCoords.length; i++) { srCoords[i] = getTransformer().worldToPan(worldCoords[i]); } currentLineStringCoordinates = srCoords; }
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 updateGeometriesOnMap() { // make list of geometries from search items List<Geometry> searchGeoms = new ArrayList<Geometry>(); for (ListGridRecord record : searchItems.getRecords()) { SearchListRecord slr = (SearchListRecord) record; if (slr.getCritter() instanceof GeometryCriterion) { Geometry geometry = GeometryConverter.toGwt(((GeometryCriterion) slr.getCritter()).getGeometry()); searchGeoms.add(geometry); } } // (re)draw the geometries for (int i = 0; i < searchGeoms.size(); i++) { GfxGeometry worldPaintable = null; if (i < geometries.size()) { worldPaintable = geometries.get(i); mapWidget.unregisterWorldPaintable(worldPaintable); } else { worldPaintable = new GfxGeometry(GEOMETRY_IDENTIFIER + "_" + (i + 1)); worldPaintable.setStyle(selectionStyle); geometries.add(worldPaintable); } worldPaintable.setGeometry(searchGeoms.get(i)); mapWidget.registerWorldPaintable(worldPaintable); } // unregister superfluous geometries for (int i = searchGeoms.size(); i < geometries.size(); i++) { mapWidget.unregisterWorldPaintable(geometries.get(i)); } }
@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); } } }