Paper.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /* Paper.java -- Information about a paper type.
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.awt.print;
  32. /**
  33. * This class describes a particular type of paper.
  34. *
  35. * @author Aaron M. Renn (arenn@urbanophile.com)
  36. */
  37. public class Paper
  38. {
  39. /*
  40. * Instance Variables
  41. */
  42. // Height of the paper
  43. private double height;
  44. // Width of the paper
  45. private double width;
  46. // Upper left imageable X coordinate
  47. private double imageableX;
  48. // Upper left imageable Y coordinate
  49. private double imageableY;
  50. // Imageable width of the page
  51. private double imageableWidth;
  52. // Imageable height of the page
  53. private double imageableHeight;
  54. /*************************************************************************/
  55. /*
  56. * Constructor
  57. */
  58. /**
  59. * This method creates a letter sized paper with one inch margins
  60. */
  61. public
  62. Paper()
  63. {
  64. width = 8.5 * 72;
  65. height = 11 * 72;
  66. imageableX = 72;
  67. imageableY = 72;
  68. imageableWidth = width - (2 * 72);
  69. imageableHeight = height - (2 * 72);
  70. }
  71. /*************************************************************************/
  72. /**
  73. * This method returns the height of the paper in 1/72nds of an inch.
  74. *
  75. * @return The height of the paper in 1/72nds of an inch.
  76. */
  77. public double
  78. getHeight()
  79. {
  80. return(height);
  81. }
  82. /*************************************************************************/
  83. /**
  84. * Returns the width of the paper in 1/72nds of an inch.
  85. *
  86. * @return The width of the paper in 1/72nds of an inch.
  87. */
  88. public double
  89. getWidth()
  90. {
  91. return(width);
  92. }
  93. /*************************************************************************/
  94. /**
  95. * This method returns the X coordinate of the upper left hand corner
  96. * of the imageable area of the paper.
  97. *
  98. * @return The X coordinate of the upper left hand corner of the imageable
  99. * area of the paper.
  100. */
  101. public double
  102. getImageableX()
  103. {
  104. return(imageableX);
  105. }
  106. /*************************************************************************/
  107. /**
  108. * This method returns the Y coordinate of the upper left hand corner
  109. * of the imageable area of the paper.
  110. *
  111. * @return The Y coordinate of the upper left hand corner of the imageable
  112. * area of the paper.
  113. */
  114. public double
  115. getImageableY()
  116. {
  117. return(imageableY);
  118. }
  119. /*************************************************************************/
  120. /**
  121. * Returns the width of the imageable area of the paper.
  122. *
  123. * @return The width of the imageable area of the paper.
  124. */
  125. public double
  126. getImageableWidth()
  127. {
  128. return(imageableWidth);
  129. }
  130. /*************************************************************************/
  131. /**
  132. * Returns the height of the imageable area of the paper.
  133. *
  134. * @return The height of the imageable area of the paper.
  135. */
  136. public double
  137. getImageableHeight()
  138. {
  139. return(imageableHeight);
  140. }
  141. /*************************************************************************/
  142. /**
  143. * This method sets the size of the paper to the specified width and
  144. * height, which are specified in 1/72nds of an inch.
  145. *
  146. * @param width The width of the paper in 1/72nds of an inch.
  147. * @param height The height of the paper in 1/72nds of an inch.
  148. */
  149. public void
  150. setSize(double width, double height)
  151. {
  152. this.width = width;
  153. this.height = height;
  154. }
  155. /*************************************************************************/
  156. /**
  157. * This method sets the imageable area of the paper by specifying the
  158. * coordinates of the upper left hand corner of that area, and its
  159. * length and height. All values are in 1/72nds of an inch.
  160. *
  161. * @param imageableX The X coordinate of the upper left hand corner of
  162. * the imageable area, in 1/72nds of an inch.
  163. * @param imageableY The Y coordinate of the upper left hand corner of
  164. * the imageable area, in 1/72nds of an inch.
  165. * @param imageableWidth The width of the imageable area of the paper,
  166. * in 1/72nds of an inch.
  167. * @param imageableHeight The heigth of the imageable area of the paper,
  168. * in 1/72nds of an inch.
  169. */
  170. public void
  171. 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
  186. clone()
  187. {
  188. try
  189. {
  190. return(super.clone());
  191. }
  192. catch(CloneNotSupportedException e)
  193. {
  194. return(null);
  195. }
  196. }
  197. } // class Paper