public class PairwiseFilteringRenderer extends AbstractChangeable implements PairwiseSequenceRenderer, Serializable
PairwiseFilteringRenderer
wraps a
PairwiseSequenceRenderer
and filters the
PairwiseRenderContext
s passed to it. The renderer
receives a new PairwiseRenderContext
which has had
both of its FeatureHolder
s filtered with the
FeatureFilter
.
Instances of this class cache up to 5 of the derived
PairwiseRenderContext
s. Therefore cycling through up
to 5 different FeatureFilter
s will only be hitting the
cache rather than recalculating everthing. Should the
FeatureHolder
s themselves change, the cache will be
flushed. As only the features overlapping the context's range are
filtered, changing the range will also result in re-filtering.
PairwiseSequenceRenderer.PairwiseRendererForwarder
Modifier and Type | Field and Description |
---|---|
protected FeatureFilter |
filter
filter is the filter applied to both
FeatureHolder s. |
static ChangeType |
FILTER
Constant
FILTER indicating a change to the
renderer's filter. |
protected boolean |
recurse
recurse indicates whether the filter should
recurse through any subfeatures. |
static ChangeType |
RECURSE
Constant
RECURSE indicating a change to the
renderer's filter recursion flag. |
static ChangeType |
RENDERER
Constant
RENDERER indicating a change to the
renderer. |
Constructor and Description |
---|
PairwiseFilteringRenderer(PairwiseSequenceRenderer renderer)
Creates a new
PairwiseFilteringRenderer which uses
a filter which accepts all features. |
PairwiseFilteringRenderer(PairwiseSequenceRenderer renderer,
FeatureFilter filter,
boolean recurse)
Creates a new
PairwiseFilteringRenderer . |
Modifier and Type | Method and Description |
---|---|
protected ChangeSupport |
getChangeSupport(ChangeType ct)
Called to retrieve the ChangeSupport for this object.
|
FeatureFilter |
getFilter()
getFilter returns the current filter. |
boolean |
getRecurse()
getRecurse returns the recursion flag of the
filter. |
PairwiseSequenceRenderer |
getRenderer()
getRenderer return the current renderer. |
protected PairwiseRenderContext |
getSubContext(PairwiseRenderContext context)
getSubContext creates a new context which has
FeatureHolder s filtered using the current filter. |
void |
paint(Graphics2D g2,
PairwiseRenderContext context)
paint s some or all of the information about the
sequence pair. |
SequenceViewerEvent |
processMouseEvent(PairwiseRenderContext context,
MouseEvent me,
List path)
processMouseEvent produces a
SequenceViewerEvent in response to a mouse
gesture. |
void |
setFilter(FeatureFilter filter)
setFilter sets the filter. |
void |
setRecurse(boolean recurse)
setRecurse sets the recursion flag on the filter. |
void |
setRenderer(PairwiseSequenceRenderer renderer)
setRenderer sets the renderer. |
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
public static final ChangeType FILTER
FILTER
indicating a change to the
renderer's filter.public static final ChangeType RECURSE
RECURSE
indicating a change to the
renderer's filter recursion flag.public static final ChangeType RENDERER
RENDERER
indicating a change to the
renderer.protected FeatureFilter filter
filter
is the filter applied to both
FeatureHolder
s.protected boolean recurse
recurse
indicates whether the filter should
recurse through any subfeatures.public PairwiseFilteringRenderer(PairwiseSequenceRenderer renderer)
PairwiseFilteringRenderer
which uses
a filter which accepts all features.renderer
- a PairwiseSequenceRenderer
.public PairwiseFilteringRenderer(PairwiseSequenceRenderer renderer, FeatureFilter filter, boolean recurse)
PairwiseFilteringRenderer
.renderer
- a PairwiseSequenceRenderer
.filter
- a FeatureFilter
.recurse
- a boolean
.protected ChangeSupport getChangeSupport(ChangeType ct)
AbstractChangeable
Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to
be transient and lazily instantiated. Be sure to register & unregister the
forwarder in the code that does the ChangeEvent handling in setter methods.
ChangeSupport cs = super.getChangeSupport(ct);
if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
someForwarder = new ChangeForwarder(...
this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
}
return cs;
getChangeSupport
in class AbstractChangeable
public PairwiseSequenceRenderer getRenderer()
getRenderer
return the current renderer.PairwiseSequenceRenderer
.public void setRenderer(PairwiseSequenceRenderer renderer) throws ChangeVetoException
setRenderer
sets the renderer.renderer
- a PairwiseSequenceRenderer
.ChangeVetoException
- if the change is vetoed.public FeatureFilter getFilter()
getFilter
returns the current filter.FeatureFilter
.public void setFilter(FeatureFilter filter) throws ChangeVetoException
setFilter
sets the filter.filter
- a FeatureFilter
.ChangeVetoException
- if the change is vetoed.public boolean getRecurse()
getRecurse
returns the recursion flag of the
filter.boolean
.public void setRecurse(boolean recurse) throws ChangeVetoException
setRecurse
sets the recursion flag on the filter.recurse
- a boolean
.ChangeVetoException
- if the change is vetoed.public void paint(Graphics2D g2, PairwiseRenderContext context)
PairwiseSequenceRenderer
paint
s some or all of the information about the
sequence pair.paint
in interface PairwiseSequenceRenderer
g2
- a Graphics2D
.context
- a PairwiseRenderContext
encapsulating
the information to be displayed.public SequenceViewerEvent processMouseEvent(PairwiseRenderContext context, MouseEvent me, List path)
PairwiseSequenceRenderer
processMouseEvent
produces a
SequenceViewerEvent
in response to a mouse
gesture.processMouseEvent
in interface PairwiseSequenceRenderer
context
- a PairwiseRenderContext
.me
- a MouseEvent
that caused the request.path
- a List
of
PairwiseSequenceRenderer
instances passed through
so far.SequenceViewerEvent
encapsulating the
mouse gesture.protected PairwiseRenderContext getSubContext(PairwiseRenderContext context)
getSubContext
creates a new context which has
FeatureHolder
s filtered using the current filter.context
- a PairwiseRenderContext
.PairwiseRenderContext
.Copyright © 2014 BioJava. All rights reserved.