Package com.mxgraph.swing
Class mxGraphComponent
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JScrollPane
com.mxgraph.swing.mxGraphComponent
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Printable
,Serializable
,Accessible
,ScrollPaneConstants
For setting the preferred size of the viewport for scrolling, use
mxGraph.setMinimumGraphSize. This component is a combined scrollpane with an
inner mxGraphControl. The control contains the actual graph display.
To set the background color of the graph, use the following code:
graphComponent.getViewport().setOpaque(true); graphComponent.getViewport().setBackground(newColor);This class fires the following events: mxEvent.START_EDITING fires before starting the in-place editor for an existing cell in startEditingAtCell. The
cell
property contains
the cell that is being edit and the event
property contains
optional EventObject which was passed to startEditingAtCell.
mxEvent.LABEL_CHANGED fires between begin- and endUpdate after the call to
mxGraph.cellLabelChanged in labelChanged. The cell
property
contains the cell, the value
property contains the new value for
the cell and the optional event
property contains the
EventObject that started the edit.
mxEvent.ADD_OVERLAY and mxEvent.REMOVE_OVERLAY fire afer an overlay was added
or removed using add-/removeOverlay. The cell
property contains
the cell for which the overlay was added or removed and the
overlay
property contain the mxOverlay.
mxEvent.BEFORE_PAINT and mxEvent.AFTER_PAINT fire before and after the paint
method is called on the component. The g
property contains the
graphics context which is used for painting.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
static class
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
Whether to extend the graph bounds and scroll towards the limit of those new bounds in the direction of mouse travel if a handler is active while the mouse leaves the container that the graph exists in.protected boolean
Whether or not to scroll the scrollable container the graph exists in if a suitable handler is active and the graph bounds already exist extended in the direction of mouse travel.protected ImageIcon
Specifies theto be returned by . protected mxInteractiveCanvas
protected mxICellEditor
protected boolean
Specifies if the background page should be centered by automatically setting the translate in the view.protected boolean
Specifies if the zoom operations should go into the center of the actual diagram rather than going from top, left.protected ImageIcon
Maps from cells to lists of heavyweights.protected mxConnectionHandler
static ImageIcon
static ImageIcon
static final double
Specifies the default page scale.static ImageIcon
protected boolean
protected boolean
If true, pressing the enter key without pressing control will stop editing and accept the new value.protected boolean
Specifiesshould be invoked when the escape key is pressed. protected mxEventSource
protected ImageIcon
protected boolean
protected boolean
Specifies if folding (collapse and expand via an image icon in the graph should be enabled).protected mxGraph
protected mxGraphComponent.mxGraphControl
protected mxGraphHandler
static final int
static final int
static final int
static final int
protected Color
protected int
protected boolean
Specifies if the grid is visible.protected int
Specifies the number of pages in the horizontal direction.protected boolean
protected boolean
If true, when editing is to be stopped by way of selection changing, data in diagram changing or other means stopCellEditing is invoked, and changes are saved.protected boolean
Specifies if the viewport should automatically contain the selection cells after a zoom operation.protected Hashtable
<Object, mxICellOverlay[]> Maps from cells to lists of overlays.protected Color
Color of the background area if layout view.protected Color
protected Color
Specifies the color of page breaksprotected boolean
Specifies if a dashed line should be drawn between multiple pages.protected PageFormat
Background page format.protected double
Defines the scaling for the background page metrics.protected Color
protected boolean
Specifies if the background page should be visible.protected mxPanningHandler
protected boolean
If the pageFormat should be used to determine the minimal graph bounds even if the page is not visible (see pageVisible).protected float
The transparency of previewed cells from 0.0.protected mxEventSource.mxIEventListener
protected mxEventSource.mxIEventListener
Resets the zoom policy if the scale is changed manually.protected mxSelectionCellsHandler
boolean
Used for debugging the dirty region.protected boolean
Specifies if swimlanes are selected when the mouse is released over the swimlanes content area.protected boolean
protected int
Specifies the tolerance for mouse clicks.protected boolean
Specifies if the content area should be transparent to events.protected BufferedImage
protected boolean
Specifies if an image buffer should be used for painting the component.protected Graphics2D
protected mxEventSource.mxIEventListener
Updates the heavyweight component structure after any changes.protected int
Specifies the number of pages in the vertical direction.protected PropertyChangeListener
protected ImageIcon
static final int
static final int
static final int
protected double
Specifies the factor used for zoomIn and zoomOut.protected int
Specifies the zoom policy.Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCellOverlay
(Object cell, mxICellOverlay overlay) Adds an overlay for the specified cell.void
addListener
(String eventName, mxEventSource.mxIEventListener listener) boolean
canExportCell
(Object cell) Returns true if the given cell can be exported via datatransfer.boolean
canImportCell
(Object cell) Returns true if the given cell can be imported via datatransfer.void
Checks if the triple buffer exists and creates a new one if it does not.void
Removes all overlays in the graph.void
clearCellOverlays
(Object cell) Removes all overlays in the graph for the given cell and all its descendants.Hook for subclassers to replace the graphics canvas for rendering and and printing.protected mxICellEditor
createComponents
(mxCellState state) Hook for subclassers to create the array of heavyweights for the given state.protected mxConnectionHandler
protected mxGraphComponent.mxGraphControl
Creates the inner control that handles tooltips, preferred size and can draw cells onto a canvas.protected mxGraphHandler
createHandler
(mxCellState state) protected void
Creates the connection-, panning and graphhandler (in this order).protected mxPanningHandler
protected mxSelectionCellsHandler
protected TransferHandler
protected void
createTripleBuffer
(int width, int height) Creates the tripleBufferGraphics and tripleBuffer for the given dimension and draws the complete graph onto the triplebuffer.void
Destroys the tripleBuffer and tripleBufferGraphics objects.void
Callback to process an escape keystroke.getCellAt
(int x, int y) getCellAt
(int x, int y, boolean hitSwimlaneContent) Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.getCellOverlays
(Object cell) Returns the array of overlays for the given cell or null, if no overlays are defined.Object[]
Returns the cells inside the given rectangle.Object[]
Returns the children of the given parent that are contained in the given rectangle (x, y, width, height).getEditingValue
(Object cell, EventObject trigger) Object[]
getExportableCells
(Object[] cells) Returns all cells which may be exported via datatransfer.getFoldingIcon
(mxCellState state) Returns the icon used to display the collapsed state of the specified cell state.getFoldingIconBounds
(mxCellState state, ImageIcon icon) getGraph()
int
int
Returns the horizontal border between the page and the control.int
Object[]
getImportableCells
(Object[] cells) Returns all cells which may be imported via datatransfer.Returns the size of the area that layouts can operate in.double
protected mxPoint
getPageTranslate
(double scale) Should be called by a hook inside mxGraphView/mxGraphReturns an mxPoint representing the given event in the unscaled, non-translated coordinate space and applies the grid.getPointForEvent
(MouseEvent e, boolean addOffset) Returns an mxPoint representing the given event in the unscaled, non-translated coordinate space and applies the grid.protected Dimension
Returns the (unscaled) preferred size for the current page format (scaled by pageScale).float
protected Dimension
Returns the scaled preferred size for the current graph.int
int
Returns the vertical border between the page and the control.int
double
int
boolean
hitFoldingIcon
(Object cell, int x, int y) Object[]
importCells
(Object[] cells, double dx, double dy, Object target, Point location) Clones and inserts the given cells into the graph using the move method and returns the inserted cells.void
insertComponent
(mxCellState state, Component c) protected void
Adds handling of edit and stop-edit events after all other handlers have been installed.protected void
installs a handler to set the focus to the container.protected void
Handles escape keystrokes.protected void
Applies the zoom policy if the size of the component changes.boolean
boolean
boolean
boolean
boolean
boolean
isCloneEvent
(MouseEvent event) boolean
boolean
isConstrainedEvent
(MouseEvent event) Note: This is not used during drag and drop operations due to limitations of the underlying API.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isForceMarqueeEvent
(MouseEvent event) Note: This is not used during drag and drop operations due to limitations of the underlying API.boolean
Hook for dynamic triple buffering condition.boolean
isGridEnabledEvent
(MouseEvent event) boolean
boolean
Returns importEnabled.boolean
boolean
boolean
boolean
boolean
boolean
isPanningEvent
(MouseEvent event) Note: This is not used during drag and drop operations due to limitations of the underlying API.boolean
boolean
isSignificant
(double dx, double dy) Returns true if the absolute value of one of the given parameters is greater than the tolerance.boolean
boolean
boolean
isToggleEvent
(MouseEvent event) boolean
labelChanged
(Object cell, Object value, EventObject evt) Sets the label of the specified cell to the given value using mxGraph.cellLabelChanged and fires mxEvent.LABEL_CHANGED while the transaction is in progress.protected void
maintainScrollBar
(boolean horizontal, double factor, boolean center) protected void
protected void
protected Rectangle
protected void
Paints the grid onto the given graphics object.int
print
(Graphics g, PageFormat printFormat, int page) Prints the specified page on the specified graphics usingpageFormat
for the page format.void
redraw
(mxCellState state) Updates the buffer (if one exists) and repaints the given cell state.void
refresh()
Refreshes the display and handles.void
removeAllComponents
(Hashtable<Object, Component[]> map) void
removeCellOverlay
(Object cell, mxICellOverlay overlay) Removes and returns the given overlay from the given cell.protected void
removeCellOverlayComponent
(mxICellOverlay overlay, Object cell) Notified when an overlay has been removed from the graph.removeCellOverlays
(Object cell) Removes all overlays from the given cell.void
removeComponent
(Component c, Object cell) void
removeListener
(mxEventSource.mxIEventListener listener) void
removeListener
(mxEventSource.mxIEventListener listener, String eventName) void
repaintTripleBuffer
(Rectangle dirty) Clears and repaints the triple buffer at the given rectangle or repaints the complete buffer if no rectangle is specified.void
scrollCellToVisible
(Object cell) Scrolls the graph so that it shows the given cell.void
scrollCellToVisible
(Object cell, boolean center) Scrolls the graph so that it shows the given cell.void
scrollToCenter
(boolean horizontal) void
selectCellForEvent
(Object cell, MouseEvent e) Selects the cell for the given event.void
selectCellsForEvent
(Object[] cells, MouseEvent event) Selects the cells for the given event.Object[]
selectRegion
(Rectangle rect, MouseEvent e) void
setAntiAlias
(boolean value) Fires a property change event forantiAlias
.void
setAutoExtend
(boolean value) void
setAutoScroll
(boolean value) void
setBackgroundImage
(ImageIcon value) void
setCellEditor
(mxICellEditor value) setCellWarning
(Object cell, String warning) Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay.setCellWarning
(Object cell, String warning, ImageIcon icon) Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay.setCellWarning
(Object cell, String warning, ImageIcon icon, boolean select) Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay.void
setCenterPage
(boolean value) zoomAndCenter should be called if this is set to true.void
setCenterZoom
(boolean value) void
setConnectable
(boolean connectable) void
setDragEnabled
(boolean value) void
setEnterStopsCellEditing
(boolean value) void
setEscapeEnabled
(boolean value) void
setEventsEnabled
(boolean eventsEnabled) void
setExportEnabled
(boolean value) void
setFoldingEnabled
(boolean value) void
void
setGridColor
(Color value) Fires a property change event forgridColor
.void
setGridStyle
(int value) Fires a property change event forgridStyle
.void
setGridVisible
(boolean value) Fires a property change event forgridVisible
.void
setHorizontalPageCount
(int value) void
setImportEnabled
(boolean value) Sets importEnabled.void
setInvokesStopCellEditing
(boolean value) void
setKeepSelectionVisibleOnZoom
(boolean value) void
setPageBackgroundColor
(Color value) Sets the color that appears behind the page.void
setPageBorderColor
(Color value) void
setPageBreakColor
(Color pageBreakColor) void
setPageBreaksVisible
(boolean value) void
setPageFormat
(PageFormat value) void
setPageScale
(double value) void
setPageShadowColor
(Color value) void
setPageVisible
(boolean value) Fires a property change event forpageVisible
.void
setPanning
(boolean enabled) void
setPreferPageSize
(boolean value) Fires a property change event forpreferPageSize
.void
setPreviewAlpha
(float value) void
setSwimlaneSelectionEnabled
(boolean value) void
setTextAntiAlias
(boolean value) Fires a property change event fortextAntiAlias
.void
setTolerance
(int value) void
setToolTips
(boolean enabled) void
setTripleBuffered
(boolean value) void
setVerticalPageCount
(int value) void
setZoomFactor
(double value) void
setZoomPolicy
(int value) snapScaledPoint
(mxPoint pt, double dx, double dy) void
void
startEditingAtCell
(Object cell) void
startEditingAtCell
(Object cell, EventObject evt) void
stopEditing
(boolean cancel) protected void
updateCellOverlayComponent
(mxCellState state, mxICellOverlay overlay) Notified when an overlay has been removed from the graph.updateCellOverlays
(Object cell) Returns a hashtable with all entries from the overlays variable where a cell still exists in the model.void
updateComponent
(mxCellState state, Component c) void
updateComponents
(Object cell) Validates the graph by validating each descendant of the given cell or the root of the model.validateGraph
(Object cell, Hashtable<Object, Object> context) Validates the graph by validating each descendant of the given cell or the root of the model.void
zoom
(boolean page, boolean center) void
zoom
(double factor) void
Function: zoomActual Resets the zoom and panning in the view.void
Invoked after the component was resized to update the zoom if the zoom policy is not none and/or update the translation of the diagram if pageVisible and centerPage are true.void
zoomIn()
Zooms into the graph by zoomFactor.void
zoomOut()
Function: zoomOut Zooms out of the graph by. void
zoomTo
(double newScale, boolean center) Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
GRID_STYLE_DOT
public static final int GRID_STYLE_DOT- See Also:
-
GRID_STYLE_CROSS
public static final int GRID_STYLE_CROSS- See Also:
-
GRID_STYLE_LINE
public static final int GRID_STYLE_LINE- See Also:
-
GRID_STYLE_DASHED
public static final int GRID_STYLE_DASHED- See Also:
-
ZOOM_POLICY_NONE
public static final int ZOOM_POLICY_NONE- See Also:
-
ZOOM_POLICY_PAGE
public static final int ZOOM_POLICY_PAGE- See Also:
-
ZOOM_POLICY_WIDTH
public static final int ZOOM_POLICY_WIDTH- See Also:
-
DEFAULT_EXPANDED_ICON
-
DEFAULT_COLLAPSED_ICON
-
DEFAULT_WARNING_ICON
-
DEFAULT_PAGESCALE
public static final double DEFAULT_PAGESCALESpecifies the default page scale. Default is 1.4- See Also:
-
graph
-
graphControl
-
eventSource
-
cellEditor
-
connectionHandler
-
panningHandler
-
selectionCellsHandler
-
graphHandler
-
previewAlpha
protected float previewAlphaThe transparency of previewed cells from 0.0. to 0.1. 0.0 indicates transparent, 1.0 indicates opaque. Default is 1. -
backgroundImage
Specifies theto be returned by . Default is null. -
pageFormat
Background page format. -
canvas
-
tripleBuffer
-
tripleBufferGraphics
-
pageScale
protected double pageScaleDefines the scaling for the background page metrics. Default isDEFAULT_PAGESCALE
. -
pageVisible
protected boolean pageVisibleSpecifies if the background page should be visible. Default is false. -
preferPageSize
protected boolean preferPageSizeIf the pageFormat should be used to determine the minimal graph bounds even if the page is not visible (see pageVisible). Default is false. -
pageBreaksVisible
protected boolean pageBreaksVisibleSpecifies if a dashed line should be drawn between multiple pages. -
pageBreakColor
Specifies the color of page breaks -
horizontalPageCount
protected int horizontalPageCountSpecifies the number of pages in the horizontal direction. -
verticalPageCount
protected int verticalPageCountSpecifies the number of pages in the vertical direction. -
centerPage
protected boolean centerPageSpecifies if the background page should be centered by automatically setting the translate in the view. Default is true. This does only apply if pageVisible is true. -
pageBackgroundColor
Color of the background area if layout view. -
pageShadowColor
-
pageBorderColor
-
gridVisible
protected boolean gridVisibleSpecifies if the grid is visible. Default is false. -
gridColor
-
autoScroll
protected boolean autoScrollWhether or not to scroll the scrollable container the graph exists in if a suitable handler is active and the graph bounds already exist extended in the direction of mouse travel. -
autoExtend
protected boolean autoExtendWhether to extend the graph bounds and scroll towards the limit of those new bounds in the direction of mouse travel if a handler is active while the mouse leaves the container that the graph exists in. -
dragEnabled
protected boolean dragEnabled -
importEnabled
protected boolean importEnabled -
exportEnabled
protected boolean exportEnabled -
foldingEnabled
protected boolean foldingEnabledSpecifies if folding (collapse and expand via an image icon in the graph should be enabled). Default is true. -
tolerance
protected int toleranceSpecifies the tolerance for mouse clicks. Default is 4. -
swimlaneSelectionEnabled
protected boolean swimlaneSelectionEnabledSpecifies if swimlanes are selected when the mouse is released over the swimlanes content area. Default is true. -
transparentSwimlaneContent
protected boolean transparentSwimlaneContentSpecifies if the content area should be transparent to events. Default is true. -
gridStyle
protected int gridStyle -
expandedIcon
-
collapsedIcon
-
warningIcon
-
antiAlias
protected boolean antiAlias -
textAntiAlias
protected boolean textAntiAlias -
escapeEnabled
protected boolean escapeEnabledSpecifiesshould be invoked when the escape key is pressed. Default is true. -
invokesStopCellEditing
protected boolean invokesStopCellEditingIf true, when editing is to be stopped by way of selection changing, data in diagram changing or other means stopCellEditing is invoked, and changes are saved. This is implemented in a mouse listener in this class. Default is true. -
enterStopsCellEditing
protected boolean enterStopsCellEditingIf true, pressing the enter key without pressing control will stop editing and accept the new value. This is used into stop cell editing. Default is false. -
zoomPolicy
protected int zoomPolicySpecifies the zoom policy. Default is ZOOM_POLICY_PAGE. The zoom policy does only apply if pageVisible is true. -
zoomFactor
protected double zoomFactorSpecifies the factor used for zoomIn and zoomOut. Default is 1.2 (120%). -
keepSelectionVisibleOnZoom
protected boolean keepSelectionVisibleOnZoomSpecifies if the viewport should automatically contain the selection cells after a zoom operation. Default is false. -
centerZoom
protected boolean centerZoomSpecifies if the zoom operations should go into the center of the actual diagram rather than going from top, left. Default is true. -
tripleBuffered
protected boolean tripleBufferedSpecifies if an image buffer should be used for painting the component. Default is false. -
showDirtyRectangle
public boolean showDirtyRectangleUsed for debugging the dirty region. -
components
Maps from cells to lists of heavyweights. -
overlays
Maps from cells to lists of overlays. -
updateHandler
Updates the heavyweight component structure after any changes. -
repaintHandler
-
viewChangeHandler
-
scaleHandler
Resets the zoom policy if the scale is changed manually.
-
-
Constructor Details
-
mxGraphComponent
- Parameters:
graph
-
-
-
Method Details
-
installFocusHandler
protected void installFocusHandler()installs a handler to set the focus to the container. -
installKeyHandler
protected void installKeyHandler()Handles escape keystrokes. -
installResizeHandler
protected void installResizeHandler()Applies the zoom policy if the size of the component changes. -
installDoubleClickHandler
protected void installDoubleClickHandler()Adds handling of edit and stop-edit events after all other handlers have been installed. -
createCellEditor
-
setGraph
-
getGraph
- Returns:
- Returns the object that contains the graph.
-
createGraphControl
Creates the inner control that handles tooltips, preferred size and can draw cells onto a canvas. -
getGraphControl
- Returns:
- Returns the control that renders the graph.
-
createHandlers
protected void createHandlers()Creates the connection-, panning and graphhandler (in this order). -
createTransferHandler
-
createSelectionCellsHandler
-
createGraphHandler
-
getSelectionCellsHandler
-
getGraphHandler
-
createConnectionHandler
-
getConnectionHandler
-
createPanningHandler
-
getPanningHandler
-
isEditing
public boolean isEditing() -
getCellEditor
-
setCellEditor
-
getTolerance
public int getTolerance()- Returns:
- the tolerance
-
setTolerance
public void setTolerance(int value) - Parameters:
value
- the tolerance to set
-
getPageFormat
-
setPageFormat
-
getPageScale
public double getPageScale() -
setPageScale
public void setPageScale(double value) -
getLayoutAreaSize
Returns the size of the area that layouts can operate in. -
getBackgroundImage
-
setBackgroundImage
-
isPageVisible
public boolean isPageVisible()- Returns:
- the pageVisible
-
setPageVisible
public void setPageVisible(boolean value) Fires a property change event forpageVisible
. zoomAndCenter should be called if this is set to true.- Parameters:
value
- the pageVisible to set
-
isPreferPageSize
public boolean isPreferPageSize()- Returns:
- the preferPageSize
-
setPreferPageSize
public void setPreferPageSize(boolean value) Fires a property change event forpreferPageSize
.- Parameters:
value
- the preferPageSize to set
-
isPageBreaksVisible
public boolean isPageBreaksVisible()- Returns:
- the pageBreaksVisible
-
setPageBreaksVisible
public void setPageBreaksVisible(boolean value) - Parameters:
value
- the pageBreaksVisible to set
-
getPageBreakColor
- Returns:
- the pageBreakColor
-
setPageBreakColor
- Parameters:
pageBreakColor
- the pageBreakColor to set
-
setHorizontalPageCount
public void setHorizontalPageCount(int value) - Parameters:
value
- the horizontalPageCount to set
-
getHorizontalPageCount
public int getHorizontalPageCount() -
setVerticalPageCount
public void setVerticalPageCount(int value) - Parameters:
value
- the verticalPageCount to set
-
getVerticalPageCount
public int getVerticalPageCount() -
isCenterPage
public boolean isCenterPage()- Returns:
- the centerPage
-
setCenterPage
public void setCenterPage(boolean value) zoomAndCenter should be called if this is set to true.- Parameters:
value
- the centerPage to set
-
getPageBackgroundColor
- Returns:
- the pageBackgroundColor
-
setPageBackgroundColor
Sets the color that appears behind the page.- Parameters:
value
- the pageBackgroundColor to set
-
getPageShadowColor
- Returns:
- the pageShadowColor
-
setPageShadowColor
- Parameters:
value
- the pageShadowColor to set
-
getPageBorderColor
- Returns:
- the pageShadowColor
-
setPageBorderColor
- Parameters:
value
- the pageBorderColor to set
-
isKeepSelectionVisibleOnZoom
public boolean isKeepSelectionVisibleOnZoom()- Returns:
- the keepSelectionVisibleOnZoom
-
setKeepSelectionVisibleOnZoom
public void setKeepSelectionVisibleOnZoom(boolean value) - Parameters:
value
- the keepSelectionVisibleOnZoom to set
-
getZoomFactor
public double getZoomFactor()- Returns:
- the zoomFactor
-
setZoomFactor
public void setZoomFactor(double value) - Parameters:
value
- the zoomFactor to set
-
isCenterZoom
public boolean isCenterZoom()- Returns:
- the centerZoom
-
setCenterZoom
public void setCenterZoom(boolean value) - Parameters:
value
- the centerZoom to set
-
setZoomPolicy
public void setZoomPolicy(int value) -
getZoomPolicy
public int getZoomPolicy() -
escape
Callback to process an escape keystroke.- Parameters:
e
-
-
importCells
Clones and inserts the given cells into the graph using the move method and returns the inserted cells. This shortcut is used if cells are inserted via datatransfer. -
refresh
public void refresh()Refreshes the display and handles. -
getPointForEvent
Returns an mxPoint representing the given event in the unscaled, non-translated coordinate space and applies the grid. -
getPointForEvent
Returns an mxPoint representing the given event in the unscaled, non-translated coordinate space and applies the grid. -
startEditing
public void startEditing() -
startEditingAtCell
-
startEditingAtCell
-
getEditingValue
-
stopEditing
public void stopEditing(boolean cancel) -
labelChanged
Sets the label of the specified cell to the given value using mxGraph.cellLabelChanged and fires mxEvent.LABEL_CHANGED while the transaction is in progress. Returns the cell whose label was changed.- Parameters:
cell
- Cell whose label should be changed.value
- New value of the label.evt
- Optional event that triggered the change.
-
getPreferredSizeForPage
Returns the (unscaled) preferred size for the current page format (scaled by pageScale). -
getVerticalPageBorder
public int getVerticalPageBorder()Returns the vertical border between the page and the control. -
getHorizontalPageBorder
public int getHorizontalPageBorder()Returns the horizontal border between the page and the control. -
getScaledPreferredSizeForGraph
Returns the scaled preferred size for the current graph. -
getPageTranslate
Should be called by a hook inside mxGraphView/mxGraph -
zoomAndCenter
public void zoomAndCenter()Invoked after the component was resized to update the zoom if the zoom policy is not none and/or update the translation of the diagram if pageVisible and centerPage are true. -
zoomIn
public void zoomIn()Zooms into the graph by zoomFactor. -
zoomOut
public void zoomOut()Function: zoomOut Zooms out of the graph by. -
zoom
public void zoom(double factor) -
zoomTo
public void zoomTo(double newScale, boolean center) -
zoomActual
public void zoomActual()Function: zoomActual Resets the zoom and panning in the view. -
zoom
public void zoom(boolean page, boolean center) -
maintainScrollBar
protected void maintainScrollBar(boolean horizontal, double factor, boolean center) -
scrollToCenter
public void scrollToCenter(boolean horizontal) -
scrollCellToVisible
Scrolls the graph so that it shows the given cell.- Parameters:
cell
-
-
scrollCellToVisible
Scrolls the graph so that it shows the given cell.- Parameters:
cell
-
-
getCellAt
- Parameters:
x
-y
-- Returns:
- Returns the cell at the given location.
-
getCellAt
- Parameters:
x
-y
-hitSwimlaneContent
-- Returns:
- Returns the cell at the given location.
-
getCellAt
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.- Parameters:
x
- X-coordinate of the location to be checked.y
- Y-coordinate of the location to be checked.parent
-that should be used as the root of the recursion. Default is . - Returns:
- Returns the child at the given location.
-
setSwimlaneSelectionEnabled
public void setSwimlaneSelectionEnabled(boolean value) -
isSwimlaneSelectionEnabled
public boolean isSwimlaneSelectionEnabled() -
selectRegion
-
getCells
Returns the cells inside the given rectangle.- Returns:
- Returns the cells inside the given rectangle.
-
getCells
Returns the children of the given parent that are contained in the given rectangle (x, y, width, height). The result is added to the optional result array, which is returned from the function. If no result array is specified then a new array is created and returned.- Returns:
- Returns the children inside the given rectangle.
-
selectCellsForEvent
Selects the cells for the given event. -
selectCellForEvent
Selects the cell for the given event. -
isSignificant
public boolean isSignificant(double dx, double dy) Returns true if the absolute value of one of the given parameters is greater than the tolerance. -
getFoldingIcon
Returns the icon used to display the collapsed state of the specified cell state. This returns null for all edges. -
getFoldingIconBounds
-
hitFoldingIcon
-
setToolTips
public void setToolTips(boolean enabled) - Parameters:
enabled
-
-
isConnectable
public boolean isConnectable() -
setConnectable
public void setConnectable(boolean connectable) - Parameters:
connectable
-
-
isPanning
public boolean isPanning() -
setPanning
public void setPanning(boolean enabled) - Parameters:
enabled
-
-
isAutoScroll
public boolean isAutoScroll()- Returns:
- the autoScroll
-
setAutoScroll
public void setAutoScroll(boolean value) - Parameters:
value
- the autoScroll to set
-
isAutoExtend
public boolean isAutoExtend()- Returns:
- the autoExtend
-
setAutoExtend
public void setAutoExtend(boolean value) - Parameters:
value
- the autoExtend to set
-
isEscapeEnabled
public boolean isEscapeEnabled()- Returns:
- the escapeEnabled
-
setEscapeEnabled
public void setEscapeEnabled(boolean value) - Parameters:
value
- the escapeEnabled to set
-
isInvokesStopCellEditing
public boolean isInvokesStopCellEditing()- Returns:
- the escapeEnabled
-
setInvokesStopCellEditing
public void setInvokesStopCellEditing(boolean value) - Parameters:
value
- the invokesStopCellEditing to set
-
isEnterStopsCellEditing
public boolean isEnterStopsCellEditing()- Returns:
- the enterStopsCellEditing
-
setEnterStopsCellEditing
public void setEnterStopsCellEditing(boolean value) - Parameters:
value
- the enterStopsCellEditing to set
-
isDragEnabled
public boolean isDragEnabled()- Returns:
- the dragEnabled
-
setDragEnabled
public void setDragEnabled(boolean value) - Parameters:
value
- the dragEnabled to set
-
isGridVisible
public boolean isGridVisible()- Returns:
- the gridVisible
-
setGridVisible
public void setGridVisible(boolean value) Fires a property change event forgridVisible
.- Parameters:
value
- the gridVisible to set
-
isAntiAlias
public boolean isAntiAlias()- Returns:
- the gridVisible
-
setAntiAlias
public void setAntiAlias(boolean value) Fires a property change event forantiAlias
.- Parameters:
value
- the antiAlias to set
-
isTextAntiAlias
public boolean isTextAntiAlias()- Returns:
- the gridVisible
-
setTextAntiAlias
public void setTextAntiAlias(boolean value) Fires a property change event fortextAntiAlias
.- Parameters:
value
- the textAntiAlias to set
-
getPreviewAlpha
public float getPreviewAlpha() -
setPreviewAlpha
public void setPreviewAlpha(float value) -
isTripleBuffered
public boolean isTripleBuffered()- Returns:
- the tripleBuffered
-
isForceTripleBuffered
public boolean isForceTripleBuffered()Hook for dynamic triple buffering condition. -
setTripleBuffered
public void setTripleBuffered(boolean value) - Parameters:
value
- the tripleBuffered to set
-
getGridColor
- Returns:
- the gridColor
-
setGridColor
Fires a property change event forgridColor
.- Parameters:
value
- the gridColor to set
-
getGridStyle
public int getGridStyle()- Returns:
- the gridStyle
-
setGridStyle
public void setGridStyle(int value) Fires a property change event forgridStyle
.- Parameters:
value
- the gridStyle to set
-
isImportEnabled
public boolean isImportEnabled()Returns importEnabled. -
setImportEnabled
public void setImportEnabled(boolean value) Sets importEnabled. -
getImportableCells
Returns all cells which may be imported via datatransfer. -
canImportCell
Returns true if the given cell can be imported via datatransfer. This returns importEnabled. -
isExportEnabled
public boolean isExportEnabled()- Returns:
- the exportEnabled
-
setExportEnabled
public void setExportEnabled(boolean value) - Parameters:
value
- the exportEnabled to set
-
getExportableCells
Returns all cells which may be exported via datatransfer. -
canExportCell
Returns true if the given cell can be exported via datatransfer. -
isFoldingEnabled
public boolean isFoldingEnabled()- Returns:
- the foldingEnabled
-
setFoldingEnabled
public void setFoldingEnabled(boolean value) - Parameters:
value
- the foldingEnabled to set
-
isEditEvent
-
isCloneEvent
- Parameters:
event
-- Returns:
- Returns true if the given event should toggle selected cells.
-
isToggleEvent
- Parameters:
event
-- Returns:
- Returns true if the given event should toggle selected cells.
-
isGridEnabledEvent
- Parameters:
event
-- Returns:
- Returns true if the given event allows the grid to be applied.
-
isPanningEvent
Note: This is not used during drag and drop operations due to limitations of the underlying API. To enable this for move operations set dragEnabled to false.- Parameters:
event
-- Returns:
- Returns true if the given event is a panning event.
-
isConstrainedEvent
Note: This is not used during drag and drop operations due to limitations of the underlying API. To enable this for move operations set dragEnabled to false.- Parameters:
event
-- Returns:
- Returns true if the given event is constrained.
-
isForceMarqueeEvent
Note: This is not used during drag and drop operations due to limitations of the underlying API. To enable this for move operations set dragEnabled to false.- Parameters:
event
-- Returns:
- Returns true if the given event is constrained.
-
snapScaledPoint
-
snapScaledPoint
-
print
Prints the specified page on the specified graphics usingpageFormat
for the page format.- Specified by:
print
in interfacePrintable
- Parameters:
g
- The graphics to paint the graph on.printFormat
- The page format to use for printing.page
- The page to print- Returns:
- Returns
Printable.PAGE_EXISTS
orPrintable.NO_SUCH_PAGE
.
-
getCanvas
-
getTripleBuffer
-
createCanvas
Hook for subclassers to replace the graphics canvas for rendering and and printing. This must be overridden to return a custom canvas if there are any custom shapes. -
createHandler
- Parameters:
state
- Cell state for which a handler should be created.- Returns:
- Returns the handler to be used for the given cell state.
-
createComponents
Hook for subclassers to create the array of heavyweights for the given state. -
insertComponent
-
removeComponent
-
updateComponent
-
updateComponents
public void updateComponents() -
removeAllComponents
-
removeAllOverlays
-
updateComponents
-
validateGraph
Validates the graph by validating each descendant of the given cell or the root of the model. Context is an object that contains the validation state for the complete validation run. The validation errors are attached to their cells using. This function returns true if no validation errors exist in the graph. -
validateGraph
Validates the graph by validating each descendant of the given cell or the root of the model. Context is an object that contains the validation state for the complete validation run. The validation errors are attached to their cells using. This function returns true if no validation errors exist in the graph. - Parameters:
cell
- Cell to start the validation recursion.context
- Object that represents the global validation state.
-
addCellOverlay
Adds an overlay for the specified cell. This method fires an addoverlay event and returns the new overlay.- Parameters:
cell
- Cell to add the overlay for.overlay
- Overlay to be added for the cell.
-
getCellOverlays
Returns the array of overlays for the given cell or null, if no overlays are defined.- Parameters:
cell
- Cell whose overlays should be returned.
-
removeCellOverlay
Removes and returns the given overlay from the given cell. This method fires a remove overlay event. If no overlay is given, then all overlays are removed using removeOverlays.- Parameters:
cell
- Cell whose overlay should be removed.overlay
- Optional overlay to be removed.
-
removeCellOverlays
Removes all overlays from the given cell. This method fires a removeoverlay event for each removed overlay and returns the array of overlays that was removed from the cell.- Parameters:
cell
- Cell whose overlays should be removed.
-
removeCellOverlayComponent
Notified when an overlay has been removed from the graph. This implementation removes the given overlay from its parent if it is a component inside a component hierarchy. -
updateCellOverlayComponent
Notified when an overlay has been removed from the graph. This implementation removes the given overlay from its parent if it is a component inside a component hierarchy. -
clearCellOverlays
public void clearCellOverlays()Removes all overlays in the graph. -
clearCellOverlays
Removes all overlays in the graph for the given cell and all its descendants. If no cell is specified then all overlays are removed from the graph. This implementation uses removeOverlays to remove the overlays from the individual cells.- Parameters:
cell
- Optional cell that represents the root of the subtree to remove the overlays from. Default is the root in the model.
-
setCellWarning
Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay. If the warning is null or a zero length string, then all overlays are removed from the cell instead.- Parameters:
cell
- Cell whose warning should be set.warning
- String that represents the warning to be displayed.
-
setCellWarning
Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay. If the warning is null or a zero length string, then all overlays are removed from the cell instead.- Parameters:
cell
- Cell whose warning should be set.warning
- String that represents the warning to be displayed.icon
- Optional image to be used for the overlay. Default is warningImageBasename.
-
setCellWarning
Creates an overlay for the given cell using the warning and image or warningImage and returns the new overlay. If the warning is null or a zero length string, then all overlays are removed from the cell instead.- Parameters:
cell
- Cell whose warning should be set.warning
- String that represents the warning to be displayed.icon
- Optional image to be used for the overlay. Default is warningImageBasename.select
- Optional boolean indicating if a click on the overlay should select the corresponding cell. Default is false.
-
updateCellOverlays
Returns a hashtable with all entries from the overlays variable where a cell still exists in the model. The entries are removed from the global hashtable so that the remaining entries reflect those whose cell have been removed from the model. If no state is available for a given cell then its overlays are temporarly removed from the rendering control, but kept in the result. -
paintBackground
-
paintBackgroundPage
-
paintBackgroundImage
-
paintGrid
Paints the grid onto the given graphics object. -
redraw
Updates the buffer (if one exists) and repaints the given cell state. -
checkTripleBuffer
public void checkTripleBuffer()Checks if the triple buffer exists and creates a new one if it does not. Also compares the size of the buffer with the size of the graph and drops the buffer if it has a different size. -
createTripleBuffer
protected void createTripleBuffer(int width, int height) Creates the tripleBufferGraphics and tripleBuffer for the given dimension and draws the complete graph onto the triplebuffer.- Parameters:
width
-height
-
-
destroyTripleBuffer
public void destroyTripleBuffer()Destroys the tripleBuffer and tripleBufferGraphics objects. -
repaintTripleBuffer
Clears and repaints the triple buffer at the given rectangle or repaints the complete buffer if no rectangle is specified.- Parameters:
dirty
-
-
isEventsEnabled
public boolean isEventsEnabled()- Returns:
- Returns true if event dispatching is enabled in the event source.
- See Also:
-
setEventsEnabled
public void setEventsEnabled(boolean eventsEnabled) - Parameters:
eventsEnabled
-- See Also:
-
addListener
- Parameters:
eventName
-listener
-- See Also:
-
removeListener
- Parameters:
listener
- Listener instance.
-
removeListener
- Parameters:
listener
- Listener instance.eventName
- Name of the event.
-