Class AbstractBeadRenderer

java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojava.bio.gui.sequence.AbstractBeadRenderer
All Implemented Interfaces:
Serializable, BeadFeatureRenderer, FeatureRenderer, Changeable
Direct Known Subclasses:
EllipticalBeadRenderer, RectangularBeadRenderer, RoundRectangularBeadRenderer

AbstractBeadRenderer is a an abstract base class for the creation of FeatureRenderers which use a 'string of beads' metaphor for displaying features. Each subclass of AbstractBeadRenderer should override the abstract method renderBead() and provide the drawing routine for its particular bead type.

A concrete BeadFeatureRenderer may render a series of features in more than one style by delegating to other BeadFeatureRenderers for the additional style(s). This is achieved using the setDelegateRenderer() method which associates an OptimizableFilter with another BeadFeatureRenderer. Any feature accepted by the filter is rendered with that renderer, while the remainder are rendered by the current renderer.

Since:
1.2
Author:
Keith James, Paul Seed
See Also:
  • Field Details

  • Constructor Details

    • AbstractBeadRenderer

      Creates a new AbstractBeadRenderer with no delegates. It will render all features itself, using its own style settings.
    • AbstractBeadRenderer

      public AbstractBeadRenderer(double beadDepth, double beadDisplacement, Paint beadOutline, Paint beadFill, Stroke beadStroke)
      Creates a new AbstractBeadRenderer object.
      Parameters:
      beadDepth - a double.
      beadDisplacement - a double.
      beadOutline - a Paint.
      beadFill - a Paint.
      beadStroke - a Stroke.
  • Method Details

    • processMouseEvent

      processMouseEvent defines the behaviour on revieving a mouse event.
      Specified by:
      processMouseEvent in interface FeatureRenderer
      Parameters:
      holder - a FeatureHolder.
      context - a SequenceRenderContext.
      mEvent - a MouseEvent.
      Returns:
      a FeatureHolder.
    • renderFeature

      public void renderFeature(Graphics2D g2, Feature f, SequenceRenderContext context)
      renderFeature draws a feature using the supplied graphics context. The rendering may be delegated to another FeatureRenderer instance.
      Specified by:
      renderFeature in interface FeatureRenderer
      Parameters:
      g2 - a Graphics2D context.
      f - a Feature to render.
      context - a SequenceRenderContext context.
    • setDelegateRenderer

      setDelegateRenderer associates an OptimizableFilter with a BeadFeatureRenderer. Any feature accepted by the filter will be passed to the associated renderer for drawing. The OptimizableFilters should be disjoint with respect to each other (a feature may not be rendered more than once).
      Specified by:
      setDelegateRenderer in interface BeadFeatureRenderer
      Parameters:
      filter - an OptimizableFilter.
      renderer - a BeadFeatureRenderer.
      Throws:
      IllegalArgumentException - if the filter is not disjoint with existing delegate filters.
    • removeDelegateRenderer

      removeDelegateRenderer removes any association of the given OptimizableFilter with a BeadFeatureRenderer.
      Parameters:
      filter - an OptimizableFilter.
    • getDepth

      public double getDepth(SequenceRenderContext context)
      getDepth calculates the depth required by this renderer to display its beads. It recurses through its delegate renderers and returns the highest value. Concrete renderers should override this method and supply code to calculate their own depth. If a subclass needs to know the depth of its delegates (as is likely if it has any) they can call this method using super.getDepth().
      Specified by:
      getDepth in interface FeatureRenderer
      Parameters:
      context - a SequenceRenderContext.
      Returns:
      a double.
    • getBeadDepth

      public double getBeadDepth()
      getBeadDepth returns the depth of a single bead produced by this renderer.
      Specified by:
      getBeadDepth in interface BeadFeatureRenderer
      Returns:
      a double.
    • setBeadDepth

      public void setBeadDepth(double depth) throws ChangeVetoException
      setBeadDepth sets the depth of a single bead produced by this renderer.
      Parameters:
      depth - a double.
      Throws:
      ChangeVetoException - if an error occurs.
    • getBeadDisplacement

      public double getBeadDisplacement()
      getBeadDisplacement returns the displacement of beads from the centre line of the renderer. A positive value indicates displacment downwards (for horizontal renderers) or to the right (for vertical renderers).
      Specified by:
      getBeadDisplacement in interface BeadFeatureRenderer
      Returns:
      a double.
    • setBeadDisplacement

      public void setBeadDisplacement(double displacement) throws ChangeVetoException
      setBeadDisplacement sets the displacement of beads from the centre line of the renderer. A positive value indicates displacment downwards (for horizontal renderers) or to the right (for vertical renderers).
      Parameters:
      displacement - a double.
      Throws:
      ChangeVetoException - if an error occurs.
    • getBeadOutline

      getBeadOutline returns the bead outline paint.
      Returns:
      a Paint.
    • setBeadOutline

      public void setBeadOutline(Paint outline) throws ChangeVetoException
      setBeadOutline sets the bead outline paint.
      Parameters:
      outline - a Paint.
      Throws:
      ChangeVetoException - if an error occurs.
    • getBeadStroke

      getBeadStroke returns the bead outline stroke.
      Returns:
      a Stroke.
    • setBeadStroke

      public void setBeadStroke(Stroke stroke) throws ChangeVetoException
      setBeadStroke sets the bead outline stroke.
      Parameters:
      stroke - a Stroke.
      Throws:
      ChangeVetoException - if an error occurs.
    • getBeadFill

      public Paint getBeadFill()
      getBeadFill returns the bead fill paint.
      Returns:
      a Paint.
    • setBeadFill

      public void setBeadFill(Paint fill) throws ChangeVetoException
      setBeadFill sets the bead fill paint.
      Parameters:
      fill - a Paint.
      Throws:
      ChangeVetoException - if an error occurs.
    • renderBead

      public abstract void renderBead(Graphics2D g2, Feature f, SequenceRenderContext context)
      renderBead should be overridden by the concrete BeadRenderer.
      Specified by:
      renderBead in interface BeadFeatureRenderer
      Parameters:
      g2 - a Graphics2D.
      f - a Feature to render.
      context - a SequenceRenderContext context.