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
AbstractBeadRendereris a an abstract base class for the creation ofFeatureRenderers which use a 'string of beads' metaphor for displaying features. Each subclass ofAbstractBeadRenderershould override the abstract methodrenderBead()and provide the drawing routine for its particular bead type.A concrete
BeadFeatureRenderermay render a series of features in more than one style by delegating to otherBeadFeatureRenderers for the additional style(s). This is achieved using thesetDelegateRenderer()method which associates anOptimizableFilterwith anotherBeadFeatureRenderer. 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doublebeadDepthprotected doublebeadDisplacementprotected PaintbeadFillprotected PaintbeadOutlineprotected StrokebeadStrokeprotected Mapdelegatesprotected MapdelegationCachestatic ChangeTypeDEPTHConstantDEPTHindicating a change to the depth of the renderer.static ChangeTypeDISPLACEMENTConstantDISPLACEMENTindicating a change to the Y-axis displacement of the features.static ChangeTypeFILLConstantFILLindicating a change to the fill of the features.static ChangeTypeOUTLINEConstantOUTLINEindicating a change to the outline paint of the features.static ChangeTypeSTROKEConstantSTROKEindicating a change to the outline stroke of the features.
-
Constructor Summary
Constructors Constructor Description AbstractBeadRenderer()Creates a newAbstractBeadRendererwith no delegates.AbstractBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke)Creates a newAbstractBeadRendererobject.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description doublegetBeadDepth()getBeadDepthreturns the depth of a single bead produced by this renderer.doublegetBeadDisplacement()getBeadDisplacementreturns the displacement of beads from the centre line of the renderer.PaintgetBeadFill()getBeadFillreturns the bead fill paint.PaintgetBeadOutline()getBeadOutlinereturns the bead outline paint.StrokegetBeadStroke()getBeadStrokereturns the bead outline stroke.doublegetDepth(SequenceRenderContext context)getDepthcalculates the depth required by this renderer to display its beads.FeatureHolderprocessMouseEvent(FeatureHolder holder, SequenceRenderContext context, MouseEvent mEvent)processMouseEventdefines the behaviour on revieving a mouse event.voidremoveDelegateRenderer(OptimizableFilter filter)removeDelegateRendererremoves any association of the givenOptimizableFilterwith aBeadFeatureRenderer.abstract voidrenderBead(Graphics2D g2, Feature f, SequenceRenderContext context)renderBeadshould be overridden by the concreteBeadRenderer.voidrenderFeature(Graphics2D g2, Feature f, SequenceRenderContext context)renderFeaturedraws a feature using the supplied graphics context.voidsetBeadDepth(double depth)setBeadDepthsets the depth of a single bead produced by this renderer.voidsetBeadDisplacement(double displacement)setBeadDisplacementsets the displacement of beads from the centre line of the renderer.voidsetBeadFill(Paint fill)setBeadFillsets the bead fill paint.voidsetBeadOutline(Paint outline)setBeadOutlinesets the bead outline paint.voidsetBeadStroke(Stroke stroke)setBeadStrokesets the bead outline stroke.voidsetDelegateRenderer(OptimizableFilter filter, BeadFeatureRenderer renderer)setDelegateRendererassociates anOptimizableFilterwith aBeadFeatureRenderer.-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
DISPLACEMENT
public static final ChangeType DISPLACEMENT
ConstantDISPLACEMENTindicating a change to the Y-axis displacement of the features.
-
DEPTH
public static final ChangeType DEPTH
ConstantDEPTHindicating a change to the depth of the renderer.
-
OUTLINE
public static final ChangeType OUTLINE
ConstantOUTLINEindicating a change to the outline paint of the features.
-
STROKE
public static final ChangeType STROKE
ConstantSTROKEindicating a change to the outline stroke of the features.
-
FILL
public static final ChangeType FILL
ConstantFILLindicating a change to the fill of the features.
-
beadDepth
protected double beadDepth
-
beadDisplacement
protected double beadDisplacement
-
beadOutline
protected Paint beadOutline
-
beadStroke
protected Stroke beadStroke
-
delegationCache
protected Map delegationCache
-
-
Constructor Detail
-
AbstractBeadRenderer
public AbstractBeadRenderer()
Creates a newAbstractBeadRendererwith 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 newAbstractBeadRendererobject.- Parameters:
beadDepth- adouble.beadDisplacement- adouble.beadOutline- aPaint.beadFill- aPaint.beadStroke- aStroke.
-
-
Method Detail
-
processMouseEvent
public FeatureHolder processMouseEvent(FeatureHolder holder, SequenceRenderContext context, MouseEvent mEvent)
processMouseEventdefines the behaviour on revieving a mouse event.- Specified by:
processMouseEventin interfaceFeatureRenderer- Parameters:
holder- aFeatureHolder.context- aSequenceRenderContext.mEvent- aMouseEvent.- Returns:
- a
FeatureHolder.
-
renderFeature
public void renderFeature(Graphics2D g2, Feature f, SequenceRenderContext context)
renderFeaturedraws a feature using the supplied graphics context. The rendering may be delegated to anotherFeatureRendererinstance.- Specified by:
renderFeaturein interfaceFeatureRenderer- Parameters:
g2- aGraphics2Dcontext.f- aFeatureto render.context- aSequenceRenderContextcontext.
-
setDelegateRenderer
public void setDelegateRenderer(OptimizableFilter filter, BeadFeatureRenderer renderer) throws IllegalArgumentException
setDelegateRendererassociates anOptimizableFilterwith aBeadFeatureRenderer. Any feature accepted by the filter will be passed to the associated renderer for drawing. TheOptimizableFilters should be disjoint with respect to each other (a feature may not be rendered more than once).- Specified by:
setDelegateRendererin interfaceBeadFeatureRenderer- Parameters:
filter- anOptimizableFilter.renderer- aBeadFeatureRenderer.- Throws:
IllegalArgumentException- if the filter is not disjoint with existing delegate filters.
-
removeDelegateRenderer
public void removeDelegateRenderer(OptimizableFilter filter)
removeDelegateRendererremoves any association of the givenOptimizableFilterwith aBeadFeatureRenderer.- Parameters:
filter- anOptimizableFilter.
-
getDepth
public double getDepth(SequenceRenderContext context)
getDepthcalculates 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:
getDepthin interfaceFeatureRenderer- Parameters:
context- aSequenceRenderContext.- Returns:
- a
double.
-
getBeadDepth
public double getBeadDepth()
getBeadDepthreturns the depth of a single bead produced by this renderer.- Specified by:
getBeadDepthin interfaceBeadFeatureRenderer- Returns:
- a
double.
-
setBeadDepth
public void setBeadDepth(double depth) throws ChangeVetoException
setBeadDepthsets the depth of a single bead produced by this renderer.- Parameters:
depth- adouble.- Throws:
ChangeVetoException- if an error occurs.
-
getBeadDisplacement
public double getBeadDisplacement()
getBeadDisplacementreturns 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:
getBeadDisplacementin interfaceBeadFeatureRenderer- Returns:
- a
double.
-
setBeadDisplacement
public void setBeadDisplacement(double displacement) throws ChangeVetoException
setBeadDisplacementsets 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
public Paint getBeadOutline()
getBeadOutlinereturns the bead outline paint.- Returns:
- a
Paint.
-
setBeadOutline
public void setBeadOutline(Paint outline) throws ChangeVetoException
setBeadOutlinesets the bead outline paint.- Parameters:
outline- aPaint.- Throws:
ChangeVetoException- if an error occurs.
-
getBeadStroke
public Stroke getBeadStroke()
getBeadStrokereturns the bead outline stroke.- Returns:
- a
Stroke.
-
setBeadStroke
public void setBeadStroke(Stroke stroke) throws ChangeVetoException
setBeadStrokesets the bead outline stroke.- Parameters:
stroke- aStroke.- Throws:
ChangeVetoException- if an error occurs.
-
getBeadFill
public Paint getBeadFill()
getBeadFillreturns the bead fill paint.- Returns:
- a
Paint.
-
setBeadFill
public void setBeadFill(Paint fill) throws ChangeVetoException
setBeadFillsets the bead fill paint.- Parameters:
fill- aPaint.- Throws:
ChangeVetoException- if an error occurs.
-
renderBead
public abstract void renderBead(Graphics2D g2, Feature f, SequenceRenderContext context)
renderBeadshould be overridden by the concreteBeadRenderer.- Specified by:
renderBeadin interfaceBeadFeatureRenderer- Parameters:
g2- aGraphics2D.f- aFeatureto render.context- aSequenceRenderContextcontext.
-
-