|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.refractions.udig.tools.edit.support.EditBlackboard
public class EditBlackboard
Maps between each pixel to a list of coordinates. Also provides convenience methods to move all coordinates at a location
Field Summary | |
---|---|
protected java.util.Map<Point,java.util.List<LazyCoord>> |
coordMapping
|
Constructor Summary | |
---|---|
EditBlackboard(int width,
int height,
java.awt.geom.AffineTransform toScreen,
MathTransform layerToMap)
Creates a PixelCoordMap. |
Method Summary | |
---|---|
Point |
addCoordinate(Coordinate coord,
PrimitiveShape shape)
|
java.util.Map<Geometry,EditGeom> |
addGeometry(Geometry geom,
java.lang.String featureID)
Adds a Geometry to the contained geometries. |
Coordinate |
addPoint(int x,
int y,
PrimitiveShape shape)
Adds a Coordinate at the x,y location on the screen to the end of the geomtry. |
java.util.List<ClosestEdge> |
addToNearestEdge(int x,
int y,
boolean treatUnknownAsPolygon)
Adds a Coordinate the nearest edge . |
ClosestEdge |
addToNearestEdge(int x,
int y,
EditGeom geom,
boolean treatUnknownAsPolygon)
Adds a Coordinate the nearest edge . |
void |
clear()
Removes all EditGeometries from blackboard and places an empty one on the black board. |
boolean |
contains(java.lang.String fid)
Returns true if the blackboard currently holds the noted feature ID. |
void |
fireBatchedEvents()
Fires all the batched events and resets the EditBlackboard so that it no longer batches events. |
java.util.List<ClosestEdge> |
getCandidates(int x,
int y,
boolean treatUnknownAsPolygon)
Returns the GeomShapes that will have the coordinate added if #addToNearestEdge(int, int) is called. |
java.util.List<Coordinate> |
getCoords(int x,
int y)
returns the list of coordinates at location:(x,y) TREAT COORDINATES AS IMMUTABLE!! |
java.util.List<EditGeom> |
getGeoms()
The list of geometries mapped. |
java.util.List<EditGeom> |
getGeoms(int x,
int y)
Returns a list of the geometries with vertices at the position (x,y). |
int |
getHeight()
|
java.util.Set<EditBlackboardListener> |
getListeners()
Returns the list of Listeners so that listeners can be added and removed. |
Selection |
getSelection()
|
int |
getWidth()
|
Coordinate |
insertCoord(int x,
int y,
int pointIndex,
PrimitiveShape shape)
Adds a Coordinate at the index indicated. |
Point |
insertCoordinate(Coordinate coord,
int index,
PrimitiveShape shape)
|
void |
insertCoords(int pointIndex,
Point p,
java.util.List<Coordinate> coords,
PrimitiveShape shape)
Inserts the list of coordinates into the shape at the index indicated. |
boolean |
isCollapseVertices()
|
java.util.List<Coordinate> |
moveCoords(int x,
int y,
int endX,
int endY)
Moves all the coordinates at location by an offset of (deltaX, deltaY). |
void |
moveSelection(int diffX,
int diffY,
Selection selection)
Moves the selection |
EditGeom |
newGeom(java.lang.String featureId,
ShapeType type)
Creates a new EditGeom in the map. |
Point |
overVertex(Point location,
int radius)
Returns the point closest to location. |
Point |
overVertex(Point location,
int radius,
boolean ignore)
Returns the point closest to location. |
void |
removeCoordinate(int pointIndex,
Coordinate coord,
PrimitiveShape shape)
Removes a coordinate from the shape. |
void |
removeCoords(int x,
int y,
PrimitiveShape shape)
Deletes the coordinates at the provided point in the provided shape. |
java.util.List<Coordinate> |
removeCoordsAtPoint(int x,
int y)
Deletes all the coordinates at a location TREAT COORDINATES AS IMMUTABLE!! |
java.util.List<EditGeom> |
removeGeometries(java.util.Collection<EditGeom> geomsToRemove)
Removes all the geometries in the list from the blackboard and all the coordinates in the geometries |
boolean |
selectionAdd(Point point)
|
boolean |
selectionAddAll(java.util.Collection<Point> points)
|
void |
selectionClear()
|
boolean |
selectionRemove(Point point)
|
boolean |
selectionRemoveAll(java.util.Collection<Point> points)
|
boolean |
selectionRetainAll(java.util.Collection<Point> points)
|
void |
setCollapseVertices(boolean collapseVertices)
|
void |
setCoords(Point point,
Coordinate newValue)
Sets all the coordinates at the point to provided coordinate. |
java.util.Map<Geometry,EditGeom> |
setGeometries(Geometry geom,
java.lang.String featureId)
Adds a Geometry to the contained geometries. |
void |
setHeight(int height)
|
void |
setMapLayerTransform(MathTransform mapToLayer)
|
void |
setToScreenTransform(java.awt.geom.AffineTransform newToScreen)
Modifies the mapping of points to coordinates so that the transform passed in as a parameter is the new toScreen transform. |
void |
setWidth(int width)
|
void |
startBatchingEvents()
Changes the behaviour of the EditBlackboard so that events are not fired but batched together until fireBatchedEvents() is called. |
Coordinate |
toCoord(Point point)
|
Point |
toPoint(Coordinate coord)
Transforms a Coordinate into the point location it would occupy on the screen. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<Point,java.util.List<LazyCoord>> coordMapping
Constructor Detail |
---|
public EditBlackboard(int width, int height, java.awt.geom.AffineTransform toScreen, MathTransform layerToMap)
getGeoms()
.get(0)
width
- width of the current ViewportPaneheight
- height of the current ViewportPanetoScreen
- transform to take the coordinates to a screen location.layerToMap
- transform to transform coordinates from a layer's CRS to the map's CRScoords
- coordinates that need to be mapped.Method Detail |
---|
public java.util.Set<EditBlackboardListener> getListeners()
public java.util.Map<Geometry,EditGeom> setGeometries(Geometry geom, java.lang.String featureId)
geom
- the geometry that will be added.featureId
- The id of the feature the geometry was part of. Maybe null.public java.util.Map<Geometry,EditGeom> addGeometry(Geometry geom, java.lang.String featureID)
geom
- the geometry that will be added.featureID
- The id of the feature the geometry was part of. Maybe null.public ClosestEdge addToNearestEdge(int x, int y, EditGeom geom, boolean treatUnknownAsPolygon) throws java.lang.IllegalArgumentException
If two edges are equidistant the first edge in the geometry will be targeted edge
x
- the x screen location to place the new coordinatey
- the x screen location to place the new coordinategeom
- the geometry to append the point to.treatUnknownAsPolygon
- declares whether to treat geometries of type UNKNOWN as a polygon
java.lang.IllegalArgumentException
public java.util.List<ClosestEdge> addToNearestEdge(int x, int y, boolean treatUnknownAsPolygon) throws java.lang.IllegalArgumentException
If two edges of the same geometry are equidistant the first edge in the geometry will be targeted edge
If two edges of different geometries are equidistant both will have a vertex added.
If the vertex would end up being added to the same location as an existing vertex then no vertext is added
x
- the x screen location to place the new coordinatey
- the x screen location to place the new coordinatetreatUnknownAsPolygon
- declares whether to treat geometries of type UNKNOWN as a polygon
java.lang.IllegalArgumentException
public Coordinate addPoint(int x, int y, PrimitiveShape shape) throws java.lang.IllegalArgumentException
x
- the x screen location to place the new coordinatey
- the x screen location to place the new coordinateholeIndex
- the hole to append to.
java.lang.IllegalArgumentException
public Point addCoordinate(Coordinate coord, PrimitiveShape shape)
public Point insertCoordinate(Coordinate coord, int index, PrimitiveShape shape)
public Coordinate insertCoord(int x, int y, int pointIndex, PrimitiveShape shape) throws java.lang.IllegalArgumentException
The index is the position in the coordinate list in the shell of the geometry.
x
- the x screen location to place the new coordinatey
- the x screen location to place the new coordinatepointIndex
- the index in terms of points in the shape to add the coordinate.geom
- the geometry to append the point to.
java.lang.IllegalArgumentException
public void insertCoords(int pointIndex, Point p, java.util.List<Coordinate> coords, PrimitiveShape shape)
pointIndex
- the location that the coordinates will be inserted.coords
- coords that will inserted.insertCoordsshape
- the shape that will have the coords inserted.public java.util.List<ClosestEdge> getCandidates(int x, int y, boolean treatUnknownAsPolygon)
x
- the x screen location to place the new coordinatey
- the x screen location to place the new coordinatetreatUnknownAsPolygon
- declares whether to treat geometries of type UNKNOWN as a polygon
public java.util.List<Coordinate> getCoords(int x, int y)
This is a dangerous method because the coordinates are mutable but if they are modified outside of this class then the model is messed up and crazy bugs will happen. The weakness is permitted for performance reasons. I'm trusting people to not be stupid.
public java.util.List<EditGeom> getGeoms()
public java.util.List<EditGeom> getGeoms(int x, int y)
x
- x coordinate of pointy
- x coordinate of point
public java.util.List<Coordinate> moveCoords(int x, int y, int endX, int endY)
x
- x coordinate of coords to movey
- y coordinate of coords to movedeltaX
- the number of pixels to move coords in the positive x direction(Screen space)deltaY
- the number of pixels to move coords in the positive y direction(Screen space)public void moveSelection(int diffX, int diffY, Selection selection)
diffX
- the distance to move the geometry in the x direction. The delta is in pixels.diffY
- the distance to move the geometry in the y direction. The delta is in pixels.selection
- the selection to move.public java.util.List<Coordinate> removeCoordsAtPoint(int x, int y)
public void removeCoords(int x, int y, PrimitiveShape shape)
x
- x coordinate in screen coordsy
- y coordinate in screen coordsshape
- shape to delete from.public void removeCoordinate(int pointIndex, Coordinate coord, PrimitiveShape shape)
pointIndex
- index of point in shapecoord
- coordinate to removeshape
- shape to remove frompublic Coordinate toCoord(Point point)
public Point toPoint(Coordinate coord)
coord
- coordinate object
public void setToScreenTransform(java.awt.geom.AffineTransform newToScreen)
transform
- new transformpublic Selection getSelection()
public void clear()
public java.util.List<EditGeom> removeGeometries(java.util.Collection<EditGeom> geomsToRemove)
geomsToRemove
- the list of geometries to remove.public EditGeom newGeom(java.lang.String featureId, ShapeType type)
featureId
- The id of the feature the geometry was part of. Maybe null.type
- the type of geometry to create if null then the type will be unknown
public int getHeight()
public void setHeight(int height)
height
- The height to set.public int getWidth()
public void setWidth(int width)
width
- The width to set.public boolean isCollapseVertices()
public void setCollapseVertices(boolean collapseVertices)
collapseVertices
- The collapseVertices to set.public Point overVertex(Point location, int radius)
location
- the locations to start searching from.radius
- the distance away from location to search.
public Point overVertex(Point location, int radius, boolean ignore)
location
- the locations to start searching from.radius
- radius the distance away from location to search.ignore
- true if the vertex at location is ignored
public void startBatchingEvents()
public void fireBatchedEvents()
public boolean selectionAdd(Point point)
public boolean selectionAddAll(java.util.Collection<Point> points)
public void selectionClear()
public boolean selectionRemoveAll(java.util.Collection<Point> points)
public boolean selectionRemove(Point point)
public boolean selectionRetainAll(java.util.Collection<Point> points)
public boolean contains(java.lang.String fid)
fid
- Feature ID
public void setMapLayerTransform(MathTransform mapToLayer)
public void setCoords(Point point, Coordinate newValue)
point
- the point at which all the coordinates will be changednewValue
- the new coordinate value of coordinates at the point
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |