001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.gui.sequence;
023
024import java.awt.Graphics2D;
025
026import org.biojava.bio.seq.Feature;
027import org.biojava.bio.seq.OptimizableFilter;
028
029/**
030 * <p><code>BeadFeatureRenderer</code>s use a 'string of beads'
031 * metaphor for displaying features.</p>
032 *
033 * <p>A concrete <code>BeadFeatureRenderer</code> may render a series
034 * of features in more than one style by delegating to other
035 * <code>BeadFeatureRenderer</code>s for the additional style(s). This
036 * is achieved using the <code>setDelegateRenderer()</code> method
037 * which associates an <code>OptimizableFilter</code> with another
038 * <code>BeadFeatureRenderer</code>. Any feature accepted by the
039 * filter is rendered with that renderer, while the remainder are
040 * rendered by the current renderer.</p>
041 *
042 * @author Keith James
043 * @since 1.2
044 */
045public interface BeadFeatureRenderer extends FeatureRenderer
046{
047    /**
048     * <code>getBeadDepth</code> returns the depth of a single bead
049     * produced by the renderer.
050     *
051     * @return a <code>double</code>.
052     */
053    public double getBeadDepth();
054
055    /**
056     * <code>getBeadDisplacement</code> returns the displacement of
057     * beads from the centre line of the renderer. A positive value
058     * indicates displacment downwards (for horizontal renderers) or
059     * to the right (for vertical renderers).
060     *
061     * @return a <code>double</code>.
062     */
063    public double getBeadDisplacement();
064
065    /**
066     * <code>setDelegateRenderer</code> associates an
067     * <code>OptimizableFilter</code> with a
068     * <code>BeadFeatureRenderer</code>. Any feature accepted by the
069     * filter will be passed to the associated renderer for
070     * drawing. The <code>OptimizableFilter</code>s should be disjoint
071     * with respect to each other (a feature may not be rendered more
072     * than once).
073     *
074     * @param filter an <code>OptimizableFilter</code>.
075     * @param renderer a <code>BeadFeatureRenderer</code>.
076     */
077    public void setDelegateRenderer(OptimizableFilter   filter,
078                                    BeadFeatureRenderer renderer);
079
080    /**
081     * <code>renderBead</code> should implement rendering for this
082     * bead type only. The <code>renderFeature</code> method is
083     * expected to handle the calls to delegate renderers.
084     *
085     * @param g2 a <code>Graphics2D</code>.
086     * @param f a <code>Feature</code> to render.
087     * @param context a <code>SequenceRenderContext</code> context.
088     */
089    public void renderBead(Graphics2D            g2,
090                           Feature               f,
091                           SequenceRenderContext context);
092}