com.ijchart.xychart.ui
Class RectangleInsets

java.lang.Object
  extended by com.ijchart.xychart.ui.RectangleInsets
All Implemented Interfaces:
java.io.Serializable

public class RectangleInsets
extends java.lang.Object
implements java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

表示长方形里的嵌入物,指定长度是绝对值还是相对值(百分比).本类是不可在外部改变的.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static RectangleInsets INSETS_ONE
          顶部、左边、底部、右边都为1的RectangleInsets.
static RectangleInsets INSETS_THREE
          顶部、左边、底部、右边都为3的RectangleInsets.
static RectangleInsets INSETS_TWO
          顶部、左边、底部、右边都为2的RectangleInsets.
static RectangleInsets INSETS_ZERO
          顶部、左边、底部、右边都为零的RectangleInsets.
 
Constructor Summary
RectangleInsets(double top, double left, double bottom, double right)
          构造器,长度类型为绝对值.
RectangleInsets(UnitType unitType, double top, double left, double bottom, double right)
          用指定的UnitType构造对象.
 
Method Summary
 double calculateBottomInset(double height)
          Returns the bottom margin.
 double calculateBottomOutset(double height)
          Returns the bottom margin.
 double calculateLeftInset(double width)
          Returns the left margin.
 double calculateLeftOutset(double width)
          Returns the left margin.
 double calculateRightInset(double width)
          Returns the right margin.
 double calculateRightOutset(double width)
          Returns the right margin.
 double calculateTopInset(double height)
          返回顶端空白.
 double calculateTopOutset(double height)
          Returns the top margin.
 java.awt.geom.Rectangle2D createAdjustedRectangle(java.awt.geom.Rectangle2D base, LengthAdjustmentType horizontal, LengthAdjustmentType vertical)
          根据本对象及水平和垂直两个方向的长度调整类型计算新的矩形.
 java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base)
          创建一个新的矩形对象.
 java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base, boolean horizontal, boolean vertical)
          创建一个新的矩形对象.
 java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base)
          创建一个新的矩形对象.
 java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base, boolean horizontal, boolean vertical)
          创建一个新的矩形对象.
 RectangleInsets ensureAtLeast(double len)
          如果本对象的某个边界的长度小于len,则扩大至len.
 boolean equals(java.lang.Object obj)
          覆盖equals方法.
 void expandRect(java.awt.geom.Rectangle2D rect)
          扩展矩形的宽度和高度.
 void expandRectHeight(java.awt.geom.Rectangle2D rect)
          扩展矩形的高度.
 void expandRectWidth(java.awt.geom.Rectangle2D rect)
          扩展矩形的宽度.
 double extendHeight(double height)
          Extends the given height to allow for the insets.
 double extendWidth(double width)
          Extends the given width to allow for the insets.
 double getBottom()
          返回底部长度.
 double getLeft()
          返回左边长度.
 double getRight()
          返回右边长度.
 double getTop()
          返回顶部长度.
 java.awt.geom.Rectangle2D getTrimArea(java.awt.geom.Rectangle2D area)
          返回area去掉空白后的图形.
 UnitType getUnitType()
          长度单位类型,绝对值或相对值(百分比).
 int hashCode()
          覆盖hasCode方法,返回hascode值.
 java.lang.String toString()
          覆盖toString方法.
 void trim(java.awt.geom.Rectangle2D area)
          把area的空白去掉.
 double trimHeight(double height)
          Trims the given height to allow for the insets.
 double trimWidth(double width)
          Trims the given width to allow for the insets.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INSETS_ZERO

public static final RectangleInsets INSETS_ZERO
顶部、左边、底部、右边都为零的RectangleInsets.


INSETS_ONE

public static final RectangleInsets INSETS_ONE
顶部、左边、底部、右边都为1的RectangleInsets.


INSETS_TWO

public static final RectangleInsets INSETS_TWO
顶部、左边、底部、右边都为2的RectangleInsets.


INSETS_THREE

public static final RectangleInsets INSETS_THREE
顶部、左边、底部、右边都为3的RectangleInsets.

Constructor Detail

RectangleInsets

public RectangleInsets(double top,
                       double left,
                       double bottom,
                       double right)
构造器,长度类型为绝对值.

Parameters:
top - 顶部长度.
left - 左边长度.
bottom - 底部长度.
right - 右边长度.

RectangleInsets

public RectangleInsets(UnitType unitType,
                       double top,
                       double left,
                       double bottom,
                       double right)
用指定的UnitType构造对象.

Parameters:
unitType - 长度值类型.
top - 顶部长度.
left - 左边长度.
bottom - 底部长度.
right - 右边长度.
Method Detail

getUnitType

public UnitType getUnitType()
长度单位类型,绝对值或相对值(百分比).

Returns:
长度单位类型,不为null.

getTop

public double getTop()
返回顶部长度.

Returns:
顶部长度.

getBottom

public double getBottom()
返回底部长度.

Returns:
底部长度.

getLeft

public double getLeft()
返回左边长度.

Returns:
左边长度.

getRight

public double getRight()
返回右边长度.

Returns:
右边长度.

createAdjustedRectangle

public java.awt.geom.Rectangle2D createAdjustedRectangle(java.awt.geom.Rectangle2D base,
                                                         LengthAdjustmentType horizontal,
                                                         LengthAdjustmentType vertical)
根据本对象及水平和垂直两个方向的长度调整类型计算新的矩形.

Parameters:
base - 要调整的矩形.
horizontal - 水平方向的长度调整类型 (不可为null).
vertical - 垂直方向的长度调整类型.
Returns:
调整后的矩形.

createInsetRectangle

public java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base)
创建一个新的矩形对象.

Parameters:
base - 创建新的矩形对象的基础矩形 (不可为null).
Returns:
新的矩形对象.

createInsetRectangle

public java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base,
                                                      boolean horizontal,
                                                      boolean vertical)
创建一个新的矩形对象.

Parameters:
base - 创建新的矩形对象的基础矩形 (不可为null).
horizontal - 是否应用水平方向insert.
vertical - 是否应用垂直方向insert.
Returns:
新的矩形对象.

createOutsetRectangle

public java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base)
创建一个新的矩形对象.

Parameters:
base - 创建新的矩形对象的基础矩形 (不可为null).
Returns:
新的矩形对象.

createOutsetRectangle

public java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base,
                                                       boolean horizontal,
                                                       boolean vertical)
创建一个新的矩形对象.

Parameters:
base - 创建新的矩形对象的基础矩形 (不可为null).
horizontal - 是否应用水平方向insert.
vertical - 是否应用垂直方向insert.
Returns:
新的矩形对象.

calculateTopInset

public double calculateTopInset(double height)
返回顶端空白.

Parameters:
height - 基础矩形的调度.
Returns:
顶部空白.

calculateTopOutset

public double calculateTopOutset(double height)
Returns the top margin.

Parameters:
height - the height of the base rectangle.
Returns:
The top margin (in Java2D units).

calculateBottomInset

public double calculateBottomInset(double height)
Returns the bottom margin.

Parameters:
height - the height of the base rectangle.
Returns:
The bottom margin (in Java2D units).

calculateBottomOutset

public double calculateBottomOutset(double height)
Returns the bottom margin.

Parameters:
height - the height of the base rectangle.
Returns:
The bottom margin (in Java2D units).

calculateLeftInset

public double calculateLeftInset(double width)
Returns the left margin.

Parameters:
width - the width of the base rectangle.
Returns:
The left margin (in Java2D units).

calculateLeftOutset

public double calculateLeftOutset(double width)
Returns the left margin.

Parameters:
width - the width of the base rectangle.
Returns:
The left margin (in Java2D units).

calculateRightInset

public double calculateRightInset(double width)
Returns the right margin.

Parameters:
width - the width of the base rectangle.
Returns:
The right margin (in Java2D units).

calculateRightOutset

public double calculateRightOutset(double width)
Returns the right margin.

Parameters:
width - the width of the base rectangle.
Returns:
The right margin (in Java2D units).

trimWidth

public double trimWidth(double width)
Trims the given width to allow for the insets.

Parameters:
width - the width.
Returns:
The trimmed width.

extendWidth

public double extendWidth(double width)
Extends the given width to allow for the insets.

Parameters:
width - the width.
Returns:
The extended width.

trimHeight

public double trimHeight(double height)
Trims the given height to allow for the insets.

Parameters:
height - the height.
Returns:
The trimmed height.

extendHeight

public double extendHeight(double height)
Extends the given height to allow for the insets.

Parameters:
height - the height.
Returns:
The extended height.

expandRectHeight

public void expandRectHeight(java.awt.geom.Rectangle2D rect)
扩展矩形的高度.

Parameters:
rect - Rectangle2D 要扩展的矩形 (不可为null).

expandRectWidth

public void expandRectWidth(java.awt.geom.Rectangle2D rect)
扩展矩形的宽度.

Parameters:
rect - Rectangle2D 要扩展的矩形 (不可为null).

expandRect

public void expandRect(java.awt.geom.Rectangle2D rect)
扩展矩形的宽度和高度.

Parameters:
rect - Rectangle2D 要扩展的矩形 (不可为null).

trim

public void trim(java.awt.geom.Rectangle2D area)
把area的空白去掉.

Parameters:
area - Rectangle2D 矩形 (不可为null).

getTrimArea

public java.awt.geom.Rectangle2D getTrimArea(java.awt.geom.Rectangle2D area)
返回area去掉空白后的图形.

Parameters:
area - Rectangle2D 要处理的矩形 (不可为null).
Returns:
Rectangle2D

ensureAtLeast

public RectangleInsets ensureAtLeast(double len)
如果本对象的某个边界的长度小于len,则扩大至len.

Parameters:
len - double 长度,必须大于等于0.
Returns:
RectangleInsets 新的RectangleInsets对象.

equals

public boolean equals(java.lang.Object obj)
覆盖equals方法.

Overrides:
equals in class java.lang.Object
Parameters:
obj - 要比较的对象.
Returns:
相等则返回true,否则返回false.

hashCode

public int hashCode()
覆盖hasCode方法,返回hascode值.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code.

toString

public java.lang.String toString()
覆盖toString方法.

Overrides:
toString in class java.lang.Object
Returns:
A string representing this instance.