home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.html;
-
- import java.io.Serializable;
- import java.util.Hashtable;
-
- class CSS$LengthUnit implements Serializable {
- static Hashtable lengthMapping = new Hashtable(6);
- short type;
- float value;
- static final short UNINITALIZED_LENGTH = 10;
-
- CSS$LengthUnit(String var1, short var2, float var3) {
- this.parse(var1, var2, var3);
- }
-
- void parse(String var1, short var2, float var3) {
- this.type = var2;
- this.value = var3;
- int var4 = var1.length();
- if (var4 > 0 && var1.charAt(var4 - 1) == '%') {
- try {
- this.value = Float.valueOf(var1.substring(0, var4 - 1)) / 100.0F;
- this.type = 1;
- } catch (NumberFormatException var11) {
- }
- }
-
- if (var4 >= 2) {
- String var5 = var1.substring(var4 - 2, var4);
- Float var6 = (Float)lengthMapping.get(var5);
- if (var6 != null) {
- try {
- this.value = Float.valueOf(var1.substring(0, var4 - 2)) * var6;
- this.type = 0;
- } catch (NumberFormatException var10) {
- }
- } else if (!var5.equals("em") && !var5.equals("ex")) {
- if (var1.equals("larger")) {
- this.value = 2.0F;
- this.type = 2;
- } else if (var1.equals("smaller")) {
- this.value = -2.0F;
- this.type = 2;
- } else {
- try {
- this.value = Float.valueOf(var1);
- this.type = 0;
- } catch (NumberFormatException var8) {
- }
- }
- } else {
- try {
- this.value = Float.valueOf(var1.substring(0, var4 - 2));
- this.type = 3;
- } catch (NumberFormatException var9) {
- }
- }
- }
-
- }
-
- public String toString() {
- return this.type + " " + this.value;
- }
-
- static {
- lengthMapping.put("pt", new Float(1.0F));
- lengthMapping.put("px", new Float(1.3F));
- lengthMapping.put("mm", new Float(2.83464F));
- lengthMapping.put("cm", new Float(28.3464F));
- lengthMapping.put("pc", new Float(12.0F));
- lengthMapping.put("in", new Float(72.0F));
- }
- }
-