Class ImagePanel.PaintPanel

    • Field Detail

      • m_Owner

        protected ImagePanel m_Owner
        the owning image panel.
      • m_Scale

        protected double m_Scale
        the scaling factor.
      • m_CurrentImage

        protected BufferedImage m_CurrentImage
        the current image.
      • m_PrintMouseListener

        protected PrintMouseListener m_PrintMouseListener
        the mouse listener.
      • m_CustomPopupMenuProvider

        protected CustomPopupMenuProvider m_CustomPopupMenuProvider
        whether to use a custom popup menu provider.
      • m_SelectionEnabled

        protected boolean m_SelectionEnabled
        whether selection via box is enabled.
      • m_SelectionShapePainter

        protected SelectionShapePainter m_SelectionShapePainter
        the color of the selection box.
      • m_Selecting

        protected boolean m_Selecting
        whether the selection box is currently been drawn.
      • m_Dragged

        protected boolean m_Dragged
        whether dragging has happened at all.
      • m_SelectionFrom

        protected Point m_SelectionFrom
        the starting corner of the selection box.
      • m_SelectionTo

        protected Point m_SelectionTo
        the finishing corner of the selection box.
      • m_SelectionTrace

        protected List<Point> m_SelectionTrace
        the selection trace.
      • m_Paintlets

        protected Set<Paintlet> m_Paintlets
        additional paintlets to execute.
      • m_InteractionLoggingFilter

        protected InteractionLoggingFilter m_InteractionLoggingFilter
        the interaction logger in use.
    • Constructor Detail

      • PaintPanel

        public PaintPanel​(ImagePanel owner)
        Initializes the panel.
        Parameters:
        owner - the image panel this paint panel belongs to
    • Method Detail

      • initialize

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

        protected void initGUI()
        Initializes the widgets.
        Overrides:
        initGUI in class BasePanel
      • logMouseButtonPressed

        protected void logMouseButtonPressed​(MouseEvent e)
        Logs a mouse button pressed.
        Parameters:
        e - the mouse event to record
      • logMouseButtonClick

        protected void logMouseButtonClick​(MouseEvent e)
        Logs a mouse click.
        Parameters:
        e - the mouse event to record
      • logMouseButtonReleased

        protected void logMouseButtonReleased​(MouseEvent e)
        Logs a mouse button released.
        Parameters:
        e - the mouse event to record
      • logMouseWheel

        protected void logMouseWheel​(MouseWheelEvent e,
                                     double oldScale,
                                     double newScale)
        Logs a mouse click.
        Parameters:
        e - the mouse wheel event to record
        oldScale - the old scale
        newScale - the new scale
      • logScale

        protected void logScale​(double newScale)
        Logs a scale change from the menu.
        Parameters:
        newScale - the new scale
      • 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
      • updateStatus

        public void updateStatus()
        Updates the status bar.
      • 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
      • isSelecting

        public boolean isSelecting()
        Whether selection is currently active.
        Returns:
        true if active
      • isDragged

        public boolean isDragged()
        Whether dragging is selection is currently active.
        Returns:
        true if active
      • updateStatus

        public void updateStatus​(Point pos)
        Updates the status bar.
        Parameters:
        pos - the mouse position
      • showPopup

        public void showPopup​(MouseEvent e)
        Displays a popup-menu. Either provided by the custom popup menu provider or the default one.
        Parameters:
        e - the event that triggered the popup
        See Also:
        m_CustomPopupMenuProvider
      • getOwner

        public ImagePanel getOwner()
        Returns the owning panel.
        Returns:
        the owner
      • setCurrentImage

        public void setCurrentImage​(BufferedImage value)
        Sets the image to display.
        Parameters:
        value - the image to use
      • setCurrentImage

        public void setCurrentImage​(BufferedImage value,
                                    double scale)
        Sets the image to display.
        Parameters:
        value - the image to use
        scale - the scale to use
      • getCurrentImage

        public BufferedImage getCurrentImage()
        Returns the current image.
        Returns:
        the image, can be null if not set
      • setScale

        public void setScale​(double value)
        Sets the scaling factor.
        Parameters:
        value - the scaling factor
      • update

        public void update()
        Updates the image.
      • update

        public void update​(boolean doLayout)
        Updates the image.
        Parameters:
        doLayout - whether to update the layout
      • getScale

        public double getScale()
        Returns the scaling factor (0-16).
        Returns:
        the scaling factor
      • clearImageOverlays

        public void clearImageOverlays()
        Removes all image overlays.
      • export

        public void export()
        Exports the current image.
      • getReportFileChooser

        protected DefaultReportFileChooser getReportFileChooser()
        Returns the report filechooser to use.
        Returns:
        the file chooser
      • loadReport

        public void loadReport()
        Loads a report from a file.
      • saveReport

        public void saveReport()
        Saves the report to a file.
      • selectImageOverlay

        public void selectImageOverlay()
        Lets the user select an overlay to add.
      • 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
      • paintSelectionShape

        protected void paintSelectionShape​(Graphics g)
        Paints the selection box, if necessary (i.e., currently selecting/dragging).
        Parameters:
        g - the graphics context
      • paint

        public void paint​(Graphics g)
        Paints the image or just a white background.
        Overrides:
        paint in class JComponent
        Parameters:
        g - the graphics context
      • setSelectionShapePainter

        public void setSelectionShapePainter​(SelectionShapePainter value)
        Sets the painter for the selection shape.
        Parameters:
        value - the painter
      • getSelectionShapePainter

        public SelectionShapePainter getSelectionShapePainter()
        Returns the painter to use for the selection shape.
        Returns:
        the painter
      • 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
      • 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
      • notifySelectionListeners

        public void notifySelectionListeners​(Point topLeft,
                                             Point bottomRight,
                                             int modifiersEx)
        Notifies all selection listeners.
        Parameters:
        topLeft - the top-left of the selection
        bottomRight - the bottom-right of the selection
        modifiersEx - the extended modifiers
        See Also:
        MouseEvent.getModifiersEx()
      • 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
      • notifyLeftClickListeners

        public void notifyLeftClickListeners​(Point position,
                                             int modifiersEx)
        Notifies all left-click listeners.
        Parameters:
        position - the position of the click
        modifiersEx - the extended modifiers
        See Also:
        MouseEvent.getModifiersEx()
      • cleanUp

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