bb.gui
Class BasicStrokeSerializer

java.lang.Object
  extended by bb.gui.BasicStrokeSerializer
All Implemented Interfaces:
Serializable

public class BasicStrokeSerializer
extends Object
implements Serializable

The sole purpose of this class is to aid classes which have a BasicStroke field that needs to get serialized.

This class would be unnecessary of Sun were to merely make BasicStroke implement Serializable. I filed a bug report with Sun about this; it has been assigned an internal review ID of: 383603

This class's instance part multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields). However, the static write and read methods restrict the calling thread to EventQueue's dispatch thread because they deal with a BasicStroke instance.

Author:
Brent Boyer
See Also:
Serialized Form

Nested Class Summary
static class BasicStrokeSerializer.UnitTest
          See the Overview page of the project's javadocs for a general description of this unit test class.
 
Field Summary
private  int cap
           
private  float[] dash
           
private  float dash_phase
           
private  int join
           
private  float miterlimit
           
private static long serialVersionUID
           
private  float width
           
 
Constructor Summary
BasicStrokeSerializer(BasicStroke basicStroke)
          Creates a new BasicStrokeSerializer instance.
 
Method Summary
 BasicStroke convert()
          Converts this instance into a new BasicStroke instance and returns it.
static BasicStroke read(ObjectInputStream objectInputStream)
          Deserializes a BasicStrokeSerializer object from objectInputStream, converts it to a new BasicStroke instance, and returns it.
static void write(BasicStroke basicStroke, ObjectOutputStream objectOutputStream)
          Constructs a new BasicStrokeSerializer(java.awt.BasicStroke) instance from basicStroke and serializes it to objectOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

width

private final float width

cap

private final int cap

join

private final int join

miterlimit

private final float miterlimit

dash

private final float[] dash

dash_phase

private final float dash_phase
Constructor Detail

BasicStrokeSerializer

public BasicStrokeSerializer(BasicStroke basicStroke)
                      throws IllegalArgumentException
Creates a new BasicStrokeSerializer instance.

Throws:
IllegalArgumentException - if basicStroke == null
Method Detail

write

public static void write(BasicStroke basicStroke,
                         ObjectOutputStream objectOutputStream)
                  throws IllegalArgumentException,
                         IllegalStateException,
                         InvalidClassException,
                         NotSerializableException,
                         IOException
Constructs a new BasicStrokeSerializer(java.awt.BasicStroke) instance from basicStroke and serializes it to objectOutputStream.

Throws:
IllegalArgumentException - if basicStroke == null; objectOutputStream == null
IllegalStateException - if calling thread is not EventQueue's dispatch thread
InvalidClassException - if something is wrong with a class used by serialization
NotSerializableException - if some object to be serialized does not implement the java.io.Serializable interface
IOException - if any is thrown by the underlying OutputStream

read

public static BasicStroke read(ObjectInputStream objectInputStream)
                        throws IllegalArgumentException,
                               IllegalStateException,
                               ClassNotFoundException,
                               InvalidClassException,
                               StreamCorruptedException,
                               OptionalDataException,
                               IOException,
                               ClassCastException
Deserializes a BasicStrokeSerializer object from objectInputStream, converts it to a new BasicStroke instance, and returns it.

Throws:
IllegalArgumentException - if objectInputStream == null
IllegalStateException - if calling thread is not EventQueue's dispatch thread
ClassNotFoundException - if a class of a serialized object cannot be found
InvalidClassException - if something is wrong with a class used by serialization
StreamCorruptedException - if control information in the stream is inconsistent
OptionalDataException - if primitive data was found in the stream instead of objects
IOException - if any is thrown by the underlying InputStream
ClassCastException - if the next Object on objectInputStream is not a BasicStrokeSerializer instance

convert

public BasicStroke convert()
Converts this instance into a new BasicStroke instance and returns it.