| java.lang.Object net.refractions.udig.tools.edit.support.EditUtils
EditUtils | public class EditUtils (Code) | | Methods for determining spatial relationships between points.
author: Jesse since: 1.1.0 |
Inner Class :public static class MinFinder | |
Method Summary | |
public UndoableComposite | appendPathToShape(EditToolHandler handler, PathIterator iter, PrimitiveShape shape) Appends the points defined in the PathIterator to the shape. | public UndoableComposite | appendPathToShape(PathIterator iter, ShapeType shapeType, EditToolHandler handler, EditBlackboard bb, IBlockingProvider<PrimitiveShape> currentProvider2) Appends the points defined in the PathIterator to the shape. | public void | cancelHideSelection(ILayer selectedLayer) When an edit is canceled the selected layer must be re-rendered because they were hidden by
EditUtils.refreshLayer(ILayer,Feature,Envelope,boolean,boolean) This method must be called in order to efficiently do that. | public void | clearLayerStateShapeCache(Collection<ILayer> layers) The framework stores the current shape and state on a layer when the currently selected layer changes. | public Coordinate | closestCoordinateOnEdge(Coordinate endPoint1, Coordinate endPoint2, Coordinate src) Returns the closest point on the line between vertex1 and vertex2 to coordinate
src
All Coordinates must be in the same CRS
Parameters: endPoint1 - first vertex of a line. Parameters: endPoint2 - second vertex of a line. Parameters: src - the closes coordinate is found with respect to src. | public Point | closestPointOnEdge(Point endPoint1, Point endPoint2, Point src) Returns the closest point on the line between vertex1 and vertex2 to coordinate
src
All Coordinates must be in the same CRS
Parameters: endPoint1 - first vertex of a line. Parameters: endPoint2 - second vertex of a line. Parameters: src - the closes coordinate is found with respect to src. | public int | getClosest(Geometry geometry, Coordinate click, Coordinate[] result) Returns the index of the coordinate closest to the click.
Parameters: geometry - the geometry to search for the closest coordinate; The default geometry is searched. Parameters: click - the closest coordinate in coordinates will be found with respect toclick Parameters: result - the first position will be fill with the closest coordinate in geometry. | public Coordinate | getClosestSnapPoint(EditToolHandler handler, EditBlackboard editBlackboard, Point centerPoint, boolean includeVerticesInCurrent, SnapBehaviour snapBehaviour, EditState stateAfterSearch) | public EditGeom | getGeomWithMouseOver(Collection<EditGeom> geoms, Point location, boolean treatUnknownAsPolygon) | public List<EditGeom> | getIntersectingGeom(EditBlackboard editBlackboard, Point point, boolean treatUnknownAsPolygons) Finds and returns the EditGeoms that intersect the point. | public Coordinate | getTransformedClick(Coordinate click, ILayer layer) Convenience method; transforms the click from the viewportModel CRS to the layer's CRS. | public void | hideSelectedFeatures(EditToolHandler handler, ILayer selectedLayer) Triggers a re-render that hides the features on the
EditBlackboard . | public Coordinate | intersectingLines(Coordinate line1P1, Coordinate line1P2, Coordinate line2P1, Coordinate line2P2) | public Point | intersectingLines(Point line1P1, Point line1P2, Point line2P1, Point line2P2) | public boolean | intersection(Point point1, Point point2, PrimitiveShape shape, int startIndex, int endIndex) Checks whether the edge from point1 to point2 intersects any edge in the shape from startIndex to the endIndex
Parameters: point1 - the first point in the reference edge Parameters: point2 - the second point in the reference edge Parameters: shape - the shape that is searched for intersections Parameters: startIndex - the index in the shape of the point at which to start searching. | public static Coordinate | midPointOnLine(Coordinate coord, Coordinate coord2) | public boolean | overEdge(Coordinate endPoint1, Coordinate endPoint2, Envelope env) Returns true if the envelope overlaps some part of the edge
Parameters: endPoint1 - one end point of the edge Parameters: endPoint2 - the other end point of the edge Parameters: env - the reference envelope. | public boolean | overEdgeCoordinatePrecision(PrimitiveShape shape, Envelope env) Return true if the envelope overlaps at least one edge of the shape. | public boolean | overEdgePixelPrecision(PrimitiveShape shape, Envelope env) Return true if the envelope overlaps at least one edge of the shape. | public int | overVertext(Coordinate[] coords, Envelope env) | public void | refreshLayer(ILayer selectedLayer, Feature feature, Envelope refreshBounds, boolean forceRefresh, boolean hidefeature) Sets the rendering hint on the layer so that the feature is hidden if hidefeature is true. | public void | refreshLayer(ILayer selectedLayer, Set<String> fids, Envelope refreshBounds, boolean forceRefresh, boolean hidefeature) Sets the rendering hint on the layer so that the feature is hidden if hidefeature is true. | public void | reverseOrder(PrimitiveShape shape) Reverse the order of the vertices in a Shape. | public boolean | selfIntersection(PrimitiveShape shape) Returns true if the shape has a self intersection. | public Coordinate | snapToGrid(Point centerPoint, IMap map) Returns the coordinate that is on the grid intersection closest to the coordinate. |
NO_INTERSECTION | final public static int NO_INTERSECTION(Code) | | |
OVER_EDGE | final public static int OVER_EDGE(Code) | | |
TOPBOTTOMRIGHTLEFT | final static int TOPBOTTOMRIGHTLEFT(Code) | | |
appendPathToShape | public UndoableComposite appendPathToShape(EditToolHandler handler, PathIterator iter, PrimitiveShape shape)(Code) | | Appends the points defined in the PathIterator to the shape. Currently curve segments are not supported
and if there is a moveto in the middle of the iterator a hole will be created in the shape.
If the GeomType is line or point then an exception will be thrown but otherwise the client code
must ensure that the request makes sense.
Parameters: iter - The iterator to append Parameters: shape - the shape to append to. Commands that will append the points to the shape. Nothing is done until commands are run. |
appendPathToShape | public UndoableComposite appendPathToShape(PathIterator iter, ShapeType shapeType, EditToolHandler handler, EditBlackboard bb, IBlockingProvider<PrimitiveShape> currentProvider2)(Code) | | Appends the points defined in the PathIterator to the shape. Currently curve segments are not supported
and if there is a move to in the middle of the iterator a hole will be created in the shape.
If the GeomType is line or point then an exception will be thrown but otherwise the client code
must ensure that the request makes sense.
Parameters: iter - The iterator to append Parameters: bb - the editblackboard used to add coordinates Parameters: currentProvider2 - the shape provider that provides the shape to append the coordinates to Parameters: shapeType - the type of geometry that is expected from currentProvider. Commands that will append the points to the shape. Nothing is done until commands are run. |
clearLayerStateShapeCache | public void clearLayerStateShapeCache(Collection<ILayer> layers)(Code) | | The framework stores the current shape and state on a layer when the currently selected layer changes. This
method clears that cache on the layers passed in. This should be called when the tool is de-actived and when
a cancel and accept is run. This is so that the shapes can be garbage collected.
Parameters: layers - |
closestCoordinateOnEdge | public Coordinate closestCoordinateOnEdge(Coordinate endPoint1, Coordinate endPoint2, Coordinate src)(Code) | | Returns the closest point on the line between vertex1 and vertex2 to coordinate
src
All Coordinates must be in the same CRS
Parameters: endPoint1 - first vertex of a line. Parameters: endPoint2 - second vertex of a line. Parameters: src - the closes coordinate is found with respect to src. the closest point on the line between vertex1 and vertex2 to coordinatesrc |
closestPointOnEdge | public Point closestPointOnEdge(Point endPoint1, Point endPoint2, Point src)(Code) | | Returns the closest point on the line between vertex1 and vertex2 to coordinate
src
All Coordinates must be in the same CRS
Parameters: endPoint1 - first vertex of a line. Parameters: endPoint2 - second vertex of a line. Parameters: src - the closes coordinate is found with respect to src. the closest point on the line between vertex1 and vertex2 to coordinatesrc |
getClosest | public int getClosest(Geometry geometry, Coordinate click, Coordinate[] result)(Code) | | Returns the index of the coordinate closest to the click.
Parameters: geometry - the geometry to search for the closest coordinate; The default geometry is searched. Parameters: click - the closest coordinate in coordinates will be found with respect toclick Parameters: result - the first position will be fill with the closest coordinate in geometry. the index of the coordinate closest to the click. |
getClosestSnapPoint | public Coordinate getClosestSnapPoint(EditToolHandler handler, EditBlackboard editBlackboard, Point centerPoint, boolean includeVerticesInCurrent, SnapBehaviour snapBehaviour, EditState stateAfterSearch)(Code) | | Searches all the layers in the map and the EditBlackboard for the closest vertex to center point
Parameters: includeVerticesInCurrent - indicates whether the vertices of the current feature should be considered. Parameters: stateAfterSearch - the Point that is the closest vertex. |
getGeomWithMouseOver | public EditGeom getGeomWithMouseOver(Collection<EditGeom> geoms, Point location, boolean treatUnknownAsPolygon)(Code) | | Returns the Geometry from the collection that the mouse is over/intersects
Parameters: geoms - Geoms to search through Parameters: location - the location the first geom that the location is over/intersects |
getIntersectingGeom | public List<EditGeom> getIntersectingGeom(EditBlackboard editBlackboard, Point point, boolean treatUnknownAsPolygons)(Code) | | Finds and returns the EditGeoms that intersect the point. This maybe an expensive operation if there
are a large number of EditGeoms each with many points. The calculation is done in screen space, however,
so the number of coordinates in the shapes do not matter so much.
Parameters: editBlackboard - Parameters: point - Parameters: treatUnknownAsPolygons - |
getTransformedClick | public Coordinate getTransformedClick(Coordinate click, ILayer layer)(Code) | | Convenience method; transforms the click from the viewportModel CRS to the layer's CRS.
Parameters: click - |
intersectingLines | public Coordinate intersectingLines(Coordinate line1P1, Coordinate line1P2, Coordinate line2P1, Coordinate line2P2)(Code) | | Returns the intersection where the two lines meet
|
intersectingLines | public Point intersectingLines(Point line1P1, Point line1P2, Point line2P1, Point line2P2)(Code) | | Returns the intersection where the two lines meet
|
intersection | public boolean intersection(Point point1, Point point2, PrimitiveShape shape, int startIndex, int endIndex)(Code) | | Checks whether the edge from point1 to point2 intersects any edge in the shape from startIndex to the endIndex
Parameters: point1 - the first point in the reference edge Parameters: point2 - the second point in the reference edge Parameters: shape - the shape that is searched for intersections Parameters: startIndex - the index in the shape of the point at which to start searching. The point indicated will be thefirst point in the edge. Parameters: endIndex - the index to stop the search. It is the index of the end point of the last edge to compare true if there is an intersection between the edge indicated by last,current and the shape |
midPointOnLine | public static Coordinate midPointOnLine(Coordinate coord, Coordinate coord2)(Code) | | |
overEdge | public boolean overEdge(Coordinate endPoint1, Coordinate endPoint2, Envelope env)(Code) | | Returns true if the envelope overlaps some part of the edge
Parameters: endPoint1 - one end point of the edge Parameters: endPoint2 - the other end point of the edge Parameters: env - the reference envelope. true if the envelope overlaps some part of the edge |
overEdgeCoordinatePrecision | public boolean overEdgeCoordinatePrecision(PrimitiveShape shape, Envelope env)(Code) | | Return true if the envelope overlaps at least one edge of the shape. This checks all the
Coordinates in the shape so the envelope must be in the "world" space (same projection as coordinates).
Parameters: shape - to search Parameters: env - envelope used to see if it overlaps an edge true if the envelope overlaps at least one edge of the shape. |
overEdgePixelPrecision | public boolean overEdgePixelPrecision(PrimitiveShape shape, Envelope env)(Code) | | Return true if the envelope overlaps at least one edge of the shape. This only checks the
Points in the shape so the envelope must be in pixel space. This also means that it is not
completely accurate but it is sufficient for interactive purposes.
Parameters: shape - to search Parameters: env - envelope used to see if it overlaps an edge true if the envelope overlaps at least one edge of the shape. |
overVertext | public int overVertext(Coordinate[] coords, Envelope env)(Code) | | |
refreshLayer | public void refreshLayer(ILayer selectedLayer, Feature feature, Envelope refreshBounds, boolean forceRefresh, boolean hidefeature)(Code) | | Sets the rendering hint on the layer so that the feature is hidden if hidefeature is true. If hidefeature is false then
the hint is reset all features are shown
EditUtils.cancelHideSelection(ILayer) should be called if the edit is canceled.
See Also: EditUtils.cancelHideSelection(ILayer) Parameters: selectedLayer - Parameters: feature - Parameters: refreshBounds - the area to refresh (should be the the area of the feature). May be null to refresh entire area. Envelope should be inLayer coordinates. Parameters: hidefeature - |
refreshLayer | public void refreshLayer(ILayer selectedLayer, Set<String> fids, Envelope refreshBounds, boolean forceRefresh, boolean hidefeature)(Code) | | Sets the rendering hint on the layer so that the feature is hidden if hidefeature is true. If hidefeature is false then
the hint is reset all features are shown
EditUtils.cancelHideSelection(ILayer) should be called if the edit is cancelled.
See Also: EditUtils.cancelHideSelection(ILayer) Parameters: selectedLayer - the currently selected layer Parameters: fids - the Feature Ids of the features that have been selected Parameters: refreshBounds - the area to refresh (should be the the area of the features). May be null to refresh entire area. Envelope should be inLayer coordinates. Parameters: hidefeature - if true then the features are hidden otherwise they will be shown again. |
reverseOrder | public void reverseOrder(PrimitiveShape shape)(Code) | | Reverse the order of the vertices in a Shape. Used because the holes and shells in polygons have to
be in a particular order.
Parameters: shape - |
selfIntersection | public boolean selfIntersection(PrimitiveShape shape)(Code) | | Returns true if the shape has a self intersection.
Only checks the points not the coordinates there for it is quicker but less accurate.
Parameters: shape - shape to test. true if the shape has a self intersection. |
snapToGrid | public Coordinate snapToGrid(Point centerPoint, IMap map)(Code) | | Returns the coordinate that is on the grid intersection closest to the coordinate.
|
|
|