public void serializeObject(Object o, DataOutputStream stream) throws IOException {
   if (o instanceof BrushSettings) {
     BrushSettings v = (BrushSettings) o;
     SerializationManager.writeObject(v.getBrushShape(), stream);
     stream.writeFloat(v.getOuterWidth());
     stream.writeFloat(v.getOuterHeight());
     stream.writeFloat(v.getInnerWidth());
     stream.writeFloat(v.getInnerHeight());
     stream.writeInt(v.getFlowRate());
   }
 }
 public Object deserializeObject(int type, int version, DataInputStream stream)
     throws IOException {
   if (!(version == 1 || (type == TYPE_BRUSH_SETTINGS && version == 2)))
     throw new IOException("Invalid version number.");
   else if (type == TYPE_BRUSH_SETTINGS) {
     BrushShape bs = (BrushShape) SerializationManager.readObject(stream);
     float ow = stream.readFloat();
     float oh = stream.readFloat();
     float iw = stream.readFloat();
     float ih = stream.readFloat();
     int fr = (version > 1) ? stream.readInt() : 20;
     return new BrushSettings(bs, ow, oh, iw, ih, fr);
   } else if (type == TYPE_DIAMOND_BS) return DiamondBrushShape.instance;
   else if (type == TYPE_HORIZONTAL_BS) return HorizontalBrushShape.instance;
   else if (type == TYPE_ROUND_BS) return RoundBrushShape.instance;
   else if (type == TYPE_ROUNDRECT_BS) return RoundRectBrushShape.instance;
   else if (type == TYPE_SQUARE_BS) return SquareBrushShape.instance;
   else if (type == TYPE_VERTICAL_BS) return VerticalBrushShape.instance;
   else if (type == TYPE_X_BS) return XBrushShape.instance;
   else if (type == TYPE_YNXDIAG_BS) return YNXDiagonalBrushShape.instance;
   else if (type == TYPE_YXDIAG_BS) return YXDiagonalBrushShape.instance;
   else return null;
 }