Source for java.awt.print.Paper

   1: /* Paper.java -- Information about a paper type.
   2:    Copyright (C) 1999, 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.awt.print;
  40: 
  41: /**
  42:  * This class describes a particular type of paper.
  43:  *
  44:  * @author Aaron M. Renn (arenn@urbanophile.com)
  45:  */
  46: public class Paper
  47:   implements Cloneable
  48: {
  49:   // Height of the paper
  50:   private double height;
  51: 
  52:   // Width of the paper
  53:   private double width;
  54: 
  55:   // Upper left imageable X coordinate
  56:   private double imageableX;
  57: 
  58:   // Upper left imageable Y coordinate
  59:   private double imageableY;
  60: 
  61:   // Imageable width of the page
  62:   private double imageableWidth;
  63: 
  64:   // Imageable height of the page
  65:   private double imageableHeight;
  66: 
  67:   /**
  68:    * This method creates a letter sized paper with one inch margins
  69:    */
  70:   public Paper()
  71:   {
  72:     width = 8.5 * 72;
  73:     height = 11 * 72;
  74:     imageableX = 72;
  75:     imageableY = 72;
  76:     imageableWidth = width - (2 * 72);
  77:     imageableHeight = height - (2 * 72);
  78:   }
  79: 
  80:   /**
  81:    * This method returns the height of the paper in 1/72nds of an inch.
  82:    *
  83:    * @return The height of the paper in 1/72nds of an inch.
  84:    */
  85:   public double getHeight()
  86:   {
  87:     return height;
  88:   }
  89: 
  90:   /**
  91:    * Returns the width of the paper in 1/72nds of an inch.
  92:    *
  93:    * @return The width of the paper in 1/72nds of an inch.
  94:    */
  95:   public double getWidth()
  96:   {
  97:     return width;
  98:   }
  99: 
 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: }