japlot.jaxodraw
Class JaxoCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- japlot.jaxodraw.JaxoCanvas
-
- All Implemented Interfaces:
- java.awt.event.ComponentListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
public class JaxoCanvas extends javax.swing.JPanel implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ComponentListenerAn instance of the canvas: responsible for all the drawing.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field and Description static java.awt.ColorBCKG_COLORThe background color of the canvas.static intHANDLE_LLThe lower left handle.static intHANDLE_LRThe lower right handle.static intHANDLE_ULThe upper left handle.static intHANDLE_URThe upper right handle.javax.swing.JMenuItemm_axesjavax.swing.JMenuItemm_clearjavax.swing.JMenuItemm_datajavax.swing.JMenuItemm_infojavax.swing.JMenuItemm_refresh-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description JaxoCanvas(JaxoMainPanel mainPanel)Constructs a new canvas within the specified panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclearOffScreenImage()Clears the offScreenImage.voidcomponentHidden(java.awt.event.ComponentEvent e)voidcomponentMoved(java.awt.event.ComponentEvent e)voidcomponentResized(java.awt.event.ComponentEvent e)voidcomponentShown(java.awt.event.ComponentEvent e)voiddispose()Copies the offScreenImage to backupOffScreenImage.voiddrawVisualAid(boolean draw)Sets the visual aid to draw or not.voiddrawWithHandles(boolean draw)Sets handles to draw or not.java.awt.ColorgetBackgroundBox()JaxoGraphgetCanvasGraph()Returns the current graph.java.lang.StringgetCanvasTick()Returns the current tick.intgetDragMode()Returns the current drag mode.intgetGridSize()Returns the current size of the grid.booleangetGridType()Returns the current type of the grid.java.awt.ImagegetOffScreenImage()Returns the current offScreenImage.double[]getOldbb()Returns the old bounding box of the object.booleanhasBeenUsed()Indicates whether the current canvas has been used.booleanisWithHandles()Indicates whether handles are drawn.booleanisWithVisualAid()Indicates whether the visual aid is drawn.voidmouseClicked(java.awt.event.MouseEvent e)The action to be taken when the mouse is clicked on the canvas.voidmouseDragged(java.awt.event.MouseEvent e)The action to be taken when the mouse is dragged on the canvas.voidmouseEntered(java.awt.event.MouseEvent e)The action to be taken when the mouse enters the canvas.voidmouseExited(java.awt.event.MouseEvent e)The action to be taken when the mouse exits the canvas.voidmouseMoved(java.awt.event.MouseEvent e)The action to be taken when the mouse is moved on the canvas.voidmousePressed(java.awt.event.MouseEvent e)The action to be taken when the mouse is pressed on the canvas.voidmouseReleased(java.awt.event.MouseEvent e)The action to be taken when the mouse is released on the canvas.voidpaintComponent(java.awt.Graphics g)Paints the canvas.voidresetNOfClicks()When drawing arc objects: resets the number of clicks to zero.voidsaveBackupImage()Copies the offScreenImage to backupOffScreenImage.voidsetBackgroundBox(java.awt.Color c)voidsetCanvasGraph(JaxoGraph theGraph)Sets the current graph.voidsetCanvasTick(java.lang.String theTick)Sets the current tick.voidsetDragMode(int newDragMode)Sets the current drag mode.voidsetGridSize(int gs)Sets the size of the grid to the given value.voidsetGridType(boolean type)Sets the type of the grid.voidsetLanguage(java.lang.String languageString)Sets the text in different languages.voidsetOldbb(double[] bb)Sets the old bounding box of the object.voidshowCoordinates(java.awt.event.MouseEvent e)Show mouse coordinatesvoidswapImages()Swaps the current offScreenImage with the backupImage.voidunsavedCanvas()Indicates that the canvas contains a graph that is not saved.voidupdate()Redraw all componentsvoidupdate(java.awt.Graphics g)Updates the canvas by just calling paintComponent.voidupdateLocations()voidupdateObjectLocation()voidupdateOffScreenImage()Updates the offScreenImage within the current clipping area.voidupdateOffScreenImage(JaObject selectedOb)Updates the offScreenImage without drawing selectedOb.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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
-
-
-
-
Field Detail
-
HANDLE_UL
public static final int HANDLE_UL
The upper left handle.- See Also:
- Constant Field Values
-
HANDLE_LL
public static final int HANDLE_LL
The lower left handle.- See Also:
- Constant Field Values
-
HANDLE_LR
public static final int HANDLE_LR
The lower right handle.- See Also:
- Constant Field Values
-
HANDLE_UR
public static final int HANDLE_UR
The upper right handle.- See Also:
- Constant Field Values
-
BCKG_COLOR
public static java.awt.Color BCKG_COLOR
The background color of the canvas.
-
m_info
public javax.swing.JMenuItem m_info
-
m_data
public javax.swing.JMenuItem m_data
-
m_axes
public javax.swing.JMenuItem m_axes
-
m_refresh
public javax.swing.JMenuItem m_refresh
-
m_clear
public javax.swing.JMenuItem m_clear
-
-
Constructor Detail
-
JaxoCanvas
public JaxoCanvas(JaxoMainPanel mainPanel)
Constructs a new canvas within the specified panel.- Parameters:
mainPanel- An instance of the main panel.
-
-
Method Detail
-
setCanvasGraph
public final void setCanvasGraph(JaxoGraph theGraph)
Sets the current graph.- Parameters:
theGraph- The graph to be set.
-
getCanvasGraph
public final JaxoGraph getCanvasGraph()
Returns the current graph.- Returns:
- The current graph.
-
setCanvasTick
public final void setCanvasTick(java.lang.String theTick)
Sets the current tick.- Parameters:
theTick- The current tick.
-
getCanvasTick
public final java.lang.String getCanvasTick()
Returns the current tick.- Returns:
- The current tick.
-
getDragMode
public final int getDragMode()
Returns the current drag mode.- Returns:
- The current drag mode.
-
setDragMode
public final void setDragMode(int newDragMode)
Sets the current drag mode.- Parameters:
newDragMode- The drag mode to be set.
-
getOldbb
public final double[] getOldbb()
Returns the old bounding box of the object.- Returns:
- The bounding box of the object befor dragging.
-
setOldbb
public final void setOldbb(double[] bb)
Sets the old bounding box of the object.- Parameters:
bb- The old bounding box of the object
-
update
public final void update(java.awt.Graphics g)
Updates the canvas by just calling paintComponent.- Overrides:
updatein classjavax.swing.JComponent- Parameters:
g- The specified graphics context.
-
paintComponent
public final void paintComponent(java.awt.Graphics g)
Paints the canvas.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
g- The specified graphics context.
-
getOffScreenImage
public final java.awt.Image getOffScreenImage()
Returns the current offScreenImage.- Returns:
- The current offScreenImage.
-
setBackgroundBox
public void setBackgroundBox(java.awt.Color c)
-
getBackgroundBox
public java.awt.Color getBackgroundBox()
-
dispose
public final void dispose()
Copies the offScreenImage to backupOffScreenImage.
-
saveBackupImage
public final void saveBackupImage()
Copies the offScreenImage to backupOffScreenImage.
-
swapImages
public final void swapImages()
Swaps the current offScreenImage with the backupImage.
-
clearOffScreenImage
public final void clearOffScreenImage()
Clears the offScreenImage.
-
updateOffScreenImage
public final void updateOffScreenImage()
Updates the offScreenImage within the current clipping area.
-
updateOffScreenImage
public final void updateOffScreenImage(JaObject selectedOb)
Updates the offScreenImage without drawing selectedOb.- Parameters:
selectedOb- The JaObject to be excluded from the update.
-
showCoordinates
public final void showCoordinates(java.awt.event.MouseEvent e)
Show mouse coordinates- Parameters:
e- The corresponding mouse event.
-
mouseClicked
public final void mouseClicked(java.awt.event.MouseEvent e)
The action to be taken when the mouse is clicked on the canvas.- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Parameters:
e- The corresponding mouse event.
-
mousePressed
public final void mousePressed(java.awt.event.MouseEvent e)
The action to be taken when the mouse is pressed on the canvas.- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Parameters:
e- The corresponding mouse event.
-
mouseDragged
public final void mouseDragged(java.awt.event.MouseEvent e)
The action to be taken when the mouse is dragged on the canvas.- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Parameters:
e- The corresponding mouse event.
-
mouseReleased
public final void mouseReleased(java.awt.event.MouseEvent e)
The action to be taken when the mouse is released on the canvas.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Parameters:
e- The corresponding mouse event.
-
mouseExited
public final void mouseExited(java.awt.event.MouseEvent e)
The action to be taken when the mouse exits the canvas.- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Parameters:
e- The corresponding mouse event.
-
mouseEntered
public final void mouseEntered(java.awt.event.MouseEvent e)
The action to be taken when the mouse enters the canvas.- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Parameters:
e- The corresponding mouse event.
-
mouseMoved
public final void mouseMoved(java.awt.event.MouseEvent e)
The action to be taken when the mouse is moved on the canvas.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Parameters:
e- The corresponding mouse event.
-
update
public void update()
Redraw all components
-
setGridSize
public final void setGridSize(int gs)
Sets the size of the grid to the given value.- Parameters:
gs- The grid size to be set.
-
getGridSize
public final int getGridSize()
Returns the current size of the grid.- Returns:
- The grid size.
-
setGridType
public final void setGridType(boolean type)
Sets the type of the grid.- Parameters:
type- The type of the grid to be set.
-
getGridType
public final boolean getGridType()
Returns the current type of the grid.- Returns:
- The type of the grid.
-
unsavedCanvas
public final void unsavedCanvas()
Indicates that the canvas contains a graph that is not saved.
-
hasBeenUsed
public final boolean hasBeenUsed()
Indicates whether the current canvas has been used.- Returns:
- True, if the canvas has been modified, false otherwise.
-
isWithHandles
public final boolean isWithHandles()
Indicates whether handles are drawn.- Returns:
- True, if handles are drawn, false otherwise.
-
drawWithHandles
public final void drawWithHandles(boolean draw)
Sets handles to draw or not.- Parameters:
draw- True, if handles should be drawn, false otherwise.
-
isWithVisualAid
public final boolean isWithVisualAid()
Indicates whether the visual aid is drawn.- Returns:
- True, if the visual aid is drawn, false otherwise.
-
drawVisualAid
public final void drawVisualAid(boolean draw)
Sets the visual aid to draw or not.- Parameters:
draw- True, if the visual aid should be drawn, false otherwise.
-
setLanguage
public final void setLanguage(java.lang.String languageString)
Sets the text in different languages.- Parameters:
languageString- A string specifying the language to be set.
-
resetNOfClicks
public final void resetNOfClicks()
When drawing arc objects: resets the number of clicks to zero.
-
updateObjectLocation
public void updateObjectLocation()
-
updateLocations
public void updateLocations()
-
componentResized
public void componentResized(java.awt.event.ComponentEvent e)
- Specified by:
componentResizedin interfacejava.awt.event.ComponentListener
-
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)
- Specified by:
componentMovedin interfacejava.awt.event.ComponentListener
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShownin interfacejava.awt.event.ComponentListener
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHiddenin interfacejava.awt.event.ComponentListener
-
-
DMelt 3.0 © DataMelt by jWork.ORG