Package adams.gui.visualization.object
Class CanvasPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.object.CanvasPanel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class CanvasPanel extends BasePanel
For drawing the image and overlays.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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 Modifier and Type Field Description protected double
m_ActualZoom
the actual zoom to use.protected boolean
m_BestFit
whether to use best fit.protected BufferedImage
m_BrightImage
the brightened image.protected float
m_Brightness
the brightness.protected ImageFileChooser
m_FileChooser
the file dialog for saving the image.protected boolean
m_FirstDisplay
first display.protected BufferedImage
m_Image
the image to display.protected InteractionLoggingFilter
m_InteractionLoggingFilter
the interaction logger in use.protected Float
m_LastBrightness
the last brightness.protected ObjectAnnotationPanel
m_Owner
the owner.protected PopupMenuCustomizer
m_PopupMenuCustomizer
the popup menu customizer to use.protected boolean
m_ResizeRequired
whether a resize is required.protected double
m_Zoom
the zoom (1.0 = 100%).-
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
-
-
Constructor Summary
Constructors Constructor Description CanvasPanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyToClipboard()
Copies the image to the clipboard.protected JPopupMenu
createPopupMenu()
Creates the popup.double
getActualZoom()
Returns the actual zoom in use (taking best fit into account if set).boolean
getBestFit()
Sets whether to use best fit.float
getBrightness()
Returns the brightness to use.BufferedImage
getImage()
Returns the image on display.InteractionLoggingFilter
getInteractionLoggingFilter()
Returns the interaction log filter in use.ObjectAnnotationPanel
getOwner()
Returns the owner.PopupMenuCustomizer
getPopupMenuCustomizer()
Returns the popup menu customizer in use.double
getZoom()
Returns the current zoom.protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.void
logMouseButtonClick(MouseEvent e)
Logs a mouse click.void
logMouseButtonPressed(MouseEvent e)
Logs a mouse button pressed.void
logMouseButtonReleased(MouseEvent e)
Logs a mouse button released.void
logMouseWheel(MouseWheelEvent e, double oldZoom, double newZoom)
Logs a mouse wheel event (zoom).void
logScale(double newScale)
Logs a scale change from the menu.Point
mouseToPixelLocation(Point mousePos)
Turns the mouse position into pixel location.void
paint(Graphics g)
Paints the image or just a white background.Point
pixelToMouseLocation(Point pixelPos)
Converts the pixel position (at 100% zoom) to a mouse location.void
saveAs()
Saves the image to disk.void
setBestFit(boolean value)
Sets whether to use best fit or specified zoom.void
setBrightness(float value)
Sets the brightness to use.void
setImage(BufferedImage value)
Sets the image to display.void
setInteractionLoggingFilter(InteractionLoggingFilter value)
Sets the interaction log filter to use.void
setOwner(ObjectAnnotationPanel value)
Sets the owner.void
setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the popup menu customizer to use.void
setZoom(double value)
Sets the zoom.void
update()
Updates the image.void
update(boolean doLayout)
Updates the image.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, unregisterKeyboardAction, update
-
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, 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
-
-
-
-
Field Detail
-
m_Owner
protected ObjectAnnotationPanel m_Owner
the owner.
-
m_Image
protected BufferedImage m_Image
the image to display.
-
m_BestFit
protected boolean m_BestFit
whether to use best fit.
-
m_Zoom
protected double m_Zoom
the zoom (1.0 = 100%).
-
m_ActualZoom
protected double m_ActualZoom
the actual zoom to use.
-
m_Brightness
protected float m_Brightness
the brightness.
-
m_LastBrightness
protected Float m_LastBrightness
the last brightness.
-
m_BrightImage
protected BufferedImage m_BrightImage
the brightened image.
-
m_ResizeRequired
protected boolean m_ResizeRequired
whether a resize is required.
-
m_FirstDisplay
protected boolean m_FirstDisplay
first display.
-
m_InteractionLoggingFilter
protected InteractionLoggingFilter m_InteractionLoggingFilter
the interaction logger in use.
-
m_PopupMenuCustomizer
protected PopupMenuCustomizer m_PopupMenuCustomizer
the popup menu customizer to use.
-
m_FileChooser
protected ImageFileChooser m_FileChooser
the file dialog for saving the image.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
setOwner
public void setOwner(ObjectAnnotationPanel value)
Sets the owner.- Parameters:
value
- the owner
-
getOwner
public ObjectAnnotationPanel getOwner()
Returns the owner.- Returns:
- the owner
-
setBestFit
public void setBestFit(boolean value)
Sets whether to use best fit or specified zoom.- Parameters:
value
- true if to use best fit
-
getBestFit
public boolean getBestFit()
Sets whether to use best fit.- Returns:
- true if to use best fit
-
setZoom
public void setZoom(double value)
Sets the zoom.- Parameters:
value
- the zoom to use (1 = 100%)
-
getZoom
public double getZoom()
Returns the current zoom.- Returns:
- the zoom (1 = 100%)
-
getActualZoom
public double getActualZoom()
Returns the actual zoom in use (taking best fit into account if set).- Returns:
- the zoom in use (1 = 100%)
-
setBrightness
public void setBrightness(float value)
Sets the brightness to use.- Parameters:
value
- the brightness (100 = default)
-
getBrightness
public float getBrightness()
Returns the brightness to use.- Returns:
- the brightness (100 = default)
-
setImage
public void setImage(BufferedImage value)
Sets the image to display.- Parameters:
value
- the image, null for none
-
getImage
public BufferedImage getImage()
Returns the image on display.- Returns:
- the image, null if none set
-
setInteractionLoggingFilter
public void setInteractionLoggingFilter(InteractionLoggingFilter value)
Sets the interaction log filter to use.- Parameters:
value
- the filter
-
getInteractionLoggingFilter
public InteractionLoggingFilter getInteractionLoggingFilter()
Returns the interaction log filter in use.- Returns:
- the filter
-
setPopupMenuCustomizer
public void setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the popup menu customizer to use.- Parameters:
value
- the customizer, null to unset
-
getPopupMenuCustomizer
public PopupMenuCustomizer getPopupMenuCustomizer()
Returns the popup menu customizer in use.- Returns:
- the customizer, null if none used
-
createPopupMenu
protected JPopupMenu createPopupMenu()
Creates the popup.- Returns:
- the popup menu
-
copyToClipboard
public void copyToClipboard()
Copies the image to the clipboard.
-
saveAs
public void saveAs()
Saves the image to disk.
-
update
public void update()
Updates the image.
-
update
public void update(boolean doLayout)
Updates the image.- Parameters:
doLayout
- whether to update the layout
-
mouseToPixelLocation
public Point mouseToPixelLocation(Point mousePos)
Turns the mouse position into pixel location. Limits the pixel position to the size of the image, i.e., no negative pixel locations or ones that exceed the image size are generated.- Parameters:
mousePos
- the mouse position- Returns:
- the pixel location
-
pixelToMouseLocation
public Point pixelToMouseLocation(Point pixelPos)
Converts the pixel position (at 100% zoom) to a mouse location.- Parameters:
pixelPos
- the pixel position- Returns:
- the mouse position
-
logMouseButtonPressed
public void logMouseButtonPressed(MouseEvent e)
Logs a mouse button pressed.- Parameters:
e
- the mouse event to record
-
logMouseButtonClick
public void logMouseButtonClick(MouseEvent e)
Logs a mouse click.- Parameters:
e
- the mouse event to record
-
logMouseButtonReleased
public void logMouseButtonReleased(MouseEvent e)
Logs a mouse button released.- Parameters:
e
- the mouse event to record
-
logMouseWheel
public void logMouseWheel(MouseWheelEvent e, double oldZoom, double newZoom)
Logs a mouse wheel event (zoom).- Parameters:
e
- the mouse wheel event to recordoldZoom
- the old zoomnewZoom
- the new zoom
-
logScale
public void logScale(double newScale)
Logs a scale change from the menu.- Parameters:
newScale
- the new scale
-
paint
public void paint(Graphics g)
Paints the image or just a white background.- Overrides:
paint
in classJComponent
- Parameters:
g
- the graphics context
-
-