org.concord.biologica.ui
Class OrganismView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.concord.biologica.ui.UIView
                          |
                          +--org.concord.biologica.ui.OrganismView
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
MultipleOrganismView, PedigreeOrganismView, SexOrganismView, SexView, StaticOrganismView

public class OrganismView
extends UIView
implements java.awt.image.ImageObserver

The basic organism view of BioLogica, used to hold all the code that is common to all views that draw organisms in a phenotypical manner.

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

Version:
$Revision: 1.15 $ $Date: 2002/04/05 17:27:41 $
Author:
$Author: dima $
See Also:
UIProp.BACKGROUND, UIProp.CHARACTERISTICS_TEXT_VISIBLE, UIProp.FONT, UIProp.FOREGROUND, UIProp.LOCK_SYMBOL_VISIBLE, UIProp.NAME_TEXT_VISIBLE, UIProp.ORGANISM_IMAGE_SIZE, UIProp.SEX_TEXT_VISIBLE, UIProp.SPECIES_TEXT_VISIBLE, UIProp.TEXT_INDENT, UIProp.TEXT_LINE_SPACING, 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
protected  boolean characteristicsTextVisible
          Characteristics text visible boolean flag.
protected  java.awt.Color highlightColor
          Highlight color for a particular view
protected  Organism hotspotOrganism
          Transient hotspot organism.
protected  OrganismImage hotspotOrganismImage
          Transient hotspot organism image.
protected  boolean lockSymbolVisible
          Lock symbol visible boolean flag
protected  boolean nameTextVisible
          Name text visible boolean flag.
protected  int organismImageSize
          Organism image size, used when drawing organisms.
protected  java.awt.Color selectionColor
          Selection color for a particular view
protected  boolean sexTextVisible
          Sex text visible boolean flag.
protected  boolean speciesTextVisible
          Species text visible boolean flag.
protected  int textIndent
          Indentation in pixels from left edge of image for text underneath the organism.
protected  int textLineSpacing
          Text line spacing, the distance between lines of text under an organism.
 
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
OrganismView()
          Creates an organism view.
 
Method Summary
static java.awt.Color getDefaultHighlightColor()
          Get the default selection color
static java.awt.Color getDefaultSelectionColor()
          Get the default selection color
 java.awt.Color getHighlightColor()
          Get the highlight color
protected  java.awt.Dimension getOrganismCellDimensions(Organism organism, int x, int y, int fontHeight, boolean drawAsTrait)
          Get organism cell dimensions, used when picking.
 int getOrganismImageSize()
          Get the organism image size for this view.
 java.awt.Color getSelectionColor()
          Get the selection color
 int getTextIndent()
          Get the text indent for this view.
 int getTextLineSpacing()
          Get the text line spacing for this view, the number of pixels between lines of text below an organism.
 boolean imageUpdate(java.awt.Image anImage, int infoFlags, int x, int y, int width, int height)
          ImageObserver method
 boolean isCharacteristicsTextVisible()
          Is the characteristics text visible?
 boolean isLockSymbolVisible()
          Is the lock symbol visible?
 boolean isNameTextVisible()
          Is the name text visible?
 boolean isSexTextVisible()
          Is the sex text visible?
 boolean isSpeciesTextVisible()
          Is the species text visible?
 void preloadSpeciesImages(Species aSpecies)
          Preload the species images for the given species at the current image size.
 void setCharacteristicsTextVisible(boolean aCharacteristicsTextVisible)
          Set the characteristics text visible boolean.
static void setDefaultHighlightColor(java.awt.Color aColor)
          Set the default Highlight color.
static void setDefaultSelectionColor(java.awt.Color aColor)
          Set the default selection color.
 void setHighlightColor(java.awt.Color aColor)
          Set the highlight color.
 void setLockSymbolVisible(boolean aLockSymbolVisible)
          Set the lock symbol visible boolean.
 void setNameTextVisible(boolean aNameTextVisible)
          Set the name text visible boolean.
 void setOrganismImageSize(int anOrganismImageSize)
          Set the organism image size for this view.
 void setSelectionColor(java.awt.Color aColor)
          Set the selection color.
 void setSexTextVisible(boolean aSexTextVisible)
          Set the sex text visible boolean.
 void setSpeciesTextVisible(boolean aSpeciesTextVisible)
          Set the species text visible boolean.
 void setTextIndent(int aTextIndent)
          Set the text indent for this view.
 void setTextLineSpacing(int aTextLineSpacing)
          Set the text line spacing for this view, the number of pixels between lines of text below an organism.
protected  void updateHotspotOnMousePress(Organism anOrganism, int xMouse, int yMouse)
          Update the hotspot state given that the user has pressed the mouse on the given organism at the given location in this view.
protected  void updateHotspotOnMouseReleased()
          Update the hotspot state given that the user has released the mouse.
 
Methods inherited from class org.concord.biologica.ui.UIView
addPropertyChangeListener, getLocalImage, getPreferredSize, paintBackground, removePropertyChangeListener, setBackground, setFont, setForeground, setScrollPane, 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, paintComponent, 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

lockSymbolVisible

protected boolean lockSymbolVisible
Lock symbol visible boolean flag

nameTextVisible

protected boolean nameTextVisible
Name text visible boolean flag.

sexTextVisible

protected boolean sexTextVisible
Sex text visible boolean flag.

speciesTextVisible

protected boolean speciesTextVisible
Species text visible boolean flag.

characteristicsTextVisible

protected boolean characteristicsTextVisible
Characteristics text visible boolean flag.

organismImageSize

protected int organismImageSize
Organism image size, used when drawing organisms. One of SpeciesImage.XXX_IMAGE_SIZE static values.

textIndent

protected int textIndent
Indentation in pixels from left edge of image for text underneath the organism. A default value is chosen when the view is created based but a script can set this value to something else explicitly.

textLineSpacing

protected int textLineSpacing
Text line spacing, the distance between lines of text under an organism.


hotspotOrganism

protected transient Organism hotspotOrganism
Transient hotspot organism. When this value is non-null, then we should paint the hotspotOrganismImage (below) for this organism.


hotspotOrganismImage

protected transient OrganismImage hotspotOrganismImage
Transient hotspot organism image. When this value and hotspotOrganism (above) are non-null, then we should paint this image for the hotspotOrganism.


highlightColor

protected java.awt.Color highlightColor
Highlight color for a particular view

selectionColor

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

OrganismView

public OrganismView()
Creates an organism view.

Method Detail

getDefaultHighlightColor

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

setDefaultHighlightColor

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

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

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)

isLockSymbolVisible

public boolean isLockSymbolVisible()
Is the lock symbol visible?
Returns:
boolean - is the lock symbol visible

setLockSymbolVisible

public void setLockSymbolVisible(boolean aLockSymbolVisible)
Set the lock symbol visible boolean.
Parameters:
aLockSymbolVisible - boolean - visible?

isCharacteristicsTextVisible

public boolean isCharacteristicsTextVisible()
Is the characteristics text visible?
Returns:
boolean - is the characteristics text visible

setCharacteristicsTextVisible

public void setCharacteristicsTextVisible(boolean aCharacteristicsTextVisible)
Set the characteristics text visible boolean.
Parameters:
aCharacteristicsTextVisible - boolean - visible?

isNameTextVisible

public boolean isNameTextVisible()
Is the name text visible?
Returns:
boolean - is the name text visible

setNameTextVisible

public void setNameTextVisible(boolean aNameTextVisible)
Set the name text visible boolean.
Parameters:
aNameTextVisible - boolean - visible?

isSexTextVisible

public boolean isSexTextVisible()
Is the sex text visible?
Returns:
boolean - is the sex text visible

setSexTextVisible

public void setSexTextVisible(boolean aSexTextVisible)
Set the sex text visible boolean.
Parameters:
aSexTextVisible - boolean - visible?

isSpeciesTextVisible

public boolean isSpeciesTextVisible()
Is the species text visible?
Returns:
boolean - is the species text visible

setSpeciesTextVisible

public void setSpeciesTextVisible(boolean aSpeciesTextVisible)
Set the species text visible boolean.
Parameters:
aSpeciesTextVisible - boolean - visible?

getHighlightColor

public java.awt.Color getHighlightColor()
Get the highlight color
Returns:
Color - highlight color for this

setHighlightColor

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

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

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

preloadSpeciesImages

public void preloadSpeciesImages(Species aSpecies)
Preload the species images for the given species at the current image size.

Note that this is just a performance enhancement and is not something a user of the BioLogica engine must call. It just speeds drawing of the first organism of this species at this image size.

Parameters:
aSpecies - Species - a species

getOrganismImageSize

public int getOrganismImageSize()
Get the organism image size for this view.

Returns:
int - organism image size

setOrganismImageSize

public void setOrganismImageSize(int anOrganismImageSize)
Set the organism image size for this view. The size must be one of the SpeciesImage.XXX_IMAGE_SIZE static values.

Parameters:
anOrganismImageSize - int - a new organism image size
Throws:
java.lang.IllegalArgumentException - - illegal input value

getTextIndent

public int getTextIndent()
Get the text indent for this view.

Returns:
int - text indent

setTextIndent

public void setTextIndent(int aTextIndent)
Set the text indent for this view.

Parameters:
aTextIndent - int - a new text indent

getTextLineSpacing

public int getTextLineSpacing()
Get the text line spacing for this view, the number of pixels between lines of text below an organism.

Returns:
int - text line spacing

setTextLineSpacing

public void setTextLineSpacing(int aTextLineSpacing)
Set the text line spacing for this view, the number of pixels between lines of text below an organism.

Parameters:
aTextLineSpacing - int - a new text line spacing

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

getOrganismCellDimensions

protected java.awt.Dimension getOrganismCellDimensions(Organism organism,
                                                       int x,
                                                       int y,
                                                       int fontHeight,
                                                       boolean drawAsTrait)
Get organism cell dimensions, used when picking.
Parameters:
organism - Organism - the organism to draw
x - int - x location
y - int - y location
fontHeight - int - font height
drawAsTrait - boolean - is organism drawn as a trait?
Returns:
Dimension - cell size

updateHotspotOnMousePress

protected void updateHotspotOnMousePress(Organism anOrganism,
                                         int xMouse,
                                         int yMouse)
Update the hotspot state given that the user has pressed the mouse on the given organism at the given location in this view. This may or may not turn on a hotspot.

Parameters:
anOrganism - Organism - the organism that the user has pressed on
xMouse - int - x coordinate of mouse press relative to topleft of organism's cell
yMouse - int - y coordinate of mouse press relative to topleft of organism's cell

updateHotspotOnMouseReleased

protected void updateHotspotOnMouseReleased()
Update the hotspot state given that the user has released the mouse. This will always turn off a hotspot if one is active.