Frames | No Frames |
1: /* =========================================================== 2: * JFreeChart : a free chart library for the Java(tm) platform 3: * =========================================================== 4: * 5: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jfreechart/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * ---------- 28: * Block.java 29: * ---------- 30: * (C) Copyright 2004, 2005, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * $Id: Block.java,v 1.4.2.1 2005/10/25 20:39:38 mungady Exp $ 36: * 37: * Changes: 38: * -------- 39: * 22-Oct-2004 : Version 1 (DG); 40: * 08-Feb-2005 : Added ID (DG); 41: * 20-Apr-2005 : Added a new draw() method that can accept params 42: * and return results (DG); 43: * 44: */ 45: 46: package org.jfree.chart.block; 47: 48: import java.awt.Graphics2D; 49: import java.awt.geom.Rectangle2D; 50: 51: import org.jfree.ui.Drawable; 52: import org.jfree.ui.Size2D; 53: 54: /** 55: * A block is an arbitrary item that can be drawn (in Java2D space) within a 56: * rectangular area, has a preferred size, and can be arranged by an 57: * {@link Arrangement} manager. 58: */ 59: public interface Block extends Drawable { 60: 61: /** 62: * Returns an ID for the block. 63: * 64: * @return An ID. 65: */ 66: public String getID(); 67: 68: /** 69: * Sets the ID for the block. 70: * 71: * @param id the ID. 72: */ 73: public void setID(String id); 74: 75: /** 76: * Arranges the contents of the block, with no constraints, and returns 77: * the block size. 78: * 79: * @param g2 the graphics device. 80: * 81: * @return The size of the block. 82: */ 83: public Size2D arrange(Graphics2D g2); 84: 85: /** 86: * Arranges the contents of the block, within the given constraints, and 87: * returns the block size. 88: * 89: * @param g2 the graphics device. 90: * @param constraint the constraint (<code>null</code> not permitted). 91: * 92: * @return The block size (in Java2D units, never <code>null</code>). 93: */ 94: public Size2D arrange(Graphics2D g2, RectangleConstraint constraint); 95: 96: /** 97: * Returns the current bounds of the block. 98: * 99: * @return The bounds. 100: */ 101: public Rectangle2D getBounds(); 102: 103: /** 104: * Sets the bounds of the block. 105: * 106: * @param bounds the bounds. 107: */ 108: public void setBounds(Rectangle2D bounds); 109: 110: /** 111: * Draws the block within the specified area. Refer to the documentation 112: * for the implementing class for information about the <code>params</code> 113: * and return value supported. 114: * 115: * @param g2 the graphics device. 116: * @param area the area. 117: * @param params optional parameters (<code>null</code> permitted). 118: * 119: * @return An optional return value (possibly <code>null</code>). 120: */ 121: public Object draw(Graphics2D g2, Rectangle2D area, Object params); 122: 123: }