1 53 package org.swixml.converters; 54 55 import org.jdom.Attribute; 56 import org.swixml.Converter; 57 import org.swixml.Localizer; 58 59 import java.awt.*; 60 import java.util.StringTokenizer ; 61 62 80 public class InsetsConverter implements Converter { 81 82 83 public static final Class TEMPLATE = Insets.class; 84 85 86 93 public Object convert( final Class type, final Attribute attr, Localizer localizer ) { 94 Insets insets = null; 95 if (attr != null) { 96 StringTokenizer st = new StringTokenizer ( attr.getValue(), "(,)" ); 97 if (5 == st.countTokens()) { st.nextToken().trim(); 99 } 100 int[] param = Util.ia( st ); 101 if (4 <= param.length) { 102 insets = new Insets( param[0], param[1], param[2], param[3] ); 103 } 104 } 105 return insets; 106 } 107 108 109 114 public Class convertsTo() { 115 return TEMPLATE; 116 } 117 } 118 | Popular Tags |