Class NodeGraph
- All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>
A pannable, zoomable view of a GraphModel where nodes are dragged,
connected and grouped: a system diagram, a mind map, or a node editor.
DefaultGraphModel model = new DefaultGraphModel();
model.addNode(new GraphNode("api", "API gateway"));
model.addNode(new GraphNode("orders", "Orders"));
model.addEdge("api", "orders");
NodeGraph graph = new NodeGraph(model);
graph.arrange(new LayeredArrangement(), false);
Form form = new Form("Services", new BorderLayout());
form.add(BorderLayout.CENTER, graph);
form.show();
What a user can do:
- drag the background to pan, with a fling; pinch, or Ctrl or Cmd with the wheel, to zoom about the pointer;
- tap a node or an edge to select it, and Shift-tap to add to the selection; drag a node to move it, with everything selected;
- drag from an output port to an input port to connect them. A node without ports shows a handle on its trailing edge while it is selected, and a long press on it starts a connection too;
- drag the end of an edge off an input port to reconnect or drop it;
- long press the background, or Shift-drag it, to select with a box;
- tap a group's title to collapse or expand it, double tap a node to open
it (and edit its label when
setLabelEditingis on); - drag in the minimap to move the view.
Every edit is offered to the GraphListeners, then to the model; either
may refuse it. With setEditingEnabled(false) the graph can only be panned,
zoomed and selected.
The nodes and edges are painted, so the component costs what is on
screen: below getDetailZoom they are drawn without text, which keeps a
graph of thousands of nodes moving at frame rate. A node can still carry a
real component from a NodeComponentFactory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEdges with ports curve between them; other edges are straight, or follow the bends an arrangement gave them.static final intSmooth curves through the bends.static final intHorizontal and vertical segments only.static final intStraight segments through the bends.Fields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR -
Constructor Summary
ConstructorsConstructorDescriptionAn empty graph backed by a newDefaultGraphModel.NodeGraph(GraphModel model) A graph showingmodel. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener.voidarrange(GraphArrangement arrangement, boolean animate) Places the nodes with an arrangement, gliding them there whenanimateis true.protected DimensionCalculates the preferred size based on component content.voidScrolls so the node is in the middle of the view.booleanPuts the selected nodes, and the edges among them, on the clipboard, as the JSONGraphJsonwrites.createNode(GraphNodeTemplate template, double worldX, double worldY) Adds a node made from a template, centred on a world point and selected.booleanCopies the selection and removes it.voidRemoves the selected nodes and edge, each offered to the listeners and then to the model.booleanAdds a copy of every selected node, and of the edges among them, a little down and to the trailing side, and selects the copies.edgeAt(int sx, int sy) The edge within a finger's reach of a point of the view, or null.voidZooms and scrolls so the whole graph fits the view, never past zoom 1.floatThe zoom below which nodes show no component from the factory.floatThe zoom below which nodes and edges are drawn without text.Paints edges.intOne ofEDGE_AUTO, the default,EDGE_STRAIGHT,EDGE_ORTHOGONALorEDGE_CURVED.double[]getGroupRect(GraphGroup group) A group's frame in world units, {x, y, width, height}, or null for a group with no members.getModel()The model shown.getNodeComponent(GraphNode node) The component made for a node, or null when none was made yet.The factory, or null.Paints nodes.The template the next tap on the background makes a node from, or null.getPortEditor(GraphNode node, GraphPort port) The editor made for a port, or null when none was made yet.The factory of port editors, or null.The selected edge, or null.The selected nodes, in the order they were selected.doublegetSnap()The step dragged nodes snap to in world units, or 0 for none.The history edits are recorded in, or null.doublegetViewX()The world x at the left edge of the view.doublegetViewY()The world y at the top edge of the view.The text of the tooltip showing, or null: what a test or an accessibility layer reads.floatgetZoom()The current zoom.voidhoverAt(int x, int y) Simulates a hovering pointer atx, yof the view, as a desktop mouse would.protected voidAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component statebooleanTrue, the default, when the user may move, connect and remove.booleanTrue, the default, when a dot grid is painted behind the graph.booleanTrue when a double tap edits the node's label in place.booleanTrue when a minimap of the whole graph is painted in a corner.booleanTrue when a node is drawn: it is not inside a collapsed group.booleanTrue when a selected node shows handles on its corners to resize it by.booleanisSelected(GraphNode node) True when the node is selected.laneAt(double worldX, double worldY) The lane under a world point, or null.voidPerforms the layout of the container if a layout is necessarynodeAt(int sx, int sy) The topmost visible node at a point of the view, or null.booleanpaste()Adds the nodes on the clipboard, each time a step further from where they were copied, and selects them.doubleThe world x of a port's anchor: inputs on the leading edge, outputs on the trailing one.doubleThe world y of a port's anchor: the ports of one side share the body under the title evenly.booleanredo()Makes the last undone edit again.voidRemoves a listener.doublescreenToWorldX(int sx) A pixel from the left of the view as a world x.doublescreenToWorldY(int sy) A pixel from the top of the view as a world y.voidSelects one node alone, or clears the selection with null.voidselectEdge(GraphEdge edge) Selects one edge alone.voidsetComponentZoom(float componentZoom) Sets the zoom below which components are hidden.voidsetDetailZoom(float detailZoom) Sets the zoom below which text is not drawn.voidReplaces the edge painter; null restores the default.voidsetEdgeStyle(int edgeStyle) Sets how edges are drawn.voidsetEditingEnabled(boolean editable) Allows or forbids edits; panning, zooming and selecting stay.voidsetGridVisible(boolean gridVisible) Shows or hides the dot grid.voidsetLabelEditing(boolean labelEditing) Lets a double tap edit a node's label in place.voidsetLiveArrangement(ForceArrangement arrangement) Runs a force arrangement live: the graph settles a step a frame, and follows a node while it is dragged.voidsetMinimapVisible(boolean minimapVisible) Shows or hides the minimap.voidsetModel(GraphModel model) Shows another model, and clears the selection.voidMakes components for node bodies; null for none.voidReplaces the node painter; null restores the default.voidsetPendingTemplate(GraphNodeTemplate template) Arms a template: the next tap on the background adds a node of it there.voidsetPortEditorFactory(PortEditorFactory factory) Makes the editors of unconnected input ports; null for none.booleansetPortValue(GraphPort port, Object value) Sets the value an input port uses while nothing is connected to it, through the model, as an edit that can be undone.voidsetResizable(boolean resizable) Lets the user resize a node by dragging a corner of it while it is the only node selected.voidsetSnap(double snap) Snaps dragged nodes to a step; 0 turns it off.voidsetUndoHistory(UndoHistory undoHistory) Records every edit the user makes in a history, so it can be undone.voidWrites the user data of copied nodes to the clipboard and reads it back on paste; without one, pasted nodes have no user data.voidsetView(double worldX, double worldY) Scrolls so the world point is at the top left corner of the view.voidsetZoom(float z) Zooms about the centre of the view.voidsetZoomRange(float min, float max) Limits the zoom.voidstartLabelEdit(GraphNode node) Edits a node's label in place, in a text field over the node; the new label goes toGraphModel.renameNodewhen editing ends.voidtoggleSelection(GraphNode node) Adds a node to the selection, or takes it out when it is in.toImage(int width, int height) Paints the whole graph into a new image of the given size, fitted with a margin, at no more than zoom 1, without the minimap or the selection.booleanundo()Takes back the last edit in the history.intworldToScreenLength(double len) A world length in pixels.intworldToScreenX(double wx) A world x as a pixel from the left of the view.intworldToScreenY(double wy) A world y as a pixel from the top of the view.booleanzoomAt(float factor, int screenX, int screenY) Multiplies the zoom byfactorkeeping the world point under the screen point where it is.Methods inherited from class Container
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndicesMethods inherited from class Component
accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addNativeDragOverListener, addNativeDropListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, canAcceptNativeDrop, consumesRawTextInput, contains, containsOrOwns, createNativeDragOperation, createStyleAnimation, deinitialize, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAcceptedDropActions, getAcceptedDropMimeTypes, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getContextMenuCommands, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getHoverStyle, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeDragOperation, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSemantics, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getTopLevelContainer, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHovered, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isNativeDragSource, isNativeDropTarget, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, keyRepeated, laidOut, longKeyPress, longPointerPress, mouseWheel, nativeDragEnter, nativeDragExit, nativeDragOver, nativeDrop, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, registerForAnimation, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removeNativeDragOverListener, removeNativeDropListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAcceptedDropActions, setAcceptedDropMimeTypes, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setContextMenuCommands, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setHovered, setHoverStyle, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNativeDragOperation, setNativeDragSource, setNativeDropTarget, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setPullToRefresh, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stopScrollMomentum, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EDGE_AUTO
public static final int EDGE_AUTOEdges with ports curve between them; other edges are straight, or follow the bends an arrangement gave them.- See Also:
-
EDGE_STRAIGHT
public static final int EDGE_STRAIGHTStraight segments through the bends.- See Also:
-
EDGE_ORTHOGONAL
public static final int EDGE_ORTHOGONALHorizontal and vertical segments only.- See Also:
-
EDGE_CURVED
public static final int EDGE_CURVEDSmooth curves through the bends.- See Also:
-
-
Constructor Details
-
NodeGraph
public NodeGraph()An empty graph backed by a newDefaultGraphModel. -
NodeGraph
A graph showingmodel.
-
-
Method Details
-
getModel
The model shown. -
setModel
Shows another model, and clears the selection. An edit under way ends, and the undo history is cleared: its steps belong to the model that was shown. -
getNodeRenderer
Paints nodes. Never null. -
setNodeRenderer
Replaces the node painter; null restores the default. -
getEdgeRenderer
Paints edges. Never null. -
setEdgeRenderer
Replaces the edge painter; null restores the default. -
addGraphListener
Adds a listener. -
removeGraphListener
Removes a listener. -
isEditingEnabled
public boolean isEditingEnabled()True, the default, when the user may move, connect and remove. -
setEditingEnabled
public void setEditingEnabled(boolean editable) Allows or forbids edits; panning, zooming and selecting stay. -
getEdgeStyle
public int getEdgeStyle()One ofEDGE_AUTO, the default,EDGE_STRAIGHT,EDGE_ORTHOGONALorEDGE_CURVED. -
setEdgeStyle
public void setEdgeStyle(int edgeStyle) Sets how edges are drawn. -
isGridVisible
public boolean isGridVisible()True, the default, when a dot grid is painted behind the graph. -
setGridVisible
public void setGridVisible(boolean gridVisible) Shows or hides the dot grid. -
getSnap
public double getSnap()The step dragged nodes snap to in world units, or 0 for none. -
setSnap
public void setSnap(double snap) Snaps dragged nodes to a step; 0 turns it off. -
isMinimapVisible
public boolean isMinimapVisible()True when a minimap of the whole graph is painted in a corner. -
setMinimapVisible
public void setMinimapVisible(boolean minimapVisible) Shows or hides the minimap. -
isLabelEditing
public boolean isLabelEditing()True when a double tap edits the node's label in place. -
setLabelEditing
public void setLabelEditing(boolean labelEditing) Lets a double tap edit a node's label in place. -
getDetailZoom
public float getDetailZoom()The zoom below which nodes and edges are drawn without text. -
setDetailZoom
public void setDetailZoom(float detailZoom) Sets the zoom below which text is not drawn. -
getComponentZoom
public float getComponentZoom()The zoom below which nodes show no component from the factory. -
setComponentZoom
public void setComponentZoom(float componentZoom) Sets the zoom below which components are hidden. -
setNodeComponentFactory
Makes components for node bodies; null for none. -
getNodeComponentFactory
The factory, or null. -
getNodeComponent
-
setZoomRange
public void setZoomRange(float min, float max) Limits the zoom. -
getZoom
public float getZoom()The current zoom. At zoom 1 a node is drawn at its world size scaled to the theme font, so labels fit on dense screens as they do on a desktop;fitToViewnever goes past it. -
setZoom
public void setZoom(float z) Zooms about the centre of the view. -
getViewX
public double getViewX()The world x at the left edge of the view. -
getViewY
public double getViewY()The world y at the top edge of the view. -
setView
public void setView(double worldX, double worldY) Scrolls so the world point is at the top left corner of the view. -
centerOn
Scrolls so the node is in the middle of the view. -
fitToView
public void fitToView()Zooms and scrolls so the whole graph fits the view, never past zoom 1. -
zoomAt
public boolean zoomAt(float factor, int screenX, int screenY) Multiplies the zoom by
factorkeeping the world point under the screen point where it is.Returns
false when the zoom was already at its limit
-
worldToScreenX
public int worldToScreenX(double wx) A world x as a pixel from the left of the view. -
worldToScreenY
public int worldToScreenY(double wy) A world y as a pixel from the top of the view. -
worldToScreenLength
public int worldToScreenLength(double len) A world length in pixels. -
screenToWorldX
public double screenToWorldX(int sx) A pixel from the left of the view as a world x. -
screenToWorldY
public double screenToWorldY(int sy) A pixel from the top of the view as a world y. -
getSelectedNodes
-
getSelectedEdge
The selected edge, or null. -
isSelected
True when the node is selected. -
select
Selects one node alone, or clears the selection with null. -
selectEdge
Selects one edge alone. -
toggleSelection
Adds a node to the selection, or takes it out when it is in. -
deleteSelection
public void deleteSelection()Removes the selected nodes and edge, each offered to the listeners and then to the model. -
arrange
Places the nodes with an arrangement, gliding them there whenanimateis true. Arrangements are not user edits: a model that refuses moves is placed anyway, the nodes moved directly. -
setLiveArrangement
Runs a force arrangement live: the graph settles a step a frame, and follows a node while it is dragged. Null stops it. -
startLabelEdit
Edits a node's label in place, in a text field over the node; the new label goes toGraphModel.renameNodewhen editing ends. -
getUndoHistory
The history edits are recorded in, or null. -
setUndoHistory
Records every edit the user makes in a history, so it can be undone. The application's history,
UndoHistory.getGlobal(), by default; null records nothing. An undone or redone step brings the graph back into view (ComponentEdit).What is recorded is what the user did through this view: moving, resizing, connecting, removing, renaming, adding, pasting, collapsing a group and
arrange. Changes the application makes to the model directly are not. -
undo
public boolean undo()Takes back the last edit in the history. Prefer this to calling the history yourself: it first lets a running arrangement land.
Returns
false when there is no history, nothing to undo, or editing is off
-
redo
public boolean redo()Makes the last undone edit again.
Returns
false when there is no history, nothing to redo, or editing is off
-
isResizable
public boolean isResizable()True when a selected node shows handles on its corners to resize it by. -
setResizable
public void setResizable(boolean resizable) Lets the user resize a node by dragging a corner of it while it is the only node selected. Off by default. -
laneAt
The lane under a world point, or null. Later lanes are over earlier ones. -
getPendingTemplate
The template the next tap on the background makes a node from, or null. -
setPendingTemplate
Arms a template: the next tap on the background adds a node of it there. AGraphPalettedoes this when one of its items is tapped, which is how a node is added without a drag. -
createNode
Adds a node made from a template, centred on a world point and selected. The node is offered to the listeners and then to the model, and joins the lane it lands in.
Returns
the node, or null when it was refused
-
duplicateSelection
public boolean duplicateSelection()Adds a copy of every selected node, and of the edges among them, a little down and to the trailing side, and selects the copies.
Returns
false when nothing was selected or every copy was refused
-
setUserDataCodec
Writes the user data of copied nodes to the clipboard and reads it back on paste; without one, pasted nodes have no user data. -
copySelection
public boolean copySelection()Puts the selected nodes, and the edges among them, on the clipboard, as the JSON
GraphJsonwrites.Returns
false when no node is selected
-
cutSelection
public boolean cutSelection()Copies the selection and removes it.
Returns
false when no node is selected or editing is off
-
paste
public boolean paste()Adds the nodes on the clipboard, each time a step further from where they were copied, and selects them.
Returns
false when the clipboard holds no nodes or every one was refused
-
setPortEditorFactory
Makes the editors of unconnected input ports; null for none. -
getPortEditorFactory
The factory of port editors, or null. -
getPortEditor
-
setPortValue
-
portX
-
portY
-
getGroupRect
A group's frame in world units, {x, y, width, height}, or null for a group with no members. A collapsed group's frame is its node, and a lane's is its own bounds. -
isNodeVisible
True when a node is drawn: it is not inside a collapsed group. -
toImage
Paints the whole graph into a new image of the given size, fitted with a margin, at no more than zoom 1, without the minimap or the selection. For a thumbnail, a share sheet or a printout. -
nodeAt
The topmost visible node at a point of the view, or null. -
edgeAt
The edge within a finger's reach of a point of the view, or null. -
getVisibleTooltip
The text of the tooltip showing, or null: what a test or an accessibility layer reads. -
hoverAt
public void hoverAt(int x, int y) Simulates a hovering pointer atx, yof the view, as a desktop mouse would. -
initComponent
protected void initComponent()Description copied from class:ComponentAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component state- Overrides:
initComponentin classComponent
-
layoutContainer
public void layoutContainer()Description copied from class:ContainerPerforms the layout of the container if a layout is necessary- Overrides:
layoutContainerin classContainer
-
calcPreferredSize
Description copied from class:ContainerCalculates the preferred size based on component content. This method is invoked lazily by getPreferred size.
Returns
the calculated preferred size based on component content
- Overrides:
calcPreferredSizein classContainer
-