1 42 43 package org.jfree.util; 44 45 import java.awt.Shape ; 46 import java.io.IOException ; 47 import java.io.ObjectInputStream ; 48 import java.io.ObjectOutputStream ; 49 50 import org.jfree.io.SerialUtilities; 51 52 53 58 public class ShapeList extends AbstractObjectList { 59 60 63 public ShapeList() { 64 super(); 65 } 66 67 74 public Shape getShape(final int index) { 75 return (Shape ) get(index); 76 } 77 78 84 public void setShape(final int index, final Shape shape) { 85 set(index, shape); 86 } 87 88 95 public Object clone() throws CloneNotSupportedException { 96 return super.clone(); 97 } 98 99 106 public boolean equals(final Object o) { 107 108 if (o == null) { 109 return false; 110 } 111 112 if (o == this) { 113 return true; 114 } 115 116 if (o instanceof ShapeList) { 117 return super.equals(o); 118 } 119 120 return false; 121 122 } 123 124 129 public int hashCode() { 130 return super.hashCode(); 131 } 132 133 140 private void writeObject(final ObjectOutputStream stream) throws IOException { 141 142 stream.defaultWriteObject(); 143 final int count = size(); 144 stream.writeInt(count); 145 for (int i = 0; i < count; i++) { 146 final Shape shape = getShape(i); 147 if (shape != null) { 148 stream.writeInt(i); 149 SerialUtilities.writeShape(shape, stream); 150 } 151 else { 152 stream.writeInt(-1); 153 } 154 } 155 156 } 157 158 166 private void readObject(final ObjectInputStream stream) throws IOException , ClassNotFoundException { 167 168 stream.defaultReadObject(); 169 final int count = stream.readInt(); 170 for (int i = 0; i < count; i++) { 171 final int index = stream.readInt(); 172 if (index != -1) { 173 setShape(index, SerialUtilities.readShape(stream)); 174 } 175 } 176 177 } 178 179 } 180 181 | Popular Tags |