To read a graphic object from a file, you must provide
a specific constructor with an IlvInputStream
parameter. This constructor must be public to allow the file reader
to call it. Also, the constructor must read the same information,
and in the same order, as that written by the write
method.
/**
* Reads the object from an IlvInputStream
* @param stream the input stream.
* @exception IlvReadFileException an error occurs when reading.
*/
public ShadowEllipse(IlvInputStream stream) throws
IlvReadFileException
{
// Calls the super class constructor that reads
// the information for the super class in the file.
super(stream);
// Reads the color.
setColor(stream.readColor("color"));
// Reads the shadow color.
setShadowColor(stream.readColor("shadowColor"));
// Reads the thickness
setThickness(stream.readInt("thickness"));
// reads the definition rectangle.
IlvRect rect = stream.readRect("rectangle");
drawrect.reshape(rect.x, rect.y, rect.width, rect.height);
}
The above constructor calls the read constructor of the
superclass which reads the information specific to the superclass
from the stream object. The subclass can then read its own information.
The constructor uses the
read
methods defined
in the class
IlvInputStream