Class ImagePanel

    • Field Detail

      • m_CurrentFile

        protected PlaceholderFile m_CurrentFile
        the current filename.
      • m_ScrollPane

        protected BaseScrollPane m_ScrollPane
        the JScrollPane that embeds the paint panel.
      • m_StatusBar

        protected BaseStatusBar m_StatusBar
        the status bar label.
      • 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_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_DependentDialogs

        protected List<Dialog> m_DependentDialogs
        list of dependent dialogs to clean up.
      • m_DependentFlows

        protected List<Flow> m_DependentFlows
        list of dependent flows to clean up.
      • m_Scale

        protected double m_Scale
        the scale that the user chose.
      • m_FileChooser

        protected ImageFileChooser m_FileChooser
        for determining readers and writers.
    • Constructor Detail

      • ImagePanel

        public ImagePanel()
        Initializes the panel.
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class UndoPanel
      • initGUI

        protected void initGUI()
        Initializes the GUI.
        Overrides:
        initGUI in class BasePanel
      • 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 point
        undoComment - the comment for the undo point
      • addUndoPoint

        public void addUndoPoint​(String comment)
        Adds an undo point with the given comment.
        Specified by:
        addUndoPoint in interface UndoHandlerWithQuickAccess
        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 display
        scale - 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 display
        scale - 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 class JComponent
        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 open
        scale - 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 open
        reader - 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 open
        reader - the reader to use, null for auto-detection
        scale - 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 to
        writer - 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.
      • 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 interface TableModelListener
      • 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 report
        current - 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 interface UndoListener
        Parameters:
        e - the trigger event
      • 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
      • hasInteractionLog

        public boolean hasInteractionLog()
        Checks whether there have been any interactions recorded.
        Specified by:
        hasInteractionLog in interface InteractionLogManager
        Returns:
        true if interactions are available
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface CleanUpHandler