1 package org.joshy.html; 2 3 import java.awt.*; 4 import org.w3c.dom.*; 5 import org.joshy.*; 6 7 class CSSUtil { 8 public static Color getColor(String val) { 9 return getColor(val,Color.black); 10 } 11 public static Color getColor(String val, Color default_color) { 12 if(val == null) { 13 return default_color; 14 } 15 if(val.equals("")) { 16 return default_color; 17 } 18 return Color.decode(val); 19 } 20 public static int getWidth(String val, int parent) { 21 if(val == null) { return 0; } 22 if(val.equals("")) { return 0; } 23 if(val.endsWith("px")) { 24 return Integer.parseInt(val.substring(0,val.length()-2)); 25 } 26 if(val.endsWith("%")) { 27 int v2 = Integer.parseInt(val.substring(0,val.length()-1)); 28 return (int)((((float)v2)/100)*parent); 29 } 30 return Integer.parseInt(val); 32 } 33 public static int getWidth(String val) { 34 if(val == null) { return 0; } 35 if(val.equals("")) { return 0; } 36 if(val.endsWith("px")) { 37 return Integer.parseInt(val.substring(0,val.length()-2)); 38 } 39 return Integer.parseInt(val); 41 } 42 public static int getSize(String val, int default_size) { 43 if(val == null) { return default_size; } 44 if(val.equals("")) { return default_size; } 45 if(val.endsWith("pt")) { 46 return Integer.parseInt(val.substring(0,val.length()-2)); 47 } 48 return Integer.parseInt(val); 50 } 51 } 52 53 | Popular Tags |