net.sf.jaxodraw.gui
Class JaxoCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.sf.jaxodraw.gui.AbstractJaxoCanvas
                  extended by net.sf.jaxodraw.gui.JaxoCanvas
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable, JaxoCanvasComponent, JaxoDrawingArea, JaxoLocalized

public final class JaxoCanvas
extends AbstractJaxoCanvas

An instance of the canvas: responsible for all the painting.

Since:
2.0
See Also:
Serialized Form

Nested Class Summary
 
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
 
Fields inherited from class net.sf.jaxodraw.gui.AbstractJaxoCanvas
HANDLE_PAINT_OFF, HANDLE_PAINT_ON, HANDLE_PAINT_SELECTION, HOVERING_EDITED_OBJECTS
 
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 net.sf.jaxodraw.gui.JaxoDrawingArea
DEFAULT_HELP_COLOR, DEFAULT_HELP_STROKE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JaxoCanvas(ActionListener listener)
          Constructs a new canvas.
 
Method Summary
 void clear()
          Clears the drawing area.
 void continueEdit(Point p, Point last)
          Continue an edit actione that has been initiated before.
 void continueSelect(Point p)
          Carry on a select action that was started previously.
protected  void deleteMarkedObjects()
          Deletes all 'marked' objects from the drawing area and the current canvas graph.
 void editNearestObject(Point p)
          Determine the closest object to the given point and bring up an edit panel for it.
 void finalizeEdit()
          Finalize a user input action.
 void finalizeSelect(Point p)
          End a select action.
 void groupMarkedObjects()
          Groups the currently marked objects.
 void initiateEdit(Point p)
          Start an edit action at a given point.
 void initiateSelect(Point p)
          Start a select action.
 void markImageInvalid(Rectangle boundingBox)
          Mark the specified region as invalid.
 void moveSelection(boolean backGround)
          Moves the currently selected objects into either fore- or background.
protected  void paintComponent(Graphics g)
          Paint the Canvas.
 void pasteFromClipboard()
          Paste the objects currently on the clipboard.
protected  void printComponent(Graphics gr)
          Print the Canvas.
protected  void rebuildImage()
          Build a new off-screen image.
 void refresh()
          Refresh the canvas.
protected  void revalidateCanvas()
          Resets the preferred size of the canvas.
 void setCanvasGraph(JaxoGraph value)
          Sets the current graph.
 void ungroupMarkedObjects()
          Ungroup all marked objects.
 void ungroupSelectedObject()
          If the selected object is a group, ungroup it.
 void updateMode(int mode)
          Resets canvas parameters for the given mode.
 void updatePointsAid(Point p)
          Updates the visual aid that is painted for objects in click-move mode.
 
Methods inherited from class net.sf.jaxodraw.gui.AbstractJaxoCanvas
asComponent, canPasteGraphFromSystemClipboard, copyMarkedObjects, cutMarkedObjects, getCanvasBackground, getCanvasBounds, getCanvasGraph, getCanvasOrigin, getCanvasSize, getClipboard, getEffectiveMaximumCanvasSize, getFboxPopup, getGrid, getHandle, getHandlePaintMode, getMaximumCanvasSize, getMinimumCanvasSize, getPreferredScrollableViewportSize, getScreenBounds, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSystemClipboardGraph, getZoom, isAntialiasEnabled, markBackgroundInvalid, markImageInvalid, moveGraph, paintBackgroundAndGrid, propertyChange, putToSystemClipboard, repaintBoundingBox, setAntialiasEnabled, setCanvasBackground, setCanvasGraphAndGrid, setGrid, setHandle, setHandlePaintMode, setMaximumCanvasSize, setMinimumCanvasSize, showColorPanel, showEditPanel, showSelectionPanel, snapObject, snapPoint, toComponentCoordinates, toComponentCoordinates, toGraphCoordinates, unMarkGraph, updateLanguage
 
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, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, 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, 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, getFont, 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, 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
 
Methods inherited from interface net.sf.jaxodraw.gui.JaxoCanvasComponent
addMouseListener, addMouseMotionListener, addPropertyChangeListener, getGraphics, print, removeMouseListener, removeMouseMotionListener, repaint
 

Constructor Detail

JaxoCanvas

public JaxoCanvas(ActionListener listener)
Constructs a new canvas.

Parameters:
listener - An ActionListener to receive events from the Canvas.
Method Detail

markImageInvalid

public void markImageInvalid(Rectangle boundingBox)
Mark the specified region as invalid. Currently this is also synchronous.

Parameters:
boundingBox - The region to update. May be null in which case the whole image is marked for update.

refresh

public void refresh()
Refresh the canvas. This should basically clean up any drawing operation and repaint the drawing area.


setCanvasGraph

public void setCanvasGraph(JaxoGraph value)
Sets the current graph. Also clears the hovering object.

Specified by:
setCanvasGraph in interface JaxoDrawingArea
Overrides:
setCanvasGraph in class AbstractJaxoCanvas
Parameters:
value - The graph to be set.

paintComponent

protected void paintComponent(Graphics g)
Paint the Canvas.

Overrides:
paintComponent in class JComponent
Parameters:
g - The graphics context to paint to.

printComponent

protected void printComponent(Graphics gr)
Print the Canvas.

Overrides:
printComponent in class JComponent
Parameters:
gr - The graphics context to print to.

rebuildImage

protected void rebuildImage()
Build a new off-screen image. This should only be needed for resizing the canvas.

Specified by:
rebuildImage in class AbstractJaxoCanvas

revalidateCanvas

protected void revalidateCanvas()
Resets the preferred size of the canvas.

Specified by:
revalidateCanvas in class AbstractJaxoCanvas

deleteMarkedObjects

protected void deleteMarkedObjects()
Deletes all 'marked' objects from the drawing area and the current canvas graph.

Specified by:
deleteMarkedObjects in class AbstractJaxoCanvas

pasteFromClipboard

public void pasteFromClipboard()
Paste the objects currently on the clipboard.


ungroupMarkedObjects

public void ungroupMarkedObjects()
Ungroup all marked objects. This is not recursive, only one level is resolved.


ungroupSelectedObject

public void ungroupSelectedObject()
If the selected object is a group, ungroup it.


groupMarkedObjects

public void groupMarkedObjects()
Groups the currently marked objects.


updateMode

public void updateMode(int mode)
Resets canvas parameters for the given mode. Sets the cursor, and determines whether to draw visualAid and handles.

Specified by:
updateMode in class AbstractJaxoCanvas
Parameters:
mode - The mode to adjust to.

clear

public void clear()
Clears the drawing area.


moveSelection

public void moveSelection(boolean backGround)
Moves the currently selected objects into either fore- or background.

Parameters:
backGround - True for moving into background, false for foreground.

editNearestObject

public void editNearestObject(Point p)
Determine the closest object to the given point and bring up an edit panel for it.

Parameters:
p - the test point

initiateEdit

public void initiateEdit(Point p)
Start an edit action at a given point.

Parameters:
p - the point associated with the edit action.

continueEdit

public void continueEdit(Point p,
                         Point last)
Continue an edit actione that has been initiated before.

Parameters:
p - the point on this drawing area associated with the edit action.
last - the last recorded action point, or null if none.

finalizeEdit

public void finalizeEdit()
Finalize a user input action.


updatePointsAid

public void updatePointsAid(Point p)
Updates the visual aid that is painted for objects in click-move mode.

Parameters:
p - the current location of the cursor.

initiateSelect

public void initiateSelect(Point p)
Start a select action.

Parameters:
p - the point where the select action was started.

continueSelect

public void continueSelect(Point p)
Carry on a select action that was started previously.

Parameters:
p - the current point of the select action.

finalizeSelect

public void finalizeSelect(Point p)
End a select action.

Parameters:
p - the point where the select action was finished.


Copyright © 2003-2011 The JaxoDraw team. All Rights Reserved.