|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvNamedProperty
ilog.views.graphlayout.labellayout.IlvLabelLayoutLabelProperty
public class IlvLabelLayoutLabelProperty
The class IlvLabelLayoutLabelProperty allows you to store
the settings of an instance of IlvLabelLayout for an
individual label as a named property in the label.
This is used by
IlvDefaultLabelingModel.saveParametersToNamedProperties(IlvLabelLayout, boolean)
which is an auxiliary to be used before
IlvManager.write(IlvOutputStream) if you
want to store layout parameter settings in .ivl files.
If you create your own subclass of IlvLabelLayout and
want to save the layout parameters of your subclass for individual labels
in .ivl files, you need to create a subclass of this class. The subclass must
provide a constructor with your IlvLabelLayout subclass and
the label as input, and transfer the layout parameters of the label from the
input layout to the property. It must also override the
transfer method to transfer the layout parameters from the
property back to the layout instance.
Further information about subclassing can be found in the documentation
of IlvNamedProperty.
As an example, assume that your subclass MyLayout of
IlvLabelLayout has a string parameter for each label that can be
accessed by getMyParameter and set by
setMyParameter.
You can create a named property that can store this parameter in
the following way:
public class MyLayoutLabelProperty extends IlvLabelLayoutLabelProperty
{
String myParameter;
public MyLayoutLabelProperty(
String name, MyLayout layout, IlvGraphic label, boolean withDefaults)
{
super(name, layout, label, withDefaults);
this.myParameter = layout.getMyParameter(label);
}
public MyLayoutLabelProperty(MyLayoutLabelProperty source)
{
super(source);
this.myParameter = source.myParameter;
}
public MyLayoutLabelProperty(IlvInputStream stream)
throws IOException, IlvReadFileException
{
super(stream);
try {
this.myParameter = stream.readString("myParameter");
} catch (IlvFieldNotFoundException e) {
this.myParameter = myParameterDefaultValue;
}
}
public IlvNamedProperty copy()
{
return new MyLayoutLabelProperty(this);
}
public void write(IlvOutputStream stream) throws IOException
{
super.write(stream);
stream.write("myParameter", this.myParameter);
}
public void transfer(IlvLabelLayout layout, IlvGraphic label)
{
super.transfer(layout, label);
((MyLayout)layout).setMyParameter(label, this.myParameter);
}
public boolean isPersistent()
{
// this will catch the case that omitDefaults is false
if (super.isPersistent())
return true;
// in case omitDefaults is true:
if (this.myParameter != myParameterDefaultValue)
return true;
return false;
}
}
Note that MyLayout must override
IlvLabelLayout.createLayoutLabelProperty(String, IlvGraphic, boolean)
to return an instance of your new class MyLayoutLabelProperty.
IlvDefaultLabelingModel.saveParametersToNamedProperties(IlvLabelLayout, boolean),
IlvDefaultLabelingModel.loadParametersFromNamedProperties(IlvLabelLayout),
IlvDefaultLabelingModel.removeParametersFromNamedProperties(),
Serialized Form| Constructor Summary | |
|---|---|
IlvLabelLayoutLabelProperty(IlvInputStream stream)
Creates a new IlvLabelLayoutLabelProperty from
an IlvInputStream. |
|
IlvLabelLayoutLabelProperty(IlvLabelLayoutLabelProperty source)
Creates a new IlvLabelLayoutLabelProperty by copying an
existing one. |
|
IlvLabelLayoutLabelProperty(String name,
IlvLabelLayout layout,
IlvGraphic label,
boolean withDefaults)
Creates a new IlvLabelLayoutLabelProperty that stores
layout parameter settings of the layout for
the label. |
|
| Method Summary | |
|---|---|
IlvNamedProperty |
copy()
Copies the named property. |
void |
dispose(IlvDefaultLabelingModel model)
Disposes of the property and releases any resources that it is using. |
protected IlvLabelLayout |
getLayout()
Returns the layout instance that created this property. |
boolean |
isPersistent()
Returns true if the property must be saved to an .ivl file. |
protected boolean |
isWritten(IlvGraphic label)
Returns true if the writing of the input label was
completed. |
protected boolean |
omitDefaults()
Returns true if the layout property is not persistent when
all stored parameter values are default values. |
void |
transfer(IlvLabelLayout layout,
IlvGraphic label)
Transfers the layout parameter settings stored in this named property back to the input layout for the input label. |
void |
write(IlvOutputStream stream)
Writes the property to the output stream. |
| Methods inherited from class ilog.views.IlvNamedProperty |
|---|
getName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IlvLabelLayoutLabelProperty(String name,
IlvLabelLayout layout,
IlvGraphic label,
boolean withDefaults)
IlvLabelLayoutLabelProperty that stores
layout parameter settings of the layout for
the label.
name - The name of the property.layout - The layout instance to be stored.label - The label whose layout parameters are to be stored.withDefaults - If true, the layout property is always
persistent. If false, it is persistent only if
nondefault parameter settings exist (that is, if the
the property is saved to an .ivl file, the default
parameter settings are not saved).public IlvLabelLayoutLabelProperty(IlvLabelLayoutLabelProperty source)
IlvLabelLayoutLabelProperty by copying an
existing one.
source - The origin of the copy.
public IlvLabelLayoutLabelProperty(IlvInputStream stream)
throws IOException,
IlvReadFileException
IlvLabelLayoutLabelProperty from
an IlvInputStream.
stream - The input stream from which the property must be read.
IlvReadFileException - if an error occurs while reading.
IOException| Method Detail |
|---|
protected IlvLabelLayout getLayout()
IlvInputStream,
it returns null.
protected boolean omitDefaults()
true if the layout property is not persistent when
all stored parameter values are default values.
Returns false if the layout property is persistent independent
of default values.
If the property was created by reading from IlvInputStream,
it returns false.
public IlvNamedProperty copy()
copy in class IlvNamedPropertypublic boolean isPersistent()
true if the property must be saved to an .ivl file.
isPersistent in class IlvNamedPropertyprotected boolean isWritten(IlvGraphic label)
true if the writing of the input label was
completed.
If customers need to subclass this class, this auxiliary can be used
inside the implementation of the write method only.
For instance, it can be used if information must be written depending
on whether another label has already been written.
label - A label of the same manager.
true if the label has been written before
this property.write(IlvOutputStream)
public void write(IlvOutputStream stream)
throws IOException
write in interface IlvPersistentObjectwrite in class IlvNamedPropertystream - The output stream.
IOException - standard IO error.
public void transfer(IlvLabelLayout layout,
IlvGraphic label)
layout - The layout instance whose parameters are to be recovered
from this named property.label - The label whose layout parameters are to be recovered
from this named property.public void dispose(IlvDefaultLabelingModel model)
model - The labeling model.IlvDefaultLabelingModel.loadParametersFromNamedProperties(IlvLabelLayout),
IlvDefaultLabelingModel.removeParametersFromNamedProperties()
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||