01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Igor A. Pyankov
19: * @version $Revision$
20: */package java.awt.print;
21:
22: import java.awt.geom.Rectangle2D;
23:
24: public class Paper implements Cloneable {
25:
26: private double paperHeight;
27: private double paperWidth;
28: private final Rectangle2D.Double paperImageableArea;
29:
30: private static final double INCH = 72D; // inch in pixels
31: private static final double INCH2 = 144D; // double inch
32: private static final double LETTER_WIDTH = 612D; // default width in pixels
33: private static final double LETTER_HEIGHT = 792D;// default height in pixels
34:
35: public Paper() {
36: super ();
37: paperWidth = LETTER_WIDTH;
38: paperHeight = LETTER_HEIGHT;
39: paperImageableArea = new Rectangle2D.Double(INCH, INCH,
40: paperWidth - INCH2, paperHeight - INCH2);
41: }
42:
43: @Override
44: public Object clone() {
45: Paper clonedPaper;
46: try {
47: clonedPaper = (Paper) super .clone();
48: } catch (CloneNotSupportedException cnse) {
49: cnse.printStackTrace();
50: clonedPaper = null;
51: }
52: return clonedPaper;
53: }
54:
55: public double getHeight() {
56: return paperHeight;
57: }
58:
59: public double getImageableWidth() {
60: return paperImageableArea.getWidth();
61: }
62:
63: public double getImageableHeight() {
64: return paperImageableArea.getHeight();
65: }
66:
67: public double getImageableX() {
68: return paperImageableArea.getX();
69: }
70:
71: public double getImageableY() {
72: return paperImageableArea.getY();
73: }
74:
75: public double getWidth() {
76: return paperWidth;
77: }
78:
79: public void setImageableArea(double x, double y, double width,
80: double height) {
81: paperImageableArea.setRect(x, y, width, height);
82: }
83:
84: public void setSize(double width, double height) {
85: paperWidth = width;
86: paperHeight = height;
87: }
88: }
|