1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.jhylafax.fax;
21
22 import static net.sf.jhylafax.JHylaFAX.i18n;
23
24 public enum Paper {
25
26 A4(209, 296) { public String toString() { return i18n.tr("DIN A4"); } },
27 A3(297, 420) { public String toString() { return i18n.tr("DIN A3"); } },
28 LETTER(216, 279) { public String toString() { return i18n.tr("Letter"); } },
29 LEGAL(216, 356) { public String toString() { return i18n.tr("Legal"); } };
30
31 private int width;
32 private int height;
33
34 private Paper(int width, int height) {
35 this.width = width;
36 this.height = height;
37 }
38
39 public int getWidth() {
40 return width;
41 }
42 public int getHeight() {
43 return height;
44 }
45
46 public static Paper getEnum(int width, int height) {
47 for (Paper value : values()) {
48 if (value.getWidth() == width && value.getHeight() == height) {
49 return value;
50 }
51 }
52 throw new IllegalArgumentException("Invalid values: " + width + ", " + height);
53 }
54
55 }