Package adams.gui.visualization.image
Class ImagePanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.core.UndoPanel
-
- adams.gui.visualization.image.ImagePanel
-
- All Implemented Interfaces:
CleanUpHandler
,StatusMessageHandler
,UndoHandler
,UndoHandlerWithQuickAccess
,UndoListener
,InteractionLogManager
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,TableModelListener
public class ImagePanel extends UndoPanel implements StatusMessageHandler, TableModelListener, CleanUpHandler, UndoHandlerWithQuickAccess, InteractionLogManager
For displaying a single image.
The scroll wheel allows zooming in/out. Mouse-wheel clicking sets scale back to 100%.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImagePanel.PaintPanel
The panel used for painting.-
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 Report
m_AdditionalProperties
the additional properties to display.protected Color
m_BackgroundColor
the background color.protected PlaceholderFile
m_CurrentFile
the current filename.protected List<Dialog>
m_DependentDialogs
list of dependent dialogs to clean up.protected List<Flow>
m_DependentFlows
list of dependent flows to clean up.protected ImageFileChooser
m_FileChooser
for determining readers and writers.protected Report
m_ImageProperties
the image properties.protected List<InteractionEvent>
m_InteractionLog
the interaction log.protected SplitPanelWithOptionalComponents
m_LeftSplitPanel
the left pane for displaying other panels.protected BaseSplitPane
m_MainSplitPane
for displaying image and properties.protected ReportFactory.Model
m_ModelProperties
the table model with all the properties.protected boolean
m_Modified
whether the image was modified.protected ImagePanel.PaintPanel
m_PaintPanel
the panel to paint on.protected BaseLogPanel
m_PanelLog
the panel for the log.protected BasePanel
m_PanelProperties
the panel with the properties.protected SearchPanel
m_PanelSearchProperties
the search panel for searching in the properties.protected double
m_Scale
the scale that the user chose.protected BaseScrollPane
m_ScrollPane
the JScrollPane that embeds the paint panel.protected BaseScrollPane
m_ScrollPaneProperties
the scrollpane for the properties.protected BaseTabbedPaneWithTabHiding
m_SideSplitPane
the tabbed pane (props/log).protected BaseStatusBar
m_StatusBar
the status bar label.protected ReportFactory.Table
m_TableProperties
the table with the image properties.static String
TAB_LOG
the tab title for the log.static String
TAB_PROPERTIES
the tab title for the properties.-
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 ImagePanel()
Initializes the panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDependentDialog(Dialog dlg)
Adds the dialog to the list of dialogs to be closed when the panel gets cleared or removed.void
addDependentFlow(Flow flow)
Adds the flow to the list of flows to be cleaned up when the panel gets cleared or removed.void
addImageOverlay(ImageOverlay io)
Adds the image overlay.void
addInteractionLog(InteractionEvent e)
Adds the interaction event to the log.void
addLeftClickListener(ImagePanelLeftClickListener l)
Adds the given listener to the internal list of left-click listeners.void
addPaintlet(Paintlet p)
Adds the paintlet to the internal list.void
addSelectionListener(ImagePanelSelectionListener l)
Adds the given listener to the internal list of selection listeners.void
addUndoPoint(String comment)
Adds an undo point with the given comment.void
addUndoPoint(String statusMsg, String undoComment)
Adds an undo point, if possible.double
calcActualScale(double scale)
Calculates the actual scale.void
cleanUp()
Cleans up data structures, frees up memory.void
clear()
Removes the image.void
clearImageOverlays()
Removes all image overlays.void
clearInteractionLog()
Clears the interaction log.void
clearLeftClickListeners()
Removes all left-click listeners.void
clearSelectionListeners()
Removes all selection listeners.void
displayProperties()
Displays the image and (optional) additional properties.void
export()
Exports the current image.double
getActualScale()
Returns the actual scaling factor (0-16).Report
getAdditionalProperties()
Returns the additional properties.Report
getAllProperties()
Returns the all the properties (image and additional combined).Color
getBackgroundColor()
Returns the background color.File
getCurrentFile()
Returns the current filename.BufferedImage
getCurrentImage()
Returns the underlying image.CustomPopupMenuProvider
getCustomPopupMenuProvider()
Returns the custom popup menu provider.Report
getImageProperties()
Returns the image properties by themselves.List<InteractionEvent>
getInteractionLog()
Returns the interaction log.InteractionLoggingFilter
getInteractionLoggingFilter()
Returns the interaction log filter in use.String
getLeftDetachedFrameTitle()
Returns the frame title for the detached left component.int
getLeftDividerLocation()
Returns the divider location between left panel and image.JPanel
getLeftPanel()
Returns the currently set left panel.int
getMainDividerLocation()
Returns the divider location between image and properties.ImagePanel.PaintPanel
getPaintPanel()
Returns the actual panel that displays the image.BaseScrollPane
getPropertiesScrollPane()
Returns the underlying table for the properties.ReportFactory.Table
getPropertiesTable()
Returns the underlying table for the properties.double
getScale()
Returns the scaling factor (0-16).BaseScrollPane
getScrollPane()
Returns the BaseScrollPane that embeds the paint panel.SelectionShapePainter
getSelectionShapePainter()
Returns the painter to use for the selection shape.boolean
getShowLog()
Returns whether the log is currently displayed or not.boolean
getShowProperties()
Returns whether the image properties are currently displayed or not.BaseSplitPane
getSplitPane()
Returns the split pane that shows image (left) and properties (right).protected List
getState()
Returns the current state of the panel.boolean
hasInteractionLog()
Checks whether there have been any interactions recorded.Iterator<ImageOverlay>
imageOverlays()
Returns an iterator over all the image overlays.protected void
initGUI()
Initializes the GUI.protected void
initialize()
Initializes the members.boolean
isModified()
Returns whether the image was modified or not.boolean
isSelectionEnabled()
Returns whether selection is enabled.boolean
load(File file)
Opens the file with the specified image reader.boolean
load(File file, double scale)
Opens the file with the specified image reader.boolean
load(File file, ImageReader reader)
Opens the file with the specified image reader.boolean
load(File file, ImageReader reader, double scale)
Opens the file with the specified image reader.void
loadReport()
Loads a report from a file.void
log(String msg)
Appends the message to the log.Point
mouseToPixelLocation(Point mousePos)
Turns the mouse position into pixel location.protected void
paintComponent(Graphics g)
Paints the component.Iterator<Paintlet>
paintlets()
Returns an iterator over all currently stored paintlets.Point
pixelToMouseLocation(Point pixelPos)
Converts the pixel position (at 100% scale) to a mouse location.void
redo()
performs a redo if possible.protected void
removeDependentDialogs()
Removes all dependent dialogs.protected void
removeDependentFlows()
Removes all dependent flows.void
removeImageOverlay(ImageOverlay io)
Removes the image overlay.void
removeImageOverlays(Class cls)
Removes all image overlay instances that are instances of the specified class.void
removeLeftClickListener(ImagePanelLeftClickListener l)
Removes the given listener from the internal list of left-click listeners.void
removeLeftPanel()
Removes the left panel and hides that part.void
removePaintlet(Paintlet p)
Removes this paintlet from its internal list.void
removeSelectionListener(ImagePanelSelectionListener l)
Removes the given listener from the internal list of selection listeners.boolean
save(File file)
Writes the current image to the given file.boolean
save(File file, ImageWriter<AbstractImageContainer> writer)
Writes the current image to the given file.void
saveReport()
Saves the report to a file.void
setAdditionalProperties(Report value)
Sets the additional properties.void
setBackgroundColor(Color value)
Sets the background color.void
setCurrentFile(File value)
Sets the filename of the current image.void
setCurrentImage(AbstractImageContainer value)
Sets the underlying image.void
setCurrentImage(AbstractImageContainer value, double scale)
Sets the underlying image.void
setCurrentImage(BufferedImage value)
Sets the underlying image.void
setCurrentImage(BufferedImage value, double scale)
Sets the underlying image.void
setCustomPopupMenuProvider(CustomPopupMenuProvider value)
Sets the custom popup menu provider.void
setInteractionLoggingFilter(InteractionLoggingFilter value)
Sets the interaction log filter to use.void
setLeftDetachedFrameTitle(String value)
Sets the frame title for the detached left component.void
setLeftDividerLocation(int value)
Sets the divider location between left panel and image.void
setLeftPanel(JPanel panel)
Sets the left panel and displays it.void
setMainDividerLocation(int value)
Sets the divider location between image and properties.void
setModified(boolean value)
Sets the modified state.void
setScale(double value)
Sets the scaling factor (0-16).void
setSelectionEnabled(boolean value)
Sets whether selection is enabled or not.void
setSelectionShapePainter(SelectionShapePainter value)
Sets the painter to use for the selection shape.void
setShowLog(boolean value)
Sets the display status of the log panel.void
setShowProperties(boolean value)
Sets the display status of the properties panel.protected void
setState(List value)
Sets the state of the image panel.void
showStatus(String msg)
Displays a message.void
tableChanged(TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.Polygon
traceToPolygon(List<Point> trace)
Turns the trace into a polygon.void
undo()
performs an undo if possible.void
undoOccurred(UndoEvent e)
An undo event, like add or remove, has occurred.protected void
updateImageProperties()
Updates the properties of the image.protected void
updateImageProperties(Report props)
Updates the properties of the image.protected boolean
updateProperties(Report modified, Report current)
Updates the current report: removes all the fields that are no longer present in the modified report, updates all modified fields.-
Methods inherited from class adams.gui.core.UndoPanel
getUndo, isUndoSupported, setUndo
-
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, paint, paintBorder, paintChildren, 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.gui.core.UndoHandler
getUndo, isUndoSupported, setUndo
-
-
-
-
Field Detail
-
TAB_PROPERTIES
public static final String TAB_PROPERTIES
the tab title for the properties.- See Also:
- Constant Field Values
-
TAB_LOG
public static final String TAB_LOG
the tab title for the log.- See Also:
- Constant Field Values
-
m_CurrentFile
protected PlaceholderFile m_CurrentFile
the current filename.
-
m_PaintPanel
protected ImagePanel.PaintPanel m_PaintPanel
the panel to paint on.
-
m_ScrollPane
protected BaseScrollPane m_ScrollPane
the JScrollPane that embeds the paint panel.
-
m_StatusBar
protected BaseStatusBar m_StatusBar
the status bar label.
-
m_SideSplitPane
protected BaseTabbedPaneWithTabHiding m_SideSplitPane
the tabbed pane (props/log).
-
m_PanelProperties
protected BasePanel m_PanelProperties
the panel with the properties.
-
m_ModelProperties
protected ReportFactory.Model m_ModelProperties
the table model with all the properties.
-
m_TableProperties
protected ReportFactory.Table m_TableProperties
the table with the image properties.
-
m_ScrollPaneProperties
protected BaseScrollPane m_ScrollPaneProperties
the scrollpane for the properties.
-
m_PanelSearchProperties
protected SearchPanel m_PanelSearchProperties
the search panel for searching in the properties.
-
m_MainSplitPane
protected BaseSplitPane m_MainSplitPane
for displaying image and properties.
-
m_LeftSplitPanel
protected SplitPanelWithOptionalComponents m_LeftSplitPanel
the left pane for displaying other panels.
-
m_BackgroundColor
protected Color m_BackgroundColor
the background color.
-
m_Modified
protected boolean m_Modified
whether the image was modified.
-
m_ImageProperties
protected Report m_ImageProperties
the image properties.
-
m_AdditionalProperties
protected Report m_AdditionalProperties
the additional properties to display.
-
m_PanelLog
protected BaseLogPanel m_PanelLog
the panel for the log.
-
m_Scale
protected double m_Scale
the scale that the user chose.
-
m_FileChooser
protected ImageFileChooser m_FileChooser
for determining readers and writers.
-
m_InteractionLog
protected List<InteractionEvent> m_InteractionLog
the interaction log.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classUndoPanel
-
getState
protected List getState()
Returns the current state of the panel.- Returns:
- the state
- See Also:
setState(List)
-
setState
protected void setState(List value)
Sets the state of the image panel.- Parameters:
value
- the state- See Also:
getState()
-
addUndoPoint
public void addUndoPoint(String statusMsg, String undoComment)
Adds an undo point, if possible.- Parameters:
statusMsg
- the status message to display while adding the undo pointundoComment
- the comment for the undo point
-
addUndoPoint
public void addUndoPoint(String comment)
Adds an undo point with the given comment.- Specified by:
addUndoPoint
in interfaceUndoHandlerWithQuickAccess
- Parameters:
comment
- the comment for the undo point
-
setCurrentImage
public void setCurrentImage(BufferedImage value)
Sets the underlying image. Removes the filename.- Parameters:
value
- the image to display
-
setCurrentImage
public void setCurrentImage(BufferedImage value, double scale)
Sets the underlying image. Removes the filename.- Parameters:
value
- the image to displayscale
- the scale to use
-
setCurrentImage
public void setCurrentImage(AbstractImageContainer value)
Sets the underlying image. Removes the filename.- Parameters:
value
- the image to display
-
setCurrentImage
public void setCurrentImage(AbstractImageContainer value, double scale)
Sets the underlying image. Removes the filename.- Parameters:
value
- the image to displayscale
- the scale to use
-
getCurrentImage
public BufferedImage getCurrentImage()
Returns the underlying image.- Returns:
- the current image, can be null
-
setCurrentFile
public void setCurrentFile(File value)
Sets the filename of the current image.
-
getCurrentFile
public File getCurrentFile()
Returns the current filename.- Returns:
- the current filename, can be null
-
setScale
public void setScale(double value)
Sets the scaling factor (0-16). Use -1 to fit inside panel.- Parameters:
value
- the scaling factor
-
getScale
public double getScale()
Returns the scaling factor (0-16).- Returns:
- the scaling factor
-
getActualScale
public double getActualScale()
Returns the actual scaling factor (0-16).- Returns:
- the scaling factor
-
calcActualScale
public double calcActualScale(double scale)
Calculates the actual scale.- Parameters:
scale
- the scale to use as basis- Returns:
- the actual scale to use
-
paintComponent
protected void paintComponent(Graphics g)
Paints the component. Also determines best fit scales.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- the graphics context
-
setBackgroundColor
public void setBackgroundColor(Color value)
Sets the background color.- Parameters:
value
- the color
-
getBackgroundColor
public Color getBackgroundColor()
Returns the background color.- Returns:
- the color
-
getScrollPane
public BaseScrollPane getScrollPane()
Returns the BaseScrollPane that embeds the paint panel.- Returns:
- the BaseScrollPane
-
getSplitPane
public BaseSplitPane getSplitPane()
Returns the split pane that shows image (left) and properties (right).- Returns:
- the split pane
-
getPropertiesTable
public ReportFactory.Table getPropertiesTable()
Returns the underlying table for the properties.- Returns:
- the table
-
getPropertiesScrollPane
public BaseScrollPane getPropertiesScrollPane()
Returns the underlying table for the properties.- Returns:
- the table
-
log
public void log(String msg)
Appends the message to the log.- Parameters:
msg
- the message to append
-
clear
public void clear()
Removes the image.
-
addDependentDialog
public void addDependentDialog(Dialog dlg)
Adds the dialog to the list of dialogs to be closed when the panel gets cleared or removed.- Parameters:
dlg
- the dialog to add
-
removeDependentDialogs
protected void removeDependentDialogs()
Removes all dependent dialogs.
-
addDependentFlow
public void addDependentFlow(Flow flow)
Adds the flow to the list of flows to be cleaned up when the panel gets cleared or removed.- Parameters:
flow
- the flow to add
-
removeDependentFlows
protected void removeDependentFlows()
Removes all dependent flows.
-
load
public boolean load(File file)
Opens the file with the specified image reader.- Parameters:
file
- the file to open- Returns:
- true if successfully read
-
load
public boolean load(File file, double scale)
Opens the file with the specified image reader.- Parameters:
file
- the file to openscale
- the scale to use- Returns:
- true if successfully read
-
load
public boolean load(File file, ImageReader reader)
Opens the file with the specified image reader.- Parameters:
file
- the file to openreader
- the reader to use, null for auto-detection- Returns:
- true if successfully read
-
load
public boolean load(File file, ImageReader reader, double scale)
Opens the file with the specified image reader.- Parameters:
file
- the file to openreader
- the reader to use, null for auto-detectionscale
- the scale to use- Returns:
- true if successfully read
-
save
public boolean save(File file)
Writes the current image to the given file. Sets the modified flag to false if successfully saved.- Parameters:
file
- the file to write to- Returns:
- true if successfully written, false if not or no image
- See Also:
isModified()
-
save
public boolean save(File file, ImageWriter<AbstractImageContainer> writer)
Writes the current image to the given file. Sets the modified flag to false if successfully saved.- Parameters:
file
- the file to write towriter
- the writer to use for writing the file, null for auto-detect- Returns:
- true if successfully written, false if not or no image
- See Also:
isModified()
-
export
public void export()
Exports the current image.
-
loadReport
public void loadReport()
Loads a report from a file.
-
saveReport
public void saveReport()
Saves the report to a file.
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandler
- Parameters:
msg
- the message to display
-
getShowProperties
public boolean getShowProperties()
Returns whether the image properties are currently displayed or not.- Returns:
- true if the properties are displayed
-
setShowProperties
public void setShowProperties(boolean value)
Sets the display status of the properties panel.- Parameters:
value
- if true then the properties get displayed
-
getShowLog
public boolean getShowLog()
Returns whether the log is currently displayed or not.- Returns:
- true if the log is displayed
-
setShowLog
public void setShowLog(boolean value)
Sets the display status of the log panel.- Parameters:
value
- if true then the log gets displayed
-
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
-
getLeftDividerLocation
public int getLeftDividerLocation()
Returns the divider location between left panel and image.- Returns:
- the position
-
setLeftDividerLocation
public void setLeftDividerLocation(int value)
Sets the divider location between left panel and image.- Parameters:
value
- the position
-
setLeftPanel
public void setLeftPanel(JPanel panel)
Sets the left panel and displays it.- Parameters:
panel
- the panel to display
-
getLeftPanel
public JPanel getLeftPanel()
Returns the currently set left panel.- Returns:
- the panel
-
removeLeftPanel
public void removeLeftPanel()
Removes the left panel and hides that part.
-
setLeftDetachedFrameTitle
public void setLeftDetachedFrameTitle(String value)
Sets the frame title for the detached left component.- Parameters:
value
- the title
-
getLeftDetachedFrameTitle
public String getLeftDetachedFrameTitle()
Returns the frame title for the detached left component.- Returns:
- the title
-
setModified
public void setModified(boolean value)
Sets the modified state.- Parameters:
value
- if true then the image gets flagged as modified
-
isModified
public boolean isModified()
Returns whether the image was modified or not.- Returns:
- true if modified
-
updateImageProperties
protected void updateImageProperties()
Updates the properties of the image.
-
updateImageProperties
protected void updateImageProperties(Report props)
Updates the properties of the image.- Parameters:
props
- additional properties, null to skip
-
displayProperties
public void displayProperties()
Displays the image and (optional) additional properties.
-
tableChanged
public void tableChanged(TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.- Specified by:
tableChanged
in interfaceTableModelListener
-
updateProperties
protected boolean updateProperties(Report modified, Report current)
Updates the current report: removes all the fields that are no longer present in the modified report, updates all modified fields.- Parameters:
modified
- the updated reportcurrent
- the report to update (ie remove fields from)- Returns:
- true if report changed
-
setAdditionalProperties
public void setAdditionalProperties(Report value)
Sets the additional properties.- Parameters:
value
- the properties, null to unset
-
getAdditionalProperties
public Report getAdditionalProperties()
Returns the additional properties.- Returns:
- the properties, null if none set
-
getImageProperties
public Report getImageProperties()
Returns the image properties by themselves.- Returns:
- the properties
-
getAllProperties
public Report getAllProperties()
Returns the all the properties (image and additional combined).- Returns:
- the properties
-
undoOccurred
public void undoOccurred(UndoEvent e)
An undo event, like add or remove, has occurred.- Specified by:
undoOccurred
in interfaceUndoListener
- Parameters:
e
- the trigger event
-
undo
public void undo()
performs an undo if possible.- Specified by:
undo
in interfaceUndoHandlerWithQuickAccess
-
redo
public void redo()
performs a redo if possible.- Specified by:
redo
in interfaceUndoHandlerWithQuickAccess
-
getPaintPanel
public ImagePanel.PaintPanel getPaintPanel()
Returns the actual panel that displays the image.- Returns:
- the panel
-
clearImageOverlays
public void clearImageOverlays()
Removes all image overlays.
-
addImageOverlay
public void addImageOverlay(ImageOverlay io)
Adds the image overlay.- Parameters:
io
- the image overlay to add
-
removeImageOverlay
public void removeImageOverlay(ImageOverlay io)
Removes the image overlay.- Parameters:
io
- the image overlay to remove
-
removeImageOverlays
public void removeImageOverlays(Class cls)
Removes all image overlay instances that are instances of the specified class.- Parameters:
cls
- the image overlay class to remove
-
imageOverlays
public Iterator<ImageOverlay> imageOverlays()
Returns an iterator over all the image overlays.- Returns:
- iterator on image overlays
-
setCustomPopupMenuProvider
public void setCustomPopupMenuProvider(CustomPopupMenuProvider value)
Sets the custom popup menu provider.- Parameters:
value
- the provider, use null to remove
-
getCustomPopupMenuProvider
public CustomPopupMenuProvider getCustomPopupMenuProvider()
Returns the custom popup menu provider.- Returns:
- the provider, null if none set
-
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% scale) to a mouse location.- Parameters:
pixelPos
- the pixel position- Returns:
- the mouse position
-
traceToPolygon
public Polygon traceToPolygon(List<Point> trace)
Turns the trace into a polygon.- Parameters:
trace
- the trace to convert- Returns:
- the polygon, null if unable to convert (eg empty trace)
-
clearSelectionListeners
public void clearSelectionListeners()
Removes all selection listeners.
-
addSelectionListener
public void addSelectionListener(ImagePanelSelectionListener l)
Adds the given listener to the internal list of selection listeners.- Parameters:
l
- the listener to add
-
removeSelectionListener
public void removeSelectionListener(ImagePanelSelectionListener l)
Removes the given listener from the internal list of selection listeners.- Parameters:
l
- the listener to remove
-
clearLeftClickListeners
public void clearLeftClickListeners()
Removes all left-click listeners.
-
addLeftClickListener
public void addLeftClickListener(ImagePanelLeftClickListener l)
Adds the given listener to the internal list of left-click listeners.- Parameters:
l
- the listener to add
-
removeLeftClickListener
public void removeLeftClickListener(ImagePanelLeftClickListener l)
Removes the given listener from the internal list of left-click listeners.- Parameters:
l
- the listener to remove
-
setSelectionShapePainter
public void setSelectionShapePainter(SelectionShapePainter value)
Sets the painter to use for the selection shape.- Parameters:
value
- the color to use
-
getSelectionShapePainter
public SelectionShapePainter getSelectionShapePainter()
Returns the painter to use for the selection shape.- Returns:
- the painter in use
-
setSelectionEnabled
public void setSelectionEnabled(boolean value)
Sets whether selection is enabled or not.- Parameters:
value
- if true then selection is enabled
-
isSelectionEnabled
public boolean isSelectionEnabled()
Returns whether selection is enabled.- Returns:
- true if selection is enabled
-
addPaintlet
public void addPaintlet(Paintlet p)
Adds the paintlet to the internal list.- Parameters:
p
- the paintlet to add.
-
removePaintlet
public void removePaintlet(Paintlet p)
Removes this paintlet from its internal list.- Parameters:
p
- the paintlet to remove
-
paintlets
public Iterator<Paintlet> paintlets()
Returns an iterator over all currently stored paintlets.- Returns:
- the paintlets
-
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
-
clearInteractionLog
public void clearInteractionLog()
Clears the interaction log.- Specified by:
clearInteractionLog
in interfaceInteractionLogManager
-
addInteractionLog
public void addInteractionLog(InteractionEvent e)
Adds the interaction event to the log.- Specified by:
addInteractionLog
in interfaceInteractionLogManager
- Parameters:
e
- the event to add
-
hasInteractionLog
public boolean hasInteractionLog()
Checks whether there have been any interactions recorded.- Specified by:
hasInteractionLog
in interfaceInteractionLogManager
- Returns:
- true if interactions are available
-
getInteractionLog
public List<InteractionEvent> getInteractionLog()
Returns the interaction log.- Specified by:
getInteractionLog
in interfaceInteractionLogManager
- Returns:
- the log, null if nothing recorded
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-