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