| The Essential JViews Framework > Graphic Objects > Creating a New Graphic Object Class > Saving and Loading the Object Description |
Saving and Loading the Object Description |
INDEX
PREVIOUS
NEXT
|
This section explains the input/output methods. To save and read an object in an ILOG JViews formatted file, you need to implement the write method and a constructor that takes an IlvInputStream parameter.
The method write writes the colors of the object, the dimensions of the rectangle, and the thickness of the shadow to the provided output stream:
In the write method, the write method of the superclass is called to save the information specific to the superclass. Then the write methods of the class IlvOutputStream are used to save the information specific to the class.
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.
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.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |