public abstract class AbstractBeadRenderer extends AbstractChangeable implements BeadFeatureRenderer, Serializable
AbstractBeadRenderer is a an abstract base class
for the creation of FeatureRenderers 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
BeadFeatureRenderers 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.
| Modifier and Type | Field and Description |
|---|---|
protected double |
beadDepth |
protected double |
beadDisplacement |
protected Paint |
beadFill |
protected Paint |
beadOutline |
protected Stroke |
beadStroke |
protected Map |
delegates |
protected Map |
delegationCache |
static ChangeType |
DEPTH
Constant
DEPTH indicating a change to the depth of
the renderer. |
static ChangeType |
DISPLACEMENT
Constant
DISPLACEMENT indicating a change to the
Y-axis displacement of the features. |
static ChangeType |
FILL
Constant
FILL indicating a change to the fill of
the features. |
static ChangeType |
OUTLINE
Constant
OUTLINE indicating a change to the
outline paint of the features. |
static ChangeType |
STROKE
Constant
STROKE indicating a change to the outline
stroke of the features. |
| Constructor and Description |
|---|
AbstractBeadRenderer()
Creates a new
AbstractBeadRenderer with no
delegates. |
AbstractBeadRenderer(double beadDepth,
double beadDisplacement,
Paint beadOutline,
Paint beadFill,
Stroke beadStroke)
Creates a new
AbstractBeadRenderer object. |
| Modifier and Type | Method and Description |
|---|---|
double |
getBeadDepth()
getBeadDepth returns the depth of a single bead
produced by this renderer. |
double |
getBeadDisplacement()
getBeadDisplacement returns the displacement of
beads from the centre line of the renderer. |
Paint |
getBeadFill()
getBeadFill returns the bead fill paint. |
Paint |
getBeadOutline()
getBeadOutline returns the bead outline paint. |
Stroke |
getBeadStroke()
getBeadStroke returns the bead outline stroke. |
double |
getDepth(SequenceRenderContext context)
getDepth calculates the depth required by this
renderer to display its beads. |
FeatureHolder |
processMouseEvent(FeatureHolder holder,
SequenceRenderContext context,
MouseEvent mEvent)
processMouseEvent defines the behaviour on
revieving a mouse event. |
void |
removeDelegateRenderer(OptimizableFilter filter)
removeDelegateRenderer removes any association
of the given OptimizableFilter with a
BeadFeatureRenderer. |
abstract void |
renderBead(Graphics2D g2,
Feature f,
SequenceRenderContext context)
renderBead should be overridden by the concrete
BeadRenderer. |
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 an
OptimizableFilter with a
BeadFeatureRenderer. |
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListenerpublic static final ChangeType DISPLACEMENT
DISPLACEMENT indicating a change to the
Y-axis displacement of the features.public static final ChangeType DEPTH
DEPTH indicating a change to the depth of
the renderer.public static final ChangeType OUTLINE
OUTLINE indicating a change to the
outline paint of the features.public static final ChangeType STROKE
STROKE indicating a change to the outline
stroke of the features.public static final ChangeType FILL
FILL indicating a change to the fill of
the features.protected double beadDepth
protected double beadDisplacement
protected Paint beadOutline
protected Stroke beadStroke
protected Map delegationCache
public AbstractBeadRenderer()
AbstractBeadRenderer with no
delegates. It will render all features itself, using its own
style settings.public AbstractBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke)
AbstractBeadRenderer object.beadDepth - a double.beadDisplacement - a double.beadOutline - a Paint.beadFill - a Paint.beadStroke - a Stroke.public FeatureHolder processMouseEvent(FeatureHolder holder, SequenceRenderContext context, MouseEvent mEvent)
processMouseEvent defines the behaviour on
revieving a mouse event.processMouseEvent in interface FeatureRendererholder - a FeatureHolder.context - a SequenceRenderContext.mEvent - a MouseEvent.FeatureHolder.public void renderFeature(Graphics2D g2, Feature f, SequenceRenderContext context)
renderFeature draws a feature using the supplied
graphics context. The rendering may be delegated to another
FeatureRenderer instance.renderFeature in interface FeatureRendererg2 - a Graphics2D context.f - a Feature to render.context - a SequenceRenderContext context.public void setDelegateRenderer(OptimizableFilter filter, BeadFeatureRenderer renderer) throws IllegalArgumentException
setDelegateRenderer associates an
OptimizableFilter with a
BeadFeatureRenderer. Any feature accepted by the
filter will be passed to the associated renderer for
drawing. The OptimizableFilters should be disjoint
with respect to each other (a feature may not be rendered more
than once).setDelegateRenderer in interface BeadFeatureRendererfilter - an OptimizableFilter.renderer - a BeadFeatureRenderer.IllegalArgumentException - if the filter is not
disjoint with existing delegate filters.public void removeDelegateRenderer(OptimizableFilter filter)
removeDelegateRenderer removes any association
of the given OptimizableFilter with a
BeadFeatureRenderer.filter - an OptimizableFilter.public double getDepth(SequenceRenderContext context)
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 using super.getDepth().getDepth in interface FeatureRenderercontext - a SequenceRenderContext.double.public double getBeadDepth()
getBeadDepth returns the depth of a single bead
produced by this renderer.getBeadDepth in interface BeadFeatureRendererdouble.public void setBeadDepth(double depth) throws ChangeVetoException
setBeadDepth sets the depth of a single bead
produced by this renderer.depth - a double.ChangeVetoException - if an error occurs.public double 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).getBeadDisplacement in interface BeadFeatureRendererdouble.public void setBeadDisplacement(double displacement) throws ChangeVetoException
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).displacement - a double.ChangeVetoException - if an error occurs.public Paint getBeadOutline()
getBeadOutline returns the bead outline paint.Paint.public void setBeadOutline(Paint outline) throws ChangeVetoException
setBeadOutline sets the bead outline paint.outline - a Paint.ChangeVetoException - if an error occurs.public Stroke getBeadStroke()
getBeadStroke returns the bead outline stroke.Stroke.public void setBeadStroke(Stroke stroke) throws ChangeVetoException
setBeadStroke sets the bead outline stroke.stroke - a Stroke.ChangeVetoException - if an error occurs.public Paint getBeadFill()
getBeadFill returns the bead fill paint.Paint.public void setBeadFill(Paint fill) throws ChangeVetoException
setBeadFill sets the bead fill paint.fill - a Paint.ChangeVetoException - if an error occurs.public abstract void renderBead(Graphics2D g2, Feature f, SequenceRenderContext context)
renderBead should be overridden by the concrete
BeadRenderer.renderBead in interface BeadFeatureRendererg2 - a Graphics2D.f - a Feature to render.context - a SequenceRenderContext context.Copyright © 2014 BioJava. All rights reserved.