Package org.biojava.bio.gui.sequence
Class RectangularBeadRenderer
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.bio.gui.sequence.AbstractBeadRenderer
-
- org.biojava.bio.gui.sequence.RectangularBeadRenderer
-
- All Implemented Interfaces:
Serializable,BeadFeatureRenderer,FeatureRenderer,Changeable
public class RectangularBeadRenderer extends AbstractBeadRenderer
RectangularBeadRendererrenders features as simple rectangles. Their outline and fillPaint,Stroke, feature depth, Y-axis displacement are configurable. The height of the rectangle will be equal to half its width, but not greater than thebeadDepthset in the constructor.An alternative bead height behaviour is available where the rectangle height does not scale with its current width. The
setHeightScalingmethod should be passed a boolean value to change this. The default is to use height scaling.- Since:
- 1.2
- Author:
- Keith James
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ChangeTypeHEIGHTSCALINGConstantHEIGHTSCALINGindicating a change to the feature height scaling policy.protected Rectangle2Drectprotected booleanscaleHeight-
Fields inherited from class org.biojava.bio.gui.sequence.AbstractBeadRenderer
beadDepth, beadDisplacement, beadFill, beadOutline, beadStroke, delegates, delegationCache, DEPTH, DISPLACEMENT, FILL, OUTLINE, STROKE
-
-
Constructor Summary
Constructors Constructor Description RectangularBeadRenderer()Creates a newRectangularBeadRendererwith the default settings.RectangularBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke)Creates a newRectangularBeadRenderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetDepth(SequenceRenderContext context)getDepthcalculates the depth required by this renderer to display its beads.booleangetHeightScaling()getHeightScalingreturns the state of the height scaling policy.voidrenderBead(Graphics2D g2, Feature f, SequenceRenderContext context)renderBeadrenders features as simple rectangle.voidsetHeightScaling(boolean isEnabled)setHeightScalingsets the height scaling policy.-
Methods inherited from class org.biojava.bio.gui.sequence.AbstractBeadRenderer
getBeadDepth, getBeadDisplacement, getBeadFill, getBeadOutline, getBeadStroke, processMouseEvent, removeDelegateRenderer, renderFeature, setBeadDepth, setBeadDisplacement, setBeadFill, setBeadOutline, setBeadStroke, setDelegateRenderer
-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
HEIGHTSCALING
public static final ChangeType HEIGHTSCALING
ConstantHEIGHTSCALINGindicating a change to the feature height scaling policy.
-
rect
protected Rectangle2D rect
-
scaleHeight
protected boolean scaleHeight
-
-
Constructor Detail
-
RectangularBeadRenderer
public RectangularBeadRenderer()
Creates a newRectangularBeadRendererwith the default settings.
-
RectangularBeadRenderer
public RectangularBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke)
Creates a newRectangularBeadRenderer.- Parameters:
beadDepth- adouble.beadDisplacement- adouble.beadOutline- aPaint.beadFill- aPaint.beadStroke- aStroke.
-
-
Method Detail
-
renderBead
public void renderBead(Graphics2D g2, Feature f, SequenceRenderContext context)
renderBeadrenders features as simple rectangle.- Specified by:
renderBeadin interfaceBeadFeatureRenderer- Specified by:
renderBeadin classAbstractBeadRenderer- Parameters:
g2- aGraphics2D.f- aFeatureto render.context- aSequenceRenderContextcontext.
-
getDepth
public double getDepth(SequenceRenderContext context)
getDepthcalculates the depth required by this renderer to display its beads.- Specified by:
getDepthin interfaceFeatureRenderer- Overrides:
getDepthin classAbstractBeadRenderer- Parameters:
context- aSequenceRenderContext.- Returns:
- a
double.
-
getHeightScaling
public boolean getHeightScaling()
getHeightScalingreturns the state of the height scaling policy.- Returns:
- a
booleantrue if height scaling is enabled.
-
setHeightScaling
public void setHeightScaling(boolean isEnabled) throws ChangeVetoException
setHeightScalingsets the height scaling policy. Default behaviour is for this to be enabled leading to features being drawn with a height equal to half their width, subject to a maximum height restriction equal to thebeadDepthset in the constructor. If disabled, features will always be drawn at the maximum height allowed by thebeadDepthparameter.- Parameters:
isEnabled- aboolean.- Throws:
ChangeVetoException- if an error occurs.
-
-