| Package | com.yworks.graph.model |
| Class | public class GraphClipboard |
IGraph instances.
This implementation copies a given graph to an internally held clipboard graph. The clipboard graph can then be pasted to a target graph instance.
See also
| Property | Defined by | ||
|---|---|---|---|
| clipboardGraph : IGraph
The graph which is used as clipboard.
| GraphClipboard | ||
| copier : GraphCopier
The
GraphCopier instance that will be used to
copy the graph to the clipboard and from the clipboard to the graph. | GraphClipboard | ||
| empty : Boolean [read-only]
Determines whether the clipboard graph is empty.
| GraphClipboard | ||
| pasteDelta : IPoint
A vector that will be used to move nodes and bends by
after they have been pasted to the target graph.
| GraphClipboard | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new initially empty clipboard.
| GraphClipboard | ||
|
clear():void
Clears the clipboard's contents.
| GraphClipboard | ||
|
Copies the elements indicated by the filter to the clipboard graph.
| GraphClipboard | ||
|
createClipBoardHelperCopyFilter():Function
Convenience method that creates a
Function that is based upon
the outcome of the IClipboardHelper.shouldCopy method that can be found
in the ILookup.lookup of the provided IModelItem. | GraphClipboard | ||
|
createClipBoardHelperCutFilter():Function
Convenience method that creates a
Function that is based upon
the outcome of the IClipboardHelper.shouldCut method that can be found
in the ILookup.Lookup of the provided IModelItem. | GraphClipboard | ||
|
createClipBoardHelperPasteFilter():Function
Convenience method that creates a filter
Function that is based upon the outcome
of the IClipboardHelper.ShouldPaste method that can be found in the
ILookup.lookup of the provided IModelItem. | GraphClipboard | ||
|
createSelectionFilter(selection:IGraphSelection):Function
Creates a
Function for use in the cut and
copy methods. | GraphClipboard | ||
|
Cuts the items indicated by
filter to the clipboard and removes
them from the graph. | GraphClipboard | ||
|
getMemento(clipboardModelItem:IModelItem):Object
Retrieves the memento associated with an item in the clipboard graph that has been stored
with the item during
onElementCopied and onElementCut. | GraphClipboard | ||
|
paste(targetGraph:IGraph, graphSelection:IGraphSelection = null, filter:Function = null, elementPasted:Function = null):void
Pastes the contents from the
clipboardGraph to the targetGraph
after applying a filter. | GraphClipboard | ||
| Method | Defined by | ||
|---|---|---|---|
|
adjustPosition(copiedItem:IModelItem):void
Moves the item after a paste operation according to
pasteDelta. | GraphClipboard | ||
|
copyImpl(sourceGraph:IGraph, filter:Function, targetGraph:IGraph, elementCopiedDelegate:Function):void
Calls
GraphCopier.copy() on the current copier instance. | GraphClipboard | ||
|
Creates the graph used for the clipboard.
| GraphClipboard | ||
|
Factory method that creates the
copier. | GraphClipboard | ||
|
Retrieves the
IClipboardHelper instance associated with the given item. | GraphClipboard | ||
|
Delegate that will be invoked for each item that has been copied into the clipboard graph
in response to a
copy | GraphClipboard | ||
|
Delegate that will be invoked for each item that has been copied into the clipboard graph
in response to a
cut operation. | GraphClipboard | ||
|
Delegate that will be invoked for each item that has been pasted into the target graph
in response to a
paste(IGraph) operation. | GraphClipboard | ||
|
removeElements(sourceGraph:IGraph, filter:Function):void
Removes elements from the graph based on the
predicate function. | GraphClipboard | ||
| clipboardGraph | property |
clipboardGraph:IGraph [read-write]The graph which is used as clipboard.
Implementation public function get clipboardGraph():IGraph
public function set clipboardGraph(value:IGraph):void
— if the clipboardGraph is set to null
|
| copier | property |
copier:GraphCopier [read-write]
The GraphCopier instance that will be used to
copy the graph to the clipboard and from the clipboard to the graph.
This instance is lazily created using createCopier.
public function get copier():GraphCopier
public function set copier(value:GraphCopier):void
| empty | property |
empty:Boolean [read-only]Determines whether the clipboard graph is empty.
Implementation public function get empty():Boolean
| pasteDelta | property |
pasteDelta:IPoint [read-write]A vector that will be used to move nodes and bends by after they have been pasted to the target graph.
onElementPasted will use this in adjustPosition
to adjust the position of the nodes and bends.
public function get pasteDelta():IPoint
public function set pasteDelta(value:IPoint):void
| GraphClipboard | () | constructor |
public function GraphClipboard()Creates a new initially empty clipboard.
| adjustPosition | () | method |
protected function adjustPosition(copiedItem:IModelItem):void
Moves the item after a paste operation according to pasteDelta.
For each INode and IBend this method will ILookup.lookup
the IMovable implementation and if successfull will move that element
by the amount specified by pasteDelta.
copiedItem:IModelItem — The item to adjust the position of after it has been pasted into the target graph.
|
| clear | () | method |
public function clear():voidClears the clipboard's contents.
| copy | () | method |
public function copy(sourceGraph:IGraph, filter:Function):voidCopies the elements indicated by the filter to the clipboard graph.
For each element copied to the clipboard graph the onElementCopied delegate
will be called. The actual work of this method is delegated to the copier's
GraphCopier.copy method.
Parameters
sourceGraph:IGraph — The graph to copy the contents from.
|
|
filter:Function — The filter to apply to the source graph's elements.
|
| copyImpl | () | method |
protected function copyImpl(sourceGraph:IGraph, filter:Function, targetGraph:IGraph, elementCopiedDelegate:Function):void
Calls GraphCopier.copy() on the current copier instance.
sourceGraph:IGraph — The graph to copy the elements from.
|
|
filter:Function — The filter that decides which elements to copy: a function which takes a
IModelItem as parameter and returns true if the item should be copied.
|
|
targetGraph:IGraph — The graph to copy the elements to.
|
|
elementCopiedDelegate:Function — A delegate to invoke for each element being copied.
|
| createClipboardGraph | () | method |
protected function createClipboardGraph():IGraphCreates the graph used for the clipboard.
ReturnsIGraph —
A new preconfigured DefaultGraph instance.
|
| createClipBoardHelperCopyFilter | () | method |
public function createClipBoardHelperCopyFilter():Function
Convenience method that creates a Function that is based upon
the outcome of the IClipboardHelper.shouldCopy method that can be found
in the ILookup.lookup of the provided IModelItem.
Function — A function that uses IClipboardHelper.shouldCopy
|
See also
| createClipBoardHelperCutFilter | () | method |
public function createClipBoardHelperCutFilter():Function
Convenience method that creates a Function that is based upon
the outcome of the IClipboardHelper.shouldCut method that can be found
in the ILookup.Lookup of the provided IModelItem.
Function — A function that uses IClipboardHelper.shouldCut
|
See also
| createClipBoardHelperPasteFilter | () | method |
public function createClipBoardHelperPasteFilter():Function
Convenience method that creates a filter Function that is based upon the outcome
of the IClipboardHelper.ShouldPaste method that can be found in the
ILookup.lookup of the provided IModelItem.
Function — A predicate that uses IClipboardHelper.shouldPaste.
|
| createCopier | () | method |
protected function createCopier():GraphCopier
Factory method that creates the copier.
GraphCopier —
A new GraphCopier instance.
|
| createSelectionFilter | () | method |
public function createSelectionFilter(selection:IGraphSelection):Function
Creates a Function for use in the cut and
copy methods.
This filter bases its predicate upon the fact whether the element is induced by a set of selected nodes, i.e. each edge that has both of its adjacent port owners selected will be included as well as each label and port whose owner is included.
Parametersselection:IGraphSelection — The selection model to base the filter on.
|
Function — A predicate that filters subgraph induced by the selection of nodes.
|
| cut | () | method |
public function cut(sourceGraph:IGraph, filter:Function):void
Cuts the items indicated by filter to the clipboard and removes
them from the graph.
This method delegates the core work to copy()
sourceGraph:IGraph — The graph to cut the items from.
|
|
filter:Function — The filter to use.
|
See also
| getClipboardHelper | () | method |
protected function getClipboardHelper(item:IModelItem):IClipboardHelper
Retrieves the IClipboardHelper instance associated with the given item.
This implementation uses the item's ILookup.lookup method
to retrieve the helper instance.
item:IModelItem — The item to find the clipboard helper for.
|
IClipboardHelper —
An instance or |
| getMemento | () | method |
public function getMemento(clipboardModelItem:IModelItem):Object
Retrieves the memento associated with an item in the clipboard graph that has been stored
with the item during onElementCopied and onElementCut.
clipboardModelItem:IModelItem — The item in the clipboard graph.
|
Object — The object returned by the IClipboardHelper methods or null.
|
| onElementCopied | () | method |
protected function onElementCopied(original:IModelItem, copy:IModelItem):void
Delegate that will be invoked for each item that has been copied into the clipboard graph
in response to a copy operation.
This implementation will ILookup.lookup a IClipboardHelper
for each item in the original graph and remember the memento retrieved by the
IClipboardHelper.copy method for later use during the
onElementPasted operation.
original:IModelItem — The original element from the source graph instance.
|
|
copy:IModelItem — The copy from the clipboard graph.
|
| onElementCut | () | method |
protected function onElementCut(original:IModelItem, copy:IModelItem):void
Delegate that will be invoked for each item that has been copied into the clipboard graph
in response to a cut operation.
This implementation will ILookup.lookup a IClipboardHelper
for each item in the original graph and remember the memento retrieved by
the IClipboardHelper.cut method for later use during the
onElementPasted operation.
Parameters
original:IModelItem — The original element from the source graph instance.
|
|
copy:IModelItem — The copy from the clipboard graph.
|
| onElementPasted | () | method |
protected function onElementPasted(original:IModelItem, copy:IModelItem):void
Delegate that will be invoked for each item that has been pasted into the target graph
in response to a paste(IGraph) operation.
This method will use a previously stored IClipboardHelper to let
IClipboardHelper.pastefinish its work.
original:IModelItem — The original element from the clipboard graph instance.
|
|
copy:IModelItem — The copy from the target graph.
|
| paste | () | method |
public function paste(targetGraph:IGraph, graphSelection:IGraphSelection = null, filter:Function = null, elementPasted:Function = null):void
Pastes the contents from the clipboardGraph to the targetGraph
after applying a filter. If the IGraphSelection instance of the target graph
is passed, all pasted items will be selected.
For each element pasted into the graph the elementPasted delegate will be invoked
and the onElementPasted method will be called.
The actual work of this method is delegated to the copier's
GraphCopier.copy() method.
As a final step, this method will invoke the adjustPosition method
for all items that have been pasted.
targetGraph:IGraph — The graph to paste the contents in.
|
|
graphSelection:IGraphSelection (default = null) — The selection model to set the selection on. If none is provided, the pasted elements will not be selected.
|
|
filter:Function (default = null) — The filter to apply to the clipboard graph: a function which takes a
IModelItem as parameter and returns true if that item
should be pasted. If no filter is provided, all items of the clipboard graph
will be pasted, except the ones which have a IClipboardHelper instance
whose shouldPaste method returns false as memento.
|
|
elementPasted:Function (default = null) — The callback to use for each element that has been pasted.
|
| removeElements | () | method |
protected function removeElements(sourceGraph:IGraph, filter:Function):void
Removes elements from the graph based on the predicate function.
sourceGraph:IGraph — The graph to remove elements from.
|
|
filter:Function — The filter that decides which elements to remove: a function which takes a
IModelItem as parameter and returns true if the item should be removed.
|