|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.peace_tools.views.overlap.OverlapPanel
class OverlapPanel
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 |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
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 ClusterColorMapper |
colorMapper
Helper to look-up color for a given cluster ID. |
private double |
colScale
The scale to be applies when rendering a single column. |
private java.awt.Font |
font
The font being used by this panel to render information for each fragment. |
private OverlapModel |
overlapModel
The OverlapModel that provides the necessary information for rendering the core information required by this panel. |
private int |
renderInfo
Variable to indicate the information about a fragment that should be rendered. |
private double |
rowScale
The scale to be applies when rendering a single row. |
private static long |
serialVersionUID
Generated serialization UID (merely 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 | |
---|---|
OverlapPanel(OverlapModel overlapModel,
ClusterColorMapper colorMapper,
double rowScale,
double colScale)
The only constructor. |
Method Summary | |
---|---|
private java.awt.Font |
computeFont(java.awt.Graphics g)
Compute the font that will fit letters within each fragment rectangle. |
double |
getColScale()
Obtain the current column scaling factor being used. |
int |
getRenderInfo()
Obtain the type of information being rendered for each fragment. |
double |
getRowScale()
Obtain the current row scaling factor being used. |
private void |
paint(java.awt.Graphics main,
int row,
ESTEntry fragment)
Helper method to paint a given fragment using a given graphics handle. |
void |
paintComponent(java.awt.Graphics g)
Override the default paint method for this panel to render fragments. |
void |
setRenderInfo(int renderInfo)
Set the type of information to be rendered for each fragment. |
void |
setScale(double rowScale,
double colScale)
Method to set the current scales used by this component. |
private java.awt.Rectangle |
toModelCoordinates(java.awt.Rectangle pixelBounds)
Helper method to translate graphics coordinates to model coordinates. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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 |
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 |
---|
private double rowScale
private double colScale
private final OverlapModel overlapModel
private final ClusterColorMapper colorMapper
private int renderInfo
private java.awt.Font font
computeFont(Graphics)
method) such that the characters fit within the scales specified
for this object. Each time the scale is changed the font is reset to
null (in the setScale(double, double)
method) to fore
computing a new font.
private static final long serialVersionUID
Constructor Detail |
---|
public OverlapPanel(OverlapModel overlapModel, ClusterColorMapper colorMapper, double rowScale, double colScale)
overlapModel
- The overlap model from where the data for
rendering the fragments is obtained.colorMapper
- The helper object to be used to determine the
color for rendering fragments belonging to various clusters.rowScale
- The initial scale for the rows that determines the
pixel size of each row.colScale
- The initial scale for columns that determines the
pixel size of each column.Method Detail |
---|
public void setRenderInfo(int renderInfo)
renderInfo
- A simple integer code indicating the type of
information to be rendered by this panel. See list above for
details.public int getRenderInfo()
public double getRowScale()
public double getColScale()
private java.awt.Rectangle toModelCoordinates(java.awt.Rectangle pixelBounds)
setScale(double, double)
method)
to perform the translation.
pixelBounds
- The graphical coordinates (in pixel values) to be
translated.
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- The graphics component to be used for rendering the
fragments.private void paint(java.awt.Graphics main, int row, ESTEntry fragment)
main
- The graphics handle to be used for rendering the given
fragment.row
- The logical model row where the fragment is to be rendered.fragment
- The fragment to be rendered.private java.awt.Font computeFont(java.awt.Graphics g)
paintComponent(Graphics)
method
whenever the font
instance variable is null. This method uses
the supplied Graphics object to compute the largest mono-spaced font that
will fit within the allocated space for a fragment.
g
- The graphics handle to be used for computing the font sizes.
public void setScale(double rowScale, double colScale)
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.
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |