1 26 27 package org.nightlabs.editor2d.iofilter.xstream; 28 29 import org.nightlabs.editor2d.DrawComponent; 30 import org.nightlabs.editor2d.EllipseDrawComponent; 31 import org.nightlabs.editor2d.IConnectable; 32 import org.nightlabs.editor2d.impl.EllipseDrawComponentImpl; 33 import com.thoughtworks.xstream.converters.MarshallingContext; 34 import com.thoughtworks.xstream.converters.UnmarshallingContext; 35 import com.thoughtworks.xstream.io.HierarchicalStreamReader; 36 import com.thoughtworks.xstream.io.HierarchicalStreamWriter; 37 38 public class EllipseDrawComponentConverter 39 extends ShapeDrawComponentConverter 40 { 41 public static final String CONNECT = IConnectable.PROP_CONNECT; 42 public static final String START_ANGLE = EllipseDrawComponent.PROP_START_ANGLE; 43 public static final String END_ANGLE = EllipseDrawComponent.PROP_END_ANGLE; 44 45 public EllipseDrawComponentConverter() { 46 super(); 47 } 48 49 public boolean canConvert(Class type) 50 { 51 if (type.equals(EllipseDrawComponentImpl.class)) { 52 return true; 53 } 54 return false; 55 } 56 57 protected void readAdditional(DrawComponent dc, HierarchicalStreamReader reader, UnmarshallingContext context) 58 { 59 EllipseDrawComponent edc = (EllipseDrawComponent) dc; 60 edc.setConnect(Boolean.parseBoolean(reader.getAttribute(CONNECT))); 61 edc.setStartAngle(Integer.parseInt(reader.getAttribute(START_ANGLE))); 62 edc.setEndAngle(Integer.parseInt(reader.getAttribute(END_ANGLE))); 63 } 64 65 protected void writeAdditional(DrawComponent dc, HierarchicalStreamWriter writer, MarshallingContext context) 66 { 67 EllipseDrawComponent edc = (EllipseDrawComponent) dc; 68 writer.addAttribute(CONNECT, ""+edc.isConnect()); 69 writer.addAttribute(START_ANGLE, ""+edc.getStartAngle()); 70 writer.addAttribute(END_ANGLE, ""+edc.getEndAngle()); 71 } 72 73 protected String getNodeName() { 74 return "EllipseDrawComponent"; 75 } 76 77 public Class getImpl() { 78 return EllipseDrawComponentImpl.class; 79 } 80 } 81 | Popular Tags |