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 doublem_ActualZoomthe actual zoom to use.protected booleanm_BestFitwhether to use best fit.protected BufferedImagem_BrightImagethe brightened image.protected floatm_Brightnessthe brightness.protected booleanm_Draggingwhether the image is being dragged.protected booleanm_DraggingEnabledwhether dragging is enabled.protected ImageFileChooserm_FileChooserthe file dialog for saving the image.protected booleanm_FirstDisplayfirst display.protected BufferedImagem_Imagethe image to display.protected InteractionLoggingFilterm_InteractionLoggingFilterthe interaction logger in use.protected Floatm_LastBrightnessthe last brightness.protected Pointm_LastDraggingPointthe last point position while dragging.protected ObjectAnnotationPanelm_Ownerthe owner.protected PopupMenuCustomizerm_PopupMenuCustomizerthe popup menu customizer to use.protected booleanm_ResizeRequiredwhether a resize is required.protected doublem_Zoomthe 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyToClipboard()Copies the image to the clipboard.protected JPopupMenucreatePopupMenu()Creates the popup.static StringdraggingHelp()Returns the help information on dragging the image.doublegetActualZoom()Returns the actual zoom in use (taking best fit into account if set).booleangetBestFit()Sets whether to use best fit.floatgetBrightness()Returns the brightness to use.BufferedImagegetImage()Returns the image on display.InteractionLoggingFiltergetInteractionLoggingFilter()Returns the interaction log filter in use.PointgetLastDraggingPoint()Returns the last point of the image being dragged.ObjectAnnotationPanelgetOwner()Returns the owner.PopupMenuCustomizergetPopupMenuCustomizer()Returns the popup menu customizer in use.doublegetZoom()Returns the current zoom.protected voidinitGUI()Initializes the widgets.protected voidinitialize()Initializes the members.booleanisDragging()Returns whether the image is currently being dragged.booleanisDraggingEnabled()Returns whether the image can be dragged.voidlogMouseButtonClick(MouseEvent e)Logs a mouse click.voidlogMouseButtonPressed(MouseEvent e)Logs a mouse button pressed.voidlogMouseButtonReleased(MouseEvent e)Logs a mouse button released.voidlogMouseWheel(MouseWheelEvent e, double oldZoom, double newZoom)Logs a mouse wheel event (zoom).voidlogScale(double newScale)Logs a scale change from the menu.PointmouseToPixelLocation(Point mousePos)Turns the mouse position into pixel location.voidpaint(Graphics g)Paints the image or just a white background.voidpaint(Graphics g, double zoom)Paints the image or just a white background at full resolution.PointpixelToMouseLocation(Point pixelPos)Converts the pixel position (at 100% zoom) to a mouse location.voidsaveAs()Saves the image to disk.voidsetBestFit(boolean value)Sets whether to use best fit or specified zoom.voidsetBrightness(float value)Sets the brightness to use.voidsetImage(BufferedImage value)Sets the image to display.voidsetInteractionLoggingFilter(InteractionLoggingFilter value)Sets the interaction log filter to use.voidsetOwner(ObjectAnnotationPanel value)Sets the owner.voidsetPopupMenuCustomizer(PopupMenuCustomizer value)Sets the popup menu customizer to use.voidsetZoom(double value)Sets the zoom.voidupdate()Updates the image.voidupdate(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.
-
m_DraggingEnabled
protected boolean m_DraggingEnabled
whether dragging is enabled.
-
m_Dragging
protected boolean m_Dragging
whether the image is being dragged.
-
m_LastDraggingPoint
protected Point m_LastDraggingPoint
the last point position while dragging.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
setOwner
public void setOwner(ObjectAnnotationPanel value)
Sets the owner.- Parameters:
value- the owner
-
getOwner
public ObjectAnnotationPanel getOwner()
Returns the owner.- Returns:
- the owner
-
isDraggingEnabled
public boolean isDraggingEnabled()
Returns whether the image can be dragged.- Returns:
- true if dragged is enabled
-
isDragging
public boolean isDragging()
Returns whether the image is currently being dragged.- Returns:
- true if dragged
-
getLastDraggingPoint
public Point getLastDraggingPoint()
Returns the last point of the image being dragged.- Returns:
- the last point, null if not set
-
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:
paintin classJComponent- Parameters:
g- the graphics context
-
paint
public void paint(Graphics g, double zoom)
Paints the image or just a white background at full resolution.- Parameters:
g- the graphics contextzoom- the zoom to use (1.0 = 100%)
-
draggingHelp
public static String draggingHelp()
Returns the help information on dragging the image.- Returns:
- the help string
-
-