org.peace_tools.views.overlap
Class Ruler

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.peace_tools.views.overlap.Ruler
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

 class Ruler
extends javax.swing.JComponent

The overlap panel that displays the actual overlap image.

This panel performs the core task of drawing the various fragments illustrating the overlap. The fragments are drawn row-by-row using the data from a given (specified in the constructor) OverlapModel object. The size and location of the rectangles for each fragment depend on the current scaling factors set for this component (via call to setScale() method). The scaling factors also control the preferred size reported by this panel. The color map maintained by this class is used to color the fragments based on their cluster ID.

NoteThis class is meant to be instantiated and used only by the OverlapView class. Consequently it has been made package private.


Nested Class Summary
static class Ruler.Orientation
          Enumerations to define the two types of rulers that this class can be used for.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  double colScale
          The scale to be applies when rendering a single column.
private  java.awt.Dimension modelSize
          The Dimension that provides the necessary information for rendering the ruler displayed in this class.
private  Ruler.Orientation orientation
          The orientation being used for this ruler.
private  double rowScale
          The scale to be applies when rendering a single row.
private  int RULE_HEIGHT
          The preferred height of the horizontal ruler.
private static int RULE_WIDTH
          The preferred width of the vertical ruler.
private static long serialVersionUID
          A generated serialization UID just to keep the compiler happy.
 
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
Ruler(int modelWidth, int modelHeight, Ruler.Orientation orientation)
          The only constructor.
 
Method Summary
 void paintComponent(java.awt.Graphics g)
           
private  void paintHorizRule(java.awt.Graphics g)
          Helper method to paint the horizontal ruler.
private  void paintVerticalRule(java.awt.Graphics g)
          Helper method to paint the horizontal ruler.
 void setScale(double rowScale, double colScale)
          Method to set the current scales used by this component.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rowScale

private double rowScale
The scale to be applies when rendering a single row. This value represents the maximum height of each row. Once the row height is above 3 at least one blank line is allocated for each row to clearly delineate one row from the other. This value is initialized in the constructor and can be changed via a call to the setScale() method in this class. Typically this value is in integral units without any fractions. However, it is maintained as a double to accommodate non-integral scales in the future. However, this value should never be set to zero.


colScale

private double colScale
The scale to be applies when rendering a single column. This value represents the maximum width of each column. This value is initialized in the constructor and can be changed via a call to the setScale() method in this class. Typically this value is in integral units when columns occupy more than 1 pixel. If a column occupies fewer than one pixel then this value is a fractional value. This value should never be set to zero.


modelSize

private final java.awt.Dimension modelSize
The Dimension that provides the necessary information for rendering the ruler displayed in this class. Horizontal ruler uses the modelWidth while the vertical ruler uses modelHeight value from this instance variable. This instance variable is initialized by the constructor and is never changed during the life time of this object.


orientation

private final Ruler.Orientation orientation
The orientation being used for this ruler. This value is set in the constructor and is never changed for this model.


RULE_WIDTH

private static int RULE_WIDTH
The preferred width of the vertical ruler. This width is defined as a constant so that it is easy to set the size of the ruler appropriately.


RULE_HEIGHT

private int RULE_HEIGHT
The preferred height of the horizontal ruler. This height is defined as a constant so that it is easy to set the size of the ruler appropriately.


serialVersionUID

private static final long serialVersionUID
A generated serialization UID just to keep the compiler happy.

See Also:
Constant Field Values
Constructor Detail

Ruler

public Ruler(int modelWidth,
             int modelHeight,
             Ruler.Orientation orientation)
The only constructor.

Parameters:
modelWidth - The total width of the model in nucleotides. This value is typically the OverlapModel.getMaxCol().
modelHeight - The total height of the model in number of rows of nucleotides. This value is typically OverlapModel.getMaxRow().
orientation - The orientation that defines the type of ruler that this instance is to represent. The orientation determines the overall behavior of this class.
Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

paintHorizRule

private void paintHorizRule(java.awt.Graphics g)
Helper method to paint the horizontal ruler. This method is invoked from the main paint component method in order to draw a horizontal rule with the necessary ticks and labels. This method assumes that this ruler will always be added to the top of the overlap view panel.

Parameters:
g - The graphics object to be used for drawing the ticks.

paintVerticalRule

private void paintVerticalRule(java.awt.Graphics g)
Helper method to paint the horizontal ruler. This method is invoked from the main paint component method in order to draw a horizontal rule with the necessary ticks and labels. This method assumes that the vertical ruler will always be displayed to the left of the overlap panel.

Parameters:
g - The graphics object to be used for drawing the ticks.

setScale

public void setScale(double rowScale,
                     double colScale)
Method to set the current scales used by this component.

This method must be used to set the scales to be used for painting rows and columns in this panel. The scales also determine the overall size of this component.

Note: The containing component my repaint itself to ensure that changes in bounds are correctly refreshed on screen.

Parameters:
rowScale - The scale that determines the number of pixels occupied by each row. This value cannot be zero. However, no checks are performed on the scale. Consequently, the behavior of this component with a zero scale is undefined.
colScale - The scale that determines the number of pixels occupied by each row. This value cannot be zero. However, no checks are performed on the scale. Consequently, the behavior of this component with a zero scale is undefined.