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 */
021package org.biojava.bio.gui;
022
023import java.awt.Color;
024import java.awt.Graphics2D;
025import java.awt.geom.Rectangle2D;
026
027import org.biojava.bio.symbol.AtomicSymbol;
028import org.biojava.bio.symbol.IllegalSymbolException;
029
030/**
031 * A painter that just draws a block (or bar).
032 *
033 * @author Matthew Pocock
034 */
035public class PlainBlock implements BlockPainter {
036  public void paintBlock(LogoContext ctxt, Rectangle2D block, AtomicSymbol sym) {
037    Graphics2D g2 = ctxt.getGraphics();
038    SymbolStyle style = ctxt.getStyle();
039    
040    try {
041      g2.setPaint(style.fillPaint(sym));
042    } catch (IllegalSymbolException ire) {
043      g2.setPaint(Color.black);
044    }
045    g2.fill(block);
046    
047    try {
048      g2.setPaint(style.outlinePaint(sym));
049    } catch (IllegalSymbolException ire) {
050      g2.setPaint(Color.gray);
051    }
052    g2.draw(block);
053  }
054}