1 7 8 package java.awt.print; 9 10 import java.awt.geom.Rectangle2D ; 11 12 25 public class Paper implements Cloneable { 26 27 28 29 private static final int INCH = 72; 30 private static final double LETTER_WIDTH = 8.5 * INCH; 31 private static final double LETTER_HEIGHT = 11 * INCH; 32 33 34 35 44 private double mHeight; 45 46 50 private double mWidth; 51 52 61 private Rectangle2D mImageableArea; 62 63 64 65 69 public Paper() { 70 mHeight = LETTER_HEIGHT; 71 mWidth = LETTER_WIDTH; 72 mImageableArea = new Rectangle2D.Double (INCH, INCH, 73 mWidth - 2 * INCH, 74 mHeight - 2 * INCH); 75 } 76 77 78 79 84 public Object clone() { 85 86 Paper newPaper; 87 88 try { 89 93 newPaper = (Paper ) super.clone(); 94 95 } catch (CloneNotSupportedException e) { 96 e.printStackTrace(); 97 newPaper = null; } 99 100 return newPaper; 101 } 102 103 108 public double getHeight() { 109 return mHeight; 110 } 111 112 123 public void setSize(double width, double height) { 124 mWidth = width; 125 mHeight = height; 126 } 127 128 134 public double getWidth() { 135 return mWidth; 136 } 137 138 149 public void setImageableArea(double x, double y, 150 double width, double height) { 151 mImageableArea = new Rectangle2D.Double (x, y, width,height); 152 } 153 154 159 public double getImageableX() { 160 return mImageableArea.getX(); 161 } 162 163 168 public double getImageableY() { 169 return mImageableArea.getY(); 170 } 171 172 177 public double getImageableWidth() { 178 return mImageableArea.getWidth(); 179 } 180 181 186 public double getImageableHeight() { 187 return mImageableArea.getHeight(); 188 } 189 } 190 | Popular Tags |