Package org.biojava.bio.gui.sequence
Class AbstractBeadRenderer
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojava.bio.gui.sequence.AbstractBeadRenderer
- All Implemented Interfaces:
Serializable
,BeadFeatureRenderer
,FeatureRenderer
,Changeable
- Direct Known Subclasses:
EllipticalBeadRenderer
,RectangularBeadRenderer
,RoundRectangularBeadRenderer
public abstract class AbstractBeadRenderer
extends AbstractChangeable
implements BeadFeatureRenderer, Serializable
AbstractBeadRenderer
is a an abstract base class
for the creation of FeatureRenderer
s which use a
'string of beads' metaphor for displaying features. Each subclass
of AbstractBeadRenderer
should override the abstract
method renderBead()
and provide the drawing routine
for its particular bead type.
A concrete BeadFeatureRenderer
may render a series
of features in more than one style by delegating to other
BeadFeatureRenderer
s for the additional style(s). This
is achieved using the setDelegateRenderer()
method
which associates an OptimizableFilter
with another
BeadFeatureRenderer
. Any feature accepted by the
filter is rendered with that renderer, while the remainder are
rendered by the current renderer.
- Since:
- 1.2
- Author:
- Keith James, Paul Seed
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
protected double
protected Paint
protected Paint
protected Stroke
protected Map
protected Map
static final ChangeType
ConstantDEPTH
indicating a change to the depth of the renderer.static final ChangeType
ConstantDISPLACEMENT
indicating a change to the Y-axis displacement of the features.static final ChangeType
ConstantFILL
indicating a change to the fill of the features.static final ChangeType
ConstantOUTLINE
indicating a change to the outline paint of the features.static final ChangeType
ConstantSTROKE
indicating a change to the outline stroke of the features. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAbstractBeadRenderer
with no delegates.AbstractBeadRenderer
(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke) Creates a newAbstractBeadRenderer
object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getBeadDepth
returns the depth of a single bead produced by this renderer.double
getBeadDisplacement
returns the displacement of beads from the centre line of the renderer.getBeadFill
returns the bead fill paint.getBeadOutline
returns the bead outline paint.getBeadStroke
returns the bead outline stroke.double
getDepth
(SequenceRenderContext context) getDepth
calculates the depth required by this renderer to display its beads.processMouseEvent
(FeatureHolder holder, SequenceRenderContext context, MouseEvent mEvent) processMouseEvent
defines the behaviour on revieving a mouse event.void
removeDelegateRenderer
removes any association of the givenOptimizableFilter
with aBeadFeatureRenderer
.abstract void
renderBead
(Graphics2D g2, Feature f, SequenceRenderContext context) renderBead
should be overridden by the concreteBeadRenderer
.void
renderFeature
(Graphics2D g2, Feature f, SequenceRenderContext context) renderFeature
draws a feature using the supplied graphics context.void
setBeadDepth
(double depth) setBeadDepth
sets the depth of a single bead produced by this renderer.void
setBeadDisplacement
(double displacement) setBeadDisplacement
sets the displacement of beads from the centre line of the renderer.void
setBeadFill
(Paint fill) setBeadFill
sets the bead fill paint.void
setBeadOutline
(Paint outline) setBeadOutline
sets the bead outline paint.void
setBeadStroke
(Stroke stroke) setBeadStroke
sets the bead outline stroke.void
setDelegateRenderer
(OptimizableFilter filter, BeadFeatureRenderer renderer) setDelegateRenderer
associates anOptimizableFilter
with aBeadFeatureRenderer
.Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Field Details
-
DISPLACEMENT
ConstantDISPLACEMENT
indicating a change to the Y-axis displacement of the features. -
DEPTH
ConstantDEPTH
indicating a change to the depth of the renderer. -
OUTLINE
ConstantOUTLINE
indicating a change to the outline paint of the features. -
STROKE
ConstantSTROKE
indicating a change to the outline stroke of the features. -
FILL
ConstantFILL
indicating a change to the fill of the features. -
beadDepth
-
beadDisplacement
-
beadOutline
-
beadFill
-
beadStroke
-
delegates
-
delegationCache
-
-
Constructor Details
-
AbstractBeadRenderer
public AbstractBeadRenderer()Creates a newAbstractBeadRenderer
with no delegates. It will render all features itself, using its own style settings. -
AbstractBeadRenderer
public AbstractBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke) Creates a newAbstractBeadRenderer
object.- Parameters:
beadDepth
- adouble
.beadDisplacement
- adouble
.beadOutline
- aPaint
.beadFill
- aPaint
.beadStroke
- aStroke
.
-
-
Method Details
-
processMouseEvent
public FeatureHolder processMouseEvent(FeatureHolder holder, SequenceRenderContext context, MouseEvent mEvent) processMouseEvent
defines the behaviour on revieving a mouse event.- Specified by:
processMouseEvent
in interfaceFeatureRenderer
- Parameters:
holder
- aFeatureHolder
.context
- aSequenceRenderContext
.mEvent
- aMouseEvent
.- Returns:
- a
FeatureHolder
.
-
renderFeature
renderFeature
draws a feature using the supplied graphics context. The rendering may be delegated to anotherFeatureRenderer
instance.- Specified by:
renderFeature
in interfaceFeatureRenderer
- Parameters:
g2
- aGraphics2D
context.f
- aFeature
to render.context
- aSequenceRenderContext
context.
-
setDelegateRenderer
public void setDelegateRenderer(OptimizableFilter filter, BeadFeatureRenderer renderer) throws IllegalArgumentException setDelegateRenderer
associates anOptimizableFilter
with aBeadFeatureRenderer
. Any feature accepted by the filter will be passed to the associated renderer for drawing. TheOptimizableFilter
s should be disjoint with respect to each other (a feature may not be rendered more than once).- Specified by:
setDelegateRenderer
in interfaceBeadFeatureRenderer
- Parameters:
filter
- anOptimizableFilter
.renderer
- aBeadFeatureRenderer
.- Throws:
IllegalArgumentException
- if the filter is not disjoint with existing delegate filters.
-
removeDelegateRenderer
removeDelegateRenderer
removes any association of the givenOptimizableFilter
with aBeadFeatureRenderer
.- Parameters:
filter
- anOptimizableFilter
.
-
getDepth
getDepth
calculates the depth required by this renderer to display its beads. It recurses through its delegate renderers and returns the highest value. Concrete renderers should override this method and supply code to calculate their own depth. If a subclass needs to know the depth of its delegates (as is likely if it has any) they can call this method usingsuper.getDepth()
.- Specified by:
getDepth
in interfaceFeatureRenderer
- Parameters:
context
- aSequenceRenderContext
.- Returns:
- a
double
.
-
getBeadDepth
getBeadDepth
returns the depth of a single bead produced by this renderer.- Specified by:
getBeadDepth
in interfaceBeadFeatureRenderer
- Returns:
- a
double
.
-
setBeadDepth
setBeadDepth
sets the depth of a single bead produced by this renderer.- Parameters:
depth
- adouble
.- Throws:
ChangeVetoException
- if an error occurs.
-
getBeadDisplacement
getBeadDisplacement
returns the displacement of beads from the centre line of the renderer. A positive value indicates displacment downwards (for horizontal renderers) or to the right (for vertical renderers).- Specified by:
getBeadDisplacement
in interfaceBeadFeatureRenderer
- Returns:
- a
double
.
-
setBeadDisplacement
setBeadDisplacement
sets the displacement of beads from the centre line of the renderer. A positive value indicates displacment downwards (for horizontal renderers) or to the right (for vertical renderers).- Parameters:
displacement
- adouble
.- Throws:
ChangeVetoException
- if an error occurs.
-
getBeadOutline
getBeadOutline
returns the bead outline paint.- Returns:
- a
Paint
.
-
setBeadOutline
setBeadOutline
sets the bead outline paint.- Parameters:
outline
- aPaint
.- Throws:
ChangeVetoException
- if an error occurs.
-
getBeadStroke
getBeadStroke
returns the bead outline stroke.- Returns:
- a
Stroke
.
-
setBeadStroke
setBeadStroke
sets the bead outline stroke.- Parameters:
stroke
- aStroke
.- Throws:
ChangeVetoException
- if an error occurs.
-
getBeadFill
getBeadFill
returns the bead fill paint.- Returns:
- a
Paint
.
-
setBeadFill
setBeadFill
sets the bead fill paint.- Parameters:
fill
- aPaint
.- Throws:
ChangeVetoException
- if an error occurs.
-
renderBead
renderBead
should be overridden by the concreteBeadRenderer
.- Specified by:
renderBead
in interfaceBeadFeatureRenderer
- Parameters:
g2
- aGraphics2D
.f
- aFeature
to render.context
- aSequenceRenderContext
context.
-