The Essential JViews Framework > Graphic Objects > Named Properties

Another kind of user property, called named property, can also be set on a graphic object. A named property is an instance of the class IlvNamedProperty. This class is an abstract class; it must be subclassed for your own needs. The difference between a named property and a user property is mainly that this type of property is named and can be saved with the graphic object in an .ivl file when the graphic object is saved. Note that a named property can also be stored in the manager or in a layer object, which is described in the section Layers.

To store a named property in a graphic object, use:

void setNamedProperty(IlvNamedProperty) 

To get a named property, use:

void getNamedProperty(String name) 

Here is an example of a named property:

import ilog.views.*;
import ilog.views.io.*;

public class MyNamedProperty extends IlvNamedProperty 
{
  String value;
                  
  public MyNamedProperty(IlvInputStream stream) throws IlvReadFileException
  {
    super(stream);
    this.value = stream.readString("value");
  }
                   
  public MyNamedProperty(String name, String value)
  {
    super(name);
    this.value = value;
  }
          
  public MyNamedProperty(MyNamedProperty source)
  {
    super(source);
    this.value = source.value;
  }
               
  public IlvNamedProperty copy()
  {
    return new MyNamedProperty(this);
  }
                 
  public boolean isPersistent()
  {
    return true;
  }
               
  public void write(IlvOutputStream stream) throws IOException
  {
    super.write(stream);
    stream.write("value", value);
  }
             
 }

This named property defines a member variable value of type String to store the value of the property.

Several methods have been created to allow the storage of the property in an .ivl file: