Package org.biojava.bio.gui.sequence
Class CrosshairRenderer
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.bio.gui.sequence.CrosshairRenderer
-
- All Implemented Interfaces:
PairwiseSequenceRenderer,Changeable
public class CrosshairRenderer extends AbstractChangeable implements PairwiseSequenceRenderer
CrosshairRendererdraws a crosshair, optionally with coordinates. The crosshair is set to a sequence position by a click and then stays there through scrolls/rescales until the next click. See theprocessMouseEventdocumentation for details of responses to various mouse actions.- Since:
- 1.2
- Author:
- Keith James
-
-
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 static ChangeTypeOUTLINEConstantOUTLINEindicating a change to the crosshair paint.protected java.awt.Pointpointpointis the current location (in sequence coordinates) of the crosshair in the X and Y sequences.protected java.awt.geom.Line2DxHairxHairis the vertical line positioned along the X-axis.protected java.awt.geom.Line2DyHairyHairis the horizontal line positioned along the Y-axis.
-
Constructor Summary
Constructors Constructor Description CrosshairRenderer()Creates a newCrosshairRendererin light grey with coordinates displayed.CrosshairRenderer(java.awt.Paint outline)Creates a newCrosshairRendererof the specified colour, with coordinates displayed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcoordinateDisplayOn(boolean display)coordinateDisplayOntoggles the display of sequence coordinates.java.awt.PaintgetOutline()getOutlinereturns the colour used to draw the lines.voidpaint(java.awt.Graphics2D g2, PairwiseRenderContext context)paints some or all of the information about the sequence pair.SequenceViewerEventprocessMouseEvent(PairwiseRenderContext context, java.awt.event.MouseEvent me, java.util.List path)processMouseEventprocesses anyMouseEvents directed to the renderer.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 crosshair paint.
-
xHair
protected java.awt.geom.Line2D xHair
xHairis the vertical line positioned along the X-axis.
-
yHair
protected java.awt.geom.Line2D yHair
yHairis the horizontal line positioned along the Y-axis.
-
point
protected java.awt.Point point
pointis the current location (in sequence coordinates) of the crosshair in the X and Y sequences.
-
-
Constructor Detail
-
CrosshairRenderer
public CrosshairRenderer()
Creates a newCrosshairRendererin light grey with coordinates displayed.
-
CrosshairRenderer
public CrosshairRenderer(java.awt.Paint outline)
Creates a newCrosshairRendererof the specified colour, with coordinates displayed.- Parameters:
outline- aPaint.
-
-
Method Detail
-
paint
public void paint(java.awt.Graphics2D g2, PairwiseRenderContext context)Description copied from interface:PairwiseSequenceRendererpaints some or all of the information about the sequence pair.- Specified by:
paintin interfacePairwiseSequenceRenderer- Parameters:
g2- aGraphics2D.context- aPairwiseRenderContextencapsulating the information to be displayed.
-
coordinateDisplayOn
public void coordinateDisplayOn(boolean display)
coordinateDisplayOntoggles the display of sequence coordinates.- Parameters:
display- aboolean.
-
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)
processMouseEventprocesses anyMouseEvents directed to the renderer.Mouse actions are as follows (all are button-1 only):
- Click sets the crosshair position and returns an event
whose target object is the
Pointin sequence coordinates. The X coordinate is in the primary sequence, the Y coordinate is in the secondary sequence. - Press same as Click
- Drag same as Click, except that the
Pointis not set - Release same as Click, except that the
Pointis not set - Move same as Click, except that the
Pointis not set and the target is null
- Specified by:
processMouseEventin interfacePairwiseSequenceRenderer- Parameters:
context- aPairwiseRenderContext.me- aMouseEvent.path- aList.- Returns:
- a
SequenceViewerEvent.
- Click sets the crosshair position and returns an event
whose target object is the
-
-