Package net.sf.jaxodraw.gui
Class AbstractJaxoCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- net.sf.jaxodraw.gui.AbstractJaxoCanvas
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.beans.PropertyChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.swing.Scrollable
,JaxoCanvasComponent
,JaxoDrawingArea
,JaxoLocalized
- Direct Known Subclasses:
JaxoCanvas
public abstract class AbstractJaxoCanvas extends javax.swing.JComponent implements JaxoDrawingArea
Abstract base class for the canvas.- Since:
- 2.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface net.sf.jaxodraw.gui.JaxoDrawingArea
DEFAULT_HELP_COLOR, DEFAULT_HELP_STROKE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractJaxoCanvas()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.awt.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.java.awt.Color
getCanvasBackground()
Background color in the region that is actually covered by the canvasgetCanvasSize()
, which is the whole canvas, unless the effective maximum size is smaller than the component size.java.awt.Rectangle
getCanvasBounds()
Part of the component that is covered by the actual canvas.protected JaxoGraph
getCanvasGraph()
Returns the current graph.java.awt.Point
getCanvasOrigin()
Origin of the actual canvas within the component.java.awt.Dimension
getCanvasSize()
Canvas size.JaxoGraph
getClipboard()
Gets the current clipboard.protected java.awt.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.java.awt.Dimension
getMaximumCanvasSize()
Maximum size of the canvas (even if there are objects with a larger bounding box).java.awt.Dimension
getMinimumCanvasSize()
Minimum size of the canvas (even if there are no objects or they have a smaller bounding box).java.awt.Dimension
getPreferredScrollableViewportSize()
Return the preferred size of the viewport.protected java.awt.Rectangle
getScreenBounds(JaxoObject o)
Determines the bounds of the given object on the screen.int
getScrollableBlockIncrement(java.awt.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(java.awt.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(java.awt.Graphics2D g, java.awt.Rectangle rect)
Paint background (unless covered by grid), and grid (if on).void
propertyChange(java.beans.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(java.awt.geom.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(java.awt.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(java.awt.Dimension value)
Sets the maximum canvas size.void
setMinimumCanvasSize(java.awt.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(java.awt.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(java.awt.Point p)
Snap the given point to the current grid.protected java.awt.Point
toComponentCoordinates(java.awt.Point p)
Point 'p' in graph coordinates converted to component coordinates.protected java.awt.Rectangle
toComponentCoordinates(java.awt.Rectangle r)
A Rectangle in graph coordinates converted to component coordinates.protected java.awt.Point
toGraphCoordinates(java.awt.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, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, 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
-
Methods inherited from interface net.sf.jaxodraw.gui.JaxoDrawingArea
clear, continueEdit, continueSelect, editNearestObject, finalizeEdit, finalizeSelect, groupMarkedObjects, initiateEdit, initiateSelect, markImageInvalid, moveSelection, pasteFromClipboard, refresh, ungroupMarkedObjects, updatePointsAid
-
-
-
-
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
-
-
Method Detail
-
getFboxPopup
protected final JaxoFBoxPopupMenu getFboxPopup()
The JaxoFBoxPopupMenu for this canvas.- Returns:
- a JaxoFBoxPopupMenu, not null.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
asComponent
public java.awt.Component asComponent()
Return this CanvasComponent as a Component.- Specified by:
asComponent
in interfaceJaxoCanvasComponent
- 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 interfaceJaxoDrawingArea
- 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 interfaceJaxoDrawingArea
- 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 interfaceJaxoDrawingArea
-
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 interfaceJaxoDrawingArea
-
unMarkGraph
public boolean unMarkGraph()
Sets all objects in the current graph as not marked.- Specified by:
unMarkGraph
in interfaceJaxoDrawingArea
- 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 java.awt.Color getCanvasBackground()
Background color in the region that is actually covered by the canvasgetCanvasSize()
, 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 interfaceJaxoCanvasComponent
- Returns:
- The canvas background color.
-
setCanvasBackground
public void setCanvasBackground(java.awt.Color color)
Sets the color of the background.- Specified by:
setCanvasBackground
in interfaceJaxoCanvasComponent
- Parameters:
color
- The background color.
-
getCanvasOrigin
public java.awt.Point getCanvasOrigin()
Origin of the actual canvas within the component. This is always the top-left corner.- Specified by:
getCanvasOrigin
in interfaceJaxoCanvasComponent
- Returns:
- a Point at the origin.
-
getCanvasBounds
public java.awt.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 interfaceJaxoCanvasComponent
- Returns:
- Rectangle the canvas bounds.
- See Also:
JaxoCanvasComponent.getCanvasSize()
,JaxoCanvasComponent.getCanvasOrigin()
-
getCanvasSize
public java.awt.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 interfaceJaxoCanvasComponent
- Returns:
- The canvas size.
-
getMinimumCanvasSize
public java.awt.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 interfaceJaxoCanvasComponent
- Returns:
- The minimum canvas size.
-
setMinimumCanvasSize
public void setMinimumCanvasSize(java.awt.Dimension value)
Sets the minimum canvas size.- Specified by:
setMinimumCanvasSize
in interfaceJaxoCanvasComponent
- Parameters:
value
- The minimum canvas size.
-
getMaximumCanvasSize
public java.awt.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 interfaceJaxoCanvasComponent
- Returns:
- The maximum canvas size.
-
setMaximumCanvasSize
public void setMaximumCanvasSize(java.awt.Dimension value)
Sets the maximum canvas size.- Specified by:
setMaximumCanvasSize
in interfaceJaxoCanvasComponent
- Parameters:
value
- The maximum canvas size.
-
getEffectiveMaximumCanvasSize
protected java.awt.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 java.awt.Point toGraphCoordinates(java.awt.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 java.awt.Point toComponentCoordinates(java.awt.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 java.awt.Rectangle toComponentCoordinates(java.awt.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 java.awt.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 interfaceJaxoDrawingArea
- 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 interfaceJaxoDrawingArea
- 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 java.awt.Dimension getPreferredScrollableViewportSize()
Return the preferred size of the viewport.- Specified by:
getPreferredScrollableViewportSize
in interfacejavax.swing.Scrollable
- Returns:
- The preferred size of the viewport.
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
Return the unit increment for scrolling.- Specified by:
getScrollableUnitIncrement
in interfacejavax.swing.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(java.awt.Rectangle visibleRect, int orientation, int direction)
Return the unit increment for block scrolling.- Specified by:
getScrollableBlockIncrement
in interfacejavax.swing.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 interfacejavax.swing.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 interfacejavax.swing.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 interfaceJaxoDrawingArea
- 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(java.awt.Graphics2D g, java.awt.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(java.awt.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 interfaceJaxoLocalized
-
repaintBoundingBox
protected void repaintBoundingBox(java.awt.geom.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(java.awt.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.
-
-