001: /*
002: Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.objects;
028:
029: import java.awt.geom.Point2D;
030: import java.awt.geom.RectangularShape;
031:
032: /**
033: PDF rectangle object [PDF:1.6:3.8.4].
034: */
035: public class PdfRectangle extends PdfArray {
036: // <class>
037: // <dynamic>
038: // <constructors>
039: public PdfRectangle(RectangularShape rectangle) {
040: this (rectangle.getX(), rectangle.getY(), rectangle.getX()
041: + rectangle.getWidth(), rectangle.getY()
042: + rectangle.getHeight());
043: }
044:
045: public PdfRectangle(Point2D upperLeft, Point2D lowerRight) {
046: this (upperLeft.getX(), upperLeft.getY(), lowerRight.getX(),
047: lowerRight.getY());
048: }
049:
050: public PdfRectangle(double left, double top, double right,
051: double bottom) {
052: super (new PdfReal[] { new PdfReal(left), new PdfReal(top),
053: new PdfReal(right), new PdfReal(bottom) });
054: }
055:
056: // </constructors>
057:
058: // <interface>
059: // <public>
060: public double getBottom() {
061: return ((PdfReal) get(3)).getValue();
062: }
063:
064: public double getHeight() {
065: return (getBottom() - getTop());
066: }
067:
068: public double getLeft() {
069: return (((PdfReal) get(0)).getValue());
070: }
071:
072: public double getRight() {
073: return (((PdfReal) get(2)).getValue());
074: }
075:
076: public double getTop() {
077: return (((PdfReal) get(1)).getValue());
078: }
079:
080: public double getWidth() {
081: return (getRight() - getLeft());
082: }
083:
084: public void setBottom(double value) {
085: ((PdfReal) get(3)).setValue(value);
086: }
087:
088: public void setHeight(double value) {
089: setBottom(getTop() + value);
090: }
091:
092: public void setLeft(double value) {
093: ((PdfReal) get(0)).setValue(value);
094: }
095:
096: public void setRight(double value) {
097: ((PdfReal) get(2)).setValue(value);
098: }
099:
100: public void setTop(double value) {
101: ((PdfReal) get(1)).setValue(value);
102: }
103:
104: public void setWidth(double value) {
105: setRight(getLeft() + value);
106: }
107: // </public>
108: // </interface>
109: // </dynamic>
110: // </class>
111: }
|