org.processmining.mining.dmcscanning.ui
Class LogItemPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.processmining.mining.dmcscanning.ui.LogItemPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class LogItemPanel
extends javax.swing.JPanel

LogItemPanel. The purpose of this class is to provide a view of a log, in form of a horizontal ribbon, with abstract items (that have a start and end time) laid out on it, equipped with handles to distinguish. This class expects SortedSets of LogItems, which are grouped automatically with a specific color and can be removed again bulk-wise. Make sure that the added LogItems fully support the methods to retrieve start and end in temporal fashion, as the implementation of this class depends on that.

Author:
Christian W. Guenther (christian at deckfour dot org)
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
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int border
           
protected  java.util.Calendar cal
           
protected  java.awt.Color colorBg
           
protected  java.awt.Color colorFg
           
protected  java.awt.Color colorLogBright
           
protected  java.awt.Color colorLogDark
           
static java.lang.String[] HANDLE_ICONS
           
protected  double handleRatio
           
static java.lang.String ITEM_HANDLE_BOX
           
static java.lang.String ITEM_HANDLE_CIRCLE
           
static java.lang.String ITEM_HANDLE_NONE
           
static java.lang.String ITEM_HANDLE_RHOMBUS
           
static java.lang.String ITEM_HANDLE_TRIANGLE
           
protected  ColorRepository itemColors
           
protected  java.lang.String itemHandle
           
protected  java.util.HashMap itemSets
           
protected  java.util.Date logBoundaryLeft
           
protected  java.util.Date logBoundaryRight
           
protected  int logLanePixStep
           
protected  long logLaneStep
           
protected  double milli2pixels
           
protected  double viewportZoom
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
LogItemPanel(java.util.Date leftBoundary, java.util.Date rightBoundary)
          constructor
 
Method Summary
 java.awt.Color addItem(java.lang.String key, LogItem item)
          Adds a new LogItem to the set of displayed items within this viewport.
 java.awt.Color addItemSet(java.lang.String key, java.util.SortedSet anItemSet)
          Adds a SortedSet of LogItems to be displayed as a group of items within this viewport.
protected  void adjustLogBoundaries()
          consolidates the global log viewing area.
 void clearItemSets()
          initializes componente, i.e.
protected  java.util.Date coord2time(double anX)
          convenience method.
protected  long coord2timeMillis(double anX)
          convenience method.
 java.awt.Color getColor(java.lang.String key)
          Retrieves the color mapped to an item set
protected  int getHandleHeight()
           
 java.util.Date getLeftLogBoundary()
           
protected  int getLogPaneHeight()
           
 java.util.Date getRightLogBoundary()
           
 double getViewportZoom()
           
protected static boolean intersects(java.util.Date d1Left, java.util.Date d1Right, java.util.Date d2Left, java.util.Date d2Right)
          Checks two time frames for intersection.
 void paintComponent(java.awt.Graphics grx)
          paints this log item panel and all contained log items as specified.
protected  void paintHandle(int x, int y, java.awt.Graphics g)
          convenience method for internal use.
protected  void paintItem(int xStart, int xEnd, int yLogTop, int yLogHeight, int yHandle, java.awt.Graphics g)
          convenience method for internal use.
protected  void paintLogLane(java.awt.Graphics g)
          convenience method for internal use.
 boolean removeItemSet(java.lang.String key)
          Removes the grouped set of LogItems referenced by the supplied key from the viewport
 void setBorder(int aBorder)
          Sets the uniform border size for the viewport
 void setHandleRatio(double aRatio)
          Sets the ratio between log display and handle view height
 void setItemHandle(java.lang.String anItemHandle)
          Sets the item handle visualization type
 void setLeftLogBoundary(java.util.Date aBoundary)
          adjusts the log boundaries to be displayed.
 void setLogBoundaries(java.util.Date leftBoundary, java.util.Date rightBoundary)
          adjusts the log boundaries to be displayed.
 void setRightLogBoundary(java.util.Date aBoundary)
          adjusts the log boundaries to be displayed.
 void setSize(java.awt.Dimension d)
          overwritten as proxy, to update mill2pixels ratio
 void setSize(int width, int height)
          overwritten as proxy, to update mill2pixels ratio
 void setViewportZoom(double aZoom)
          adjusts the viewable are of the log (zoom)
protected  int time2coord(java.util.Date aTimestamp)
          Convenience method.
protected  int time2coord(long aTimeMillis)
          Convenience method.
protected  void updateMilli2pixelsRatio()
          Updates the internally cached ratio between milliseconds (of events) and pixels on the screen.
 
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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ITEM_HANDLE_NONE

public static java.lang.String ITEM_HANDLE_NONE

ITEM_HANDLE_CIRCLE

public static java.lang.String ITEM_HANDLE_CIRCLE

ITEM_HANDLE_TRIANGLE

public static java.lang.String ITEM_HANDLE_TRIANGLE

ITEM_HANDLE_BOX

public static java.lang.String ITEM_HANDLE_BOX

ITEM_HANDLE_RHOMBUS

public static java.lang.String ITEM_HANDLE_RHOMBUS

HANDLE_ICONS

public static java.lang.String[] HANDLE_ICONS

itemSets

protected java.util.HashMap itemSets

logBoundaryLeft

protected java.util.Date logBoundaryLeft

logBoundaryRight

protected java.util.Date logBoundaryRight

milli2pixels

protected double milli2pixels

logLaneStep

protected long logLaneStep

logLanePixStep

protected int logLanePixStep

viewportZoom

protected double viewportZoom

itemHandle

protected java.lang.String itemHandle

colorBg

protected java.awt.Color colorBg

colorFg

protected java.awt.Color colorFg

colorLogDark

protected java.awt.Color colorLogDark

colorLogBright

protected java.awt.Color colorLogBright

itemColors

protected ColorRepository itemColors

border

protected int border

handleRatio

protected double handleRatio

cal

protected java.util.Calendar cal
Constructor Detail

LogItemPanel

public LogItemPanel(java.util.Date leftBoundary,
                    java.util.Date rightBoundary)
constructor

Parameters:
leftBoundary - Date representing the left boundary (start) of the log to be visualized
rightBoundary - Date representing the right boundary (end) of the log to be visualized
Method Detail

addItemSet

public java.awt.Color addItemSet(java.lang.String key,
                                 java.util.SortedSet anItemSet)
Adds a SortedSet of LogItems to be displayed as a group of items within this viewport. They are referenced by a string key, to be able to e.g. selectively remove groups of items later on.

Parameters:
key - reference to this item set, for e.g. later selective removal
anItemSet - expects a sorted set of 'LogItem' instances.
Returns:
the color assigned with this item set

addItem

public java.awt.Color addItem(java.lang.String key,
                              LogItem item)
Adds a new LogItem to the set of displayed items within this viewport. The supplied key is used to group items belonging together (e.g. of one cluster or process instance).

Parameters:
key - identifier used to group related items (by color etc.)
item - the item to be added
Returns:
color used for item (group) display

removeItemSet

public boolean removeItemSet(java.lang.String key)
Removes the grouped set of LogItems referenced by the supplied key from the viewport

Parameters:
key - reference string for the set to remove
Returns:
success indicator: if false, the set was not contained and thus not removed

clearItemSets

public void clearItemSets()
initializes componente, i.e. all item sets formerly displayed are removed.


getColor

public java.awt.Color getColor(java.lang.String key)
Retrieves the color mapped to an item set

Parameters:
key - the key referencing the item set
Returns:
color associated with this key

setLeftLogBoundary

public void setLeftLogBoundary(java.util.Date aBoundary)
adjusts the log boundaries to be displayed. Notice: non-checking, care for sane values!

Parameters:
aBoundary - the left log boundary

setRightLogBoundary

public void setRightLogBoundary(java.util.Date aBoundary)
adjusts the log boundaries to be displayed. Notice: non-checking, care for sane values!

Parameters:
aBoundary - the right log boundary

setLogBoundaries

public void setLogBoundaries(java.util.Date leftBoundary,
                             java.util.Date rightBoundary)
adjusts the log boundaries to be displayed. Notice: non-checking, care for sane values!

Parameters:
leftBoundary - the left log boundary
rightBoundary - the right log boundary

getLeftLogBoundary

public java.util.Date getLeftLogBoundary()
Returns:
the left log viewport boundary

getRightLogBoundary

public java.util.Date getRightLogBoundary()
Returns:
the right log viewport boundary

updateMilli2pixelsRatio

protected void updateMilli2pixelsRatio()
Updates the internally cached ratio between milliseconds (of events) and pixels on the screen. Interpretation: displayedYcoordinate = timeInMillis * milli2pixels;


setSize

public void setSize(int width,
                    int height)
overwritten as proxy, to update mill2pixels ratio

Overrides:
setSize in class java.awt.Component

setSize

public void setSize(java.awt.Dimension d)
overwritten as proxy, to update mill2pixels ratio

Overrides:
setSize in class java.awt.Component

setViewportZoom

public void setViewportZoom(double aZoom)
adjusts the viewable are of the log (zoom)

Parameters:
aZoom - fraction of the log to be viewable (within (0,1] !)

getViewportZoom

public double getViewportZoom()
Returns:
the fraction of the log that is visible (within (0,1])

adjustLogBoundaries

protected void adjustLogBoundaries()
consolidates the global log viewing area. Iterates through all contained subsets and compares their boundaries to the current log boundaries set. If necessary, global log boundaries are adjusted to the outside (i.e., only extended)


setItemHandle

public void setItemHandle(java.lang.String anItemHandle)
Sets the item handle visualization type

Parameters:
anItemHandle - use one of the static ITEM_HANDLE_* strings provided, otherwise it will be a mess

setBorder

public void setBorder(int aBorder)
Sets the uniform border size for the viewport

Parameters:
aBorder -

setHandleRatio

public void setHandleRatio(double aRatio)
Sets the ratio between log display and handle view height

Parameters:
aRatio - a value within [0.1, 0.9]

getHandleHeight

protected int getHandleHeight()
Returns:
the height (in pixels) of the item handles pane

getLogPaneHeight

protected int getLogPaneHeight()
Returns:
the height (in pixels) of the log display pane

time2coord

protected int time2coord(java.util.Date aTimestamp)
Convenience method. Transforms a timestamp (Date) into the corresponding horizontal position within the viewport.

Parameters:
aTimestamp -
Returns:

time2coord

protected int time2coord(long aTimeMillis)
Convenience method. Transforms a timestamp (milliseconds) into the corresponding horizontal position within the viewport.

Parameters:
aTimeMillis -
Returns:

coord2time

protected java.util.Date coord2time(double anX)
convenience method. transforms a given horizontal coordinate within the viewport into the correspondig timestamp (Date) in the log space.

Parameters:
anX -
Returns:

coord2timeMillis

protected long coord2timeMillis(double anX)
convenience method. transforms a given horizontal coordinate within the viewport into the correspondig timestamp (milliseconds) in the log space.

Parameters:
anX -
Returns:

intersects

protected static boolean intersects(java.util.Date d1Left,
                                    java.util.Date d1Right,
                                    java.util.Date d2Left,
                                    java.util.Date d2Right)
Checks two time frames for intersection. Interpret as follows: one timeframe is delimited by d1Left on the right and d1Right on the right, this is the reference frame. the second timeframe is delimited by d2Left/Right. This method checks, if any part of the second timeframe is contained within the first timeframe.

Parameters:
d1Left -
d1Right -
d2Left -
d2Right -
Returns:

paintItem

protected void paintItem(int xStart,
                         int xEnd,
                         int yLogTop,
                         int yLogHeight,
                         int yHandle,
                         java.awt.Graphics g)
convenience method for internal use. paints a log item according to the given coordinates

Parameters:
xStart - horizontal start coordinate of the event
xEnd - horizontal end coordinate of the event
yLogTop - vertical coordinate of the log pane level (top)
yLogHeight - vertical size (height) of log items
yHandle - vertical coordinate of the handle level (center)
g - the Graphics object used for painting

paintHandle

protected void paintHandle(int x,
                           int y,
                           java.awt.Graphics g)
convenience method for internal use. paints a log item handle visualization.

Parameters:
x - horizontal anchor coordinate of the handle
y - vertical anchor coordinate of the handle
g - the Graphics object used for painting

paintLogLane

protected void paintLogLane(java.awt.Graphics g)
convenience method for internal use. paints the log lane, with time indicators.

Parameters:
gOrig -
dMin - date on the left boundary
dMax - date on the right boundary

paintComponent

public void paintComponent(java.awt.Graphics grx)
paints this log item panel and all contained log items as specified.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics object used for painting