AFLPgui
Class GelView

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

public class GelView
extends java.awt.Canvas
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Displays the gel as an image and provides the methods used to allow user interaction with the gel, such as placing bins and zooming. It also lets the user adjust the size range displayed and the intensity of the image. The class will resize itself to contain the whole gel image, so the parent should accomadate these changes.

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
GelView(Gel gel, java.awt.Frame topWindow)
          Creates a new viewable object of the specified gel
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Deal with action events.
 void drawBins(java.awt.Graphics g)
          Draws all the bins in the gel onto the specified graphics object.
 void drawLaneHeaders(java.awt.Graphics g)
          Draws the headers for the lanes, (the little grey tabs at the top of the gel).
 void finalize()
          Cleans up before this class is disposed off.
 int findLaneAt(int pos)
          Gives the position in the gel of the lane at the given size.
 double findSizeAt(int pos)
          Calculates the size in bp that corresponds to the screen location given.
 ButtonBar getButtonBar()
          Gives the button bar that should be used with this object.
 Bin getCurrentBin()
          Gives the bin that is currently selected on the gel.
 Bar getInfoBar()
          Returns a bar that displays information about the gel.
 boolean isSizeSet()
           
 void itemStateChanged(java.awt.event.ItemEvent e)
          Handle events for the choice box, which adjusts the zoom.
 void keyPressed(java.awt.event.KeyEvent e)
          Unused
 void keyReleased(java.awt.event.KeyEvent e)
          Watches for the enter key to be pushed in a text field, and then refreshes the gel when it is.
 void keyTyped(java.awt.event.KeyEvent e)
          Unused
 void mouseClicked(java.awt.event.MouseEvent e)
          Handle the click of the mouse.
 void mouseDragged(java.awt.event.MouseEvent e)
          Handle the dragging of the mouse.
 void mouseEntered(java.awt.event.MouseEvent e)
          Don't care about this event.
 void mouseExited(java.awt.event.MouseEvent e)
          Don't care about this event.
 void mouseMoved(java.awt.event.MouseEvent e)
          Handle moving the mouse.
 int mouseOverType(int x, int y)
          Determines what the mouse is pointing to.
 void mousePressed(java.awt.event.MouseEvent e)
          Handle the event of the mouse button being pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          Handle the event of the mouse button being released.
 void paint(java.awt.Graphics g)
          Manages the display area and is called automatically when needed.
 void rebuild()
          Recreates the gel image from the data.
 void refresh(boolean rebuildGel)
          Called when the image on screen should be redrawn.
 void setCurrentBin(Bin bin)
          Sets the selection to the specified bin.
 void setGelLength(int length)
          Set the length of the gel image to the specified value.
 void setGelSizeToMax(int laneNum)
           
 void syncDisplay()
           
 void update(java.awt.Graphics g)
          Called when the screen needs to be updated.
 
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, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GelView

public GelView(Gel gel,
               java.awt.Frame topWindow)
Creates a new viewable object of the specified gel
Parameters:
gel - the gel to be displayed and manipulated
Method Detail

syncDisplay

public void syncDisplay()

isSizeSet

public boolean isSizeSet()

setGelSizeToMax

public void setGelSizeToMax(int laneNum)

paint

public void paint(java.awt.Graphics g)
Manages the display area and is called automatically when needed. If the gel has been changed and needs to be redrawn, then refresh should be called. It will determine what action to take. Paint will only display the image of the gel known to this class, which may have to be rebuilt. The paint method makes use of double buffering to speed the display.
Overrides:
paint in class java.awt.Canvas
See Also:
refresh(boolean)

drawBins

public void drawBins(java.awt.Graphics g)
Draws all the bins in the gel onto the specified graphics object.
Parameters:
g - the graphics object to draw to

drawLaneHeaders

public void drawLaneHeaders(java.awt.Graphics g)
Draws the headers for the lanes, (the little grey tabs at the top of the gel).
Parameters:
g - the graphics object to draw on.

update

public void update(java.awt.Graphics g)
Called when the screen needs to be updated.
Overrides:
update in class java.awt.Component

getButtonBar

public ButtonBar getButtonBar()
Gives the button bar that should be used with this object. The bar contains the controls for the gel.
Returns:
a bar with the controls for the gel, to be displayed by the parent class

getInfoBar

public Bar getInfoBar()
Returns a bar that displays information about the gel. This object should be displayed somewhere by the container of this object.
Returns:
the bar as described above

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Deal with action events. The two buttons are the bin dialog button, which when clicked displays the dialog, and the refreshButton, which reads in the sizes and intensity from the bar and then redisplays the gel.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Handle events for the choice box, which adjusts the zoom.
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Handle the click of the mouse. Includes double clicks. When the mouse is clicked on the gel, a bin is added. If it is double-clicked on a lane header, that lane is selected.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Don't care about this event.
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Don't care about this event.
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Handle the event of the mouse button being pressed. Use this to set up for drags, however, be careful not to duplicate work done be the click handler. The type of action performed depends on where the mouse is pressed. Over a blank area will create a new bin, while pressing down on a bin border will prepare the program to move that border. The types of places that the mouse can be over are defined by constants and the mouseOverType method. The type the mouse is currently over is stored in an instance variable and is updated whenever the mouse moves.
Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
mouseOverType(int, int)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Handle the event of the mouse button being released. This will finalize any dragging only if the mouse has been dragged between when this is called and the press event has been called. This is since press + release w/o drag = click. The action performed depends on where the mouse started.
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
mouseOverType(int, int)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Handle the dragging of the mouse. Mostly used to adjust bin borders or to move bins around.
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Handle moving the mouse. It displays information about whatever the mouse is pointing to in the gel. This is done by calling the mouseOverType method, and then displaying the appropriate information.
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
mouseOverType(int, int)

mouseOverType

public int mouseOverType(int x,
                         int y)
Determines what the mouse is pointing to. This is done be looking first to see if the mouse is even on the gel. Then the position is used to look for a bin at that position. If none is found, the method looks for a bin up one pixel from the current position of the mouse. If it finds one, then the mouse must be on the border of the bin. If not, the same search is performed, except one pixel lower. This also allows the method to tell which border it is on, which is important to know when adjusting the borders and figuring out which direction should increase the bin size and which way should decrease it. If no bin is found, and the mouse is on the gel, then the mouse is assumed to be on a blank portion of the gel.
Parameters:
x - the x coordinate of the mouse, relative to this component.
y - the y coordinate of the mouse, relative to this component.
Returns:
the type of object the mouse is over, defined by static variables in this class.

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Watches for the enter key to be pushed in a text field, and then refreshes the gel when it is.
Specified by:
keyReleased in interface java.awt.event.KeyListener

findSizeAt

public double findSizeAt(int pos)
Calculates the size in bp that corresponds to the screen location given.
Parameters:
pos - the verticle position to calculate the size in bp for
Returns:
the size

findLaneAt

public int findLaneAt(int pos)
Gives the position in the gel of the lane at the given size. The lanes are numbered 1 through n, where 1 is the rightmost lane.

refresh

public void refresh(boolean rebuildGel)
Called when the image on screen should be redrawn. For example, when a bin has been added. This will not read in a new image if the image has been changed.
Parameters:
rebuildGel - if this is true, then the gel image will be recreated from the data in the gel, using the current gel settings.
See Also:
Gel

rebuild

public void rebuild()
Recreates the gel image from the data. This should be used if the size or intensity parameters of the gel have changed. Or if a larger image is desired, etc.

getCurrentBin

public Bin getCurrentBin()
Gives the bin that is currently selected on the gel. This bin should be the one that appears highlighted in a different color.
Returns:
the bin

setCurrentBin

public void setCurrentBin(Bin bin)
Sets the selection to the specified bin. The bin must be valid, but no check will be performed. As long as the bin is retrieved from the list, there shouldn't be any problem. This is used to keep the bin selection synchronized across bins.
Parameters:
bin - the bin to highlight as selected.

setGelLength

public void setGelLength(int length)
Set the length of the gel image to the specified value. The image will be recreated when this is called.
Parameters:
length - the length in pixels.

finalize

public void finalize()
              throws java.lang.Throwable
Cleans up before this class is disposed off.
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - something bad happened.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Unused
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Unused
Specified by:
keyTyped in interface java.awt.event.KeyListener