1   /**
2    * JHylaFax - A java client for HylaFAX.
3    *
4    * Copyright (C) 2005 by Steffen Pingel <steffenp@gmx.de>
5    *
6    * This program 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 of the License, or
9    * (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with this program; if not, write to the Free Software
18   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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  }