|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nwoods.jgo.JGoLayer
A JGoLayer holds a collection of objects in a document. Although these document objects may be spread out all over the document in (X,Y) positions, they are all grouped together in Z order. JGoLayer implements JGoObjectCollection, so JGoLayer provides all the standard methods of determining the number of objects in a layer, adding, re-ordering, and removing objects in a layer, and traversing the collection forwards and backwards.
A JGoDocument is composed of a list of JGoLayers. The next layer after this one is above it in the Z-order, so that all of the objects in that next layer will appear in front of all of the objects in this layer. Similarly, all of the objects in this layer will appear in front of all of the objects in a layer previous to this one.
All of the objects in the layer are top-level objects; i.e. getParent() returns null. Currently you cannot have an area with some parts in one layer and other parts in a different layer.
A layer must be owned by a single document (returned by the getDocument method). Each document is created with one layer initially. Use JGoDocument methods to add, rearrange, or remove layers from a document.
You can control the visibility of all of the objects in a layer by setting the Visible property. Note that calling JGoLayer.setVisible does not call JGoObject.setVisible on each of the objects in the layer.
The modifiable property affects the default view behavior for all of the objects in a layer. If the document is modifiable, you will be able to selectively make some layers read-only.
JGoDocument
,
JGoObject
,
JGoView
,
Serialized FormConstructor Summary | |
JGoLayer()
Don't use this constructor--instead call JGoDocument.addLayerAfter or JGoDocument.addLayerBefore. |
Method Summary | |
java.util.ArrayList |
addCollection(java.util.ArrayList coll,
boolean reparentLinks,
JGoLayer linkslayer)
Re-parent some objects to be top-level objects, even if they are part of areas in this same layer. |
java.util.ArrayList |
addCollection(JGoObjectSimpleCollection coll,
boolean reparentLinks,
JGoLayer linksLayer)
Re-parent some objects to be top-level objects, even if they are part of areas in this same layer. |
JGoListPosition |
addObjectAtHead(JGoObject obj)
Adds an object behind all other objects in the layer. |
JGoListPosition |
addObjectAtTail(JGoObject obj)
Adds an object in front of all other objects in the layer. |
void |
bringObjectToFront(JGoObject obj)
Moves an object in front of other objects in the layer (moved to the end of the list of objects). |
JGoListPosition |
findObject(JGoObject obj)
Return the position of a specific object in the collection. |
JGoDocument |
getDocument()
Return the JGoDocument that this layer is a part of. |
JGoListPosition |
getFirstObjectPos()
Return the position of the first object in the collection. |
java.lang.Object |
getIdentifier()
Return an object identifying this layer. |
JGoListPosition |
getLastObjectPos()
Return the position of the last object in the collection. |
JGoLayer |
getNextLayer()
Return the layer in front of this layer, or null if this is the top-most layer. |
JGoListPosition |
getNextObjectPos(JGoListPosition pos)
Return the next object position, recursing into any JGoAreas. |
JGoListPosition |
getNextObjectPosAtTop(JGoListPosition pos)
Return the position for the next top-level object in the collection. |
int |
getNumObjects()
Returns the number of top-level objects in the layer. |
JGoObject |
getObjectAtPos(JGoListPosition pos)
Return the object for the given position. |
JGoLayer |
getPrevLayer()
Return the layer behind this layer, or null if this is the layer closest to the background. |
JGoListPosition |
getPrevObjectPos(JGoListPosition pos)
Return the position of the previous object in the collection. |
JGoListPosition |
insertObjectAfter(JGoListPosition pos,
JGoObject obj)
Adds an object to the layer after the given position. |
JGoListPosition |
insertObjectBefore(JGoListPosition pos,
JGoObject obj)
Adds an object to the layer before the given position. |
boolean |
isEmpty()
Returns true if the layer contains no objects. |
boolean |
isModifiable()
Return whether the user can modify this layer interactively. |
boolean |
isVisible()
Return whether the objects in this layer should be visible and take part in other operations such as selection. |
void |
paint(Graphics2D g,
JGoView view,
org.eclipse.swt.graphics.Rectangle clipRect)
Paint all of the objects in this layer. |
JGoObject |
pickObject(org.eclipse.swt.graphics.Point pointToCheck,
boolean selectableOnly)
Given a point in document coordinates, return the topmost object of this layer only, that contains that point. |
java.util.ArrayList |
pickObjects(org.eclipse.swt.graphics.Point p,
boolean selectableOnly,
java.util.ArrayList coll,
int max)
Return a list of all the JGoObjects in this layer that contain a given point. |
void |
removeAll()
Remove all of the objects in this layer, and thus from this document. |
void |
removeObject(JGoObject obj)
Removes an object from this layer, and thus from the document. |
JGoObject |
removeObjectAtPos(JGoListPosition pos)
Remove an object at specified position from the collection. |
void |
sendObjectToBack(JGoObject obj)
Moves an object behind other objects in the layer (moved to the head of the list of objects). |
void |
setIdentifier(java.lang.Object x)
Change the layer's identifying object. |
void |
setModifiable(boolean b)
Change whether the user is able to modify this layer. |
void |
setVisible(boolean v)
Change whether all the objects in this layer are visible. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JGoLayer()
Method Detail |
public JGoDocument getDocument()
public JGoLayer getNextLayer()
public JGoLayer getPrevLayer()
public int getNumObjects()
getNumObjects
in interface JGoObjectSimpleCollection
public boolean isEmpty()
isEmpty
in interface JGoObjectSimpleCollection
public JGoListPosition addObjectAtHead(JGoObject obj)
If the object is already a top-level part of this layer, the object is moved in the drawing order. The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
addObjectAtHead
in interface JGoObjectCollection
obj
- the object to add to the document.
public JGoListPosition addObjectAtTail(JGoObject obj)
If the object is already a top-level part of this layer, the object is moved in the drawing order. The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
addObjectAtTail
in interface JGoObjectCollection
obj
- the object to add to the document.
public JGoListPosition insertObjectBefore(JGoListPosition pos, JGoObject obj)
If the object is already a top-level part of this layer, the object is moved in the drawing order. The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
insertObjectBefore
in interface JGoObjectCollection
pos
- the position before which to add the object.obj
- the object to add.
public JGoListPosition insertObjectAfter(JGoListPosition pos, JGoObject obj)
If the object is already a top-level part of this layer, the object is moved in the drawing order. The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
insertObjectAfter
in interface JGoObjectCollection
pos
- the position after which to add the object.obj
- the object to add.
public void bringObjectToFront(JGoObject obj)
The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
The object should already be a part of this document.
bringObjectToFront
in interface JGoObjectCollection
obj
- the object to move to the front.public void sendObjectToBack(JGoObject obj)
The CHANGED document event will have a JGoObject.ChangedZOrder hint/flag and a previous value that is the JGoObject that used to follow the given object in the layer.
The object should already be a part of this document.
sendObjectToBack
in interface JGoObjectCollection
obj
- the object to move to the back.public void removeObject(JGoObject obj)
If the object is not part of this layer, this method is a no-op. If the object is a child of a JGoArea instead of being a top-level document object, it is removed from that area.
removeObject
in interface JGoObjectCollection
obj
- the object to remove.public JGoObject removeObjectAtPos(JGoListPosition pos)
JGoObjectCollection
removeObjectAtPos
in interface JGoObjectCollection
pos
- the position of the object to remove.
public void paint(Graphics2D g, JGoView view, org.eclipse.swt.graphics.Rectangle clipRect)
Iterate over all of the objects in this layer and paint all of the visible objects whose expanded paint bounding rectangle intersects with the given clipping rectangle.
g
- the Graphics2Dview
- the JGoView being painted; this is passed on to the JGoObject.paint methodclipRect
- a Rectangle in document coordinatespublic JGoObject pickObject(org.eclipse.swt.graphics.Point pointToCheck, boolean selectableOnly)
If no object is found that contains the given point and that meets the selection criteria, null is returned.
This calls JGoObject.pick to let each object decide if it is pickable. This method returns null if isVisible() is false.
pickObject
in interface JGoObjectCollection
pointToCheck
- the point under which to search, in document coordinates.selectableOnly
- if true, only consider selectable objects.
public java.util.ArrayList pickObjects(org.eclipse.swt.graphics.Point p, boolean selectableOnly, java.util.ArrayList coll, int max)
This examines each of the objects in this layer in reverse order, from front to back. For instances of JGoArea, this will call JGoArea.pickObjects. Please note that when objects are found, they might not be a top-level objects. In fact, when "selectableOnly" is false, it is very likely that if any object is found at the given point, it will be a child of some group.
p
- a Point in document coordinatesselectableOnly
- if true, only consider selectable objectscoll
- an ArrayList to which any objects found are added; if null, this method allocates a new ArrayList and returns itmax
- a limit on the number of objects that may be returned in the ArrayList
public JGoListPosition getFirstObjectPos()
JGoObjectSimpleCollection
getFirstObjectPos
in interface JGoObjectSimpleCollection
public JGoListPosition getLastObjectPos()
JGoObjectCollection
getLastObjectPos
in interface JGoObjectCollection
public JGoListPosition getNextObjectPos(JGoListPosition pos)
getNextObjectPos
in interface JGoObjectSimpleCollection
pos
- the current position
public JGoListPosition getNextObjectPosAtTop(JGoListPosition pos)
JGoObjectSimpleCollection
getNextObjectPosAtTop
in interface JGoObjectSimpleCollection
pos
- the position from which to start searching for the next
top-level object.
public JGoListPosition getPrevObjectPos(JGoListPosition pos)
JGoObjectCollection
getPrevObjectPos
in interface JGoObjectCollection
pos
- the position of the object that follows the object position
to be returned.
public JGoObject getObjectAtPos(JGoListPosition pos)
JGoObjectSimpleCollection
getObjectAtPos
in interface JGoObjectSimpleCollection
pos
- the position of an object in the collection.
public JGoListPosition findObject(JGoObject obj)
JGoObjectCollection
findObject
in interface JGoObjectCollection
obj
- the object whose position in the collection is to be returned.
to be returned.
public final java.util.ArrayList addCollection(JGoObjectSimpleCollection coll, boolean reparentLinks, JGoLayer linksLayer)
This just calls addCollection(ArrayList, boolean) with an ArrayList composed of the JGoObjects provided in the argument collection. Making a separate list of the JGoObjects is useful in case there are any changes made to the original JGoObjectSimpleCollection, such as a JGoArea.
coll
- a collection of JGoObjectsreparentLinks
- whether to call JGoSubGraphBase.reparentAllLinksToSubGraphs
to make sure each link belongs to the proper subgraph or layerlinksLayer
- the JGoLayer of the document that should hold any top-level links
public java.util.ArrayList addCollection(java.util.ArrayList coll, boolean reparentLinks, JGoLayer linkslayer)
This just calls addCollection(ArrayList) with an ArrayList composed of the JGoObjects provided in the argument collection. Making a separate list of the JGoObjects is useful in case there are any changes made to the original JGoObjectSimpleCollection, such as a JGoArea. This method tries to preserve the links connecting any ports of the nodes being added to this layer. Each object to be added to this layer must either not belong to any layer or must already be part of this layer, although perhaps part of a JGoArea such as a JGoSubGraph. Just as with the addObjectAtTail method, you may find that you will want to set the Selectable property to true for each of the objects being added to this layer. The need for this depends on the behavior you want in your application.
coll
- a collection of JGoObjectsreparentLinks
- whether to call JGoSubGraphBase.reparentAllLinksToSubGraphs
to make sure each link belongs to the proper subgraph or layerlinkslayer
- the JGoLayer of the document that should hold any top-level links
public void removeAll()
public boolean isVisible()
public void setVisible(boolean v)
public boolean isModifiable()
The default value is true.
public void setModifiable(boolean b)
This method only changes the layer's modifiable property. If the document is not modifiable, isModifiable will return false regardless of the layer's modifiable property value.
public java.lang.Object getIdentifier()
public void setIdentifier(java.lang.Object x)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |