Class ReparentContext
- All Implemented Interfaces:
Serializable
,ProjectionContext
- Direct Known Subclasses:
SimpleGappedSequence.GappedContext
,SubSequence.SubProjectedFeatureContext
,TranslateFlipContext
ReparentContext takes care of much of the ugliness of implementing ProjectionContext, such as handling listeners and grafting features onto a new parent. It also sets up a framework for mutating feature filters. Think carefully before overriding methods in this class.
- Author:
- Matthew Pocock, Thomas Down
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addChangeListener
(Feature f, ChangeListener cl, ChangeType ct) Add a ChangeListener to a projected feature.final Feature
createFeature
(Feature.Template projTempl) Create a projected feature with properties matching the template.final Feature
createFeature
(Feature f, Feature.Template projTempl) Create a new projected feature.final FeatureHolder
final FeatureHolder
protected FilterUtils.FilterTransformer
final FeatureFilter
final Sequence
Get the sequence for a feature.protected FilterUtils.FilterTransformer
final FeatureHolder
Get the features before projection.projectChildFeatures
(Feature f, FeatureHolder parent) Project all features that are children of feature so that they become children of parent.projectFeature
(Feature feat) Create a single projected feature using the rules of thisProjectedFeatureHolder
.final FeatureHolder
Project all of the features in a FeatureHolder.final FeatureFilter
Transform a filter on unprojected features so that it applies to projected features.final void
removeChangeListener
(Feature f, ChangeListener cl, ChangeType ct) Remove a ChangeListener from a projected feature.final void
removeFeature
(Feature dyingChild) Remove the dying child.final void
removeFeature
(Feature f, Feature f2) Remove the dying child.revertFeature
(Feature feat) Unproject a feature.final FeatureFilter
Transform a filter on projected features so that it applies to unprojected features.
-
Constructor Details
-
ReparentContext
-
-
Method Details
-
getParent
-
getUnprojectedFeatures
Description copied from interface:ProjectionContext
Get the features before projection.If you are projecting all the features in some feature holder, that is what this method should return.
- Specified by:
getUnprojectedFeatures
in interfaceProjectionContext
- Returns:
- the features before projection
-
projectFeature
Create a single projected feature using the rules of thisProjectedFeatureHolder
.- Specified by:
projectFeature
in interfaceProjectionContext
- Parameters:
feat
- the Feature to project- Returns:
- a Feature representing feat after being transformed by this context
-
revertFeature
Description copied from interface:ProjectionContext
Unproject a feature.This is the inverse opperation to @link projectFeature().
Note: The result of calling this method for a feature that is not projected through this context is not specified by this API, but it is reasonable to assume that bad things will happen.
- Specified by:
revertFeature
in interfaceProjectionContext
- Parameters:
feat
- the Feature to un-project- Returns:
- the unprojected feature
-
projectFilter
Description copied from interface:ProjectionContext
Transform a filter on unprojected features so that it applies to projected features.- Specified by:
projectFilter
in interfaceProjectionContext
- Parameters:
ff
- the FeatureFilter to transform- Returns:
- the transformed FeatureFilter
-
revertFilter
Description copied from interface:ProjectionContext
Transform a filter on projected features so that it applies to unprojected features.- Specified by:
revertFilter
in interfaceProjectionContext
- Parameters:
ff
- the FeatureFilter to transform- Returns:
- the transformed FeatureFilter
-
getTransformer
-
getReverter
-
getParent
- Specified by:
getParent
in interfaceProjectionContext
-
getSequence
Description copied from interface:ProjectionContext
Get the sequence for a feature.This will be the return value of
projFeat.getParent()
.- Specified by:
getSequence
in interfaceProjectionContext
- Parameters:
f
- the projected Feature- Returns:
- the Sequence of the Feature
-
projectChildFeatures
Description copied from interface:ProjectionContext
Project all features that are children of feature so that they become children of parent.- Specified by:
projectChildFeatures
in interfaceProjectionContext
- Parameters:
f
- the Feature to project all children ofparent
- the new parent feature holder- Returns:
- a FeatureHolder containing projections of all children of feature so that f.getParent() is equal to parent
-
createFeature
public final Feature createFeature(Feature.Template projTempl) throws BioException, ChangeVetoException Description copied from interface:ProjectionContext
Create a projected feature with properties matching the template.You will probably implement this by delegating to the unprojected feature holder. It is imperative that the template properties are unprojected first so that when the newly created feature is projected, the properties match up.
Not every projection context has fully reversible semantics. Use your discression and come up with a reasonable plan that causes least supprise to the user.
- Specified by:
createFeature
in interfaceProjectionContext
- Parameters:
projTempl
- the Feature.Template to instantiate- Returns:
- a new projected Feature matching the template as closely as possible
- Throws:
BioException
- if there was a problem instantiating the templateChangeVetoException
- if the feature creation was vetoed
-
removeFeature
Description copied from interface:ProjectionContext
Remove the dying child.- Specified by:
removeFeature
in interfaceProjectionContext
- Parameters:
dyingChild
- a projected feature to remove- Throws:
BioException
- if there is an error removing the featureChangeVetoException
- if the removal of the feature was vetoed
-
createFeature
public final Feature createFeature(Feature f, Feature.Template projTempl) throws BioException, ChangeVetoException Description copied from interface:ProjectionContext
Create a new projected feature.See the notes for @link createFeature(Feature.Template) for implementation advice.
- Specified by:
createFeature
in interfaceProjectionContext
- Parameters:
f
- the parent for the newly created featureprojTempl
- the Feature.Template specifying the new feature- Returns:
- a new ProjectedFeature that is a child of projParent
- Throws:
BioException
- if there was a problem creating the featureChangeVetoException
- if the creation of the feature was vetoed
-
removeFeature
Description copied from interface:ProjectionContext
Remove the dying child.- Specified by:
removeFeature
in interfaceProjectionContext
- Parameters:
f
- the projected parent Featuref2
- the child Feature to remove- Throws:
ChangeVetoException
- if the removal of the feature was vetoedBioException
-
getSchema
-
addChangeListener
Description copied from interface:ProjectionContext
Add a ChangeListener to a projected feature.- Specified by:
addChangeListener
in interfaceProjectionContext
- Parameters:
f
- the projected Feature to add the listener forcl
- the ChangeListener to addct
- the ChangeType to register it for
-
removeChangeListener
Description copied from interface:ProjectionContext
Remove a ChangeListener from a projected feature.- Specified by:
removeChangeListener
in interfaceProjectionContext
- Parameters:
f
- the projected Feature to remove the listener forcl
- the ChangeListener to removect
- the ChangeType it is registered for
-
projectFeatures
Description copied from interface:ProjectionContext
Project all of the features in a FeatureHolder.Warning: The results of calling this method for features that are not in getUnprojectedFeatures() is not specified by this API, but it is reasonable to assume that bad things will happen.
- Specified by:
projectFeatures
in interfaceProjectionContext
- Parameters:
fh
- the FeatureHolder containing the features to project- Returns:
- a FeatureHolder containing all the features projected
-