| 1 | /* PageFormat.java -- Information about the page format
|
|---|
| 2 | Copyright (C) 1999 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., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 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 contains information about the desired page format to
|
|---|
| 43 | * use for printing a particular set of pages.
|
|---|
| 44 | *
|
|---|
| 45 | * @author Aaron M. Renn ([email protected])
|
|---|
| 46 | */
|
|---|
| 47 | public class PageFormat implements Cloneable
|
|---|
| 48 | {
|
|---|
| 49 |
|
|---|
| 50 | /*
|
|---|
| 51 | * Static Variables
|
|---|
| 52 | */
|
|---|
| 53 |
|
|---|
| 54 | /**
|
|---|
| 55 | * A constant for a landscaped page orientation. Used by
|
|---|
| 56 | * <code>getOrientation</code> and <code>setOrientation</code>.
|
|---|
| 57 | */
|
|---|
| 58 | public static final int LANDSCAPE = 0;
|
|---|
| 59 |
|
|---|
| 60 | /**
|
|---|
| 61 | * A constant for a portrait page orientation. Used by
|
|---|
| 62 | * <code>getOrientation</code> and <code>setOrientation</code>.
|
|---|
| 63 | */
|
|---|
| 64 | public static final int PORTRAIT = 1;
|
|---|
| 65 |
|
|---|
| 66 | /**
|
|---|
| 67 | * A constant for a reversed landscaped page orientation. This is
|
|---|
| 68 | * the orientation used by Macintosh's for landscape. The origin is
|
|---|
| 69 | * in the upper right hand corner instead of the upper left. The
|
|---|
| 70 | * X and Y axes are reversed. Used by <code>getOrientation</code> and
|
|---|
| 71 | * <code>setOrientation</code>.
|
|---|
| 72 | */
|
|---|
| 73 | public static final int REVERSE_LANDSCAPE = 2;
|
|---|
| 74 |
|
|---|
| 75 | /*************************************************************************/
|
|---|
| 76 |
|
|---|
| 77 | /*
|
|---|
| 78 | * Instance Variables
|
|---|
| 79 | */
|
|---|
| 80 |
|
|---|
| 81 | // The page orientation
|
|---|
| 82 | private int orientation;
|
|---|
| 83 |
|
|---|
| 84 | // The paper type
|
|---|
| 85 | private Paper paper;
|
|---|
| 86 |
|
|---|
| 87 | /*************************************************************************/
|
|---|
| 88 |
|
|---|
| 89 | /*
|
|---|
| 90 | * Constructors
|
|---|
| 91 | */
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * This method creates a default page layout, which will be in portrait
|
|---|
| 95 | * format.
|
|---|
| 96 | */
|
|---|
| 97 | public
|
|---|
| 98 | PageFormat()
|
|---|
| 99 | {
|
|---|
| 100 | this.paper = new Paper();
|
|---|
| 101 | this.orientation = PORTRAIT;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /*************************************************************************/
|
|---|
| 105 |
|
|---|
| 106 | /*
|
|---|
| 107 | * Instance Methods
|
|---|
| 108 | */
|
|---|
| 109 |
|
|---|
| 110 | /**
|
|---|
| 111 | * This method returns the width of the page, in 1/72nd's of an inch. The
|
|---|
| 112 | * "width" measured depends on orientation.
|
|---|
| 113 | *
|
|---|
| 114 | * @return The width of the page.
|
|---|
| 115 | */
|
|---|
| 116 | public double
|
|---|
| 117 | getWidth()
|
|---|
| 118 | {
|
|---|
| 119 | return(paper.getWidth());
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | /*************************************************************************/
|
|---|
| 123 |
|
|---|
| 124 | /**
|
|---|
| 125 | * This method returns the height of the page, in 1/72nd's of an inch.
|
|---|
| 126 | * The "height" measured depends on the orientation.
|
|---|
| 127 | *
|
|---|
| 128 | * @return The height of the page.
|
|---|
| 129 | */
|
|---|
| 130 | public double
|
|---|
| 131 | getHeight()
|
|---|
| 132 | {
|
|---|
| 133 | return(paper.getHeight());
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | /*************************************************************************/
|
|---|
| 137 |
|
|---|
| 138 | /**
|
|---|
| 139 | * This method returns the X coordinate value of the upper leftmost
|
|---|
| 140 | * drawable area of the paper.
|
|---|
| 141 | *
|
|---|
| 142 | * @return The upper leftmost imageable X coordinate.
|
|---|
| 143 | */
|
|---|
| 144 | public double
|
|---|
| 145 | getImageableX()
|
|---|
| 146 | {
|
|---|
| 147 | return(paper.getImageableX());
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | /*************************************************************************/
|
|---|
| 151 |
|
|---|
| 152 | /**
|
|---|
| 153 | * This method returns the Y coordinate value of the upper leftmost
|
|---|
| 154 | * drawable area of the paper.
|
|---|
| 155 | *
|
|---|
| 156 | * @return The upper leftmost imageable Y coordinate.
|
|---|
| 157 | */
|
|---|
| 158 | public double
|
|---|
| 159 | getImageableY()
|
|---|
| 160 | {
|
|---|
| 161 | return(paper.getImageableY());
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | /*************************************************************************/
|
|---|
| 165 |
|
|---|
| 166 | /**
|
|---|
| 167 | * This method returns the imageable width of the paper, in 1/72nd's of
|
|---|
| 168 | * an inch.
|
|---|
| 169 | *
|
|---|
| 170 | * @return The imageable width of the paper.
|
|---|
| 171 | */
|
|---|
| 172 | public double
|
|---|
| 173 | getImageableWidth()
|
|---|
| 174 | {
|
|---|
| 175 | return(paper.getImageableWidth());
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | /*************************************************************************/
|
|---|
| 179 |
|
|---|
| 180 | /**
|
|---|
| 181 | * This method returns the imageable height of the paper, in 1/72nd's of
|
|---|
| 182 | * an inch.
|
|---|
| 183 | *
|
|---|
| 184 | * @return The imageable height of the paper.
|
|---|
| 185 | */
|
|---|
| 186 | public double
|
|---|
| 187 | getImageableHeigth()
|
|---|
| 188 | {
|
|---|
| 189 | return(paper.getImageableHeight());
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | /*************************************************************************/
|
|---|
| 193 |
|
|---|
| 194 | /**
|
|---|
| 195 | * Returns a copy of the <code>paper</code> object being used for this
|
|---|
| 196 | * page format.
|
|---|
| 197 | *
|
|---|
| 198 | * @return A copy of the <code>Paper</code> object for this format.
|
|---|
| 199 | */
|
|---|
| 200 | public Paper
|
|---|
| 201 | getPaper()
|
|---|
| 202 | {
|
|---|
| 203 | return((Paper)paper.clone());
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | /*************************************************************************/
|
|---|
| 207 |
|
|---|
| 208 | /**
|
|---|
| 209 | * Sets the <code>Paper</code> object to be used by this page format.
|
|---|
| 210 | *
|
|---|
| 211 | * @param paper The new <code>Paper</code> object for this page format.
|
|---|
| 212 | */
|
|---|
| 213 | public void
|
|---|
| 214 | setPaper(Paper paper)
|
|---|
| 215 | {
|
|---|
| 216 | this.paper = paper;
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | /*************************************************************************/
|
|---|
| 220 |
|
|---|
| 221 | /**
|
|---|
| 222 | * This method returns the current page orientation. The value returned
|
|---|
| 223 | * will be one of the page orientation constants from this class.
|
|---|
| 224 | *
|
|---|
| 225 | * @return The current page orientation.
|
|---|
| 226 | */
|
|---|
| 227 | public int
|
|---|
| 228 | getOrientation()
|
|---|
| 229 | {
|
|---|
| 230 | return(orientation);
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | /*************************************************************************/
|
|---|
| 234 |
|
|---|
| 235 | /**
|
|---|
| 236 | * This method sets the page orientation for this format to the
|
|---|
| 237 | * specified value. It must be one of the page orientation constants
|
|---|
| 238 | * from this class or an exception will be thrown.
|
|---|
| 239 | *
|
|---|
| 240 | * @param orientation The new page orientation.
|
|---|
| 241 | *
|
|---|
| 242 | * @exception IllegalArgumentException If the specified page orientation
|
|---|
| 243 | * value is not one of the constants from this class.
|
|---|
| 244 | */
|
|---|
| 245 | public void
|
|---|
| 246 | setOrientation(int orientation) throws IllegalArgumentException
|
|---|
| 247 | {
|
|---|
| 248 | if ((orientation != PORTRAIT) &&
|
|---|
| 249 | (orientation != LANDSCAPE) &&
|
|---|
| 250 | (orientation != REVERSE_LANDSCAPE))
|
|---|
| 251 | throw new IllegalArgumentException("Bad page orientation value: " +
|
|---|
| 252 | orientation);
|
|---|
| 253 |
|
|---|
| 254 | this.orientation = orientation;
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | /*************************************************************************/
|
|---|
| 258 |
|
|---|
| 259 | /**
|
|---|
| 260 | * This method returns a matrix used for transforming user space
|
|---|
| 261 | * coordinates to page coordinates. The value returned will be six
|
|---|
| 262 | * doubles as described in <code>java.awt.geom.AffineTransform</code>.
|
|---|
| 263 | *
|
|---|
| 264 | * @return The transformation matrix for this page format.
|
|---|
| 265 | */
|
|---|
| 266 | public double[]
|
|---|
| 267 | getMatrix()
|
|---|
| 268 | {
|
|---|
| 269 | throw new RuntimeException("Not implemented since I don't know what to do");
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | /*************************************************************************/
|
|---|
| 273 |
|
|---|
| 274 | /**
|
|---|
| 275 | * This method returns a copy of this object.
|
|---|
| 276 | *
|
|---|
| 277 | * @return A copy of this object.
|
|---|
| 278 | */
|
|---|
| 279 | public Object
|
|---|
| 280 | clone()
|
|---|
| 281 | {
|
|---|
| 282 | try
|
|---|
| 283 | {
|
|---|
| 284 | return(super.clone());
|
|---|
| 285 | }
|
|---|
| 286 | catch(CloneNotSupportedException e)
|
|---|
| 287 | {
|
|---|
| 288 | return(null);
|
|---|
| 289 | }
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | } // class PageFormat
|
|---|
| 293 |
|
|---|