private void draw( Object parentGroup, GeometryIndex parentIndex, LineString lineString, GraphicsContext graphics) { String groupName = baseName; if (parentIndex != null) { groupName += "." + editingService.getIndexService().format(parentIndex); } Composite edgeGroup = getOrCreateGroup(parentGroup, groupName + ".edges"); Composite vertexGroup = getOrCreateGroup(parentGroup, groupName + ".vertices"); Coordinate[] coordinates = lineString.getCoordinates(); if (coordinates != null) { // Draw individual edges: for (int i = 1; i < coordinates.length; i++) { GeometryIndex edgeIndex = editingService .getIndexService() .addChildren(parentIndex, GeometryIndexType.TYPE_EDGE, i - 1); String identifier = baseName + "." + editingService.getIndexService().format(edgeIndex); LineString edge = lineString .getGeometryFactory() .createLineString(new Coordinate[] {coordinates[i - 1], coordinates[i]}); graphics.drawLine(edgeGroup, identifier, edge, findEdgeStyle(edgeIndex)); graphics.setController(edgeGroup, identifier, createEdgeController(edgeIndex)); } addInivisibleShapeToGraphicsContext(graphics, vertexGroup); for (int i = 0; i < coordinates.length; i++) { GeometryIndex vertexIndex = editingService .getIndexService() .addChildren(parentIndex, GeometryIndexType.TYPE_VERTEX, i); String identifier = baseName + "." + editingService.getIndexService().format(vertexIndex); addShapeToGraphicsContext( graphics, vertexGroup, identifier, coordinates[i], findVertexStyle(vertexIndex)); graphics.setController(vertexGroup, identifier, createVertexController(vertexIndex)); } } }
private LineString undo(LineString lineString) { RemoveCoordinateOperation op = new RemoveCoordinateOperation(lineString.getNumPoints()); return (LineString) op.execute(lineString); }
private LineString execute(LineString lineString) { InsertCoordinateOperation op = new InsertCoordinateOperation(lineString.getNumPoints(), coordinate); return (LineString) op.execute(lineString); }