1 17 18 package org.objectweb.jac.aspects.gui; 19 20 import java.text.ParsePosition ; 21 import org.objectweb.jac.core.rtti.FieldItem; 22 import java.awt.Point ; 23 24 public class PointFormat implements Format { 25 26 protected FieldItem field; 27 28 public PointFormat(FieldItem field) { 29 this.field = field; 30 } 31 32 public String format(Object value) { 33 if (value!=null) { 34 Point p = (Point )value; 35 return p.x+","+p.y; 36 } else { 37 return ""; 38 } 39 } 40 41 public Object parse(String str, ParsePosition pos) { 42 int coma = str.indexOf(","); 43 if (coma!=-1) { 44 return new Point (Integer.parseInt(str.substring(0,coma).trim()), 45 Integer.parseInt(str.substring(coma+1,str.length()).trim())); 46 } else { 47 throw new RuntimeException ("Malformed point string: \""+str+"\""); 48 } 49 } 50 } 51 | Popular Tags |