AFLPgui
Class CutoffSlider

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--AFLPgui.CutoffSlider
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class CutoffSlider
extends java.awt.Canvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This class provides a way to manipulate a cutoff with the mouse. It should be told several important pieces of information, specifically the cutoff to display, the lanes to apply the cutoff too, the scale for coverting pixels to height, and the starting position of the cutoff. The cutoff will be displayed as a bar with arrows at positions corresponding to the levels of the cutoff. The cutoff can be changed by dragging the arrows or by clicking and having the arrows snap to the location. The class also provides a message that gives some info about the slider, normally what a cutoff was set to.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
CutoffSlider()
          Create a new cutoff slider.
 
Method Summary
 void addCutoffFunction(CutoffFunction ct)
          Adds the specified CutoffFucntion to all of the lanes known to this class.
 java.awt.Polygon createArrow()
          Creates a polygon that is in the shape of the arrow used to indicate different levels.
 java.lang.String getMessage()
          Gets a message describing the current state of the slider.
 void mouseClicked(java.awt.event.MouseEvent e)
          Handles the mouse clicks.
 void mouseDragged(java.awt.event.MouseEvent e)
          If the mouse is over an arrow, it moves the associated function to the new location.
 void mouseEntered(java.awt.event.MouseEvent e)
          Unused
 void mouseExited(java.awt.event.MouseEvent e)
          Unused
 void mouseMoved(java.awt.event.MouseEvent e)
          Determines if the mouse is over an arrow or a blank spot.
 void mousePressed(java.awt.event.MouseEvent e)
          Unused
 void mouseReleased(java.awt.event.MouseEvent e)
          Unused
 int overType(int x, int y)
          Determines if the given point is in a blank area or in an arrow.
 void paint(java.awt.Graphics g)
          Draws a bar with arrows at the different cutoff levels.
 void refresh()
          Causes any changes in the underlying data to be shown on the screen.
 void setCutoff(Cutoff cutoff)
          Sets the cutoff that this slider is based on.
 void setFunction(int pos, int level)
          Adjusts the cutoff function at level so that it's height matches the height represented by pos.
 void setLanes(DataList lanes)
          Sets the lanes known to the cutoff.
 void setScale(double scale)
          Sets the scale for the cutoff slider.
 void setSize(double size)
          This determines where the cutoff should be applied in the lanes.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CutoffSlider

public CutoffSlider()
Create a new cutoff slider. It will be initialized with a default cutoff. This should be changed using the setCutoff method.
Method Detail

addCutoffFunction

public void addCutoffFunction(CutoffFunction ct)
Adds the specified CutoffFucntion to all of the lanes known to this class. If a cutoff does not already exist at the position this slider applies to, then a new cutoff is added. Otherwise, the cutoff is replaced.
Parameters:
ct - the function to add.
See Also:
setSize(double), setLanes(AFLPcore.DataList)

setCutoff

public void setCutoff(Cutoff cutoff)
Sets the cutoff that this slider is based on. The slider will use this to determine the levels, etc.
Parameters:
cutoff - the cutoff to use

setSize

public void setSize(double size)
This determines where the cutoff should be applied in the lanes. A cutoff applies from size to the next cutoff. This class will use this value when it adds new cutoffs to lanes.
Parameters:
size - the location in bp, where this cutoff should first apply.

getMessage

public java.lang.String getMessage()
Gets a message describing the current state of the slider.
Returns:
info about the slider

paint

public void paint(java.awt.Graphics g)
Draws a bar with arrows at the different cutoff levels. Called every time this objects needs to be redisplayed.
Overrides:
paint in class java.awt.Canvas

setLanes

public void setLanes(DataList lanes)
Sets the lanes known to the cutoff. These are the lanes that any changes to the cutoff wil be applied to.
Parameters:
lanes - the lanes to have their cutoffs modified by the slider.

setScale

public void setScale(double scale)
Sets the scale for the cutoff slider. The scale is used to convert between pixels and intensity.
Parameters:
scale - the intensity per pixel.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Handles the mouse clicks. If the mouse is clicked over a blank (non-arrow) part of the bar, then one of the cutoff levels will be set to the point the mouse clicked on. First, a level above the point the mouse clicked will be searched for. If this is not found, then the method looks for a level below the click point.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Unused
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Unused
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Determines if the mouse is over an arrow or a blank spot.
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
If the mouse is over an arrow, it moves the associated function to the new location.
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

overType

public int overType(int x,
                    int y)
Determines if the given point is in a blank area or in an arrow.
Parameters:
x - the x position
y - the y position

setFunction

public void setFunction(int pos,
                        int level)
Adjusts the cutoff function at level so that it's height matches the height represented by pos. The function is adjusted for all of the lanes defined. If a cutoff function does not exist at the position of this slider, then a new cutoff is added. Otherwise, the existing cutoff is replaced.
Parameters:
pos - the position, in pixels, to move the cutoff function to
level - specifies the part of the cutoff to adjust.
See Also:
setLanes(AFLPcore.DataList), setSize(double)

createArrow

public java.awt.Polygon createArrow()
Creates a polygon that is in the shape of the arrow used to indicate different levels.
Returns:
the arrow

refresh

public void refresh()
Causes any changes in the underlying data to be shown on the screen.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Unused
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Unused
Specified by:
mouseExited in interface java.awt.event.MouseListener