001package org.biojava.bio.gui.sequence; 002 003import java.awt.Graphics2D; 004import java.util.ArrayList; 005import java.util.Iterator; 006import java.util.List; 007 008 009/** 010 * Renders multiple renderers, each in their own concentric rings. 011 * 012 * @author Matthew Pocock 013 * @since 1.4 014 */ 015public class CircularMLR 016implements CircularRenderer { 017 private List renderers = new ArrayList(); 018 019 public void addRenderer(CircularRenderer renderer) { 020 renderers.add(renderer); 021 } 022 023 public void removeRenderer(CircularRenderer renderer) { 024 renderers.remove(renderer); 025 } 026 027 public double getDepth(CircularRendererContext crc) { 028 double depth = 0; 029 030 for(Iterator i = renderers.iterator(); i.hasNext(); ) { 031 CircularRenderer rend = (CircularRenderer) i.next(); 032 CircularRendererContext subCtxt = new SubCircularRendererContext( 033 crc, 034 null, 035 null, 036 crc.getRadius() + depth); 037 depth += rend.getDepth(subCtxt); 038 } 039 040 return depth; 041 } 042 043 public void paint(Graphics2D g2, CircularRendererContext crc) { 044 double depth = 0.0; 045 046 for(Iterator i = renderers.iterator(); i.hasNext(); ) { 047 CircularRenderer rend = (CircularRenderer) i.next(); 048 CircularRendererContext subCtxt = new SubCircularRendererContext( 049 crc, 050 null, 051 null, 052 crc.getRadius() + depth); 053 rend.paint(g2, subCtxt); 054 depth += rend.getDepth(crc); 055 } 056 } 057}