public class PairwiseSequencePanel extends JComponent implements PairwiseRenderContext, Changeable, Serializable
A PairwiseSequencePanel is a panel that displays a
pair of sequences; one sequence (the primary) may be either
left-to-right (HORIZONTAL) or from top-to-bottom (VERTICAL). The
other sequence (secondary) will then occupy the remaining
direction. It has an associated scale which is the number of pixels
per symbol and applies to both sequences. The leading and trailing
borders apply to the primary sequence only.
The primary purpose of this component is to provide a means for representing graphically comparisons between two sequences. This could be anything from traditional dotplots (or variants created with lines) to a more complex layered plot involving superimposed renderers.
Each sequence has a translation which is the number of
Symbols to skip before rendering starts. In order to
produce a scrolling effect, the setSymbolTranslation
or setSecondarySymbolTranslation method may be hooked
up to an Adjustable such as JScrollBar or
to an event listener.
The exact number of Symbols rendered in each
sequence depends on the dimensions of the panel and the
scale. Resizing the panel will cause the number of
Symbols rendered to change accordingly.
The panel will fill its background to the Color
defined by the setBackground() method provided that it
has been defined as opaque using setOpaque().
The change event handling code is based on the original panel and other BioJava components by Matthew and Thomas.
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategySequenceRenderContext.Border| Modifier and Type | Field and Description |
|---|---|
static ChangeType |
RENDERER
Constant
RENDERER is a ChangeType
which indicates a change to the renderer, requiring a layout
update. |
static ChangeType |
TRANSLATION
Constant
TRANSLATION is a ChangeType
which indicates a change to the translation, requiring a paint
update. |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTLAYOUT, REPAINTBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
PairwiseSequencePanel()
Creates a new
PairwiseSequencePanel with the
default settings (primary sequence direction HORIZONTAL, scale
10.0 pixels per symbol, symbol translation 0, secondary symbol
translation 0, leading border 0.0, trailing border 0.0, 12
point sanserif font). |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener cl)
addChangeListener adds a listener for all types of
change. |
void |
addChangeListener(ChangeListener cl,
ChangeType ct)
addChangeListener adds a listener for specific
types of change. |
void |
addSequenceViewerListener(SequenceViewerListener svl)
addSequenceViewerListener adds a listener for
mouse click SequenceViewerEvents. |
void |
addSequenceViewerMotionListener(SequenceViewerMotionListener svml)
addSequenceViewerMotionListener adds a listener for
mouse motion SequenceViewerEvents. |
protected ChangeSupport |
getChangeSupport(ChangeType ct)
getChangeSupport lazily instantiates a helper for
change listeners. |
int |
getDirection()
getDirection returns the direction in which this
context expects the sequence to be rendered - HORIZONTAL or
VERTICAL. |
FeatureHolder |
getFeatures()
getFeatures returns all of the
Features belonging to the currently rendered
Sequence. |
SequenceRenderContext.Border |
getLeadingBorder()
getLeadingBorder returns the leading border of the
primary sequence. |
RangeLocation |
getRange()
getRange returns a RangeLocation
representing the region of the sequence currently being
rendered. |
PairwiseSequenceRenderer |
getRenderer()
getRenderer returns the current
PairwiseSequenceRenderer. |
RenderingHints |
getRenderingHints()
getRenderingHints returns the
RenderingHints currently being used by the
Graphics2D instances of delegate renderers. |
double |
getScale()
getScale returns the scale in pixels per
Symbol. |
int |
getSecondaryDirection()
getSecondaryDirection returns the direction in
which this context expects the secondary sequence to be
rendered - HORIZONTAL or VERTICAL. |
FeatureHolder |
getSecondaryFeatures()
getSecondaryFeatures returns all of the
Features belonging to the currently rendered
secondary Sequence. |
RangeLocation |
getSecondaryRange()
getSecondaryRange returns a
RangeLocation representing the region of the
secondary sequence currently being rendered. |
Sequence |
getSecondarySequence()
getSecondarySequence returns the entire secondary
Sequence currently being rendered. |
SymbolList |
getSecondarySymbols()
getSecondarySymbols returns all of the
Symbols belonging to the currently rendered
secondary Sequence. |
int |
getSecondarySymbolTranslation()
getSecondarySymbolTranslation returns the current
translation in Symbols which will be applied when
rendering. |
Sequence |
getSequence()
getSequence returns the entire
Sequence currently being rendered. |
SymbolList |
getSymbols()
getSymbols returns all of the Symbols
belonging to the currently rendered Sequence. |
int |
getSymbolTranslation()
getSymbolTranslation returns the current
translation in Symbols which will be applied when
rendering. |
SequenceRenderContext.Border |
getTrailingBorder()
getTrailingBorder returns the trailing border of
the primary sequence. |
int |
getVisibleSecondarySymbolCount()
getVisibleSecondarySymbolCount returns the
maximum number of secondary
Symbols which can be rendered in the visible area
(excluding all borders) of the
PairwiseSequencePanel at the current scale. |
int |
getVisibleSymbolCount()
getVisibleSymbolCount returns the
maximum number of Symbols which
can be rendered in the visible area (excluding all borders) of
the PairwiseSequencePanel at the current
scale. |
int |
graphicsToSecondarySequence(double graphicsPos)
graphicsToSecondarySequence converts a graphical
position to a secondary sequence index. |
int |
graphicsToSecondarySequence(Point point)
graphicsToSecondarySequence converts a graphical
position to a secondary sequence index. |
int |
graphicsToSequence(double graphicsPos)
graphicsToSequence converts a graphical position
to a sequence index. |
int |
graphicsToSequence(Point2D point)
graphicsToSequence converts a graphical position
to a sequence index. |
protected boolean |
hasListeners()
hasListeners returns true if there are active
listeners for BioJava events. |
protected boolean |
isActive()
isActive returns true if both the
Sequences to be rendered and the
PairwiseHomologyRenderer are not null. |
boolean |
isUnchanging(ChangeType ct)
A particular ChangeType can never be raised by this Changeable.
|
void |
paintComponent(Graphics g) |
void |
removeChangeListener(ChangeListener cl)
removeChangeListener removes a listener. |
void |
removeChangeListener(ChangeListener cl,
ChangeType ct)
removeChangeListener removes a listener. |
void |
removeSequenceViewerListener(SequenceViewerListener svl)
removeSequenceViewerListener removes a listener
for mouse click SequenceViewerEvents. |
void |
removeSequenceViewerMotionListener(SequenceViewerMotionListener svml)
addSequenceViewerMotionListener removes a listener for
mouse motion SequenceViewerEvents. |
void |
resizeAndValidate()
resizeAndValidate sets the minimum, preferred and
maximum sizes of the component according to the current visible
symbol count. |
double |
secondarySequenceToGraphics(int sequencePos)
secondarySequenceToGraphics converts a sequence
index to a graphical position. |
double |
sequenceToGraphics(int sequencePos)
sequenceToGraphics converts a sequence index
to a graphical position. |
void |
setDirection(int direction)
setDirection sets the direction in which this
context will render the sequence - HORIZONTAL or VERTICAL. |
void |
setRenderer(PairwiseSequenceRenderer renderer)
setRenderer sets the current
PairwiseSequenceRenderer. |
void |
setRenderingHints(RenderingHints hints)
setRenderingHints sets the
RenderingHints which will be used by the
Graphics2D instances of delegate renderers. |
void |
setScale(double scale)
setScale sets the scale in pixels per
Symbol. |
void |
setSecondarySequence(Sequence sequence)
setSecondarySequence sets the secondary
Sequence to be rendered. |
void |
setSecondarySymbolTranslation(int translation)
setSecondarySymbolTranslation sets the translation
in Symbols which will be applied when
rendering. |
void |
setSequence(Sequence sequence)
setSequence sets the Sequence
to be rendered. |
void |
setSymbolTranslation(int translation)
setSymbolTranslation sets the translation in
Symbols which will be applied when rendering. |
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateUIadd, 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, validateTreeaction, 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, getAccessibleContext, 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, 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, transferFocusUpCycleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFontpublic static final ChangeType RENDERER
RENDERER is a ChangeType
which indicates a change to the renderer, requiring a layout
update.public static final ChangeType TRANSLATION
TRANSLATION is a ChangeType
which indicates a change to the translation, requiring a paint
update.public PairwiseSequencePanel()
PairwiseSequencePanel with the
default settings (primary sequence direction HORIZONTAL, scale
10.0 pixels per symbol, symbol translation 0, secondary symbol
translation 0, leading border 0.0, trailing border 0.0, 12
point sanserif font).public Sequence getSequence()
getSequence returns the entire
Sequence currently being rendered.Sequence.public void setSequence(Sequence sequence)
setSequence sets the Sequence
to be rendered.sequence - a Sequence.public Sequence getSecondarySequence()
getSecondarySequence returns the entire secondary
Sequence currently being rendered.Sequence.public void setSecondarySequence(Sequence sequence)
setSecondarySequence sets the secondary
Sequence to be rendered.sequence - a Sequence.public SymbolList getSymbols()
getSymbols returns all of the Symbols
belonging to the currently rendered Sequence.getSymbols in interface SequenceRenderContextSymbolList.public SymbolList getSecondarySymbols()
getSecondarySymbols returns all of the
Symbols belonging to the currently rendered
secondary Sequence.getSecondarySymbols in interface PairwiseRenderContextSymbolList.public FeatureHolder getFeatures()
getFeatures returns all of the
Features belonging to the currently rendered
Sequence.getFeatures in interface SequenceRenderContextFeatureHolder.public FeatureHolder getSecondaryFeatures()
getSecondaryFeatures returns all of the
Features belonging to the currently rendered
secondary Sequence.getSecondaryFeatures in interface PairwiseRenderContextFeatureHolder.public RangeLocation getRange()
getRange returns a RangeLocation
representing the region of the sequence currently being
rendered. This is calculated from the size of the
PairwiseSequencePanel, the current rendering
translation and the current scale. The value will therefore
change when the PairwiseSequencePanel is resized
or "scrolled" by changing the translation.getRange in interface SequenceRenderContextRangeLocation.public RangeLocation getSecondaryRange()
getSecondaryRange returns a
RangeLocation representing the region of the
secondary sequence currently being rendered. This is calculated
from the size of the PairwiseSequencePanel, the
current rendering translation and the current scale. The value
will therefore change when the
PairwiseSequencePanel is resized or "scrolled" by
changing the translation.getSecondaryRange in interface PairwiseRenderContextRangeLocation.public int getDirection()
getDirection returns the direction in which this
context expects the sequence to be rendered - HORIZONTAL or
VERTICAL.getDirection in interface SequenceRenderContextint.public void setDirection(int direction) throws IllegalArgumentException
setDirection sets the direction in which this
context will render the sequence - HORIZONTAL or VERTICAL.direction - an int.IllegalArgumentException - if an invalid direction is
used.public int getSecondaryDirection()
getSecondaryDirection returns the direction in
which this context expects the secondary sequence to be
rendered - HORIZONTAL or VERTICAL.getSecondaryDirection in interface PairwiseRenderContextint.public double getScale()
getScale returns the scale in pixels per
Symbol.getScale in interface SequenceRenderContextdouble.public void setScale(double scale)
setScale sets the scale in pixels per
Symbol.scale - a double.public int getSymbolTranslation()
getSymbolTranslation returns the current
translation in Symbols which will be applied when
rendering. The sequence will be rendered starting at this
translation. Values may be from 0 to the length of the rendered
sequence.int.public void setSymbolTranslation(int translation) throws IndexOutOfBoundsException
setSymbolTranslation sets the translation in
Symbols which will be applied when rendering. The
sequence will be rendered starting at that translation. Values
may be from 0 to the length of the rendered sequence.translation - an int.IndexOutOfBoundsException - if the translation is
greater than the sequence length.public int getSecondarySymbolTranslation()
getSecondarySymbolTranslation returns the current
translation in Symbols which will be applied when
rendering. The secondary sequence will be rendered starting at
this translation. Values may be from 0 to the length of the
rendered sequence.int.public void setSecondarySymbolTranslation(int translation) throws IndexOutOfBoundsException
setSecondarySymbolTranslation sets the translation
in Symbols which will be applied when
rendering. The secondary sequence will be rendered starting at
that translation. Values may be from 0 to the length of the
rendered sequence.translation - an int.IndexOutOfBoundsException - if the translation is
greater than the sequence length.public SequenceRenderContext.Border getLeadingBorder()
getLeadingBorder returns the leading border of the
primary sequence.getLeadingBorder in interface SequenceRenderContextSequenceRenderContext.Border.public SequenceRenderContext.Border getTrailingBorder()
getTrailingBorder returns the trailing border of
the primary sequence.getTrailingBorder in interface SequenceRenderContextSequenceRenderContext.Border.public PairwiseSequenceRenderer getRenderer()
getRenderer returns the current
PairwiseSequenceRenderer.PairwiseSequenceRenderer.public void setRenderer(PairwiseSequenceRenderer renderer) throws ChangeVetoException
setRenderer sets the current
PairwiseSequenceRenderer.ChangeVetoExceptionpublic RenderingHints getRenderingHints()
getRenderingHints returns the
RenderingHints currently being used by the
Graphics2D instances of delegate renderers. If
none is set, the constructor creates one with a null
Map.RenderingHints.public void setRenderingHints(RenderingHints hints)
setRenderingHints sets the
RenderingHints which will be used by the
Graphics2D instances of delegate renderers.hints - a RenderingHints.public double sequenceToGraphics(int sequencePos)
sequenceToGraphics converts a sequence index
to a graphical position.sequenceToGraphics in interface SequenceRenderContextsequencePos - an int.double.public double secondarySequenceToGraphics(int sequencePos)
secondarySequenceToGraphics converts a sequence
index to a graphical position.secondarySequenceToGraphics in interface PairwiseRenderContextsequencePos - an int.double.public int graphicsToSequence(double graphicsPos)
graphicsToSequence converts a graphical position
to a sequence index.graphicsToSequence in interface SequenceRenderContextgraphicsPos - a double.int.public int graphicsToSequence(Point2D point)
graphicsToSequence converts a graphical position
to a sequence index.graphicsToSequence in interface SequenceRenderContextpoint - a graphic position.int.public int graphicsToSecondarySequence(double graphicsPos)
graphicsToSecondarySequence converts a graphical
position to a secondary sequence index.graphicsToSecondarySequence in interface PairwiseRenderContextgraphicsPos - a double.int.public int graphicsToSecondarySequence(Point point)
graphicsToSecondarySequence converts a graphical
position to a secondary sequence index.graphicsToSecondarySequence in interface PairwiseRenderContextpoint - a Point.int.public int getVisibleSymbolCount()
getVisibleSymbolCount returns the
maximum number of Symbols which
can be rendered in the visible area (excluding all borders) of
the PairwiseSequencePanel at the current
scale. Note that if the translation is greater than 0, the
actual number of Symbols rendered will be less.int.public int getVisibleSecondarySymbolCount()
getVisibleSecondarySymbolCount returns the
maximum number of secondary
Symbols which can be rendered in the visible area
(excluding all borders) of the
PairwiseSequencePanel at the current scale. Note
that if the translation is greater than 0, the actual number of
Symbols rendered will be less.int.public void paintComponent(Graphics g)
paintComponent in class JComponentpublic void resizeAndValidate()
resizeAndValidate sets the minimum, preferred and
maximum sizes of the component according to the current visible
symbol count.public void addChangeListener(ChangeListener cl)
addChangeListener adds a listener for all types of
change.addChangeListener in interface Changeablecl - a ChangeListener.public void addChangeListener(ChangeListener cl, ChangeType ct)
addChangeListener adds a listener for specific
types of change.addChangeListener in interface Changeablecl - a ChangeListener.ct - a ChangeType.public void removeChangeListener(ChangeListener cl)
removeChangeListener removes a listener.removeChangeListener in interface Changeablecl - a ChangeListener.public void removeChangeListener(ChangeListener cl, ChangeType ct)
removeChangeListener removes a listener.removeChangeListener in interface Changeablecl - a ChangeListener.ct - a ChangeType.public boolean isUnchanging(ChangeType ct)
ChangeableA particular ChangeType can never be raised by this Changeable.
If this returns true, then it is guaranteed that change events of this type (and all child types) can never under any circumstances be fired by this Changeable instance. If it returns false, that does not mean that this type of event will or even can be raised, but that it is worth registering listeners incase.
isUnchanging in interface Changeablect - the ChangeType to checkpublic void addSequenceViewerListener(SequenceViewerListener svl)
addSequenceViewerListener adds a listener for
mouse click SequenceViewerEvents.svl - a SequenceViewerListener.public void removeSequenceViewerListener(SequenceViewerListener svl)
removeSequenceViewerListener removes a listener
for mouse click SequenceViewerEvents.svl - a SequenceViewerListener.public void addSequenceViewerMotionListener(SequenceViewerMotionListener svml)
addSequenceViewerMotionListener adds a listener for
mouse motion SequenceViewerEvents.svml - a SequenceViewerMotionListener.public void removeSequenceViewerMotionListener(SequenceViewerMotionListener svml)
addSequenceViewerMotionListener removes a listener for
mouse motion SequenceViewerEvents.svml - a SequenceViewerMotionListener.protected ChangeSupport getChangeSupport(ChangeType ct)
getChangeSupport lazily instantiates a helper for
change listeners.ct - a ChangeType.ChangeSupport object.protected boolean hasListeners()
hasListeners returns true if there are active
listeners for BioJava events.boolean value.protected boolean isActive()
isActive returns true if both the
Sequences to be rendered and the
PairwiseHomologyRenderer are not null.boolean value.Copyright © 2020 BioJava. All rights reserved.