Class NavigableSVGPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.processmining.plugins.graphviz.visualisation.NavigableSVGPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.awt.print.Printable,java.io.Serializable,javax.accessibility.Accessible
- Direct Known Subclasses:
DotPanel
public class NavigableSVGPanel extends javax.swing.JPanel implements java.awt.print.PrintableA JPanel that displays an SVG image. Animation support is present, but not complete, i.e. you'll need a subclass to perform animation. Controls are included to ease implementation of subclasses.- Author:
- sleemans
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.RectangleanimationControlsprotected java.awt.RectanglecontrolsPlayPauseprotected java.awt.RectanglecontrolsTimeScalestatic float[]dash1protected static java.awt.FonthelperControlsButtonFontprotected static java.lang.StringhelperControlsButtonStringprotected java.util.List<java.lang.String>helperControlsExplanationsstatic java.awt.FonthelperControlsFontprotected java.util.List<java.lang.String>helperControlsShortcutsstatic inthelperControlsWidthprotected com.kitfox.svg.SVGDiagramimageprotected java.awt.geom.AffineTransformimage2userprotected booleanisDraggingAnimationprotected booleanisDraggingImageprotected booleanisDraggingTimeScalestatic java.awt.ColornavigationImageBorderColorstatic java.awt.BasicStrokenavigationImageOutlineStrokestatic doublenavigationImageWidthInPartOfPanel-
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
-
-
Constructor Summary
Constructors Constructor Description NavigableSVGPanel(com.kitfox.svg.SVGDiagram newImage)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcenterImageAround(java.awt.Point pointInNavigationCoordinates)The user clicked within the navigation image and this part of the image is displayed in the panel.protected voiddrawAnimation(java.awt.Graphics2D g)Draw the animation.static voiddrawSVG(java.awt.Graphics2D g, com.kitfox.svg.SVGDiagram image, int x, int y, int width, int height)Draw an svg image at the given coordinates and of the given size.voidexportView()Prompts the user for a file name and saves the view under that file name.doublegetAnimationMaximumTime()Needs to be overridden by a subclass.doublegetAnimationMinimumTime()Needs to be overridden by a subclass.doublegetAnimationTime()Needs to be overridden by a subclass.java.awt.RectanglegetControlsProgressLine()java.util.List<Exporter>getExporters()java.util.List<java.lang.String>getHelperControlsExplanations()java.util.List<java.lang.String>getHelperControlsShortcuts()com.kitfox.svg.SVGDiagramgetImage()java.awt.RectanglegetImageBoundingBoxInUserCoordinates()doublegetTimeScale()Needs to be overridden by a subclass.java.awt.RectanglegetVisibleImageBoundingBoxInUserCoordinates()booleanisAnimationControlsShowing()booleanisAnimationEnabled()Needs to be overridden by a subclass.booleanisAnimationPlaying()Needs to be overridden by a subclass.booleanisImageCompletelyInPanel()Returns whether the image is completely visible in the panelprotected booleanisInAnimationControls(java.awt.Point p)booleanisInHelperControls(java.awt.Point pointInUserCoordinates)booleanisInImage(java.awt.Point pointInUserCoordinates)Returns whether a point (in user coordinates) is in the image and not in the navigation image.booleanisInNavigation(java.awt.Point pointInUserCoordinates)Returns whether a point (in user coordinates) is in the navigation image.protected voidpaintComponent(java.awt.Graphics g)Paints the panel and its image at the current zoom level, location, and interpolation method dependent on the image scale.protected voidpaintImage(java.awt.Graphics2D g)voidpause()Request the animation to pause.voidpauseResume()Request the animation to pause or resume.intprint(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int page)protected booleanprocessMouseClick(java.awt.event.MouseEvent e)Process a mouse clickprotected booleanprocessMouseDrag(java.awt.event.MouseEvent e)Process a mouse drag;protected booleanprocessMouseExit(java.awt.event.MouseEvent e)Process a mouse exitprotected booleanprocessMouseMove(java.awt.event.MouseEvent e)Process a mouse move.protected booleanprocessMousePress(java.awt.event.MouseEvent e)Process a mouse press.protected booleanprocessMouseRelease(java.awt.event.MouseEvent e)Process a mouse releasevoidrenderOneFrame()Request one frame of the animation to be rendered.voidresetView()Scale and center the image just in the viewport.voidresume()Resume the animation from pausing.voidseek(double time)Request the next animation frame to be rendered at the given time.voidsetHelperControlsExplanations(java.util.List<java.lang.String> helperControlsExplanations)Sets the shortcut explanations, displayed when hovering over the question mark in the lower right corner.voidsetHelperControlsShortcuts(java.util.List<java.lang.String> helperControlsShortcuts)Sets the shortcuts, displayed when hovering over the question mark in the lower right corner.voidsetImage(com.kitfox.svg.SVGDiagram image, boolean resetView)Sets an image for display in the panel.voidsetImageTransformationChangedListener(ImageTransformationChangedListener listener)voidsetTimeScale(double time)Request the time scale to be set.voidsetTransformation(java.awt.geom.AffineTransform image2user, java.awt.geom.AffineTransform user2image)voidsetupListeners()java.awt.geom.Point2DtransformElement2Image(java.awt.geom.Point2D p, com.kitfox.svg.SVGElement svgElement)java.awt.geom.Point2DtransformImage2User(java.awt.geom.Point2D p)java.awt.geom.Point2DtransformImageToNavigation(java.awt.geom.Point2D p)Transforms the given point in image coordinates to navigation coordinatesjava.awt.geom.Point2DtransformNavigationToImage(java.awt.geom.Point2D p)Transforms the given point in navigation coordinates to image coordinatesjava.awt.geom.Point2DtransformUser2Image(java.awt.geom.Point2D p)-
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, setVisible, 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
-
image
protected com.kitfox.svg.SVGDiagram image
-
image2user
protected java.awt.geom.AffineTransform image2user
-
isDraggingImage
protected boolean isDraggingImage
-
isDraggingAnimation
protected boolean isDraggingAnimation
-
isDraggingTimeScale
protected boolean isDraggingTimeScale
-
animationControls
protected java.awt.Rectangle animationControls
-
controlsPlayPause
protected java.awt.Rectangle controlsPlayPause
-
controlsTimeScale
protected java.awt.Rectangle controlsTimeScale
-
navigationImageWidthInPartOfPanel
public static final double navigationImageWidthInPartOfPanel
- See Also:
- Constant Field Values
-
navigationImageBorderColor
public static final java.awt.Color navigationImageBorderColor
-
dash1
public static final float[] dash1
-
navigationImageOutlineStroke
public static final java.awt.BasicStroke navigationImageOutlineStroke
-
helperControlsWidth
public static final int helperControlsWidth
- See Also:
- Constant Field Values
-
helperControlsFont
public static final java.awt.Font helperControlsFont
-
helperControlsButtonFont
protected static final java.awt.Font helperControlsButtonFont
-
helperControlsButtonString
protected static final java.lang.String helperControlsButtonString
- See Also:
- Constant Field Values
-
helperControlsShortcuts
protected java.util.List<java.lang.String> helperControlsShortcuts
-
helperControlsExplanations
protected java.util.List<java.lang.String> helperControlsExplanations
-
-
Method Detail
-
setupListeners
public void setupListeners()
-
paintComponent
protected void paintComponent(java.awt.Graphics g)
Paints the panel and its image at the current zoom level, location, and interpolation method dependent on the image scale.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
g- theGraphicscontext for painting
-
paintImage
protected void paintImage(java.awt.Graphics2D g)
-
drawSVG
public static void drawSVG(java.awt.Graphics2D g, com.kitfox.svg.SVGDiagram image, int x, int y, int width, int height)Draw an svg image at the given coordinates and of the given size.- Parameters:
g-image-x-y-width-height-
-
drawAnimation
protected void drawAnimation(java.awt.Graphics2D g)
Draw the animation.- Parameters:
g-
-
transformNavigationToImage
public java.awt.geom.Point2D transformNavigationToImage(java.awt.geom.Point2D p)
Transforms the given point in navigation coordinates to image coordinates- Parameters:
p-- Returns:
-
transformImageToNavigation
public java.awt.geom.Point2D transformImageToNavigation(java.awt.geom.Point2D p)
Transforms the given point in image coordinates to navigation coordinates- Parameters:
p-- Returns:
-
isInImage
public boolean isInImage(java.awt.Point pointInUserCoordinates)
Returns whether a point (in user coordinates) is in the image and not in the navigation image.- Parameters:
pointInUserCoordinates-- Returns:
-
isInNavigation
public boolean isInNavigation(java.awt.Point pointInUserCoordinates)
Returns whether a point (in user coordinates) is in the navigation image.- Parameters:
pointInUserCoordinates-- Returns:
-
isInHelperControls
public boolean isInHelperControls(java.awt.Point pointInUserCoordinates)
-
getHelperControlsShortcuts
public java.util.List<java.lang.String> getHelperControlsShortcuts()
- Returns:
- The currently registered shortcuts, which are displayed when hovering over the question mark in the lower right corner.
-
setHelperControlsShortcuts
public void setHelperControlsShortcuts(java.util.List<java.lang.String> helperControlsShortcuts)
Sets the shortcuts, displayed when hovering over the question mark in the lower right corner.- Parameters:
helperControlsShortcuts-
-
getHelperControlsExplanations
public java.util.List<java.lang.String> getHelperControlsExplanations()
- Returns:
- The currently registered shortcut explanations, which are displayed when hovering over the question mark in the lower right corner.
-
setHelperControlsExplanations
public void setHelperControlsExplanations(java.util.List<java.lang.String> helperControlsExplanations)
Sets the shortcut explanations, displayed when hovering over the question mark in the lower right corner.- Parameters:
helperControlsExplanations-
-
getImage
public com.kitfox.svg.SVGDiagram getImage()
- Returns:
- The currently displaying svg image.
-
getVisibleImageBoundingBoxInUserCoordinates
public java.awt.Rectangle getVisibleImageBoundingBoxInUserCoordinates()
- Returns:
- The bounding box of the image in user coordinates, truncated (approximately) to the visible area.
-
getImageBoundingBoxInUserCoordinates
public java.awt.Rectangle getImageBoundingBoxInUserCoordinates()
- Returns:
- the bounding box of the complete image in user coordinates
-
isImageCompletelyInPanel
public boolean isImageCompletelyInPanel()
Returns whether the image is completely visible in the panel- Parameters:
panState-diagram-panel-- Returns:
-
setImage
public void setImage(com.kitfox.svg.SVGDiagram image, boolean resetView)Sets an image for display in the panel.
- Parameters:
image- an image to be set in the panel
-
resetView
public void resetView() throws java.awt.geom.NoninvertibleTransformExceptionScale and center the image just in the viewport.- Throws:
java.awt.geom.NoninvertibleTransformException
-
centerImageAround
public void centerImageAround(java.awt.Point pointInNavigationCoordinates) throws java.awt.geom.NoninvertibleTransformExceptionThe user clicked within the navigation image and this part of the image is displayed in the panel. The clicked point of the image is centered in the panel.- Parameters:
pointInNavigationCoordinates-- Throws:
java.awt.geom.NoninvertibleTransformException
-
processMousePress
protected boolean processMousePress(java.awt.event.MouseEvent e)
Process a mouse press.- Parameters:
e-- Returns:
- whether the press was handled and did something.
-
processMouseRelease
protected boolean processMouseRelease(java.awt.event.MouseEvent e)
Process a mouse release- Parameters:
e-- Returns:
- whether the hover was handled and did something.
-
processMouseDrag
protected boolean processMouseDrag(java.awt.event.MouseEvent e)
Process a mouse drag;- Parameters:
e-- Returns:
- whether the drag was handled and did something.
-
processMouseMove
protected boolean processMouseMove(java.awt.event.MouseEvent e)
Process a mouse move. Captured = true implies that the hover was already processed (and we should hide everything related to hovering).- Parameters:
e-- Returns:
- whether the move is hovering something.
-
processMouseClick
protected boolean processMouseClick(java.awt.event.MouseEvent e)
Process a mouse click- Parameters:
e-- Returns:
- whether the click was handled and did something.
-
processMouseExit
protected boolean processMouseExit(java.awt.event.MouseEvent e)
Process a mouse exit- Parameters:
e-- Returns:
- whether the exit was handled and did something.
-
setImageTransformationChangedListener
public void setImageTransformationChangedListener(ImageTransformationChangedListener listener)
-
setTransformation
public void setTransformation(java.awt.geom.AffineTransform image2user, java.awt.geom.AffineTransform user2image)
-
transformUser2Image
public java.awt.geom.Point2D transformUser2Image(java.awt.geom.Point2D p)
-
transformImage2User
public java.awt.geom.Point2D transformImage2User(java.awt.geom.Point2D p)
-
transformElement2Image
public java.awt.geom.Point2D transformElement2Image(java.awt.geom.Point2D p, com.kitfox.svg.SVGElement svgElement)
-
isAnimationEnabled
public boolean isAnimationEnabled()
Needs to be overridden by a subclass.- Returns:
- whether the animation is rendered and controls are displayed.
-
isAnimationPlaying
public boolean isAnimationPlaying()
Needs to be overridden by a subclass.- Returns:
- whether the animation is currently playing (not paused)
-
getTimeScale
public double getTimeScale()
Needs to be overridden by a subclass.- Returns:
- the time scale set, which is a 0 <= number <= 1.
-
setTimeScale
public void setTimeScale(double time)
Request the time scale to be set. Needs to be overridden by a subclass.- Parameters:
time-
-
getAnimationTime
public double getAnimationTime()
Needs to be overridden by a subclass.- Returns:
- the current animation time.
-
getAnimationMinimumTime
public double getAnimationMinimumTime()
Needs to be overridden by a subclass.- Returns:
- the minimum animation time.
-
getAnimationMaximumTime
public double getAnimationMaximumTime()
Needs to be overridden by a subclass.- Returns:
- the maximum animation time.
-
isInAnimationControls
protected boolean isInAnimationControls(java.awt.Point p)
- Parameters:
p-- Returns:
- whether a point lies in the animation controls.
-
seek
public void seek(double time)
Request the next animation frame to be rendered at the given time. Needs to be overridden by a subclass.- Parameters:
time-
-
pause
public void pause()
Request the animation to pause. Needs to be overridden by a subclass.
-
resume
public void resume()
Resume the animation from pausing. Needs to be overridden by a subclass.
-
pauseResume
public void pauseResume()
Request the animation to pause or resume. Needs to be overridden by a subclass.
-
renderOneFrame
public void renderOneFrame()
Request one frame of the animation to be rendered. Needs to be overridden by a subclass.
-
getControlsProgressLine
public java.awt.Rectangle getControlsProgressLine()
-
isAnimationControlsShowing
public boolean isAnimationControlsShowing()
-
getExporters
public java.util.List<Exporter> getExporters()
- Returns:
- The list of exporters. Subclasses can override this to a relevant list. Called everytime the user attempts to export the image.
-
exportView
public void exportView()
Prompts the user for a file name and saves the view under that file name.
-
print
public int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int page) throws java.awt.print.PrinterException- Specified by:
printin interfacejava.awt.print.Printable- Throws:
java.awt.print.PrinterException
-
-