org.concord.biologica.ui
Class ChromosomeView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.concord.biologica.ui.UIView
                          |
                          +--org.concord.biologica.ui.ChromosomeView
All Implemented Interfaces:
java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.beans.PropertyChangeListener, java.io.Serializable

public final class ChromosomeView
extends UIView
implements java.awt.image.ImageObserver, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.beans.PropertyChangeListener

The chromosome view of BioLogica.

An object of this class will generate the following property change events:

Version:
$Revision: 1.10 $ $Date: 2002/03/29 20:13:04 $
Author:
$Author: qliao $
See Also:
UIProp.ORGANISM, UIProp.SELECTED_ALLELE, UIProp.SELECTED_CHROMOSOME, PropertyChangeListener, Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int[] CHROMOSOME_BOTTOM_LENGTH
           
static int[] CHROMOSOME_BOTTOM_SECTION_BOTTOM
           
static int[] CHROMOSOME_BOTTOM_SECTION_TOP
           
static int CHROMOSOME_IMAGE_HEIGHT
           
static int CHROMOSOME_IMAGE_WIDTH
           
static float[] CHROMOSOME_MID_POINT
           
static int[] CHROMOSOME_TOP_LENGTH
           
static int[] CHROMOSOME_TOP_SECTION_BOTTOM
           
static int[] CHROMOSOME_TOP_SECTION_TOP
          Chromosome image values, used to draw genes and alleles on them
static int[] CHROMOSOME_TOTAL_LENGTH
           
static int MIN_PREFERRED_HEIGHT
           
protected  java.awt.Color selectionColor
          Selection color for a particular view
static int X_BLUE_CHROMOSOME
           
static int X_COMBO_BOX_OFFSET
           
static int X_LEFT_IMAGE
           
static int X_RIGHT_IMAGE
           
static int X_YELLOW_CHROMOSOME
           
static int Y_IMAGE_OFFSET
           
static int Y_TOP_IMAGE
           
 
Fields inherited from class org.concord.biologica.ui.UIView
changes, fontAscent, fontDescent, fontHeight, fontMetrics, preferredHeight, preferredWidth, scrollPane
 
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
ChromosomeView()
          Creates a chromosome view.
 
Method Summary
 int getChromosomesToShow()
          Get the chromosomes to show.
 OrganismChromosome getCurrentChromosome()
           
static java.awt.Color getDefaultSelectionColor()
          Get the default selection color
 java.lang.String getNewAllele()
           
 java.lang.String getOldAllele()
           
 Organism getOrganism()
          Get the shown organism for this view.
 java.awt.Dimension getPreferredSize()
          Return the preferred size of this canvas
 OrganismAllele getSelectedAllele()
          Get the selected allele.
 OrganismChromosome getSelectedChromosome()
          Get the selected chromosome.
 java.awt.Color getSelectionColor()
          Get the selection color
 SelectionSet getSelectionSet()
           
 boolean imageUpdate(java.awt.Image anImage, int infoFlags, int x, int y, int width, int height)
          ImageObserver method
 boolean isChromosomesSelectable(boolean selectable)
           
 void mouseClicked(java.awt.event.MouseEvent event)
          Handle mouse click events
 void mouseDragged(java.awt.event.MouseEvent event)
          Handle mouse dragged event
 void mouseEntered(java.awt.event.MouseEvent event)
          Handle mouse entered event
 void mouseExited(java.awt.event.MouseEvent event)
          Handle mouse exited event
 void mouseMoved(java.awt.event.MouseEvent event)
          Handle mouse moved event
 void mousePressed(java.awt.event.MouseEvent event)
          Handle mouse pressed event
 void mouseReleased(java.awt.event.MouseEvent event)
          Handle mouse released event
 void organismAlleleControlChanged(OrganismAlleleControl control, OrganismAllele allele, java.lang.String newValue)
          Handle combo box item changed events.
 void paintComponent(java.awt.Graphics g)
          Draw the graphics in this view.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle property change events
 void setChromosomesSelectable(boolean selectable)
           
 void setChromosomesToShow(int aChromosomesToShow)
          Set the chromosomes to show.
 void setCurrentChromosome(OrganismChromosome chr)
           
static void setDefaultSelectionColor(java.awt.Color aColor)
          Set the default selection color.
 void setNewAllele(java.lang.String newOne)
           
 void setOldAllele(java.lang.String oldOne)
           
 void setOrganism(Organism anOrganism)
          Set the shown organism for this view.
 void setScrollPane(javax.swing.JScrollPane aScrollPane)
          Tell this view its scroll pane.
 void setSelectedAllele(OrganismAllele anAllele)
          Set the selected allele.
 void setSelectedChromosome(OrganismChromosome aChromosome)
          Set the selected chromosome.
 void setSelectionColor(java.awt.Color aColor)
          Set the selection color.
 void setSelectionSet(SelectionSet selectSet)
           
 void updateScrollBars()
          Update the scroll bar extents based on the number of organisms
 void updateState()
          Update our view state.
 
Methods inherited from class org.concord.biologica.ui.UIView
addPropertyChangeListener, getLocalImage, paintBackground, removePropertyChangeListener, setBackground, setFont, setForeground, toolChanged, updateFont
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
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, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, 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, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, 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

CHROMOSOME_IMAGE_WIDTH

public static final int CHROMOSOME_IMAGE_WIDTH

CHROMOSOME_IMAGE_HEIGHT

public static final int CHROMOSOME_IMAGE_HEIGHT

X_YELLOW_CHROMOSOME

public static final int X_YELLOW_CHROMOSOME

X_BLUE_CHROMOSOME

public static final int X_BLUE_CHROMOSOME

MIN_PREFERRED_HEIGHT

public static final int MIN_PREFERRED_HEIGHT

Y_TOP_IMAGE

public static final int Y_TOP_IMAGE

Y_IMAGE_OFFSET

public static final int Y_IMAGE_OFFSET

X_LEFT_IMAGE

public static final int X_LEFT_IMAGE

X_RIGHT_IMAGE

public static final int X_RIGHT_IMAGE

X_COMBO_BOX_OFFSET

public static final int X_COMBO_BOX_OFFSET

CHROMOSOME_TOP_SECTION_TOP

public static final int[] CHROMOSOME_TOP_SECTION_TOP
Chromosome image values, used to draw genes and alleles on them

CHROMOSOME_TOP_SECTION_BOTTOM

public static final int[] CHROMOSOME_TOP_SECTION_BOTTOM

CHROMOSOME_BOTTOM_SECTION_TOP

public static final int[] CHROMOSOME_BOTTOM_SECTION_TOP

CHROMOSOME_BOTTOM_SECTION_BOTTOM

public static final int[] CHROMOSOME_BOTTOM_SECTION_BOTTOM

CHROMOSOME_TOP_LENGTH

public static final int[] CHROMOSOME_TOP_LENGTH

CHROMOSOME_BOTTOM_LENGTH

public static final int[] CHROMOSOME_BOTTOM_LENGTH

CHROMOSOME_TOTAL_LENGTH

public static final int[] CHROMOSOME_TOTAL_LENGTH

CHROMOSOME_MID_POINT

public static final float[] CHROMOSOME_MID_POINT

selectionColor

protected java.awt.Color selectionColor
Selection color for a particular view
Constructor Detail

ChromosomeView

public ChromosomeView()
Creates a chromosome view.
Method Detail

getDefaultSelectionColor

public static java.awt.Color getDefaultSelectionColor()
Get the default selection color
Returns:
Color - default selection color, never null

setDefaultSelectionColor

public static void setDefaultSelectionColor(java.awt.Color aColor)
Set the default selection color. This will be used as the default selection color for views created after calling this method.

Parameters:
aColor - Color - a default selection color, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal (null)

setScrollPane

public void setScrollPane(javax.swing.JScrollPane aScrollPane)
Tell this view its scroll pane.
Overrides:
setScrollPane in class UIView
Parameters:
aScrollPane - JScrollPane - the scroll pane containing this view

updateScrollBars

public void updateScrollBars()
Update the scroll bar extents based on the number of organisms

setChromosomesSelectable

public void setChromosomesSelectable(boolean selectable)

isChromosomesSelectable

public boolean isChromosomesSelectable(boolean selectable)

setSelectionSet

public void setSelectionSet(SelectionSet selectSet)

getSelectionSet

public SelectionSet getSelectionSet()

getSelectionColor

public java.awt.Color getSelectionColor()
Get the selection color
Returns:
Color - selection color for this

setSelectionColor

public void setSelectionColor(java.awt.Color aColor)
Set the selection color. If null is input, the color reverts back to the default selection color.

Parameters:
aColor - Color - a new selection color, may be null

paintComponent

public void paintComponent(java.awt.Graphics g)
Draw the graphics in this view. Note that we are NOT overriding the paint method, as that would mean we're also responsible for painting the border and children, which we would rather leave to standard JFC code.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - Graphics - the given graphics to use in drawing

getPreferredSize

public java.awt.Dimension getPreferredSize()
Return the preferred size of this canvas
Overrides:
getPreferredSize in class UIView
Returns:
Dimension - preferred size of canvas

getChromosomesToShow

public int getChromosomesToShow()
Get the chromosomes to show. The returned value will be one of the following:
Returns:
chromosomesToShow int - the chromosomes to be shown (IChromosome.SEX_CHROMOSOME, 0 or positive integer)

setChromosomesToShow

public void setChromosomesToShow(int aChromosomesToShow)
Set the chromosomes to show. The input value must be one of the following: Note that this means you can pass exactly the result you get from calling the method getNumberType() on a SpeciesChromosome or OrganismChromosome object into this function and it will work properly.
Parameters:
aChromosomesToShow - int - the chromosome pair to show

imageUpdate

public boolean imageUpdate(java.awt.Image anImage,
                           int infoFlags,
                           int x,
                           int y,
                           int width,
                           int height)
ImageObserver method
Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Handle mouse click events
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Handle mouse entered event
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Handle mouse exited event
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Handle mouse pressed event
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Handle mouse released event
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Handle mouse dragged event
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Handle mouse moved event
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

getOrganism

public Organism getOrganism()
Get the shown organism for this view.
Returns:
Organism - the shown organism in this view, may be null

setOrganism

public void setOrganism(Organism anOrganism)
Set the shown organism for this view. This will result in the given organism's chromosomes being shown in the view. No particular chromosome nor allele is selected initially.

Parameters:
anOrganism - Organism - the organism whose chromosomes to show, may be null

getSelectedChromosome

public OrganismChromosome getSelectedChromosome()
Get the selected chromosome.
Returns:
OrganismChromosome - the currently selected chromosome, may be null

setSelectedChromosome

public void setSelectedChromosome(OrganismChromosome aChromosome)
Set the selected chromosome. This chromosome must be a chromosome of the current organism. If not, the call is ignored.

Parameters:
aChromosome - - an organism chromosome to select, may be null

getSelectedAllele

public OrganismAllele getSelectedAllele()
Get the selected allele.
Returns:
OrganismAllele - the currently selected allele, may be null

setSelectedAllele

public void setSelectedAllele(OrganismAllele anAllele)
Set the selected allele. The allele must be an allele of the current selected chromosome If not, the call is ignored.

Parameters:
anAllele - - an organism allele to select, may be null

updateState

public void updateState()
Update our view state. In this case, that means showing and hiding allele value combo boxes, etc.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle property change events
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - PropertyChangeEvent - the property change event

setOldAllele

public void setOldAllele(java.lang.String oldOne)

getOldAllele

public java.lang.String getOldAllele()

setNewAllele

public void setNewAllele(java.lang.String newOne)

getNewAllele

public java.lang.String getNewAllele()

setCurrentChromosome

public void setCurrentChromosome(OrganismChromosome chr)

getCurrentChromosome

public OrganismChromosome getCurrentChromosome()

organismAlleleControlChanged

public void organismAlleleControlChanged(OrganismAlleleControl control,
                                         OrganismAllele allele,
                                         java.lang.String newValue)
Handle combo box item changed events.