⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractblock.java

📁 JfreeChart 常用图表例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info:  http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it  * under the terms of the GNU Lesser General Public License as published by  * the Free Software Foundation; either version 2.1 of the License, or  * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public  * License for more details. * * You should have received a copy of the GNU Lesser General Public License  * along with this library; if not, write to the Free Software Foundation,  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc.  * in the United States and other countries.] *  * ------------------ * AbstractBlock.java * ------------------ * (C) Copyright 2004, 2005, by Object Refinery Limited. * * Original Author:  David Gilbert (for Object Refinery Limited); * Contributor(s):   -; * * $Id: AbstractBlock.java,v 1.12 2005/05/19 15:42:55 mungady Exp $ * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 02-Feb-2005 : Added accessor methods for margin (DG); * 04-Feb-2005 : Added equals() method and implemented Serializable (DG); * 03-May-2005 : Added null argument checks (DG); * 06-May-2005 : Added convenience methods for setting margin, border and  *               padding (DG); *  */package org.jfree.chart.block;import java.awt.Graphics2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import org.jfree.data.Range;import org.jfree.io.SerialUtilities;import org.jfree.ui.RectangleInsets;import org.jfree.ui.Size2D;/** * A convenience class for creating new classes that implement  * the {@link Block} interface. */public class AbstractBlock implements Serializable {    /** For serialization. */    private static final long serialVersionUID = 7689852412141274563L;        /** The id for the block. */    private String id;        /** The margin around the outside of the block. */    private RectangleInsets margin;        /** The border for the block. */    private BlockBorder border;    /** The padding between the block content and the border. */    private RectangleInsets padding;        /**      * The natural width of the block (may be overridden if there are      * constraints in sizing).     */    private double width;        /**      * The natural height of the block (may be overridden if there are      * constraints in sizing).     */    private double height;        /**     * The current bounds for the block (position of the block in Java2D space).     */    private transient Rectangle2D bounds;        /**     * Creates a new block.     */    protected AbstractBlock() {        this.id = null;        this.width = 0.0;        this.height = 0.0;        this.bounds = new Rectangle2D.Float();        this.margin = RectangleInsets.ZERO_INSETS;        this.border = BlockBorder.NONE;         this.padding = RectangleInsets.ZERO_INSETS;    }        /**     * Returns the id.     *      * @return The id (possibly <code>null</code>).     */    public String getID() {        return this.id;       }        /**     * Sets the id for the block.     *      * @param id  the id (<code>null</code> permitted).     */    public void setID(String id) {        this.id = id;       }        /**     * Returns the natural width of the block, if this is known in advance.     * The actual width of the block may be overridden if layout constraints     * make this necessary.       *      * @return The width.     */    public double getWidth() {        return this.width;    }        /**     * Sets the natural width of the block, if this is known in advance.     *      * @param width  the width (in Java2D units)     */    public void setWidth(double width) {        this.width = width;    }        /**     * Returns the natural height of the block, if this is known in advance.     * The actual height of the block may be overridden if layout constraints     * make this necessary.       *      * @return The height.     */    public double getHeight() {        return this.height;    }        /**     * Sets the natural width of the block, if this is known in advance.     *      * @param height  the width (in Java2D units)     */    public void setHeight(double height) {        this.height = height;    }        /**     * Returns the margin.     *      * @return The margin (never <code>null</code>).     */    public RectangleInsets getMargin() {        return this.margin;    }            /**     * Sets the margin (use {@link RectangleInsets#ZERO_INSETS} for no      * padding).     *      * @param margin  the margin (<code>null</code> not permitted).     */    public void setMargin(RectangleInsets margin) {        if (margin == null) {            throw new IllegalArgumentException("Null 'margin' argument.");           }        this.margin = margin;    }    /**     * Sets the margin.     *      * @param top  the top margin.     * @param left  the left margin.     * @param bottom  the bottom margin.     * @param right  the right margin.     */    public void setMargin(double top, double left, double bottom,                           double right) {        setMargin(new RectangleInsets(top, left, bottom, right));    }    /**     * Returns the border.     *      * @return The border (never <code>null</code>).     */    public BlockBorder getBorder() {        return this.border;    }        /**     * Sets the border for the block (use {@link BlockBorder#NONE} for     * no border).     *      * @param border  the border (<code>null</code> not permitted).     */    public void setBorder(BlockBorder border) {        if (border == null) {            throw new IllegalArgumentException("Null 'border' argument.");           }        this.border = border;    }        /**     * Sets a black border with the specified line widths.     *      * @param top  the top border line width.     * @param left  the left border line width.     * @param bottom  the bottom border line width.     * @param right  the right border line width.     */    public void setBorder(double top, double left, double bottom,                           double right) {        setBorder(new BlockBorder(top, left, bottom, right));    }        /**     * Returns the padding.     *      * @return The padding (never <code>null</code>).     */    public RectangleInsets getPadding() {        return this.padding;    }        /**     * Sets the padding (use {@link RectangleInsets#ZERO_INSETS} for no      * padding).     *      * @param padding  the padding (<code>null</code> not permitted).     */    public void setPadding(RectangleInsets padding) {        if (padding == null) {            throw new IllegalArgumentException("Null 'padding' argument.");           }        this.padding = padding;    }    public double getContentXOffset() {        return this.margin.getLeft() + this.border.getInsets().getLeft() + this.padding.getLeft();        }        public double getContentYOffset() {        return this.margin.getTop() + this.border.getInsets().getTop() + this.padding.getTop();       }        /**     * Sets the padding.     *      * @param top  the top padding.     * @param left  the left padding.     * @param bottom  the bottom padding.     * @param right  the right padding.     */    public void setPadding(double top, double left, double bottom,                            double right) {        setPadding(new RectangleInsets(top, left, bottom, right));    }        /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -