Source Code Cross Referenced for MediaSize.java in  » Apache-Harmony-Java-SE » javax-package » javax » print » attribute » standard » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.print.attribute.standard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package javax.print.attribute.standard;
019:
020:        import java.util.ArrayList;
021:        import java.util.HashMap;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:        import javax.print.attribute.Attribute;
026:        import javax.print.attribute.Size2DSyntax;
027:
028:        @SuppressWarnings("unused")
029:        public class MediaSize extends Size2DSyntax implements  Attribute {
030:            private static final long serialVersionUID = -1967958664615414771L;
031:
032:            private static final List<MediaSize> sizesList = new ArrayList<MediaSize>(
033:                    80);
034:
035:            private static final Map<MediaSizeName, MediaSize> mediaSizeMap = new HashMap<MediaSizeName, MediaSize>(
036:                    80, 1);
037:
038:            public static final class Engineering {
039:                private Engineering() {
040:                    super ();
041:                }
042:
043:                public static final MediaSize A = new MediaSize(8.5f, 11.0f,
044:                        Size2DSyntax.INCH, MediaSizeName.A);
045:
046:                public static final MediaSize B = new MediaSize(11, 17,
047:                        Size2DSyntax.INCH, MediaSizeName.B);
048:
049:                public static final MediaSize C = new MediaSize(17, 22,
050:                        Size2DSyntax.INCH, MediaSizeName.C);
051:
052:                public static final MediaSize D = new MediaSize(22, 34,
053:                        Size2DSyntax.INCH, MediaSizeName.D);
054:
055:                public static final MediaSize E = new MediaSize(34, 44,
056:                        Size2DSyntax.INCH, MediaSizeName.E);
057:            }
058:
059:            public static final class ISO {
060:                private ISO() {
061:                    super ();
062:                }
063:
064:                public static final MediaSize A0 = new MediaSize(841, 1189,
065:                        Size2DSyntax.MM, MediaSizeName.ISO_A0);
066:
067:                public static final MediaSize A1 = new MediaSize(594, 841,
068:                        Size2DSyntax.MM, MediaSizeName.ISO_A1);
069:
070:                public static final MediaSize A2 = new MediaSize(420, 594,
071:                        Size2DSyntax.MM, MediaSizeName.ISO_A2);
072:
073:                public static final MediaSize A3 = new MediaSize(297, 420,
074:                        Size2DSyntax.MM, MediaSizeName.ISO_A3);
075:
076:                public static final MediaSize A4 = new MediaSize(210, 297,
077:                        Size2DSyntax.MM, MediaSizeName.ISO_A4);
078:
079:                public static final MediaSize A5 = new MediaSize(148, 210,
080:                        Size2DSyntax.MM, MediaSizeName.ISO_A5);
081:
082:                public static final MediaSize A6 = new MediaSize(105, 148,
083:                        Size2DSyntax.MM, MediaSizeName.ISO_A6);
084:
085:                public static final MediaSize A7 = new MediaSize(74, 105,
086:                        Size2DSyntax.MM, MediaSizeName.ISO_A7);
087:
088:                public static final MediaSize A8 = new MediaSize(52, 74,
089:                        Size2DSyntax.MM, MediaSizeName.ISO_A8);
090:
091:                public static final MediaSize A9 = new MediaSize(37, 52,
092:                        Size2DSyntax.MM, MediaSizeName.ISO_A9);
093:
094:                public static final MediaSize A10 = new MediaSize(26, 37,
095:                        Size2DSyntax.MM, MediaSizeName.ISO_A10);
096:
097:                public static final MediaSize B0 = new MediaSize(1000, 1414,
098:                        Size2DSyntax.MM, MediaSizeName.ISO_B0);
099:
100:                public static final MediaSize B1 = new MediaSize(707, 1000,
101:                        Size2DSyntax.MM, MediaSizeName.ISO_B1);
102:
103:                public static final MediaSize B2 = new MediaSize(500, 707,
104:                        Size2DSyntax.MM, MediaSizeName.ISO_B2);
105:
106:                public static final MediaSize B3 = new MediaSize(353, 500,
107:                        Size2DSyntax.MM, MediaSizeName.ISO_B3);
108:
109:                public static final MediaSize B4 = new MediaSize(250, 353,
110:                        Size2DSyntax.MM, MediaSizeName.ISO_B4);
111:
112:                public static final MediaSize B5 = new MediaSize(176, 250,
113:                        Size2DSyntax.MM, MediaSizeName.ISO_B5);
114:
115:                public static final MediaSize B6 = new MediaSize(125, 176,
116:                        Size2DSyntax.MM, MediaSizeName.ISO_B6);
117:
118:                public static final MediaSize B7 = new MediaSize(88, 125,
119:                        Size2DSyntax.MM, MediaSizeName.ISO_B7);
120:
121:                public static final MediaSize B8 = new MediaSize(62, 88,
122:                        Size2DSyntax.MM, MediaSizeName.ISO_B8);
123:
124:                public static final MediaSize B9 = new MediaSize(44, 62,
125:                        Size2DSyntax.MM, MediaSizeName.ISO_B9);
126:
127:                public static final MediaSize B10 = new MediaSize(31, 44,
128:                        Size2DSyntax.MM, MediaSizeName.ISO_B10);
129:
130:                public static final MediaSize C3 = new MediaSize(324, 458,
131:                        Size2DSyntax.MM, MediaSizeName.ISO_C3);
132:
133:                public static final MediaSize C4 = new MediaSize(229, 324,
134:                        Size2DSyntax.MM, MediaSizeName.ISO_C4);
135:
136:                public static final MediaSize C5 = new MediaSize(162, 229,
137:                        Size2DSyntax.MM, MediaSizeName.ISO_C5);
138:
139:                public static final MediaSize C6 = new MediaSize(114, 162,
140:                        Size2DSyntax.MM, MediaSizeName.ISO_C6);
141:
142:                public static final MediaSize DESIGNATED_LONG = new MediaSize(
143:                        110, 220, Size2DSyntax.MM,
144:                        MediaSizeName.ISO_DESIGNATED_LONG);
145:            }
146:
147:            public static final class JIS {
148:                private JIS() {
149:                    super ();
150:                }
151:
152:                public static final MediaSize B0 = new MediaSize(1030, 1456,
153:                        Size2DSyntax.MM, MediaSizeName.JIS_B0);
154:
155:                public static final MediaSize B1 = new MediaSize(728, 1030,
156:                        Size2DSyntax.MM, MediaSizeName.JIS_B1);
157:
158:                public static final MediaSize B2 = new MediaSize(515, 728,
159:                        Size2DSyntax.MM, MediaSizeName.JIS_B2);
160:
161:                public static final MediaSize B3 = new MediaSize(364, 515,
162:                        Size2DSyntax.MM, MediaSizeName.JIS_B3);
163:
164:                public static final MediaSize B4 = new MediaSize(257, 364,
165:                        Size2DSyntax.MM, MediaSizeName.JIS_B4);
166:
167:                public static final MediaSize B5 = new MediaSize(182, 257,
168:                        Size2DSyntax.MM, MediaSizeName.JIS_B5);
169:
170:                public static final MediaSize B6 = new MediaSize(128, 182,
171:                        Size2DSyntax.MM, MediaSizeName.JIS_B6);
172:
173:                public static final MediaSize B7 = new MediaSize(91, 128,
174:                        Size2DSyntax.MM, MediaSizeName.JIS_B7);
175:
176:                public static final MediaSize B8 = new MediaSize(64, 91,
177:                        Size2DSyntax.MM, MediaSizeName.JIS_B8);
178:
179:                public static final MediaSize B9 = new MediaSize(45, 64,
180:                        Size2DSyntax.MM, MediaSizeName.JIS_B9);
181:
182:                public static final MediaSize B10 = new MediaSize(32, 45,
183:                        Size2DSyntax.MM, MediaSizeName.JIS_B10);
184:
185:                public static final MediaSize CHOU_1 = new MediaSize(142, 332,
186:                        Size2DSyntax.MM);
187:
188:                public static final MediaSize CHOU_2 = new MediaSize(119, 277,
189:                        Size2DSyntax.MM);
190:
191:                public static final MediaSize CHOU_3 = new MediaSize(120, 235,
192:                        Size2DSyntax.MM);
193:
194:                public static final MediaSize CHOU_4 = new MediaSize(90, 205,
195:                        Size2DSyntax.MM);
196:
197:                public static final MediaSize CHOU_30 = new MediaSize(92, 235,
198:                        Size2DSyntax.MM);
199:
200:                public static final MediaSize CHOU_40 = new MediaSize(90, 225,
201:                        Size2DSyntax.MM);
202:
203:                public static final MediaSize KAKU_0 = new MediaSize(287, 382,
204:                        Size2DSyntax.MM);
205:
206:                public static final MediaSize KAKU_1 = new MediaSize(270, 382,
207:                        Size2DSyntax.MM);
208:
209:                public static final MediaSize KAKU_2 = new MediaSize(240, 332,
210:                        Size2DSyntax.MM);
211:
212:                public static final MediaSize KAKU_3 = new MediaSize(216, 277,
213:                        Size2DSyntax.MM);
214:
215:                public static final MediaSize KAKU_4 = new MediaSize(197, 267,
216:                        Size2DSyntax.MM);
217:
218:                public static final MediaSize KAKU_5 = new MediaSize(190, 240,
219:                        Size2DSyntax.MM);
220:
221:                public static final MediaSize KAKU_6 = new MediaSize(162, 229,
222:                        Size2DSyntax.MM);
223:
224:                public static final MediaSize KAKU_7 = new MediaSize(142, 205,
225:                        Size2DSyntax.MM);
226:
227:                public static final MediaSize KAKU_8 = new MediaSize(119, 197,
228:                        Size2DSyntax.MM);
229:
230:                public static final MediaSize KAKU_20 = new MediaSize(229, 324,
231:                        Size2DSyntax.MM);
232:
233:                public static final MediaSize KAKU_A4 = new MediaSize(228, 312,
234:                        Size2DSyntax.MM);
235:
236:                public static final MediaSize YOU_1 = new MediaSize(120, 176,
237:                        Size2DSyntax.MM);
238:
239:                public static final MediaSize YOU_2 = new MediaSize(114, 162,
240:                        Size2DSyntax.MM);
241:
242:                public static final MediaSize YOU_3 = new MediaSize(98, 148,
243:                        Size2DSyntax.MM);
244:
245:                public static final MediaSize YOU_4 = new MediaSize(105, 235,
246:                        Size2DSyntax.MM);
247:
248:                public static final MediaSize YOU_5 = new MediaSize(95, 217,
249:                        Size2DSyntax.MM);
250:
251:                public static final MediaSize YOU_6 = new MediaSize(98, 190,
252:                        Size2DSyntax.MM);
253:
254:                public static final MediaSize YOU_7 = new MediaSize(92, 165,
255:                        Size2DSyntax.MM);
256:            }
257:
258:            public static final class NA {
259:                private NA() {
260:                    super ();
261:                }
262:
263:                public static final MediaSize LETTER = new MediaSize(8.5f,
264:                        11.0f, Size2DSyntax.INCH, MediaSizeName.NA_LETTER);
265:
266:                public static final MediaSize LEGAL = new MediaSize(8.5f,
267:                        14.0f, Size2DSyntax.INCH, MediaSizeName.NA_LEGAL);
268:
269:                public static final MediaSize NA_5X7 = new MediaSize(5, 7,
270:                        Size2DSyntax.INCH, MediaSizeName.NA_5X7);
271:
272:                public static final MediaSize NA_8X10 = new MediaSize(8, 10,
273:                        Size2DSyntax.INCH, MediaSizeName.NA_8X10);
274:
275:                public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(
276:                        3.875f, 8.875f, Size2DSyntax.INCH,
277:                        MediaSizeName.NA_NUMBER_9_ENVELOPE);
278:
279:                public static final MediaSize NA_NUMBER_10_ENVELOPE = new MediaSize(
280:                        4.125f, 9.5f, Size2DSyntax.INCH,
281:                        MediaSizeName.NA_NUMBER_10_ENVELOPE);
282:
283:                public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(
284:                        4.5f, 10.375f, Size2DSyntax.INCH,
285:                        MediaSizeName.NA_NUMBER_11_ENVELOPE);
286:
287:                public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(
288:                        4.75f, 11.0f, Size2DSyntax.INCH,
289:                        MediaSizeName.NA_NUMBER_12_ENVELOPE);
290:
291:                public static final MediaSize NA_NUMBER_14_ENVELOPE = new MediaSize(
292:                        5.0f, 11.5f, Size2DSyntax.INCH,
293:                        MediaSizeName.NA_NUMBER_14_ENVELOPE);
294:
295:                public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(
296:                        6, 9, Size2DSyntax.INCH, MediaSizeName.NA_6X9_ENVELOPE);
297:
298:                public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(
299:                        7, 9, Size2DSyntax.INCH, MediaSizeName.NA_7X9_ENVELOPE);
300:
301:                public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(
302:                        9, 11, Size2DSyntax.INCH,
303:                        MediaSizeName.NA_9X11_ENVELOPE);
304:
305:                public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(
306:                        9, 12, Size2DSyntax.INCH,
307:                        MediaSizeName.NA_9X12_ENVELOPE);
308:
309:                public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(
310:                        10, 13, Size2DSyntax.INCH,
311:                        MediaSizeName.NA_10X13_ENVELOPE);
312:
313:                public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(
314:                        10, 14, Size2DSyntax.INCH,
315:                        MediaSizeName.NA_10X14_ENVELOPE);
316:
317:                public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(
318:                        10, 15, Size2DSyntax.INCH,
319:                        MediaSizeName.NA_10X15_ENVELOPE);
320:            }
321:
322:            public static final class Other {
323:                private Other() {
324:                    super ();
325:                }
326:
327:                public static final MediaSize EXECUTIVE = new MediaSize(7.25f,
328:                        10.5f, Size2DSyntax.INCH, MediaSizeName.EXECUTIVE);
329:
330:                public static final MediaSize LEDGER = new MediaSize(11, 17,
331:                        Size2DSyntax.INCH, MediaSizeName.LEDGER);
332:
333:                public static final MediaSize TABLOID = new MediaSize(11, 17,
334:                        Size2DSyntax.INCH, MediaSizeName.TABLOID);
335:
336:                public static final MediaSize INVOICE = new MediaSize(5.5f,
337:                        8.5f, Size2DSyntax.INCH, MediaSizeName.INVOICE);
338:
339:                public static final MediaSize FOLIO = new MediaSize(8.5f,
340:                        13.0f, Size2DSyntax.INCH, MediaSizeName.FOLIO);
341:
342:                public static final MediaSize QUARTO = new MediaSize(8.5f,
343:                        10.83f, Size2DSyntax.INCH, MediaSizeName.QUARTO);
344:
345:                public static final MediaSize ITALY_ENVELOPE = new MediaSize(
346:                        110, 230, Size2DSyntax.MM, MediaSizeName.ITALY_ENVELOPE);
347:
348:                public static final MediaSize MONARCH_ENVELOPE = new MediaSize(
349:                        3.87f, 7.5f, Size2DSyntax.INCH,
350:                        MediaSizeName.MONARCH_ENVELOPE);
351:
352:                public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(
353:                        3.625f, 6.5f, Size2DSyntax.INCH,
354:                        MediaSizeName.PERSONAL_ENVELOPE);
355:
356:                public static final MediaSize JAPANESE_POSTCARD = new MediaSize(
357:                        100, 148, Size2DSyntax.MM,
358:                        MediaSizeName.JAPANESE_POSTCARD);
359:
360:                public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(
361:                        148, 200, Size2DSyntax.MM,
362:                        MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
363:            }
364:
365:            /*
366:             * Force the load and initialization of inner classes.
367:             */
368:            static {
369:
370:                MediaSize initClass = MediaSize.Engineering.A;
371:                initClass = MediaSize.ISO.A0;
372:                initClass = MediaSize.JIS.B0;
373:                initClass = MediaSize.NA.LEGAL;
374:                initClass = MediaSize.Other.EXECUTIVE;
375:            }
376:
377:            private MediaSizeName mediaSizeName;
378:
379:            public MediaSize(int x, int y, int units) {
380:                super (x, y, units);
381:                if (x > y) {
382:                    throw new IllegalArgumentException("x > y");
383:                }
384:                synchronized (MediaSize.class) {
385:                    sizesList.add(this );
386:                }
387:            }
388:
389:            public MediaSize(float x, float y, int units) {
390:                super (x, y, units);
391:                if (x > y) {
392:                    throw new IllegalArgumentException("x > y");
393:                }
394:                synchronized (MediaSize.class) {
395:                    sizesList.add(this );
396:                }
397:            }
398:
399:            public MediaSize(int x, int y, int units,
400:                    MediaSizeName mediaSizeName) {
401:                super (x, y, units);
402:                if (x > y) {
403:                    throw new IllegalArgumentException("x > y");
404:                }
405:                this .mediaSizeName = mediaSizeName;
406:                synchronized (MediaSize.class) {
407:                    sizesList.add(this );
408:                    mediaSizeMap.put(mediaSizeName, this );
409:                }
410:            }
411:
412:            public MediaSize(float x, float y, int units,
413:                    MediaSizeName mediaSizeName) {
414:                super (x, y, units);
415:                if (x > y) {
416:                    throw new IllegalArgumentException("x > y");
417:                }
418:                this .mediaSizeName = mediaSizeName;
419:                synchronized (MediaSize.class) {
420:                    sizesList.add(this );
421:                    mediaSizeMap.put(mediaSizeName, this );
422:                }
423:            }
424:
425:            @Override
426:            public boolean equals(Object object) {
427:                if (!(object instanceof  MediaSize)) {
428:                    return false;
429:                }
430:                return super .equals(object);
431:            }
432:
433:            public static MediaSizeName findMedia(float x, float y, int units) {
434:                if ((x <= 0.0) || (y <= 0.0) || (units < 1)) {
435:                    throw new IllegalArgumentException("Valid values are: "
436:                            + "x > 0, y > 0, units >= 1");
437:                }
438:                synchronized (MediaSize.class) {
439:                    MediaSize hit = null;
440:                    double curX, curY, curDif;
441:                    double difference = Double.MAX_VALUE;
442:                    Iterator<MediaSize> i = sizesList.iterator();
443:                    while (i.hasNext()) {
444:                        MediaSize mediaSize = i.next();
445:                        curX = mediaSize.getX(units);
446:                        curY = mediaSize.getY(units);
447:                        if ((x == curX) && (y == curY)) {
448:                            hit = mediaSize;
449:                            break;
450:                        }
451:                        curDif = curX * curX - 2 * x * curX - 2 * y * curY
452:                                + curY * curY;
453:                        if (curDif <= difference) {
454:                            difference = curDif;
455:                            hit = mediaSize;
456:                        }
457:                    }
458:                    if (hit != null) {
459:                        return hit.getMediaSizeName();
460:                    }
461:                    return null;
462:                }
463:            }
464:
465:            public final Class<? extends Attribute> getCategory() {
466:                return MediaSize.class;
467:            }
468:
469:            public static MediaSize getMediaSizeForName(
470:                    MediaSizeName mediaSizeName) {
471:                synchronized (MediaSize.class) {
472:                    return mediaSizeMap.get(mediaSizeName);
473:                }
474:            }
475:
476:            public MediaSizeName getMediaSizeName() {
477:                return mediaSizeName;
478:            }
479:
480:            public final String getName() {
481:                return "media-size";
482:            }
483:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.