Class PairwiseDiagonalRenderer
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.bio.gui.sequence.PairwiseDiagonalRenderer
-
- All Implemented Interfaces:
java.io.Serializable,PairwiseSequenceRenderer,Changeable
public class PairwiseDiagonalRenderer extends AbstractChangeable implements PairwiseSequenceRenderer, java.io.Serializable
PairwiseDiagonalRendererrenders a region of similarity between two sequences as a straight line. The effect produced is similar to a dotplot. This implementation requires that these regions be represented bySimilarityPairFeatures.Drawing outside the visible area using a range of valid
doubles may cause Java to hang (Sun JDK 1.3.1 on Linux, Compaq JDK 1.3.1 on Tru64, but not Sun JDK 1.4.0-beta2-b77 on Linux). I got round this by manual clipping of the lines to the clip area. The code uses an implementation of the Cohen-Sutherland line-clipping algorithm which clips lines to within a rectangle.The clipping code is taken from Computer Graphics for Java Programmers by Leen Ammeraal (1998, ISBN 0-471-98142-7) and cosmetically altered to support Java2D objects. Any bugs introduced are my responsibility.
- Since:
- 1.2
- Author:
- Keith James, Leen Ammeraal
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.bio.gui.sequence.PairwiseSequenceRenderer
PairwiseSequenceRenderer.PairwiseRendererForwarder
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.geom.Line2D.Floatlinelineis the line to be drawn for each feature.protected java.awt.Paintoutlineoutlineis the line colour.static ChangeTypeOUTLINEConstantOUTLINEindicating a change to the fill of the features.
-
Constructor Summary
Constructors Constructor Description PairwiseDiagonalRenderer()Creates a newPairwiseDiagonalRendererwhich will draw black lines.PairwiseDiagonalRenderer(java.awt.Paint outline)Creates a newPairwiseDiagonalRendererwhich will draw lines using the specifiedPaint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.PaintgetOutline()getOutlinereturns the colour used to draw the lines.voidpaint(java.awt.Graphics2D g2, PairwiseRenderContext context)paintrenders the feature as a simple line.SequenceViewerEventprocessMouseEvent(PairwiseRenderContext context, java.awt.event.MouseEvent me, java.util.List path)processMouseEventacts on a mouse gesture.voidsetOutline(java.awt.Paint outline)setOutlinesets the the colour used to draw the lines.-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
OUTLINE
public static final ChangeType OUTLINE
ConstantOUTLINEindicating a change to the fill of the features.
-
line
protected java.awt.geom.Line2D.Float line
lineis the line to be drawn for each feature.
-
outline
protected java.awt.Paint outline
outlineis the line colour.
-
-
Constructor Detail
-
PairwiseDiagonalRenderer
public PairwiseDiagonalRenderer()
Creates a newPairwiseDiagonalRendererwhich will draw black lines.
-
PairwiseDiagonalRenderer
public PairwiseDiagonalRenderer(java.awt.Paint outline)
Creates a newPairwiseDiagonalRendererwhich will draw lines using the specifiedPaint.- Parameters:
outline- aPaint.
-
-
Method Detail
-
paint
public void paint(java.awt.Graphics2D g2, PairwiseRenderContext context)paintrenders the feature as a simple line.- Specified by:
paintin interfacePairwiseSequenceRenderer- Parameters:
g2- aGraphics2D.context- aPairwiseRenderContext.
-
getOutline
public java.awt.Paint getOutline()
getOutlinereturns the colour used to draw the lines.- Returns:
- a
Paint.
-
setOutline
public void setOutline(java.awt.Paint outline) throws ChangeVetoExceptionsetOutlinesets the the colour used to draw the lines.- Parameters:
outline- aPaint.- Throws:
ChangeVetoException- if an error occurs.
-
processMouseEvent
public SequenceViewerEvent processMouseEvent(PairwiseRenderContext context, java.awt.event.MouseEvent me, java.util.List path)
processMouseEventacts on a mouse gesture. The target object is aFeatureHoldercontaining the features on the primary sequence which contain the mouse pointer.- Specified by:
processMouseEventin interfacePairwiseSequenceRenderer- Parameters:
context- aPairwiseRenderContext.me- aMouseEvent.path- aList.- Returns:
- a
SequenceViewerEvent.
-
-