net.sf.jaxodraw.gui
Class AbstractJaxoCanvas

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
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable, JaxoCanvasComponent, JaxoDrawingArea, JaxoLocalized
Direct Known Subclasses:
JaxoCanvas

public abstract class AbstractJaxoCanvas
extends JComponent
implements JaxoDrawingArea

Abstract base class for the canvas.

Since:
2.1
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
protected static int HANDLE_PAINT_OFF
          Do not paint handles.
protected static int HANDLE_PAINT_ON
          Paint handles.
protected static int HANDLE_PAINT_SELECTION
          Only paint handles of selected objects.
protected static boolean 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
protected AbstractJaxoCanvas()
          Constructor.
 
Method Summary
 Component asComponent()
          Return this CanvasComponent as a Component.
protected  boolean canPasteGraphFromSystemClipboard()
          Check if the system clipboard contains a JaxoGraph.
 void copyMarkedObjects()
          Puts the current clipboard to the system clipboard.
 void cutMarkedObjects()
          Copies the current clipboard to the system clipboard and removes the corresponding objects from the drawing area.
protected abstract  void deleteMarkedObjects()
          Deletes all 'marked' objects from the drawing area and the current canvas graph.
 Color getCanvasBackground()
          Background color in the region that is actually covered by the canvas getCanvasSize(), which is the whole canvas, unless the effective maximum size is smaller than the component size.
 Rectangle getCanvasBounds()
          Part of the component that is covered by the actual canvas.
protected  JaxoGraph getCanvasGraph()
          Returns the current graph.
 Point getCanvasOrigin()
          Origin of the actual canvas within the component.
 Dimension getCanvasSize()
          Canvas size.
 JaxoGraph getClipboard()
          Gets the current clipboard.
protected  Dimension getEffectiveMaximumCanvasSize()
          The effective maximum canvas size.
protected  JaxoFBoxPopupMenu getFboxPopup()
          The JaxoFBoxPopupMenu for this canvas.
protected  JaxoPaintableGrid getGrid()
          Grid to be used.
protected  JaxoHandle getHandle()
          The currently set handle.
protected  int getHandlePaintMode()
          How to paint handles.
 Dimension getMaximumCanvasSize()
          Maximum size of the canvas (even if there are objects with a larger bounding box).
 Dimension getMinimumCanvasSize()
          Minimum size of the canvas (even if there are no objects or they have a smaller bounding box).
 Dimension getPreferredScrollableViewportSize()
          Return the preferred size of the viewport.
protected  Rectangle getScreenBounds(JaxoObject o)
          Determines the bounds of the given object on the screen.
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
          Return the unit increment for block scrolling.
 boolean getScrollableTracksViewportHeight()
          Return true if a viewport should force the height of the scrollable.
 boolean getScrollableTracksViewportWidth()
          Return true if a viewport should force the width of the scrollable.
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
          Return the unit increment for scrolling.
protected  JaxoGraph getSystemClipboardGraph()
          Graph on the system clipboard.
 JaxoZoom getZoom()
          Return a zoom on this drawing area.
protected  boolean isAntialiasEnabled()
          Determines if objects are painted with antialiasing turned on.
protected  void markBackgroundInvalid()
          Mark background or grid invalid (but not the graph/objects).
 void markImageInvalid()
          Mark the whole image as invalid.
 void moveGraph(int dx, int dy)
          Displace the whole graph by a given offset.
protected  void paintBackgroundAndGrid(Graphics2D g, Rectangle rect)
          Paint background (unless covered by grid), and grid (if on).
 void propertyChange(PropertyChangeEvent evt)
          
protected  void putToSystemClipboard(JaxoGraph g)
          Make 'g' the contents of the system clipboard.
protected abstract  void rebuildImage()
          Build a new off-screen image.
protected  void repaintBoundingBox(Rectangle2D r)
          Repaint the given Rectangle in graph coordinates.
protected abstract  void revalidateCanvas()
          Resets the preferred size of the canvas.
 void setAntialiasEnabled(boolean value)
          Sets the antialias property.
 void setCanvasBackground(Color color)
          Sets the color of the background.
 void setCanvasGraph(JaxoGraph value)
          Sets the graph to be painted.
 void setCanvasGraphAndGrid(JaxoGraph newGraph, JaxoPaintableGrid newGrid)
          Set both graph and grid.
 void setGrid(JaxoPaintableGrid value)
          Sets the grid to be painted on this drawing area.
 void setHandle(JaxoHandle newHandle)
          Sets a new handle.
protected  void setHandlePaintMode(int value)
          Sets how to paint handles.
 void setMaximumCanvasSize(Dimension value)
          Sets the maximum canvas size.
 void setMinimumCanvasSize(Dimension value)
          Sets the minimum canvas size.
protected  boolean showColorPanel(JaxoObject ob)
          Brings up a ColorChooser panel for the given object.
protected  boolean showEditPanel(JaxoObject o)
          Bring up an EditPanel to edit properties of the given JaxoObject.
protected  boolean showSelectionPanel(Point location)
          Brings up the faint-box popup panel for the current selection.
protected  void snapObject(JaxoObject o)
          Moves the given JaxoObject so that its first point is snapped to the current grid.
protected  void snapPoint(Point p)
          Snap the given point to the current grid.
protected  Point toComponentCoordinates(Point p)
          Point 'p' in graph coordinates converted to component coordinates.
protected  Rectangle toComponentCoordinates(Rectangle r)
          A Rectangle in graph coordinates converted to component coordinates.
protected  Point toGraphCoordinates(Point p)
          Point 'p' in component coordinates converted to graph coordinates.
 boolean unMarkGraph()
          Sets all objects in the current graph as not marked.
 void updateLanguage()
          Updates the language on any localized sub-components.
protected abstract  void updateMode(int mode)
          Resets canvas parameters for the given mode.
 
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, paintComponent, paintImmediately, paintImmediately, paramString, 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, 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.JaxoDrawingArea
clear, continueEdit, continueSelect, editNearestObject, finalizeEdit, finalizeSelect, groupMarkedObjects, initiateEdit, initiateSelect, markImageInvalid, moveSelection, pasteFromClipboard, refresh, ungroupMarkedObjects, updatePointsAid
 
Methods inherited from interface net.sf.jaxodraw.gui.JaxoCanvasComponent
addMouseListener, addMouseMotionListener, addPropertyChangeListener, getGraphics, print, removeMouseListener, removeMouseMotionListener, repaint
 

Field Detail

HANDLE_PAINT_OFF

protected static final int HANDLE_PAINT_OFF
Do not paint handles.

See Also:
Constant Field Values

HANDLE_PAINT_ON

protected static final int HANDLE_PAINT_ON
Paint handles.

See Also:
Constant Field Values

HANDLE_PAINT_SELECTION

protected static final int HANDLE_PAINT_SELECTION
Only paint handles of selected objects.

See Also:
Constant Field Values

HOVERING_EDITED_OBJECTS

protected static final boolean HOVERING_EDITED_OBJECTS
See Also:
Constant Field Values
Constructor Detail

AbstractJaxoCanvas

protected AbstractJaxoCanvas()
Constructor.

Method Detail

getFboxPopup

protected final JaxoFBoxPopupMenu getFboxPopup()
The JaxoFBoxPopupMenu for this canvas.

Returns:
a JaxoFBoxPopupMenu, not null.

propertyChange

public void propertyChange(PropertyChangeEvent evt)

Specified by:
propertyChange in interface PropertyChangeListener

asComponent

public Component asComponent()
Return this CanvasComponent as a Component.

Specified by:
asComponent in interface JaxoCanvasComponent
Returns:
this CanvasComponent as a Component or null, if this is not a Component.

getHandle

protected JaxoHandle getHandle()
The currently set handle.

Returns:
The current handle.

setHandle

public void setHandle(JaxoHandle newHandle)
Sets a new handle.

Parameters:
newHandle - The handle to set.

getHandlePaintMode

protected int getHandlePaintMode()
How to paint handles.

Returns:
the current handle paint mode.

setHandlePaintMode

protected void setHandlePaintMode(int value)
Sets how to paint handles.

Parameters:
value - One of the HANDLE_PAINT constants.

getCanvasGraph

protected JaxoGraph getCanvasGraph()
Returns the current graph.

Returns:
The current graph.

setCanvasGraph

public void setCanvasGraph(JaxoGraph value)
Sets the graph to be painted.

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

moveGraph

public void moveGraph(int dx,
                      int dy)
Displace the whole graph by a given offset.

Specified by:
moveGraph in interface JaxoDrawingArea
Parameters:
dx - the offset in x direction.
dy - the offset in y direction.

copyMarkedObjects

public void copyMarkedObjects()
Puts the current clipboard to the system clipboard.

Specified by:
copyMarkedObjects in interface JaxoDrawingArea

cutMarkedObjects

public void cutMarkedObjects()
Copies the current clipboard to the system clipboard and removes the corresponding objects from the drawing area.

Specified by:
cutMarkedObjects in interface JaxoDrawingArea

unMarkGraph

public boolean unMarkGraph()
Sets all objects in the current graph as not marked.

Specified by:
unMarkGraph in interface JaxoDrawingArea
Returns:
true if the graph had actually contained marked objects. In this case the canvas was also repainted. False otherwise, in which case this method has no effect.

getCanvasBackground

public Color getCanvasBackground()
Background color in the region that is actually covered by the canvas getCanvasSize(), which is the whole canvas, unless the effective maximum size is smaller than the component size. Note that this color may be overwritten by the grid.

Specified by:
getCanvasBackground in interface JaxoCanvasComponent
Returns:
The canvas background color.

setCanvasBackground

public void setCanvasBackground(Color color)
Sets the color of the background.

Specified by:
setCanvasBackground in interface JaxoCanvasComponent
Parameters:
color - The background color.

getCanvasOrigin

public Point getCanvasOrigin()
Origin of the actual canvas within the component. This is always the top-left corner.

Specified by:
getCanvasOrigin in interface JaxoCanvasComponent
Returns:
a Point at the origin.

getCanvasBounds

public Rectangle getCanvasBounds()
Part of the component that is covered by the actual canvas. This includes canvas background and grid, -- i.e. a rectangle with size 'canvasSize' and origin 'canvasOrigin'.

Specified by:
getCanvasBounds in interface JaxoCanvasComponent
Returns:
Rectangle the canvas bounds.
See Also:
JaxoCanvasComponent.getCanvasSize(), JaxoCanvasComponent.getCanvasOrigin()

getCanvasSize

public Dimension getCanvasSize()
Canvas size. This is equal to the (inner) component size unless because of viewport size tracking, the component has become larger than the effective maximum canvas size.

Specified by:
getCanvasSize in interface JaxoCanvasComponent
Returns:
The canvas size.

getMinimumCanvasSize

public Dimension getMinimumCanvasSize()
Minimum size of the canvas (even if there are no objects or they have a smaller bounding box). The default value is (0,0).

Specified by:
getMinimumCanvasSize in interface JaxoCanvasComponent
Returns:
The minimum canvas size.

setMinimumCanvasSize

public void setMinimumCanvasSize(Dimension value)
Sets the minimum canvas size.

Specified by:
setMinimumCanvasSize in interface JaxoCanvasComponent
Parameters:
value - The minimum canvas size.

getMaximumCanvasSize

public Dimension getMaximumCanvasSize()
Maximum size of the canvas (even if there are objects with a larger bounding box). The default value is larger than (0,0). If the maximum canvas size is smaller (in either direction) than the minimum canvas size, the latter wins.

Specified by:
getMaximumCanvasSize in interface JaxoCanvasComponent
Returns:
The maximum canvas size.

setMaximumCanvasSize

public void setMaximumCanvasSize(Dimension value)
Sets the maximum canvas size.

Specified by:
setMaximumCanvasSize in interface JaxoCanvasComponent
Parameters:
value - The maximum canvas size.

getEffectiveMaximumCanvasSize

protected Dimension getEffectiveMaximumCanvasSize()
The effective maximum canvas size. This is equal to the maximum canvas size, but with a lower bound of minimum canvas size for width and height.

Returns:
the effective maximum canvas size.

toGraphCoordinates

protected Point toGraphCoordinates(Point p)
Point 'p' in component coordinates converted to graph coordinates. At the moment, only translated by canvas origin.

Parameters:
p - Point in component coordinates.
Returns:
Point in graph coordinates.

toComponentCoordinates

protected Point toComponentCoordinates(Point p)
Point 'p' in graph coordinates converted to component coordinates. At the moment, only translated by canvas origin.

Parameters:
p - Point in graph coordinates.
Returns:
Point in component coordinates.

toComponentCoordinates

protected Rectangle toComponentCoordinates(Rectangle r)
A Rectangle in graph coordinates converted to component coordinates. At the moment, only translated by canvas origin.

Parameters:
r - Rectangle in graph coordinates.
Returns:
Rectangle in component coordinates.

getScreenBounds

protected Rectangle getScreenBounds(JaxoObject o)
Determines the bounds of the given object on the screen.

Parameters:
o - the JaxoObject.
Returns:
Rectangle

getZoom

public JaxoZoom getZoom()
Return a zoom on this drawing area.

Specified by:
getZoom in interface JaxoDrawingArea
Returns:
a zoom on this drawing area.

getGrid

protected JaxoPaintableGrid getGrid()
Grid to be used. A non-null grid is painted and potentially used for snapping points. If grid properties change, the canvas automatically updates and repaints itself.

Returns:
The grid currently used by this canvas. May be null.

setGrid

public void setGrid(JaxoPaintableGrid value)
Sets the grid to be painted on this drawing area.

Specified by:
setGrid in interface JaxoDrawingArea
Parameters:
value - The new grid. May be null.

setCanvasGraphAndGrid

public void setCanvasGraphAndGrid(JaxoGraph newGraph,
                                  JaxoPaintableGrid newGrid)
Set both graph and grid. This is an optimization to avoid painting to the background image twice (because that is done synchronously).

Parameters:
newGraph - The new graph.
newGrid - The new grid.

isAntialiasEnabled

protected boolean isAntialiasEnabled()
Determines if objects are painted with antialiasing turned on. This does not apply to handles.

Returns:
True if antialising is enabled.

setAntialiasEnabled

public void setAntialiasEnabled(boolean value)
Sets the antialias property.

Parameters:
value - True if antialising should be enabled.

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Return the preferred size of the viewport.

Specified by:
getPreferredScrollableViewportSize in interface Scrollable
Returns:
The preferred size of the viewport.

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Return the unit increment for scrolling.

Specified by:
getScrollableUnitIncrement in interface Scrollable
Parameters:
visibleRect - the visible view area.
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - less than zero to scroll up/left, greater than zero for down/right.
Returns:
Returns 6.

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Return the unit increment for block scrolling.

Specified by:
getScrollableBlockIncrement in interface Scrollable
Parameters:
visibleRect - the visible view area.
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - less than zero to scroll up/left, greater than zero for down/right.
Returns:
Returns the width/height of visibleRect depending on orientation.

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Return true if a viewport should force the width of the scrollable.

Specified by:
getScrollableTracksViewportWidth in interface Scrollable
Returns:
true if the parent's width is larger than the width of the preferred size.

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Return true if a viewport should force the height of the scrollable.

Specified by:
getScrollableTracksViewportHeight in interface Scrollable
Returns:
true if the parent's height is larger than the height of the preferred size.

canPasteGraphFromSystemClipboard

protected boolean canPasteGraphFromSystemClipboard()
Check if the system clipboard contains a JaxoGraph.

Returns:
true if the system clipboard contains a JaxoGraph, false otherwise.

getSystemClipboardGraph

protected JaxoGraph getSystemClipboardGraph()
Graph on the system clipboard.

Returns:
the current graph on the system clipboard, or null if none.

putToSystemClipboard

protected void putToSystemClipboard(JaxoGraph g)
Make 'g' the contents of the system clipboard.

Parameters:
g - the graph to put on the clipboard.

getClipboard

public JaxoGraph getClipboard()
Gets the current clipboard. This never returns null.

Specified by:
getClipboard in interface JaxoDrawingArea
Returns:
A JaxoGraph holding all the objects that are currently on the clipboard, or an empty graph, if the clipboard is empty.

markBackgroundInvalid

protected void markBackgroundInvalid()
Mark background or grid invalid (but not the graph/objects).


markImageInvalid

public void markImageInvalid()
Mark the whole image as invalid. Currently this repaints everything at once, could be changed to defer until later.


paintBackgroundAndGrid

protected void paintBackgroundAndGrid(Graphics2D g,
                                      Rectangle rect)
Paint background (unless covered by grid), and grid (if on). This method may change the graphics clip and color.

Parameters:
g - the graphics context to paint to.
rect - the rectangle to paint.

snapPoint

protected void snapPoint(Point p)
Snap the given point to the current grid. If the current grid is null, does nothing.

Parameters:
p - the point to snap.

snapObject

protected void snapObject(JaxoObject o)
Moves the given JaxoObject so that its first point is snapped to the current grid. If the current grid is null, does nothing.

Parameters:
o - the JaxoObject to snap.

updateLanguage

public void updateLanguage()
Updates the language on any localized sub-components.

Specified by:
updateLanguage in interface JaxoLocalized

repaintBoundingBox

protected void repaintBoundingBox(Rectangle2D r)
Repaint the given Rectangle in graph coordinates. Currently these are always the same as component coordinates.

Parameters:
r - the Rectangle to repaint.

showColorPanel

protected boolean showColorPanel(JaxoObject ob)
Brings up a ColorChooser panel for the given object.

Parameters:
ob - the object to edit.
Returns:
true if the color of the object has been changed, false if it is unchanged.

showSelectionPanel

protected boolean showSelectionPanel(Point location)
Brings up the faint-box popup panel for the current selection.

Parameters:
location - the location of the popup panel.
Returns:
true if the selection panel was actually shown. This is the case if either the graph contained marked objects (i.e. the selection is not empty) or there are currently objects on the clipboard to paste. Returns false if none of this is the case.

showEditPanel

protected boolean showEditPanel(JaxoObject o)
Bring up an EditPanel to edit properties of the given JaxoObject.

Parameters:
o - the object to edit.
Returns:
true if the object has been modified, false if the object was unchanged.

revalidateCanvas

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


rebuildImage

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


deleteMarkedObjects

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


updateMode

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

Parameters:
mode - The mode to adjust to.


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