|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.Graph2DClipboard
public class Graph2DClipboard
Provides clipboard functionality for diagrams of type Graph2D
.
The clipboard can be used to create a copy of the selected parts of
a Graph2D
instance. Also it can be used to paste a formerly copied
subgraph into a graph again. Swing Actions are provided that encapsulate
Cut, Copy and Paste functionality.
The clipboard uses a GraphFactory
to create copies of graph elements.
By default an instance of Graph2DCopyFactory
is used as
factory.
setCopyFactory(y.util.GraphCopier.CopyFactory)
Field Summary | |
---|---|
static byte |
PASTE_TARGET_GROUP_POLICY_LOCATION
Policy that specifies that the paste action should use a group node that contains the coordinates of the paste location as parent node for the pasted graph elements. |
static byte |
PASTE_TARGET_GROUP_POLICY_NONE
Policy that specifies that the paste action should not try to find a suitable parent group node for the pasted graph elements. |
static byte |
PASTE_TARGET_GROUP_POLICY_SELECTION
Policy that specifies that the paste action should use a group node that is selected as parent node for the pasted graph elements. |
Constructor Summary | |
---|---|
Graph2DClipboard(ViewContainer vc)
Creates a new clipboard for the graphs managed by the given view container. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to this clipboard. |
protected Edge |
copyEdge(Graph targetGraph,
Node newSource,
Node newTarget,
Edge sourceEdge)
Copies the given source edge to the targetGraph using the getCopyFactory(y.base.Graph) and the provide
new source and target nodes. |
protected NodeList |
copyGraph(Graph sourceGraph,
Graph targetGraph,
NodeCursor sourceNodes)
Copies parts of one graph to another graph. |
protected Node |
copyNode(Graph targetGraph,
Node sourceNode)
Copies the given source node to the targetGraph using the getCopyFactory(y.base.Graph) . |
void |
copyToClipBoard(Graph graph,
NodeCursor nc)
Copies parts of the given graph to the clipboard. |
protected Graph |
getClipboardGraph()
Returns the internal graph that is used to store the contents of the clipboard. |
javax.swing.Action |
getCopyAction()
Returns a swing action that provides the Copy operation on graphs. |
GraphCopier.CopyFactory |
getCopyFactory()
|
protected GraphCopier.CopyFactory |
getCopyFactory(Graph forGraph)
|
javax.swing.Action |
getCutAction()
Returns a swing action that provides the Cut operation on graphs. |
protected Graph2D |
getGraph2D()
Returns the graph that is displayed in the current view. |
javax.swing.Action |
getPasteAction()
Returns a swing action that provides the Paste operation on graphs. |
byte |
getPasteTargetGroupPolicy()
Returns the policy used to determine the parent node for nodes that are pasted using the clipboard's paste action. |
ViewContainer |
getViewContainer()
Returns the viewContainer associated with this clipboard. |
boolean |
isEmpty()
Returns whether or not the clipboard is currently empty. |
boolean |
isSelectionEmpty()
Returns whether or not there are selected nodes in the active graph. |
boolean |
isSelectionStateObserverEnabled()
Whether or not the selection state of the current graph will be observed. |
NodeList |
pasteFromClipBoard(Graph targetGraph)
Pastes the elements of the clipboard graph to the given graph. |
NodeList |
pasteFromClipBoard(Graph targetGraph,
double x,
double y)
Pastes the elements of the clipboard graph to the given graph. |
NodeList |
pasteFromClipBoard(Graph targetGraph,
Node targetParentGroup)
Pastes the elements of the clipboard graph to the given graph. |
NodeList |
pasteFromClipBoard(Graph targetGraph,
Node targetParentGroup,
double x,
double y)
Pastes the elements of the clipboard graph to the given graph. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from this clipboard. |
void |
setCopyFactory(GraphCopier.CopyFactory copyFactory)
|
void |
setPasteTargetGroupPolicy(byte pasteTargetGroupPolicy)
Specifies the policy used to determine the parent node for nodes that are pasted using the clipboard's paste action. |
void |
setSelectionStateObserverEnabled(boolean enabled)
Whether or not to enable the observation of the selection state of the current graph. |
void |
updateSelectionState()
Forces update of the selection state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte PASTE_TARGET_GROUP_POLICY_NONE
getPasteTargetGroupPolicy()
,
setPasteTargetGroupPolicy(byte)
,
Constant Field Valuespublic static final byte PASTE_TARGET_GROUP_POLICY_LOCATION
getPasteTargetGroupPolicy()
,
setPasteTargetGroupPolicy(byte)
,
Constant Field Valuespublic static final byte PASTE_TARGET_GROUP_POLICY_SELECTION
getPasteTargetGroupPolicy()
,
setPasteTargetGroupPolicy(byte)
,
Constant Field ValuesConstructor Detail |
---|
public Graph2DClipboard(ViewContainer vc)
Method Detail |
---|
public GraphCopier.CopyFactory getCopyFactory()
public void setCopyFactory(GraphCopier.CopyFactory copyFactory)
protected Graph getClipboardGraph()
public boolean isEmpty()
public boolean isSelectionEmpty()
public void copyToClipBoard(Graph graph, NodeCursor nc)
protected GraphCopier.CopyFactory getCopyFactory(Graph forGraph)
protected Graph2D getGraph2D()
protected NodeList copyGraph(Graph sourceGraph, Graph targetGraph, NodeCursor sourceNodes)
public NodeList pasteFromClipBoard(Graph targetGraph, double x, double y)
pasteFromClipBoard(targetGraph, null, x, y);
targetGraph
- the graph pasted to.x
- the x-coordinate of the paste locationy
- the y-coordinate of the paste location
pasteFromClipBoard(y.base.Graph, y.base.Node, double, double)
public NodeList pasteFromClipBoard(Graph targetGraph, Node targetParentGroup, double x, double y)
targetGraph
- the graph pasted to.targetParentGroup
- the group node that is to be assigned as parent
node for the pasted nodes or null
if the pasted nodes should
not be assigned to any group node.x
- the x-coordinate of the paste locationy
- the y-coordinate of the paste location
java.lang.IllegalStateException
- if a non-null parent node is specified
and there is no HierarchyManager
assigned
to the target graph.
java.lang.IllegalArgumentException
- if a non-null parent node is specified
and the specified parent node does not belong to the target graph,
or the specified parent node is not a group node (according to
HierarchyManager.isGroupNode(y.base.Node)
).public NodeList pasteFromClipBoard(Graph targetGraph)
pasteFromClipBoard(targetGraph, null);
targetGraph
- the graph pasted to.
pasteFromClipBoard(y.base.Graph, y.base.Node)
public NodeList pasteFromClipBoard(Graph targetGraph, Node targetParentGroup)
targetGraph
- the graph pasted to.targetParentGroup
- the group node that is to be assigned as parent
node for the pasted nodes or null
if the pasted nodes should
not be assigned to any group node.
java.lang.IllegalStateException
- if a non-null parent node is specified
and there is no HierarchyManager
assigned
to the target graph.
java.lang.IllegalArgumentException
- if a non-null parent node is specified
and the specified parent node does not belong to the target graph,
or the specified parent node is not a group node (according to
HierarchyManager.isGroupNode(y.base.Node)
).public byte getPasteTargetGroupPolicy()
PASTE_TARGET_GROUP_POLICY_NONE
,PASTE_TARGET_GROUP_POLICY_LOCATION
,PASTE_TARGET_GROUP_POLICY_SELECTION
Defaults to PASTE_TARGET_GROUP_POLICY_NONE
.
Note:
The paste action's PASTE_TARGET_GROUP_POLICY
property value
will supersede the clipboard's pasteTargetGroupPolicy
value, if the action's property value is set and of type
Byte
.
setPasteTargetGroupPolicy(byte)
,
Action.getValue(java.lang.String)
public void setPasteTargetGroupPolicy(byte pasteTargetGroupPolicy)
Defaults to PASTE_TARGET_GROUP_POLICY_NONE
.
Alternatively, property PASTE_TARGET_GROUP_POLICY
can
be used to specify the policy to determine the parent node on the paste
action using the action's putValue
method.
pasteTargetGroupPolicy
- the policy used to determine the parent
node for nodes that are pasted using the clipboard's paste action.
One of
getPasteTargetGroupPolicy()
,
Action.putValue(java.lang.String,java.lang.Object)
public javax.swing.Action getCutAction()
public javax.swing.Action getCopyAction()
public javax.swing.Action getPasteAction()
PASTE_LOCATION
can be used to provide an
instance of YPoint
that specifies the preferred paste
location.
The property value PASTE_TARGET_GROUP_POLICY
can be used
to provide a Byte
instance that specifies the preferred
policy used to determine the parent node for pasted graph elements.
setPasteTargetGroupPolicy(byte)
,
PASTE_TARGET_GROUP_POLICY_NONE
,
PASTE_TARGET_GROUP_POLICY_LOCATION
,
PASTE_TARGET_GROUP_POLICY_SELECTION
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
public ViewContainer getViewContainer()
protected Node copyNode(Graph targetGraph, Node sourceNode)
getCopyFactory(y.base.Graph)
.
protected Edge copyEdge(Graph targetGraph, Node newSource, Node newTarget, Edge sourceEdge)
getCopyFactory(y.base.Graph)
and the provide
new source and target nodes.
public void updateSelectionState()
public boolean isSelectionStateObserverEnabled()
public void setSelectionStateObserverEnabled(boolean enabled)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |