Source for org.jfree.chart.block.Block

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2007, 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-2007, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * Changes:
  36:  * --------
  37:  * 22-Oct-2004 : Version 1 (DG);
  38:  * 08-Feb-2005 : Added ID (DG);
  39:  * 20-Apr-2005 : Added a new draw() method that can accept params
  40:  *               and return results (DG);
  41:  *
  42:  */
  43: 
  44: package org.jfree.chart.block;
  45: 
  46: import java.awt.Graphics2D;
  47: import java.awt.geom.Rectangle2D;
  48: 
  49: import org.jfree.ui.Drawable;
  50: import org.jfree.ui.Size2D;
  51: 
  52: /**
  53:  * A block is an arbitrary item that can be drawn (in Java2D space) within a 
  54:  * rectangular area, has a preferred size, and can be arranged by an 
  55:  * {@link Arrangement} manager.
  56:  */
  57: public interface Block extends Drawable {
  58:     
  59:     /**
  60:      * Returns an ID for the block.
  61:      * 
  62:      * @return An ID.
  63:      */
  64:     public String getID();
  65:     
  66:     /**
  67:      * Sets the ID for the block.
  68:      * 
  69:      * @param id  the ID.
  70:      */
  71:     public void setID(String id);
  72:     
  73:     /**
  74:      * Arranges the contents of the block, with no constraints, and returns
  75:      * the block size.
  76:      * 
  77:      * @param g2  the graphics device.
  78:      * 
  79:      * @return The size of the block.
  80:      */
  81:     public Size2D arrange(Graphics2D g2);  
  82:     
  83:     /**
  84:      * Arranges the contents of the block, within the given constraints, and 
  85:      * returns the block size.
  86:      * 
  87:      * @param g2  the graphics device.
  88:      * @param constraint  the constraint (<code>null</code> not permitted).
  89:      * 
  90:      * @return The block size (in Java2D units, never <code>null</code>).
  91:      */
  92:     public Size2D arrange(Graphics2D g2, RectangleConstraint constraint);
  93:     
  94:     /**
  95:      * Returns the current bounds of the block.
  96:      * 
  97:      * @return The bounds.
  98:      */
  99:     public Rectangle2D getBounds();
 100:     
 101:     /**
 102:      * Sets the bounds of the block.
 103:      * 
 104:      * @param bounds  the bounds.
 105:      */
 106:     public void setBounds(Rectangle2D bounds);
 107:     
 108:     /**
 109:      * Draws the block within the specified area.  Refer to the documentation 
 110:      * for the implementing class for information about the <code>params</code>
 111:      * and return value supported.
 112:      * 
 113:      * @param g2  the graphics device.
 114:      * @param area  the area.
 115:      * @param params  optional parameters (<code>null</code> permitted).
 116:      * 
 117:      * @return An optional return value (possibly <code>null</code>).
 118:      */
 119:     public Object draw(Graphics2D g2, Rectangle2D area, Object params);   
 120: 
 121: }