KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > objects > PdfRectangle


1 /*
2   Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright © 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.objects;
28
29 import java.awt.geom.Point2D JavaDoc;
30 import java.awt.geom.RectangularShape JavaDoc;
31
32 /**
33   PDF rectangle object.
34 */

35 public class PdfRectangle
36   extends PdfArray
37 {
38   // <class>
39
// <dynamic>
40
// <constructors>
41
public PdfRectangle(
42     RectangularShape JavaDoc rectangle
43     )
44   {
45     this(
46       rectangle.getX(),
47       rectangle.getY(),
48       rectangle.getX() + rectangle.getWidth(),
49       rectangle.getY() + rectangle.getHeight()
50       );
51   }
52
53   public PdfRectangle(
54     Point2D JavaDoc upperLeft,
55     Point2D JavaDoc lowerRight
56     )
57   {
58     this(
59       upperLeft.getX(),
60       upperLeft.getY(),
61       lowerRight.getX(),
62       lowerRight.getY()
63       );
64   }
65
66   public PdfRectangle(
67     double left,
68     double top,
69     double right,
70     double bottom
71     )
72   {
73     super(
74       new PdfReal[]
75       {
76         new PdfReal(left),
77         new PdfReal(top),
78         new PdfReal(right),
79         new PdfReal(bottom)
80       }
81       );
82   }
83   // </constructors>
84

85   // <interface>
86
// <public>
87
public double getBottom(
88     )
89   {return ((PdfReal)get(3)).getValue();}
90
91   public double getHeight(
92     )
93   {return(getBottom() - getTop());}
94
95   public double getLeft(
96     )
97   {return(((PdfReal)get(0)).getValue());}
98
99   public double getRight(
100     )
101   {return(((PdfReal)get(2)).getValue());}
102
103   public double getTop(
104     )
105   {return(((PdfReal)get(1)).getValue());}
106
107   public double getWidth(
108     )
109   {return(getRight() - getLeft());}
110
111   public void setBottom(
112     double value
113     )
114   {((PdfReal)get(3)).setValue(value);}
115
116   public void setHeight(
117     double value
118     )
119   {setBottom(getTop() + value);}
120
121   public void setLeft(
122     double value
123     )
124   {((PdfReal)get(0)).setValue(value);}
125
126   public void setRight(
127     double value
128     )
129   {((PdfReal)get(2)).setValue(value);}
130
131   public void setTop(
132     double value
133     )
134   {((PdfReal)get(1)).setValue(value);}
135
136   public void setWidth(
137     double value
138     )
139   {setRight(getLeft() + value);}
140   // </public>
141
// </interface>
142
// </dynamic>
143
// </class>
144
}
Popular Tags