com.mindfusion.diagramming
Class DiagramView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.mindfusion.diagramming.DiagramView
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.swing.event.AncestorListener, javax.swing.Scrollable

public class DiagramView
extends javax.swing.JComponent
implements java.awt.print.Printable, javax.swing.Scrollable, javax.swing.event.AncestorListener, java.awt.datatransfer.ClipboardOwner

DiagramView is a Swing component that displays the content of a Diagram object.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DiagramView()
          Initializes a new instance of the DiagramView class.
DiagramView(Diagram diagram)
          Initializes a new instance of the DiagramView class.
 
Method Summary
 void ancestorAdded(javax.swing.event.AncestorEvent event)
          Implements AncestorListener.
 void ancestorMoved(javax.swing.event.AncestorEvent event)
          Implements AncestorListener.
 void ancestorRemoved(javax.swing.event.AncestorEvent event)
          Implements AncestorListener.
 void beginEdit(InplaceEditable item)
          Enters inplace-edit mode, letting the user edit the text of the specified item.
 void beginEdit(InplaceEditable item, java.awt.geom.Point2D mousePosition)
          Enters inplace-edit mode, letting the user edit the text of the specified item.
 void bringIntoView(DiagramItem item)
          Scrolls the viewport so that the specified item will be visible.
 void cancelDrag()
           
 boolean copyToClipboard()
          Copies the current selection of items to the system clipboard.
 boolean copyToClipboard(boolean groups)
          Copies the current selection of items to the system clipboard.
 boolean cutToClipboard()
          Cuts the currently selected items to the system clipboard.
 boolean cutToClipboard(boolean groups)
          Cuts the currently selected items to the system clipboard.
 java.awt.geom.Point2D.Float deviceToDoc(int x, int y)
          Transforms points from the client coordinate space to the document coordinate space.
 java.awt.geom.Point2D.Float deviceToDoc(java.awt.Point devPoint)
          Transforms points from the client coordinate space to the document coordinate space.
 java.awt.geom.Rectangle2D.Float deviceToDoc(java.awt.Rectangle devRect)
          Transforms points from the client coordinate space to the document coordinate space.
 java.awt.Point docToDevice(java.awt.geom.Point2D docPoint)
          Transforms points from the document coordinate space to the device coordinate space.
 java.awt.Rectangle docToDevice(java.awt.geom.Rectangle2D docRect)
          Transforms points from the document coordinate space to the device coordinate space.
 void endEdit(boolean accept)
          Exits inplace-edit mode and either accepts or rejects the changes made to the item's text.
 boolean getAllowInplaceEdit()
          Gets a value indicating whether users are allowed to edit the text of diagram items.
 java.awt.Cursor getAllowLinkCursor()
          Gets the cursor shown when the currently drawn arrow can be attached to the item at the current mouse pointer location.
 SmoothingMode getAntiAlias()
          Gets the current anti-aliasing mode for non text objects.
 boolean getAutoScroll()
          Gets a value indicating whether the diagram will scroll automatically when the mouse is dragged towards the edge of the view.
 int getBehavior()
          Gets a value indicating how the control responds to users actions.
 java.awt.Cursor getCounterDiagonalResizeCursor()
          Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its secondary diagonal.
 BehaviorBase getCustomBehavior()
          Gets custom behavior object specifying how the control responds to mouse input.
 java.lang.Class getCustomLinkType()
          Gets a custom type of DiagramLink-derived objects that will be created when the users starts drawing with the mouse.
 java.lang.Class getCustomNodeType()
          Gets the type of a DiagramNode-derived class whose instance should be created when a user starts drawing.
 int getDelKeyAction()
          Gets a value that specifies what action should be carried out when the user hits the Del key.
 java.awt.Cursor getDiagonalResizeCursor()
          Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its main diagonal.
 Diagram getDiagram()
          Gets the diagram displayed by this view.
 java.awt.Cursor getDisallowCursor()
          Gets the cursor shown when an item cannot be created at the current mouse pointer location.
 java.awt.Cursor getDisallowLinkCursor()
          Gets the cursor shown when the currently created arrow cannot be attached to the item at the current mouse pointer location.
 int getDragThreshold()
          Gets the minimum distance the mouse should be dragged, measured in pixels, that would cause a drag event instead of click.
 java.awt.Cursor getDrawLinkCursor()
          Gets the cursor shown when an arrow can be drawn from the current mouse pointer location.
 java.awt.Font getFont()
           
 java.awt.Cursor getHorizontalResizeCursor()
          Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item horizontally.
 boolean getInplaceEditAcceptOnEnter()
          Gets a value indicating whether pressing the ENTER key ends inplace editing and accepts changes.
 boolean getInplaceEditCancelOnEsc()
          Gets a value indicating whether pressing the ESC key ends inplace editing and cancels changes.
 java.awt.Font getInplaceEditFont()
          Gets the font used to display text in the inplace- edit text control.
 int getModificationStart()
          Gets a value indicating how users can start modifying items in the diagram.
 java.awt.Cursor getMoveCursor()
          Gets the cursor shown when the item under the mouse pointer can be modified.
 java.awt.Cursor getPanCursor()
          Gets the cursor shown when panning the diagram view.
 java.awt.Cursor getPointerCursor()
          Gets the mouse cursor shown when no modification is performed.
 java.awt.Dimension getPreferredScrollableViewportSize()
          Provides support for scrolling when the diagram in placed inside a scroll pane.
 java.awt.Dimension getPreferredSize()
          Returns the size of the diagram in pixels, based on the currently set document size and zoom level.
 PrintOptions getPrintOptions()
          Returns a PrintOptions instance that allows customizing various aspects of printing and print-preview.
 java.awt.Cursor getRotateCursor()
          Gets the cursor shown when dragging from the current mouse pointer location would start rotating a box.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Provides support for scrolling when the diagram in placed inside a scroll pane.
 boolean getScrollableTracksViewportHeight()
          Provides support for scrolling when the diagram in placed inside a scroll pane.
 boolean getScrollableTracksViewportWidth()
          Provides support for scrolling when the diagram in placed inside a scroll pane.
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Provides support for scrolling when the diagram in placed inside a scroll pane.
 float getScrollX()
          Gets the horizontal scroll position.
 float getScrollY()
          Gets the vertical scroll position.
 SmoothingMode getTextAntiAlias()
          Gets the current anti-aliasing mode for text.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Returns the string to be used as the tooltip for event.
 boolean getTrackPointedItem()
          Gets a value indicating whether the control will raise the mouseEnterItem and mouseLeaveItem events.
 java.awt.Cursor getVerticalResizeCursor()
          Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item vertically.
 float getZoomFactor()
          Gets the current zoom level.
 void loadFrom(java.io.InputStream in)
          Loads the diagram contents from a stream.
 void loadFrom(java.lang.String fileName)
          Loads the diagram contents from a file.
 void loadFromString(java.lang.String chartData)
          Loads the diagram contents from a string.
 void loadFromXml(org.w3c.dom.Document document, boolean freeProcessedXml)
          Loads the contents of the XML diagram document.
 void loadFromXml(org.xml.sax.InputSource source)
          Loads the contents of the XML diagram document.
 void loadFromXml(java.io.InputStream stream)
          Loads the contents of the XML diagram document.
 void loadFromXml(java.lang.String fileName)
          Loads the contents of the XML diagram document.
 void lostOwnership(java.awt.datatransfer.Clipboard arg0, java.awt.datatransfer.Transferable arg1)
           
protected  void paintComponent(java.awt.Graphics g)
           
 boolean pasteFromClipboard(float dx, float dy)
          Pastes diagram items from the system clipboard.
 boolean pasteFromClipboard(float dx, float dy, boolean unconnectedLinks)
          Pastes diagram items from the system clipboard.
 void print()
          Prints the current diagram using the default page format.
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
          Implements the Printable interface.
 void print(java.awt.print.PageFormat pageFormat, java.lang.String printer)
          Prints the current diagram using the specified page format.
 void print(java.lang.String printer)
          Prints the current diagram using the default page format.
 void printPreview()
          Displays a print preview window, that shows how the diagram would look when printed on paper.
protected  void processKeyEvent(java.awt.event.KeyEvent e)
           
 void recreateCacheImage()
          Recreates the off-screen cache bitmap used for fast drawing while modifying items.
 void repaint()
          Repaints the whole diagram.
 void repaint(java.awt.geom.Rectangle2D docRect)
          Repaints the specified region of the diagram.
 void resumeRepaint()
          Resumes repainting the control after a suspendRepaint() call.
 void saveTo(java.io.OutputStream out)
          Saves the diagram contents into a stream.
 void saveTo(java.lang.String fileName)
          Saves the diagram contents into a file.
 java.lang.String saveToString()
          Saves the diagram contents into a string.
 java.lang.String saveToString(int format, boolean includeUnalteredProperties)
          Saves the diagram contents into a string.
 void saveToXml(org.w3c.dom.Document document)
          Saves the diagram to the specified XML document.
 void saveToXml(org.w3c.dom.Document document, boolean includeUnalteredProperties)
          Saves the diagram to the specified XML document.
 void saveToXml(java.io.OutputStream stream, boolean includeUnalteredProperties)
          Saves the diagram to the specified XML document.
 void saveToXml(java.lang.String fileName)
          Saves the diagram to the specified XML document.
 void scrollTo(float x, float y)
          Scrolls the diagram to the specified position.
 void setAllowInplaceEdit(boolean value)
          Sets a value indicating whether users are allowed to edit the text of diagram items.
 void setAllowLinkCursor(java.awt.Cursor value)
          Sets the cursor shown when the currently drawn arrow can be attached to the item at the current mouse pointer location.
 void setAntiAlias(SmoothingMode antiAlias)
          Sets the current anti-aliasing mode for non text objects.
 void setAutoScroll(boolean value)
          Sets a value indicating whether the diagram should scroll automatically when the mouse is dragged towards the edge of the view.
 void setBehavior(int value)
          Sets a value indicating how the control should respond to users actions.
 void setCounterDiagonalResizeCursor(java.awt.Cursor value)
          Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its secondary diagonal.
 void setCustomBehavior(BehaviorBase value)
          Sets a custom behavior object specifying how the control responds to mouse input.
 void setCustomLinkType(java.lang.Class value)
          Sets a custom type of DiagramLink-derived objects that will be created when the users starts drawing with the mouse.
 void setCustomNodeType(java.lang.Class value)
          Sets the type of a DiagramNode-derived class whose instance should be created when a user starts drawing.
 void setDelKeyAction(int delKeyAction)
          Sets a value that specifies what action should be carried out when the user hits the Del key.
 void setDiagonalResizeCursor(java.awt.Cursor value)
          Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its main diagonal.
 void setDiagram(Diagram value)
          Sets the diagram displayed by this view.
 void setDisallowCursor(java.awt.Cursor value)
          Sets the cursor shown when an item cannot be created at the current mouse pointer location.
 void setDisallowLinkCursor(java.awt.Cursor value)
          Sets the cursor shown when the currently created arrow can be attached to the item at the current mouse pointer location.
 void setDragThreshold(int dragThreshold)
          Sets the minimum distance the mouse should be dragged, measured in pixels, that would cause a drag event instead of click.
 void setDrawLinkCursor(java.awt.Cursor value)
          Sets the cursor shown when an arrow can be drawn from the current mouse pointer location.
 void setHorizontalResizeCursor(java.awt.Cursor value)
          Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item horizontally.
 void setInplaceEditAcceptOnEnter(boolean inplaceEditAcceptOnEnter)
          Sets a value indicating whether pressing the ENTER key ends inplace editing and accepts changes.
 void setInplaceEditCancelOnEsc(boolean inplaceEditCancelOnEsc)
          Sets a value indicating whether pressing the ESC key ends inplace editing and cancels changes.
 void setInplaceEditFont(java.awt.Font value)
          Sets the font used to display text in the inplace- edit text control.
 void setModificationStart(int value)
          Sets a value indicating how users can start modifying items in the diagram.
 void setMoveCursor(java.awt.Cursor value)
          Sets the cursor shown when the item under the mouse pointer can be modified.
 void setPanCursor(java.awt.Cursor panCursor)
          Sets the cursor shown when panning the diagram view
 void setPointerCursor(java.awt.Cursor value)
          Sets the mouse cursor that should be shown when no modification is performed.
 void setRotateCursor(java.awt.Cursor value)
          Sets the cursor shown when dragging from the current mouse pointer location would start rotating a box.
 void setScrollX(float value)
          Sets the horizontal scroll position.
 void setScrollY(float value)
          Sets the vertical scroll position.
 void setTextAntiAlias(SmoothingMode antiAlias)
          Sets the current anti-aliasing mode for text.
 void setTrackPointedItem(boolean value)
          Sets a value indicating whether the control should raise the mouseEnterItem and mouseLeaveItem events.
 void setVerticalResizeCursor(java.awt.Cursor value)
          Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item vertically.
 void setZoomFactor(float value)
          Sets the zoom level.
 void suspendRepaint()
          Stops repainting the control.
 void zoomToFit()
          Zooms the diagram so that all its contents becomes visible.
 void zoomToFit(java.awt.geom.Rectangle2D rect)
          Zooms and scrolls the diagram so that the specified rectangular area becomes visible.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, updateUI
 
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, setLayout, transferFocusBackward, 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiagramView

public DiagramView()
Initializes a new instance of the DiagramView class.


DiagramView

public DiagramView(Diagram diagram)
Initializes a new instance of the DiagramView class.

Method Detail

getTrackPointedItem

public boolean getTrackPointedItem()
Gets a value indicating whether the control will raise the mouseEnterItem and mouseLeaveItem events.

Returns:
true if mouseEnterItem and mouseLeaveItem events are raised when the mouse pointer enters or leaves the bounds of an item, otherwise false.

setTrackPointedItem

public void setTrackPointedItem(boolean value)
Sets a value indicating whether the control should raise the mouseEnterItem and mouseLeaveItem events.

Parameters:
value - true if mouseEnterItem and mouseLeaveItem events should be raised when the mouse pointer enters or leaves the bounds of an item, otherwise false.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the size of the diagram in pixels, based on the currently set document size and zoom level.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
A Dimension object representing the preferred size.

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Provides support for scrolling when the diagram in placed inside a scroll pane.

Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
A Dimension object representing the preferred size.

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Provides support for scrolling when the diagram in placed inside a scroll pane.

Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable
Returns:
The "block" increment for scrolling in the specified direction.

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Provides support for scrolling when the diagram in placed inside a scroll pane.

Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable
Returns:
The "unit" increment for scrolling in the specified direction.

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Provides support for scrolling when the diagram in placed inside a scroll pane.

Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable
Returns:
false

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Provides support for scrolling when the diagram in placed inside a scroll pane.

Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable
Returns:
false

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Returns the string to be used as the tooltip for event.

Overrides:
getToolTipText in class javax.swing.JComponent

saveTo

public void saveTo(java.io.OutputStream out)
            throws java.io.IOException
Saves the diagram contents into a stream.

Parameters:
out - An OutputStream where the diagram contents should be saved.
Throws:
java.io.IOException

saveToString

public java.lang.String saveToString()
Saves the diagram contents into a string.

Returns:
A String containing the base64 encoded diagram contents.

saveToString

public java.lang.String saveToString(int format,
                                     boolean includeUnalteredProperties)
Saves the diagram contents into a string.

Parameters:
format - A SaveToStringFormat contstant that indicates the desired serialized string format.
includeUnalteredProperties - true to serialize all properties; false to serialize only properties different from their default value.
Returns:
A String containing the serialized diagram.

loadFrom

public void loadFrom(java.io.InputStream in)
              throws java.io.IOException
Loads the diagram contents from a stream.

Parameters:
in - An InputStream from which to load the diagram contents.
Throws:
java.io.IOException

loadFromString

public void loadFromString(java.lang.String chartData)
Loads the diagram contents from a string.

Parameters:
chartData - A String from which to load the diagram contents.

saveTo

public void saveTo(java.lang.String fileName)
            throws java.io.FileNotFoundException,
                   java.io.IOException
Saves the diagram contents into a file.

Parameters:
fileName - The name of the file into which the diagram contents should be saved.
Throws:
java.io.FileNotFoundException
java.io.IOException

loadFrom

public void loadFrom(java.lang.String fileName)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Loads the diagram contents from a file.

Parameters:
fileName - The name of the file from which the diagram contents should be loaded.
Throws:
java.io.FileNotFoundException
java.io.IOException

saveToXml

public void saveToXml(java.lang.String fileName)
               throws java.io.FileNotFoundException,
                      java.io.IOException,
                      XmlException
Saves the diagram to the specified XML document.

Parameters:
fileName - The full path and name of the disk file where the diagram should be saved.
Throws:
java.io.FileNotFoundException
java.io.IOException
XmlException

saveToXml

public void saveToXml(java.io.OutputStream stream,
                      boolean includeUnalteredProperties)
               throws XmlException,
                      java.io.IOException
Saves the diagram to the specified XML document.

Parameters:
stream - An OutputStream where the XML markup should be serialized.
Throws:
XmlException
java.io.IOException

saveToXml

public void saveToXml(org.w3c.dom.Document document)
Saves the diagram to the specified XML document.

Parameters:
document - A DOM Document object where the diagram should be saved.

saveToXml

public void saveToXml(org.w3c.dom.Document document,
                      boolean includeUnalteredProperties)
Saves the diagram to the specified XML document.

Parameters:
document - A DOM Document object where the diagram should be saved.

loadFromXml

public void loadFromXml(java.lang.String fileName)
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        XmlException
Loads the contents of the XML diagram document.

Parameters:
fileName - The name of the XML file the data should be read from.
Throws:
java.io.FileNotFoundException
java.io.IOException
XmlException

loadFromXml

public void loadFromXml(java.io.InputStream stream)
                 throws XmlException
Loads the contents of the XML diagram document.

Parameters:
stream - An InputStream where the XML markup should be read from.
Throws:
XmlException

loadFromXml

public void loadFromXml(org.xml.sax.InputSource source)
                 throws XmlException
Loads the contents of the XML diagram document.

Parameters:
source - An InputSource where the XML markup should be read from.
Throws:
XmlException

loadFromXml

public void loadFromXml(org.w3c.dom.Document document,
                        boolean freeProcessedXml)
                 throws XmlException
Loads the contents of the XML diagram document.

Parameters:
document - A DOM Document object from which to load the diagram data.
Throws:
XmlException

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e)
Overrides:
processKeyEvent in class javax.swing.JComponent

suspendRepaint

public void suspendRepaint()
Stops repainting the control. This is useful when using the JDiagram API from JavaScript, where the control would be repainted after each script line executes.


resumeRepaint

public void resumeRepaint()
Resumes repainting the control after a suspendRepaint() call.


paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

recreateCacheImage

public void recreateCacheImage()
Recreates the off-screen cache bitmap used for fast drawing while modifying items.


docToDevice

public java.awt.Rectangle docToDevice(java.awt.geom.Rectangle2D docRect)
Transforms points from the document coordinate space to the device coordinate space.

Parameters:
docRect - A Rectangle2D object, whose coordinates should be transformed and returned.
Returns:
A Rectangle instance, which represents the device coordinates of docRect.

deviceToDoc

public java.awt.geom.Rectangle2D.Float deviceToDoc(java.awt.Rectangle devRect)
Transforms points from the client coordinate space to the document coordinate space.

Parameters:
devRect - An instance of the Rectangle object, whose coordinates should be transformed and returned.
Returns:
A Rectangle2D.Float object, which represents the document coordinates of devRect

docToDevice

public java.awt.Point docToDevice(java.awt.geom.Point2D docPoint)
Transforms points from the document coordinate space to the device coordinate space.

Parameters:
docPoint - A Point2D object, whose coordinates should be transformed and returned.
Returns:
A Point instance, which represents the device coordinates of docPoint.

deviceToDoc

public java.awt.geom.Point2D.Float deviceToDoc(java.awt.Point devPoint)
Transforms points from the client coordinate space to the document coordinate space.

Parameters:
devPoint - An instance of the Point object, whose coordinates should be transformed and returned.
Returns:
A Point2D.Float object, which represents the document coordinates of devPoint

deviceToDoc

public java.awt.geom.Point2D.Float deviceToDoc(int x,
                                               int y)
Transforms points from the client coordinate space to the document coordinate space.

Parameters:
x -
y -
Returns:
A Point2D.Float object, which represents the document coordinates of device point (x, y)

getPrintOptions

public PrintOptions getPrintOptions()
Returns a PrintOptions instance that allows customizing various aspects of printing and print-preview.

Returns:
A PrintOptions object.

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
Implements the Printable interface.

Specified by:
print in interface java.awt.print.Printable

print

public void print()
Prints the current diagram using the default page format.


print

public void print(java.lang.String printer)
Prints the current diagram using the default page format.

Parameters:
printer - Specifies the destination printer

print

public void print(java.awt.print.PageFormat pageFormat,
                  java.lang.String printer)
Prints the current diagram using the specified page format.

Parameters:
pageFormat - The size and orientation of each page to be printed.
printer - Specifies the destination printer

printPreview

public void printPreview()
Displays a print preview window, that shows how the diagram would look when printed on paper. The preview is rendered with the same settings that are used for printing, assigned via getPrintOptions(). That ensures uniform output of the printed document both on paper and in the preview window. Print job settings include document title and several flags that control whether images, shadows, headers, etc. are printed.


copyToClipboard

public boolean copyToClipboard()
                        throws java.io.IOException
Copies the current selection of items to the system clipboard.

Returns:
true if items were successfully copied; otherwise, false.
Throws:
java.io.IOException

copyToClipboard

public boolean copyToClipboard(boolean groups)
                        throws java.io.IOException
Copies the current selection of items to the system clipboard.

Parameters:
groups - true to copy item groups; otherwise, false.
Returns:
true if items were successfully copied; otherwise, false.
Throws:
java.io.IOException

cutToClipboard

public boolean cutToClipboard()
                       throws java.io.IOException
Cuts the currently selected items to the system clipboard.

Returns:
true if items are successfully copied to clipboard; otherwise, false.
Throws:
java.io.IOException

cutToClipboard

public boolean cutToClipboard(boolean groups)
                       throws java.io.IOException
Cuts the currently selected items to the system clipboard.

Parameters:
groups - true to cut item groups; otherwise, false.
Returns:
true if items are successfully copied to clipboard; otherwise, false.
Throws:
java.io.IOException

pasteFromClipboard

public boolean pasteFromClipboard(float dx,
                                  float dy)
                           throws java.io.IOException
Pastes diagram items from the system clipboard.

Parameters:
dx - Horizontal offset of pasted items from their original positions.
dy - Vertical offset of pasted items from their original positions.
Throws:
java.io.IOException

pasteFromClipboard

public boolean pasteFromClipboard(float dx,
                                  float dy,
                                  boolean unconnectedLinks)
                           throws java.io.IOException
Pastes diagram items from the system clipboard.

Parameters:
dx - Horizontal offset of pasted items from their original positions.
dy - Vertical offset of pasted items from their original positions.
unconnectedLinks - true to allow pasting arrows whose origin or destination node has not been copied; otherwise, false. Default is false.
Throws:
java.io.IOException

lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard arg0,
                          java.awt.datatransfer.Transferable arg1)
Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface java.awt.MenuContainer
Overrides:
getFont in class java.awt.Component

getInplaceEditFont

public java.awt.Font getInplaceEditFont()
Gets the font used to display text in the inplace- edit text control.

Returns:
A java.awt.Font object representing the font of the inplace edit control.

setInplaceEditFont

public void setInplaceEditFont(java.awt.Font value)
Sets the font used to display text in the inplace- edit text control.

Parameters:
value - A java.awt.Font object representing the font of the inplace edit control.

getBehavior

public int getBehavior()
Gets a value indicating how the control responds to users actions.

Returns:
One of the Behavior constants.

setBehavior

public void setBehavior(int value)
Sets a value indicating how the control should respond to users actions.

Parameters:
value - One of the Behavior constants.

getCustomBehavior

public BehaviorBase getCustomBehavior()
Gets custom behavior object specifying how the control responds to mouse input.


setCustomBehavior

public void setCustomBehavior(BehaviorBase value)
Sets a custom behavior object specifying how the control responds to mouse input.


cancelDrag

public void cancelDrag()

getScrollX

public float getScrollX()
Gets the horizontal scroll position.

Returns:
A float value specifying the current horizontal scroll position.

setScrollX

public void setScrollX(float value)
Sets the horizontal scroll position. The Diagram component must be contained within a JScrollPane in order to use this method.

Parameters:
value - A float value specifying the horizontal scroll position.

getScrollY

public float getScrollY()
Gets the vertical scroll position.

Returns:
A float value specifying the current vertical scroll position.

setScrollY

public void setScrollY(float value)
Sets the vertical scroll position. The Diagram component must be contained within a JScrollPane in order to use this method.

Parameters:
value - A float value specifying the vertical scroll position.

scrollTo

public void scrollTo(float x,
                     float y)
Scrolls the diagram to the specified position. The Diagram component must be contained within a JScrollPane in order to use this method.

Parameters:
x - A float value specifying the horizontal scroll position.
y - A float value specifying the vertical scroll position.

getZoomFactor

public float getZoomFactor()
Gets the current zoom level.

Returns:
A float value specifying the current zoom factor.

setZoomFactor

public void setZoomFactor(float value)
Sets the zoom level.

Parameters:
value - A float value specifying the zoom factor as percents of the original view size.

zoomToFit

public void zoomToFit()
Zooms the diagram so that all its contents becomes visible.


zoomToFit

public void zoomToFit(java.awt.geom.Rectangle2D rect)
Zooms and scrolls the diagram so that the specified rectangular area becomes visible. The DiagramView component must be contained within a JScrollPane in order to use this method.

Parameters:
rect - A Rectangle2D object representing the region to which the view should be fitted.

getPointerCursor

public java.awt.Cursor getPointerCursor()
Gets the mouse cursor shown when no modification is performed.

Returns:
A java.awt.Cursor object.

setPointerCursor

public void setPointerCursor(java.awt.Cursor value)
Sets the mouse cursor that should be shown when no modification is performed.

Parameters:
value - A java.awt.Cursor object.

getDisallowCursor

public java.awt.Cursor getDisallowCursor()
Gets the cursor shown when an item cannot be created at the current mouse pointer location.

Returns:
A java.awt.Cursor object.

setDisallowCursor

public void setDisallowCursor(java.awt.Cursor value)
Sets the cursor shown when an item cannot be created at the current mouse pointer location.

Parameters:
value - A java.awt.Cursor object.

getMoveCursor

public java.awt.Cursor getMoveCursor()
Gets the cursor shown when the item under the mouse pointer can be modified.

Returns:
A java.awt.Cursor object.

setMoveCursor

public void setMoveCursor(java.awt.Cursor value)
Sets the cursor shown when the item under the mouse pointer can be modified.

Parameters:
value - A java.awt.Cursor object.

getDrawLinkCursor

public java.awt.Cursor getDrawLinkCursor()
Gets the cursor shown when an arrow can be drawn from the current mouse pointer location.

Returns:
A java.awt.Cursor object.

setDrawLinkCursor

public void setDrawLinkCursor(java.awt.Cursor value)
Sets the cursor shown when an arrow can be drawn from the current mouse pointer location.

Parameters:
value - A java.awt.Cursor object.

getAllowLinkCursor

public java.awt.Cursor getAllowLinkCursor()
Gets the cursor shown when the currently drawn arrow can be attached to the item at the current mouse pointer location.

Returns:
A java.awt.Cursor object.

setAllowLinkCursor

public void setAllowLinkCursor(java.awt.Cursor value)
Sets the cursor shown when the currently drawn arrow can be attached to the item at the current mouse pointer location.

Parameters:
value - A java.awt.Cursor object.

getDisallowLinkCursor

public java.awt.Cursor getDisallowLinkCursor()
Gets the cursor shown when the currently created arrow cannot be attached to the item at the current mouse pointer location.

Returns:
A java.awt.Cursor object.

setDisallowLinkCursor

public void setDisallowLinkCursor(java.awt.Cursor value)
Sets the cursor shown when the currently created arrow can be attached to the item at the current mouse pointer location.

Parameters:
value - A java.awt.Cursor object.

getHorizontalResizeCursor

public java.awt.Cursor getHorizontalResizeCursor()
Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item horizontally.

Returns:
A java.awt.Cursor object.

setHorizontalResizeCursor

public void setHorizontalResizeCursor(java.awt.Cursor value)
Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item horizontally.

Parameters:
value - A java.awt.Cursor object.

getRotateCursor

public java.awt.Cursor getRotateCursor()
Gets the cursor shown when dragging from the current mouse pointer location would start rotating a box.

Returns:
A java.awt.Cursor object.

setRotateCursor

public void setRotateCursor(java.awt.Cursor value)
Sets the cursor shown when dragging from the current mouse pointer location would start rotating a box.

Parameters:
value - A java.awt.Cursor object.

getPanCursor

public java.awt.Cursor getPanCursor()
Gets the cursor shown when panning the diagram view.

Returns:
A java.awt.Cursor object.

setPanCursor

public void setPanCursor(java.awt.Cursor panCursor)
Sets the cursor shown when panning the diagram view

Parameters:
value - A java.awt.Cursor object.

getVerticalResizeCursor

public java.awt.Cursor getVerticalResizeCursor()
Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item vertically.

Returns:
A java.awt.Cursor object.

setVerticalResizeCursor

public void setVerticalResizeCursor(java.awt.Cursor value)
Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item vertically.

Parameters:
value - A java.awt.Cursor object.

getDiagonalResizeCursor

public java.awt.Cursor getDiagonalResizeCursor()
Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its main diagonal.

Returns:
A java.awt.Cursor object.

setDiagonalResizeCursor

public void setDiagonalResizeCursor(java.awt.Cursor value)
Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its main diagonal.

Parameters:
value - A java.awt.Cursor object.

getCounterDiagonalResizeCursor

public java.awt.Cursor getCounterDiagonalResizeCursor()
Gets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its secondary diagonal.

Returns:
A java.awt.Cursor object.

setCounterDiagonalResizeCursor

public void setCounterDiagonalResizeCursor(java.awt.Cursor value)
Sets the cursor shown when dragging from the current mouse pointer location would start resizing an item along its secondary diagonal.

Parameters:
value - A java.awt.Cursor object.

getDragThreshold

public int getDragThreshold()
Gets the minimum distance the mouse should be dragged, measured in pixels, that would cause a drag event instead of click.

Returns:
The minimal distance to move the mouse before starting a drag operation.

getCustomNodeType

public java.lang.Class getCustomNodeType()
Gets the type of a DiagramNode-derived class whose instance should be created when a user starts drawing.

Returns:
the custom node object.

setCustomNodeType

public void setCustomNodeType(java.lang.Class value)
Sets the type of a DiagramNode-derived class whose instance should be created when a user starts drawing.

Parameters:
value -

getCustomLinkType

public java.lang.Class getCustomLinkType()
Gets a custom type of DiagramLink-derived objects that will be created when the users starts drawing with the mouse.

Returns:
the custom link class.

setCustomLinkType

public void setCustomLinkType(java.lang.Class value)
Sets a custom type of DiagramLink-derived objects that will be created when the users starts drawing with the mouse.


setDragThreshold

public void setDragThreshold(int dragThreshold)
Sets the minimum distance the mouse should be dragged, measured in pixels, that would cause a drag event instead of click.

Parameters:
dragThreshold - The minimal distance to move the mouse before starting a drag operation.

getAutoScroll

public boolean getAutoScroll()
Gets a value indicating whether the diagram will scroll automatically when the mouse is dragged towards the edge of the view.

Returns:
true if the diagram will scroll automatically, otherwise false.

setAutoScroll

public void setAutoScroll(boolean value)
Sets a value indicating whether the diagram should scroll automatically when the mouse is dragged towards the edge of the view.

Parameters:
value - true if the diagram should scroll automatically, otherwise false.

getModificationStart

public int getModificationStart()
Gets a value indicating how users can start modifying items in the diagram.

Returns:
One of the ModificationStart constants.

setModificationStart

public void setModificationStart(int value)
Sets a value indicating how users can start modifying items in the diagram.

Parameters:
value - One of the ModificationStart constants.

bringIntoView

public void bringIntoView(DiagramItem item)
Scrolls the viewport so that the specified item will be visible. This works only when the diagram is contained within a JScrollPane.

Parameters:
item - The DiagramItem to bring into view.

repaint

public void repaint(java.awt.geom.Rectangle2D docRect)
Repaints the specified region of the diagram.

Parameters:
docRect - A Rectangle2D object representing the region of the diagram that should be repainted.

repaint

public void repaint()
Repaints the whole diagram.

Overrides:
repaint in class java.awt.Component

getAllowInplaceEdit

public boolean getAllowInplaceEdit()
Gets a value indicating whether users are allowed to edit the text of diagram items.

Returns:
true if users are allowed to edit the text of diagram items, otherwise false.

setAllowInplaceEdit

public void setAllowInplaceEdit(boolean value)
Sets a value indicating whether users are allowed to edit the text of diagram items.

Parameters:
value - true if users are allowed to edit the text of diagram items, otherwise false.

getInplaceEditAcceptOnEnter

public boolean getInplaceEditAcceptOnEnter()
Gets a value indicating whether pressing the ENTER key ends inplace editing and accepts changes.

Returns:
true if ENTER ends inplace editing, otherwise false

setInplaceEditAcceptOnEnter

public void setInplaceEditAcceptOnEnter(boolean inplaceEditAcceptOnEnter)
Sets a value indicating whether pressing the ENTER key ends inplace editing and accepts changes.

Parameters:
inplaceEditAcceptOnEnter - true if ENTER should end inplace editing, otherwise false

getInplaceEditCancelOnEsc

public boolean getInplaceEditCancelOnEsc()
Gets a value indicating whether pressing the ESC key ends inplace editing and cancels changes.

Returns:
true if ESC should end inplace editing, otherwise false

setInplaceEditCancelOnEsc

public void setInplaceEditCancelOnEsc(boolean inplaceEditCancelOnEsc)
Sets a value indicating whether pressing the ESC key ends inplace editing and cancels changes.

Parameters:
inplaceEditCancelOnEsc - true if ESC should end inplace editing, otherwise false

beginEdit

public void beginEdit(InplaceEditable item)
Enters inplace-edit mode, letting the user edit the text of the specified item.

Parameters:
item - The diagram item or table's cell whose text should be edited.

beginEdit

public void beginEdit(InplaceEditable item,
                      java.awt.geom.Point2D mousePosition)
Enters inplace-edit mode, letting the user edit the text of the specified item.

Parameters:
item - The diagram item or table's cell whose text should be edited.

endEdit

public void endEdit(boolean accept)
Exits inplace-edit mode and either accepts or rejects the changes made to the item's text.

Parameters:
accept - true to accept changes made to text; false to reject them.

getAntiAlias

public SmoothingMode getAntiAlias()
Gets the current anti-aliasing mode for non text objects.

Returns:
A member of the SmoothingMode enumeration.

setAntiAlias

public void setAntiAlias(SmoothingMode antiAlias)
Sets the current anti-aliasing mode for non text objects.

Parameters:
antiAlias - A member of the SmoothingMode enumeration
See Also:
setTextAntiAlias(com.mindfusion.diagramming.SmoothingMode)

getTextAntiAlias

public SmoothingMode getTextAntiAlias()
Gets the current anti-aliasing mode for text.

Returns:
A member of the SmoothingMode enumeration.

setTextAntiAlias

public void setTextAntiAlias(SmoothingMode antiAlias)
Sets the current anti-aliasing mode for text.

Parameters:
antiAlias - A member of the SmoothingMode enumeration
See Also:
setAntiAlias(com.mindfusion.diagramming.SmoothingMode)

getDelKeyAction

public int getDelKeyAction()
Gets a value that specifies what action should be carried out when the user hits the Del key.

Returns:
A member of the DelKeyAction enumeration.

setDelKeyAction

public void setDelKeyAction(int delKeyAction)
Sets a value that specifies what action should be carried out when the user hits the Del key.

Parameters:
A - member of the DelKeyAction enumeration.

ancestorAdded

public void ancestorAdded(javax.swing.event.AncestorEvent event)
Implements AncestorListener. Call the base method if you inherit the Diagram class and need to override this method.

Specified by:
ancestorAdded in interface javax.swing.event.AncestorListener

ancestorRemoved

public void ancestorRemoved(javax.swing.event.AncestorEvent event)
Implements AncestorListener. Call the base method if you inherit the Diagram class and need to override this method.

Specified by:
ancestorRemoved in interface javax.swing.event.AncestorListener

ancestorMoved

public void ancestorMoved(javax.swing.event.AncestorEvent event)
Implements AncestorListener. Call the base method if you inherit the Diagram class and need to override this method.

Specified by:
ancestorMoved in interface javax.swing.event.AncestorListener

getDiagram

public Diagram getDiagram()
Gets the diagram displayed by this view.


setDiagram

public void setDiagram(Diagram value)
Sets the diagram displayed by this view.