fsmvis.gui
Class ScatterPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--fsmvis.gui.ScatterPanel

public class ScatterPanel
extends javax.swing.JPanel
implements java.lang.Runnable, Selectable, SelectionChangedListener

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  boolean animating
           
static java.awt.Color BACKGROUND
           
protected  int colorField
           
protected  java.awt.Color[] colorScheme
           
static double DATA_DOT_SIZE
           
protected  int dataSize
           
protected  long delay
           
static java.awt.Color DES_TRAIL_COL
           
static java.awt.Color DESELECTED_DOT
           
protected  boolean drawTrails
           
protected  int height
           
static long MAX_DELAY
           
protected  java.lang.Thread me
           
protected  LayoutModel model
           
protected  MouseHandler mouse
           
protected  boolean notFirst
           
protected  double offsetX
           
protected  double offsetY
           
protected  java.awt.Point origin
           
protected  Viewer parent
           
protected  boolean paused
           
protected  PropertiesHandler properties
           
protected  java.awt.Rectangle rec
           
protected  boolean running
           
protected  double scaleX
           
protected  double scaleY
           
protected  SelectionHandler selected
           
protected  int selectedCol
           
protected  java.util.Set selection
           
static java.awt.Color TRAIL_COLOR
           
static double TRAIL_DOT_SIZE
           
static int TRAIL_LENGTH
           
protected  java.util.ArrayList trails
           
protected  int width
           
 
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
 
Constructor Summary
ScatterPanel(LayoutModel model)
           
ScatterPanel(LayoutModel model, Viewer parent)
           
 
Method Summary
 void addToSelection(java.awt.Rectangle rect)
          Adds all the data items which are within the on screen rectangle rect to the currently selected indices that this object holds
 double calcPosX(double x)
          calculates the x position that this object should be at within the current JPanel and layoutbounds of the layoutModel
 double calcPosY(double y)
          calculates the y position that this object should be at within the current JPanel and layoutbounds of the layoutModel
protected  void drawDot(java.awt.Graphics g, int index, java.awt.Color col)
          Draws a dot located at index index in the data item collection, with the color col.
protected  void drawTrail(java.awt.Graphics g, int index, java.awt.Color color)
          Draws a trail on the data item with index index.
 long getDelay()
          Returns the current delay between iterations
 java.util.Collection getDeselection()
          Returns the indices of the deselected items in this object This method may return null if the getSelection method is being used instead.
 java.awt.Color getDotColor(int index)
          Returns the dot with index current drawing color, gets this from the ColorScales class by looking up this dots colour relative to the current colorScheme and colorField.
 double getOffsetX()
          Returns the x offset value
 double getOffsetY()
          Returns the y offset value
 java.awt.Point getOrigin()
          Returns the Point at the centre of the display, the origin
protected  java.util.Collection getRectContents(java.awt.Rectangle rect)
          Returns the indices of the data items that are contained inside the on screen rectangle rect.
 double getScaleX()
          Returns the current value of scale in the x direction
 double getScaleY()
          Returns the current value of scale in the y direction
 java.util.Collection getSelection()
          Returns the selection of this object
 java.awt.Point getToolTipLocation(java.awt.event.MouseEvent event)
          Sets the location that the tool tip should be displayed at
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Sets the tool tip text to be displayed to be relative to the data element under the cursor
 void handleSelection(java.awt.Rectangle rect)
          Sets the currently selected indices of the scatter panel to be the indices of the data items held within rect
protected  void initProperties()
          Initialises the properties associated with this object
 void newThread()
           
 void paint(java.awt.Graphics g)
          Overrides the standard paint method, displays all the dots onto the screen
 void pause()
          Pauses the layout model
 void removeFromSelection(java.awt.Rectangle rect)
          Removes all the data items which are within the on screen rectangle rect from the currently selected indices that this object holds
 void reset()
          resets the scale and offset values to their original values.
 void run()
          run method defined by runnable interface
 void selectAll()
          Sets this selectable object to select all its items
 void selectionChanged(SelectionHandler select)
          Method that will be called the selection is changed in the selection handler
 void selectNone()
          Sets this selectable item to select none of it items
 void setAnimate(boolean animating)
           
 void setColorField(java.lang.String field)
           
 void setColorScheme(java.lang.String color)
          Sets the color scheme for the scatter panel to use
 void setDelay(long delay)
          Sets the delay between calls to do runIteration
 void setDrawTrails(boolean drawTrails)
          Sets whether or not the scatter panel should draw trails on the data items
 void setModel(LayoutModel model)
          called when the layout model that is being used has changed
 void setOffsetX(double offsetX)
          sets the x offset value
 void setOffsetY(double offsetY)
          sets the y offset value
 void setRect(java.awt.Rectangle r)
          Stores the last drawn rectangle
 void setScale(double scaleX, double scaleY)
          Sets the scale to be the new value scale
 void setScaleX(double scaleX)
          Sets the x scale to be the new value scale
 void setScaleY(double scaleY)
          Sets the y scale to be the new value scale
 void setSelectedColumn(java.lang.String colName)
          Sets the selected column value, this is used for the tooltips to give a value
 void start()
          starts the layout model
 void threadRunning(boolean r)
           
 void update()
          Method that should be called whenever an screen update is required,
 void updateTrails()
          updates the contents of the trails information.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

model

protected LayoutModel model

parent

protected Viewer parent

dataSize

protected int dataSize

me

protected java.lang.Thread me

running

protected volatile boolean running

drawTrails

protected volatile boolean drawTrails

paused

protected volatile boolean paused

animating

protected volatile boolean animating

delay

protected volatile long delay

width

protected int width

height

protected int height

scaleX

protected double scaleX

scaleY

protected double scaleY

offsetX

protected double offsetX

offsetY

protected double offsetY

origin

protected java.awt.Point origin

trails

protected java.util.ArrayList trails

properties

protected PropertiesHandler properties

selected

protected SelectionHandler selected

selection

protected java.util.Set selection

mouse

protected MouseHandler mouse

colorScheme

protected java.awt.Color[] colorScheme

colorField

protected int colorField

selectedCol

protected int selectedCol

DATA_DOT_SIZE

public static double DATA_DOT_SIZE

TRAIL_DOT_SIZE

public static double TRAIL_DOT_SIZE

TRAIL_LENGTH

public static int TRAIL_LENGTH

TRAIL_COLOR

public static java.awt.Color TRAIL_COLOR

DES_TRAIL_COL

public static java.awt.Color DES_TRAIL_COL

DESELECTED_DOT

public static java.awt.Color DESELECTED_DOT

BACKGROUND

public static java.awt.Color BACKGROUND

MAX_DELAY

public static long MAX_DELAY

rec

protected java.awt.Rectangle rec

notFirst

protected boolean notFirst
Constructor Detail

ScatterPanel

public ScatterPanel(LayoutModel model,
                    Viewer parent)

ScatterPanel

public ScatterPanel(LayoutModel model)
Method Detail

initProperties

protected void initProperties()
Initialises the properties associated with this object

pause

public void pause()
Pauses the layout model

start

public void start()
starts the layout model

run

public void run()
run method defined by runnable interface
Specified by:
run in interface java.lang.Runnable

update

public void update()
Method that should be called whenever an screen update is required,

paint

public void paint(java.awt.Graphics g)
Overrides the standard paint method, displays all the dots onto the screen
Overrides:
paint in class javax.swing.JComponent

drawDot

protected void drawDot(java.awt.Graphics g,
                       int index,
                       java.awt.Color col)
Draws a dot located at index index in the data item collection, with the color col. Draw all of this onto the graphics g.

drawTrail

protected void drawTrail(java.awt.Graphics g,
                         int index,
                         java.awt.Color color)
Draws a trail on the data item with index index. and colour col
Parameters:
g -  
index -  
col -  

calcPosX

public double calcPosX(double x)
calculates the x position that this object should be at within the current JPanel and layoutbounds of the layoutModel

calcPosY

public double calcPosY(double y)
calculates the y position that this object should be at within the current JPanel and layoutbounds of the layoutModel

getDotColor

public java.awt.Color getDotColor(int index)
Returns the dot with index current drawing color, gets this from the ColorScales class by looking up this dots colour relative to the current colorScheme and colorField.
Parameters:
index - The index of the dot to retrieve color for
Returns:
The color that this dot should be

setModel

public void setModel(LayoutModel model)
called when the layout model that is being used has changed
Parameters:
model - The new layout model to use

setDrawTrails

public void setDrawTrails(boolean drawTrails)
Sets whether or not the scatter panel should draw trails on the data items
Parameters:
drawTrails - Sets the state of draw trails

newThread

public void newThread()

threadRunning

public void threadRunning(boolean r)

setAnimate

public void setAnimate(boolean animating)

updateTrails

public void updateTrails()
updates the contents of the trails information.

handleSelection

public void handleSelection(java.awt.Rectangle rect)
Sets the currently selected indices of the scatter panel to be the indices of the data items held within rect
Parameters:
rect - The rectangle to look in

addToSelection

public void addToSelection(java.awt.Rectangle rect)
Adds all the data items which are within the on screen rectangle rect to the currently selected indices that this object holds
Parameters:
rect - The rectange of data items

removeFromSelection

public void removeFromSelection(java.awt.Rectangle rect)
Removes all the data items which are within the on screen rectangle rect from the currently selected indices that this object holds
Parameters:
rect - The rectange of data items

getRectContents

protected java.util.Collection getRectContents(java.awt.Rectangle rect)
Returns the indices of the data items that are contained inside the on screen rectangle rect.
Parameters:
rect - The rectangle
Returns:
The collection of indices inside this rectangle

setColorField

public void setColorField(java.lang.String field)

setColorScheme

public void setColorScheme(java.lang.String color)
Sets the color scheme for the scatter panel to use

setSelectedColumn

public void setSelectedColumn(java.lang.String colName)
Sets the selected column value, this is used for the tooltips to give a value
Parameters:
colName - The name of the column which is selected

getDelay

public long getDelay()
Returns the current delay between iterations
Returns:
The delay bewtween iterations

setDelay

public void setDelay(long delay)
Sets the delay between calls to do runIteration
Parameters:
delay - The new delay value

reset

public void reset()
resets the scale and offset values to their original values. This should be called whenever a new layout is being started or someone has scrolled or zoomed away from all the data

setScale

public void setScale(double scaleX,
                     double scaleY)
Sets the scale to be the new value scale
Parameters:
scale - The new scale value

setScaleX

public void setScaleX(double scaleX)
Sets the x scale to be the new value scale
Parameters:
scaleX - The new x scale value

setScaleY

public void setScaleY(double scaleY)
Sets the y scale to be the new value scale
Parameters:
scaleY - The new y scale value

getScaleX

public double getScaleX()
Returns the current value of scale in the x direction
Returns:
The scale value

getScaleY

public double getScaleY()
Returns the current value of scale in the y direction
Returns:
The scale value

getOffsetX

public double getOffsetX()
Returns the x offset value
Returns:
The x offset

getOffsetY

public double getOffsetY()
Returns the y offset value
Returns:
The y offset

setOffsetX

public void setOffsetX(double offsetX)
sets the x offset value
Returns:
The x offset

setOffsetY

public void setOffsetY(double offsetY)
sets the y offset value
Returns:
The y offset

getOrigin

public java.awt.Point getOrigin()
Returns the Point at the centre of the display, the origin
Returns:
The origin

selectionChanged

public void selectionChanged(SelectionHandler select)
Method that will be called the selection is changed in the selection handler
Specified by:
selectionChanged in interface SelectionChangedListener
Parameters:
select - The selection handler that created the selection changed

getSelection

public java.util.Collection getSelection()
Returns the selection of this object
Specified by:
getSelection in interface Selectable
Returns:
The selection

getDeselection

public java.util.Collection getDeselection()
Returns the indices of the deselected items in this object This method may return null if the getSelection method is being used instead.
Specified by:
getDeselection in interface Selectable
Returns:
The deselection

selectAll

public void selectAll()
Sets this selectable object to select all its items
Specified by:
selectAll in interface Selectable

selectNone

public void selectNone()
Sets this selectable item to select none of it items
Specified by:
selectNone in interface Selectable

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Sets the tool tip text to be displayed to be relative to the data element under the cursor
Parameters:
event - The mouse event that caused this tool tip to be displayed
Returns:
The tool tip text to display
Overrides:
getToolTipText in class javax.swing.JComponent

getToolTipLocation

public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent event)
Sets the location that the tool tip should be displayed at
Parameters:
event - The mouse event that caused this to be called
Returns:
The coords of the tool tip
Overrides:
getToolTipLocation in class javax.swing.JComponent

setRect

public void setRect(java.awt.Rectangle r)
Stores the last drawn rectangle
Parameters:
r - The rectangle