public final class JaxoCanvas
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.Scrollable
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
JaxoCanvas(JaxoMainPanel mainPanel)
Constructs a new canvas within the specified panel.
|
Modifier and Type | Method and Description |
---|---|
void |
applyPrefs()
Applies the preferences.
|
void |
clear()
Clears the canvas.
|
void |
copyMarkedObjects()
Puts the current clipboard to the system clipboard.
|
void |
deleteMarkedObjects()
Deletes all 'marked' objects from the current canvas graph.
|
java.awt.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. |
java.awt.Rectangle |
getCanvasBounds()
Part of the component that is covered by the actual canvas.
|
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.
|
JaxoDefaultGrid |
getGrid()
Grid to be used, may be null.
|
JaxoHandle |
getHandle()
The current handle.
|
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.
|
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.
|
JaxoZoom |
getZoom()
Return the zoom of this canvas.
|
void |
groupMarkedObjects()
Groups the currently marked objects.
|
boolean |
isAntialiasEnabled()
Should objects (but not handles) be painted with
antialiasing turned explicitly on?
|
boolean |
isGridPainted()
Whether the grid is painted.
|
boolean |
isSnappingToGrid()
Determines if points are snapped to the grid.
|
void |
markImageInvalid()
Mark the whole image as invalid.
|
void |
markImageInvalid(java.awt.Rectangle boundingBox)
Mark the specified region as invalid.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
The action to be taken when the mouse is clicked on the canvas.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
The action to be taken when the mouse is dragged on the canvas.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Process the event when the mouse enters the canvas.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Process the event when the mouse exits the canvas.
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Process the event when the mouse is moved on the canvas.
|
void |
mousePressed(java.awt.event.MouseEvent e)
The action to be taken when the mouse is pressed on the canvas.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
The action to be taken when the mouse is released on the canvas.
|
void |
moveSelection(boolean backGround)
Moves the currently selected objects into either fore- or background.
|
protected void |
paintComponent(java.awt.Graphics g)
Paint the Canvas.
|
void |
pasteFromClipboard()
Paste the objects currently on the clipboard.
|
protected void |
printComponent(java.awt.Graphics gr)
Print the Canvas.
|
void |
refresh()
Refresh the canvas.
|
void |
setAntialiasEnabled(boolean value)
Sets the antialias property.
|
void |
setCanvasBackground(java.awt.Color value)
Sets the color of the background.
|
void |
setCanvasGraph(JaxoGraph value)
Sets the current graph.
|
void |
setCanvasGraphAndGrid(JaxoGraph newGraph,
JaxoDefaultGrid newGrid)
Set both graph and grid.
|
void |
setGrid(JaxoDefaultGrid value)
Sets the grid to be used by this canvas.
|
void |
setGridPainted(boolean value)
Switches the grid painting on/off.
|
void |
setHandle(JaxoHandle newHandle)
Sets the handle.
|
void |
setMaximumCanvasSize(java.awt.Dimension value)
Sets the maximum canvas size.
|
void |
setMinimumCanvasSize(java.awt.Dimension value)
Sets the minimum canvas size.
|
void |
setMouseLocation(java.awt.Point value)
Sets the current mouse location in graph coordinates.
|
void |
setSnappingToGrid(boolean value)
Switches snapping on/off.
|
void |
setZoom(JaxoZoom newZoom)
Set the zoom for this canvas.
|
void |
ungroupMarkedObjects()
Ungroup (one level) all marked objects.
|
void |
ungroupSelectedObject()
If the selected object is a group, ungroup it.
|
void |
updateLanguage()
Updates the language on any localized sub-components.
|
void |
updateMode(int mode)
Resets canvas parameters for the given mode.
|
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, isPaintingOrigin, 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
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
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, transferFocusBackward, transferFocusUpCycle
public JaxoCanvas(JaxoMainPanel mainPanel)
mainPanel
- An instance of the main panel.public java.awt.Point getCanvasOrigin()
public java.awt.Rectangle getCanvasBounds()
getCanvasSize()
,
getCanvasOrigin()
public void markImageInvalid()
public void markImageInvalid(java.awt.Rectangle boundingBox)
boundingBox
- The region to update.public void refresh()
public java.awt.Color getCanvasBackground()
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.public void setCanvasBackground(java.awt.Color value)
value
- The background color.public boolean isSnappingToGrid()
public void setSnappingToGrid(boolean value)
value
- Whether to snap or not.public boolean isAntialiasEnabled()
public void setAntialiasEnabled(boolean value)
value
- True if antialising should be enabled.public boolean isGridPainted()
public void setGridPainted(boolean value)
value
- True if the grid should be painted.public JaxoDefaultGrid getGrid()
public void setGrid(JaxoDefaultGrid value)
value
- The new grid.public void updateLanguage()
public void setCanvasGraphAndGrid(JaxoGraph newGraph, JaxoDefaultGrid newGrid)
newGraph
- The new graph.newGrid
- The new grid.public void setCanvasGraph(JaxoGraph value)
value
- The graph to be set.public JaxoGraph getCanvasGraph()
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- The graphics context to paint to.protected void printComponent(java.awt.Graphics gr)
printComponent
in class javax.swing.JComponent
gr
- The graphics context to print to.public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- The corresponding mouse event.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- The corresponding mouse event.public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- The corresponding mouse event.public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- The corresponding mouse event.public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- The mouse event to process.public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- The mouse event to process.public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- The mouse event to process.public void setMouseLocation(java.awt.Point value)
value
- The new mouse coordinates.public java.awt.Dimension getCanvasSize()
public java.awt.Dimension getMinimumCanvasSize()
public void setMinimumCanvasSize(java.awt.Dimension value)
value
- The minimum canvas size.public java.awt.Dimension getMaximumCanvasSize()
public void setMaximumCanvasSize(java.awt.Dimension value)
value
- The maximum canvas size.public JaxoHandle getHandle()
public void setHandle(JaxoHandle newHandle)
newHandle
- The handle to set.public void applyPrefs()
public void copyMarkedObjects()
public JaxoGraph getClipboard()
public void pasteFromClipboard()
public void deleteMarkedObjects()
public void ungroupMarkedObjects()
public void ungroupSelectedObject()
public void groupMarkedObjects()
public void updateMode(int mode)
mode
- The mode to adjust to.public void clear()
public void moveSelection(boolean backGround)
backGround
- True for moving into background, false for foreground.public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
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.public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
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.public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public JaxoZoom getZoom()
public void setZoom(JaxoZoom newZoom)
newZoom
- the zoom to set.Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.