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 voidaddChangeListener(Feature f, ChangeListener cl, ChangeType ct) Add a ChangeListener to a projected feature.final FeaturecreateFeature(Feature.Template projTempl) Create a projected feature with properties matching the template.final FeaturecreateFeature(Feature f, Feature.Template projTempl) Create a new projected feature.final FeatureHolderfinal FeatureHolderprotected FilterUtils.FilterTransformerfinal FeatureFilterfinal SequenceGet the sequence for a feature.protected FilterUtils.FilterTransformerfinal FeatureHolderGet 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 FeatureHolderProject all of the features in a FeatureHolder.final FeatureFilterTransform a filter on unprojected features so that it applies to projected features.final voidremoveChangeListener(Feature f, ChangeListener cl, ChangeType ct) Remove a ChangeListener from a projected feature.final voidremoveFeature(Feature dyingChild) Remove the dying child.final voidremoveFeature(Feature f, Feature f2) Remove the dying child.revertFeature(Feature feat) Unproject a feature.final FeatureFilterTransform a filter on projected features so that it applies to unprojected features.
-
Constructor Details
-
ReparentContext
-
-
Method Details
-
getParent
-
getUnprojectedFeatures
Description copied from interface:ProjectionContextGet the features before projection.If you are projecting all the features in some feature holder, that is what this method should return.
- Specified by:
getUnprojectedFeaturesin interfaceProjectionContext- Returns:
- the features before projection
-
projectFeature
Create a single projected feature using the rules of thisProjectedFeatureHolder.- Specified by:
projectFeaturein interfaceProjectionContext- Parameters:
feat- the Feature to project- Returns:
- a Feature representing feat after being transformed by this context
-
revertFeature
Description copied from interface:ProjectionContextUnproject 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:
revertFeaturein interfaceProjectionContext- Parameters:
feat- the Feature to un-project- Returns:
- the unprojected feature
-
projectFilter
Description copied from interface:ProjectionContextTransform a filter on unprojected features so that it applies to projected features.- Specified by:
projectFilterin interfaceProjectionContext- Parameters:
ff- the FeatureFilter to transform- Returns:
- the transformed FeatureFilter
-
revertFilter
Description copied from interface:ProjectionContextTransform a filter on projected features so that it applies to unprojected features.- Specified by:
revertFilterin interfaceProjectionContext- Parameters:
ff- the FeatureFilter to transform- Returns:
- the transformed FeatureFilter
-
getTransformer
-
getReverter
-
getParent
- Specified by:
getParentin interfaceProjectionContext
-
getSequence
Description copied from interface:ProjectionContextGet the sequence for a feature.This will be the return value of
projFeat.getParent().- Specified by:
getSequencein interfaceProjectionContext- Parameters:
f- the projected Feature- Returns:
- the Sequence of the Feature
-
projectChildFeatures
Description copied from interface:ProjectionContextProject all features that are children of feature so that they become children of parent.- Specified by:
projectChildFeaturesin 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:ProjectionContextCreate 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:
createFeaturein 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:ProjectionContextRemove the dying child.- Specified by:
removeFeaturein 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:ProjectionContextCreate a new projected feature.See the notes for @link createFeature(Feature.Template) for implementation advice.
- Specified by:
createFeaturein 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:ProjectionContextRemove the dying child.- Specified by:
removeFeaturein 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:ProjectionContextAdd a ChangeListener to a projected feature.- Specified by:
addChangeListenerin 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:ProjectionContextRemove a ChangeListener from a projected feature.- Specified by:
removeChangeListenerin 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:ProjectionContextProject 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:
projectFeaturesin interfaceProjectionContext- Parameters:
fh- the FeatureHolder containing the features to project- Returns:
- a FeatureHolder containing all the features projected
-