This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / libjava / javax / print / attribute / standard / MediaPrintableArea.java
blobcc1a07e13220fdaf415aed4db68cd04b068c2f1c
1 /* MediaPrintableArea.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
39 package javax.print.attribute.standard;
41 import javax.print.attribute.DocAttribute;
42 import javax.print.attribute.PrintJobAttribute;
43 import javax.print.attribute.PrintRequestAttribute;
45 /**
46 * @author Michael Koch (konqueror@gmx.de)
48 public final class MediaPrintableArea
49 implements DocAttribute, PrintJobAttribute, PrintRequestAttribute
51 private static final long serialVersionUID = -1597171464050795793L;
53 public static final int INCH = 25400;
54 public static final int MM = 1000;
56 private float x;
57 private float y;
58 private float width;
59 private float height;
61 /**
62 * Creates a new <code>MediaPrintableArea</code> object.
64 * @throws IllegalArgumentException if x i&lt; 0 or y i&lt; 0 or w i&lt;= 0
65 * or h i&lt;= 0 or units i&lt; 1
67 public MediaPrintableArea(float x, float y, float w, float h, int units)
69 if (x < 0.0f || y < 0.0f || w <= 0.0f || h <= 0.0f)
70 throw new IllegalArgumentException();
72 this.x = x;
73 this.y = y;
74 this.width = w;
75 this.height = h;
78 /**
79 * Creates a new <code>MediaPrintableArea</code> object.
81 * @throws IllegalArgumentException if x i&lt; 0 or y i&lt; 0 or w i&lt;= 0
82 * or h i&lt;= 0 or units i&lt; 1
84 public MediaPrintableArea(int x, int y, int w, int h, int units)
86 if (x < 0 || y < 0 || w <= 0 || h <= 0)
87 throw new IllegalArgumentException();
89 this.x = x;
90 this.y = y;
91 this.width = w;
92 this.height = h;
95 /**
96 * Returns category of this class.
98 * @return the class <code>MediaPrintableArea</code> itself
100 public Class getCategory()
102 return MediaPrintableArea.class;
106 * Returns name of this class.
108 * @return the string "media-printable-area"
110 public String getName()
112 return "media-printable-area";
115 public float getHeight(int units)
117 if (units < 1)
118 throw new IllegalArgumentException();
120 return height * units;
123 public float getWidth(int units)
125 if (units < 1)
126 throw new IllegalArgumentException();
128 return width * units;
131 public float getX(int units)
133 if (units < 1)
134 throw new IllegalArgumentException();
136 return x * units;
139 public float getY(int units)
141 if (units < 1)
142 throw new IllegalArgumentException();
144 return y * units;