01: /*
02: Copyright © 2007 Stefano Chizzolini. http://clown.stefanochizzolini.it
03:
04: Contributors:
05: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
06: contributed code is Copyright © 2007 by Stefano Chizzolini.
07:
08: This file should be part of the source code distribution of "PDF Clown library"
09: (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.documents.contents.objects;
28:
29: import it.stefanochizzolini.clown.objects.IPdfNumber;
30: import it.stefanochizzolini.clown.objects.PdfDirectObject;
31: import it.stefanochizzolini.clown.objects.PdfReal;
32:
33: import java.util.Arrays;
34: import java.util.List;
35:
36: /**
37: 'Append a rectangle to the current path as a complete subpath' operation
38: [PDF:1.6:4.4.1].
39:
40: @author Stefano Chizzolini
41: @version 0.0.4, 06/17/07
42: @since 0.0.4
43: */
44: public final class DrawRectangle extends Operation {
45: // <class>
46: // <static>
47: // <fields>
48: public static final String Operator = "re";
49:
50: // </fields>
51: // </static>
52:
53: // <dynamic>
54: // <constructors>
55: public DrawRectangle(double x, double y, double width, double height) {
56: super (
57: Operator,
58: (List<PdfDirectObject>) (List<? extends PdfDirectObject>) Arrays
59: .asList(new PdfReal(x), new PdfReal(y),
60: new PdfReal(width), new PdfReal(height)));
61: }
62:
63: public DrawRectangle(List<PdfDirectObject> operands) {
64: super (Operator, operands);
65: }
66:
67: // </constructors>
68:
69: // <interface>
70: // <public>
71: public double getX() {
72: return ((IPdfNumber) operands.get(0)).getNumberValue();
73: }
74:
75: public double getY() {
76: return ((IPdfNumber) operands.get(1)).getNumberValue();
77: }
78:
79: public double getWidth() {
80: return ((IPdfNumber) operands.get(2)).getNumberValue();
81: }
82:
83: public double getHeight() {
84: return ((IPdfNumber) operands.get(3)).getNumberValue();
85: }
86: // </public>
87: // </interface>
88: // </dynamic>
89: // </class>
90: }
|