When we want to use Rectangle2D.Double with RMI we will need Serializable Rectangle2D.Double.
Rectangle2D is serialized by sun. <------- java.awt.Rectangle
But java.awt.Rectangle is supported just for Integer Version.
So, I made SerializableRectangle2D like as following code.
public class SerializableRectangle2D
extends Rectangle2D.Double
implements Serializable
{
public SerializableRectangle2D()
{
super();
}
public SerializableRectangle2D(double x, double y, double w, double h)
{
super(x, y, w, h);
}
}
However the getting value is just 0 when I use rmi and get message.
But, no documents was google in japanse.... I lose 3 days.......
Some of web site said i cannot do it using easy way....
And some of site said java 1.6 will be able to be suported it.
This meaning.......it will be able to use serialized Rectangle2D.Double.......
Actuary........I have no way how to make solution for this problem......
Rectangle2D is serialized by sun. <------- java.awt.Rectangle
But java.awt.Rectangle is supported just for Integer Version.
So, I made SerializableRectangle2D like as following code.
public class SerializableRectangle2D
extends Rectangle2D.Double
implements Serializable
{
public SerializableRectangle2D()
{
super();
}
public SerializableRectangle2D(double x, double y, double w, double h)
{
super(x, y, w, h);
}
}
However the getting value is just 0 when I use rmi and get message.
But, no documents was google in japanse.... I lose 3 days.......
Some of web site said i cannot do it using easy way....
And some of site said java 1.6 will be able to be suported it.
This meaning.......it will be able to use serialized Rectangle2D.Double.......
Actuary........I have no way how to make solution for this problem......
Comments
**********************************************
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import java.io.ObjectOutputStream ;
import java.io.ObjectInputStream ;
import java.io.IOException ;
public class SerializableRectangle2D
extends Rectangle2D.Double
implements Serializable
{
public SerializableRectangle2D(double x, double y, double w, double h)
{
super(x, y , w, h);
}
public SerializableRectangle2D(Rectangle2D rect)
{
super(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
}
private void writeObject(ObjectOutputStream stream) throws IOException
{
System.err.println("serializing "+this);
stream.writeDouble(x) ;
stream.writeDouble(y) ;
stream.writeDouble(width);
stream.writeDouble(height);
} // writeObject
private void readObject(ObjectInputStream stream) throws IOException
{
x = stream.readDouble();
y = stream.readDouble();
width = stream.readDouble();
height = stream.readDouble();
}//readObject
}