001 /* Paper.java -- Information about a paper type. 002 Copyright (C) 1999, 2006 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package java.awt.print; 040 041 /** 042 * This class describes a particular type of paper. 043 * 044 * @author Aaron M. Renn (arenn@urbanophile.com) 045 */ 046 public class Paper 047 implements Cloneable 048 { 049 // Height of the paper 050 private double height; 051 052 // Width of the paper 053 private double width; 054 055 // Upper left imageable X coordinate 056 private double imageableX; 057 058 // Upper left imageable Y coordinate 059 private double imageableY; 060 061 // Imageable width of the page 062 private double imageableWidth; 063 064 // Imageable height of the page 065 private double imageableHeight; 066 067 /** 068 * This method creates a letter sized paper with one inch margins 069 */ 070 public Paper() 071 { 072 width = 8.5 * 72; 073 height = 11 * 72; 074 imageableX = 72; 075 imageableY = 72; 076 imageableWidth = width - (2 * 72); 077 imageableHeight = height - (2 * 72); 078 } 079 080 /** 081 * This method returns the height of the paper in 1/72nds of an inch. 082 * 083 * @return The height of the paper in 1/72nds of an inch. 084 */ 085 public double getHeight() 086 { 087 return height; 088 } 089 090 /** 091 * Returns the width of the paper in 1/72nds of an inch. 092 * 093 * @return The width of the paper in 1/72nds of an inch. 094 */ 095 public double getWidth() 096 { 097 return width; 098 } 099 100 /** 101 * This method returns the X coordinate of the upper left hand corner of the 102 * imageable area of the paper. 103 * 104 * @return The X coordinate of the upper left hand corner of the imageable 105 * area of the paper. 106 */ 107 public double getImageableX() 108 { 109 return imageableX; 110 } 111 112 /** 113 * This method returns the Y coordinate of the upper left hand corner of the 114 * imageable area of the paper. 115 * 116 * @return The Y coordinate of the upper left hand corner of the imageable 117 * area of the paper. 118 */ 119 public double getImageableY() 120 { 121 return imageableY; 122 } 123 124 /** 125 * Returns the width of the imageable area of the paper. 126 * 127 * @return The width of the imageable area of the paper. 128 */ 129 public double getImageableWidth() 130 { 131 return imageableWidth; 132 } 133 134 /** 135 * Returns the height of the imageable area of the paper. 136 * 137 * @return The height of the imageable area of the paper. 138 */ 139 public double getImageableHeight() 140 { 141 return imageableHeight; 142 } 143 144 /** 145 * This method sets the size of the paper to the specified width and height, 146 * which are specified in 1/72nds of an inch. 147 * 148 * @param width The width of the paper in 1/72nds of an inch. 149 * @param height The height of the paper in 1/72nds of an inch. 150 */ 151 public void setSize(double width, double height) 152 { 153 this.width = width; 154 this.height = height; 155 } 156 157 /** 158 * This method sets the imageable area of the paper by specifying the 159 * coordinates of the upper left hand corner of that area, and its length 160 * and height. All values are in 1/72nds of an inch. 161 * 162 * @param imageableX The X coordinate of the upper left hand corner of the 163 * imageable area, in 1/72nds of an inch. 164 * @param imageableY The Y coordinate of the upper left hand corner of the 165 * imageable area, in 1/72nds of an inch. 166 * @param imageableWidth The width of the imageable area of the paper, in 167 * 1/72nds of an inch. 168 * @param imageableHeight The heigth of the imageable area of the paper, in 169 * 1/72nds of an inch. 170 */ 171 public void setImageableArea(double imageableX, double imageableY, 172 double imageableWidth, double imageableHeight) 173 { 174 this.imageableX = imageableX; 175 this.imageableY = imageableY; 176 this.imageableWidth = imageableWidth; 177 this.imageableHeight = imageableHeight; 178 } 179 180 /** 181 * This method creates a copy of this object. 182 * 183 * @return A copy of this object. 184 */ 185 public Object clone() 186 { 187 try 188 { 189 return (super.clone()); 190 } 191 catch (CloneNotSupportedException e) 192 { 193 return (null); 194 } 195 } 196 197 }