Package adams.flow.transformer
Class ImageAnnotator.AnnotatorPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.flow.transformer.ImageAnnotator.AnnotatorPanel
-
- All Implemented Interfaces:
ImagePanelLeftClickListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
- Enclosing class:
- ImageAnnotator
public static class ImageAnnotator.AnnotatorPanel extends BasePanel implements ImagePanelLeftClickListener
Panel for annotating an image.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- 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 ImageOverlay
m_ActualOverlay
the actual overlay to use for highlighting the objects.protected SelectionProcessor
m_ActualSelectionProcessor
the actual selection processor.protected ButtonGroup
m_ButtonGroup
the button group.protected BaseToggleButton[]
m_ButtonLabels
the label buttons.protected BaseButton
m_ButtonReset
the reset button.protected BaseToggleButton
m_ButtonUnset
the unset button.protected AbstractImageContainer
m_CurrentImage
the current image.protected String
m_CurrentLabel
the current label.protected Double
m_CurrentScale
the current scale.protected InteractionLoggingFilter
m_InteractionLoggingFilter
the interaction logger to use.protected BaseString[]
m_Labels
the labels.protected LocatedObjects
m_Objects
the rectangles of the located objects.protected ImageOverlay
m_Overlay
the overlay to use for highlighting the objects.protected ImagePanel
m_PanelImage
the image panel.protected String
m_Prefix
the prefix to use in the report.protected Report
m_ReportBackup
the backup of the report.protected SelectionProcessor
m_SelectionProcessor
the selection processor to apply.protected SelectionShapePainter
m_SelectionShapePainter
the painter for the selection shape.protected String
m_Suffix
the suffix to use for the labels.protected double
m_Zoom
the zoom level.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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 AnnotatorPanel(String prefix, String suffix, BaseString[] labels, SelectionProcessor selectionProcessor, SelectionShapePainter selectionShapePainter, ImageOverlay overlay, double zoom, InteractionLoggingFilter interactionLoggingFilter)
Initializes the panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearInteractionLog()
Clears the interaction log.void
clicked(ImagePanelLeftClickEvent e)
Invoked when a left-click happened in anImagePanel
.protected void
finishInit()
finishes the initialization.AbstractImageContainer
getCurrentImage()
Returns the current image.String
getCurrentLabel()
Returns the currently used label.Report
getCurrentReport()
Returns the current report.ImagePanel
getImagePanel()
Returns the underlying image panel.List<InteractionEvent>
getInteractionLog()
Returns the interaction log.int
getMainDividerLocation()
Returns the divider location between image and properties.boolean
hasInteractionLog()
Checks whether there have been any interactions recorded.void
imageChanged(ImagePanel.PaintPanel panel)
Notifies the overlay that the image has changed.protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.protected void
logLabelClick(boolean add, LocatedObject object, String label)
Logs the addition/removal of a label.protected void
logObjectRemoval(LocatedObject object)
Logs the removal of an object.protected void
notifyLabelChange(String label)
Sends notifications that the label has changed.void
preselectLabel(String label)
Pre-selects the label.protected void
resetLabels()
Resets all the labels.void
setCurrentImage(AbstractImageContainer value)
Sets the current image.void
setCurrentImage(AbstractImageContainer value, double zoom)
Sets the current image.protected void
setCurrentLabel(String label)
Sets the label to use from now on.void
setMainDividerLocation(int value)
Sets the divider location between image and properties.protected void
updateLabelButtons()
Updates the colors of the label button.protected void
updateObjects()
Reads the object locations from the report.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, 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, paint, 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_Prefix
protected String m_Prefix
the prefix to use in the report.
-
m_Suffix
protected String m_Suffix
the suffix to use for the labels.
-
m_Labels
protected BaseString[] m_Labels
the labels.
-
m_SelectionProcessor
protected SelectionProcessor m_SelectionProcessor
the selection processor to apply.
-
m_SelectionShapePainter
protected SelectionShapePainter m_SelectionShapePainter
the painter for the selection shape.
-
m_Overlay
protected ImageOverlay m_Overlay
the overlay to use for highlighting the objects.
-
m_Zoom
protected double m_Zoom
the zoom level.
-
m_InteractionLoggingFilter
protected InteractionLoggingFilter m_InteractionLoggingFilter
the interaction logger to use.
-
m_ButtonLabels
protected BaseToggleButton[] m_ButtonLabels
the label buttons.
-
m_ButtonUnset
protected BaseToggleButton m_ButtonUnset
the unset button.
-
m_ButtonReset
protected BaseButton m_ButtonReset
the reset button.
-
m_ButtonGroup
protected ButtonGroup m_ButtonGroup
the button group.
-
m_PanelImage
protected ImagePanel m_PanelImage
the image panel.
-
m_CurrentLabel
protected String m_CurrentLabel
the current label.
-
m_CurrentImage
protected AbstractImageContainer m_CurrentImage
the current image.
-
m_ReportBackup
protected Report m_ReportBackup
the backup of the report.
-
m_Objects
protected LocatedObjects m_Objects
the rectangles of the located objects.
-
m_CurrentScale
protected Double m_CurrentScale
the current scale.
-
m_ActualSelectionProcessor
protected SelectionProcessor m_ActualSelectionProcessor
the actual selection processor.
-
m_ActualOverlay
protected ImageOverlay m_ActualOverlay
the actual overlay to use for highlighting the objects.
-
-
Constructor Detail
-
AnnotatorPanel
public AnnotatorPanel(String prefix, String suffix, BaseString[] labels, SelectionProcessor selectionProcessor, SelectionShapePainter selectionShapePainter, ImageOverlay overlay, double zoom, InteractionLoggingFilter interactionLoggingFilter)
Initializes the panel.- Parameters:
prefix
- the prefix in the reportsuffix
- the suffix in the reportlabels
- the labelsselectionProcessor
- the selection processselectionShapePainter
- the painteroverlay
- the overlayzoom
- the zoominteractionLoggingFilter
- the interaction logger
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
finishInit
protected void finishInit()
finishes the initialization.- Overrides:
finishInit
in classBasePanel
-
getImagePanel
public ImagePanel getImagePanel()
Returns the underlying image panel.- Returns:
- the panel
-
updateLabelButtons
protected void updateLabelButtons()
Updates the colors of the label button.
-
setCurrentLabel
protected void setCurrentLabel(String label)
Sets the label to use from now on.- Parameters:
label
- the label, null if to unset
-
notifyLabelChange
protected void notifyLabelChange(String label)
Sends notifications that the label has changed.- Parameters:
label
- the new label
-
getCurrentLabel
public String getCurrentLabel()
Returns the currently used label.- Returns:
- the label
-
resetLabels
protected void resetLabels()
Resets all the labels.
-
preselectLabel
public void preselectLabel(String label)
Pre-selects the label.- Parameters:
label
- the label to use, ignored if null
-
getMainDividerLocation
public int getMainDividerLocation()
Returns the divider location between image and properties.- Returns:
- the position
-
setMainDividerLocation
public void setMainDividerLocation(int value)
Sets the divider location between image and properties.- Parameters:
value
- the position
-
setCurrentImage
public void setCurrentImage(AbstractImageContainer value)
Sets the current image.- Parameters:
value
- the image
-
setCurrentImage
public void setCurrentImage(AbstractImageContainer value, double zoom)
Sets the current image.- Parameters:
value
- the imagezoom
- the zoom to use
-
getCurrentImage
public AbstractImageContainer getCurrentImage()
Returns the current image.- Returns:
- the image
-
getCurrentReport
public Report getCurrentReport()
Returns the current report.- Returns:
- the report
-
updateObjects
protected void updateObjects()
Reads the object locations from the report.
-
imageChanged
public void imageChanged(ImagePanel.PaintPanel panel)
Notifies the overlay that the image has changed.- Specified by:
imageChanged
in interfaceImagePanelLeftClickListener
- Parameters:
panel
- the panel this overlay belongs to
-
logLabelClick
protected void logLabelClick(boolean add, LocatedObject object, String label)
Logs the addition/removal of a label.- Parameters:
add
- true if label added, false if removedobject
- the affected objectlabel
- the label, can be null
-
logObjectRemoval
protected void logObjectRemoval(LocatedObject object)
Logs the removal of an object.- Parameters:
object
- the removed object
-
clicked
public void clicked(ImagePanelLeftClickEvent e)
Invoked when a left-click happened in anImagePanel
.- Specified by:
clicked
in interfaceImagePanelLeftClickListener
- Parameters:
e
- the event
-
clearInteractionLog
public void clearInteractionLog()
Clears the interaction log.
-
hasInteractionLog
public boolean hasInteractionLog()
Checks whether there have been any interactions recorded.- Returns:
- true if interactions are available
-
getInteractionLog
public List<InteractionEvent> getInteractionLog()
Returns the interaction log.- Returns:
- the log, null if nothing recorded
-
-