Class PairwiseFilteringRenderer

  • All Implemented Interfaces:
    java.io.Serializable, PairwiseSequenceRenderer, Changeable

    public class PairwiseFilteringRenderer
    extends AbstractChangeable
    implements PairwiseSequenceRenderer, java.io.Serializable

    PairwiseFilteringRenderer wraps a PairwiseSequenceRenderer and filters the PairwiseRenderContexts passed to it. The renderer receives a new PairwiseRenderContext which has had both of its FeatureHolders filtered with the FeatureFilter.

    Instances of this class cache up to 5 of the derived PairwiseRenderContexts. Therefore cycling through up to 5 different FeatureFilters will only be hitting the cache rather than recalculating everthing. Should the FeatureHolders 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.

    Since:
    1.2
    Author:
    Keith James, Matthew Pocock
    See Also:
    Serialized Form
    • Field Detail

      • FILTER

        public static final ChangeType FILTER
        Constant FILTER indicating a change to the renderer's filter.
      • RECURSE

        public static final ChangeType RECURSE
        Constant RECURSE indicating a change to the renderer's filter recursion flag.
      • RENDERER

        public static final ChangeType RENDERER
        Constant RENDERER indicating a change to the renderer.
      • recurse

        protected boolean recurse
        recurse indicates whether the filter should recurse through any subfeatures.
    • Method Detail

      • getChangeSupport

        protected ChangeSupport getChangeSupport​(ChangeType ct)
        Description copied from class: AbstractChangeable
        Called to retrieve the ChangeSupport for this object.

        Your implementation of this method should have the following structure:

         ChangeSupport cs = super.getChangeSupport(ct);
        
         if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
           someForwarder = new ChangeForwarder(...
        
           this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
         }
        
         return cs;
         
        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.
        Overrides:
        getChangeSupport in class AbstractChangeable
      • getFilter

        public FeatureFilter getFilter()
        getFilter returns the current filter.
        Returns:
        a FeatureFilter.
      • getRecurse

        public boolean getRecurse()
        getRecurse returns the recursion flag of the filter.
        Returns:
        a boolean.
      • getSubContext

        protected PairwiseRenderContext getSubContext​(PairwiseRenderContext context)
        getSubContext creates a new context which has FeatureHolders filtered using the current filter.
        Parameters:
        context - a PairwiseRenderContext.
        Returns:
        a PairwiseRenderContext.