public class IlvGraphLayoutLinkProperty extends IlvNamedProperty
IlvGraphLayoutLinkProperty allows you to store
the settings of an instance of IlvGraphLayout for an
individual link as a named property in the link. This is used by
IlvGrapherPropertyAdapter.saveParametersToNamedProperties(IlvGraphLayout,
boolean) which is an auxiliary to be used before IlvGrapher.write(IlvOutputStream) if you want to store layout
parameter settings in .ivl files.
If you create your own subclass of IlvGraphLayout and
want to save the layout parameters of your subclass for individual
links in .ivl files, you need to create a subclass of
this class. The subclass must provide a constructor with your
IlvGraphLayout subclass and the link as input, and
transfer the layout parameters of the link 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
IlvGraphLayout has a string parameter for each link 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 MyLayoutLinkProperty extends IlvGraphLayoutLinkProperty
{
String myParameter;
public MyLayoutLinkProperty(
String name, MyLayout layout, IlvGraphic link, boolean withDefaults)
{
super(name, layout, link, withDefaults);
this.myParameter = layout.getMyParameter(link);
}
public MyLayoutLinkProperty(MyLayoutLinkProperty source)
{
super(source);
this.myParameter = source.myParameter;
}
public MyLayoutLinkProperty(IlvInputStream stream)
throws IOException, IlvReadFileException
{
super(stream);
try {
this.myParameter = stream.readString("myParameter");
} catch (IlvFieldNotFoundException e) {
this.myParameter = myParameterDefaultValue;
}
}
public IlvNamedProperty copy()
{
return new MyLayoutLinkProperty(this);
}
public void write(IlvOutputStream stream) throws IOException
{
super.write(stream);
stream.write("myParameter", this.myParameter);
}
public void transfer(IlvGraphLayout layout, IlvGraphic link)
{
super.transfer(layout, link);
((MyLayout)layout).setMyParameter(link, 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 IlvGraphLayout.createLayoutLinkProperty(String, IlvGraphic, boolean)
to return an instance of your new class
MyLayoutLinkProperty.| Modifier | Constructor and Description |
|---|---|
|
IlvGraphLayoutLinkProperty(IlvGraphLayoutLinkProperty source)
Creates a new
IlvGraphLayoutLinkProperty by copying an
existing one. |
|
IlvGraphLayoutLinkProperty(IlvInputStream stream)
Creates a new
IlvGraphLayoutLinkProperty from an
IlvInputStream. |
protected |
IlvGraphLayoutLinkProperty(IlvInputStream stream,
boolean fromSubclass)
Creates a new
IlvGraphLayoutLinkProperty from an
IlvInputStream. |
|
IlvGraphLayoutLinkProperty(String name,
IlvGraphLayout layout,
IlvGraphic link,
boolean withDefaults)
Creates a new
IlvGraphLayoutLinkProperty that stores
layout parameter settings of the layout for the
link. |
| Modifier and Type | Method and Description |
|---|---|
IlvNamedProperty |
copy()
Copies the named property.
|
void |
dispose(IlvGrapherAdapter adapter)
Deprecated.
Since JViews 8.8, use
dispose(IlvGrapherPropertyAdapter). |
void |
dispose(IlvGrapherPropertyAdapter adapter)
Disposes of the property and releases any resources that it is using.
|
protected IlvGraphLayout |
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 nodeOrLink)
Returns
true if the writing of the input node or link was
completed. |
protected boolean |
omitDefaults()
Returns
true if the layout property is not persistent
when all stored parameter values are default values. |
protected boolean |
readProperties(IlvInputStream stream)
Reads the properties from an
IlvInputStream. |
void |
transfer(IlvGraphLayout layout,
IlvGraphic link)
Transfers the layout parameter settings stored in this named property
back to the input layout for the input link.
|
void |
write(IlvOutputStream stream)
Writes the property to the output stream.
|
getNamepublic IlvGraphLayoutLinkProperty(String name, IlvGraphLayout layout, IlvGraphic link, boolean withDefaults)
IlvGraphLayoutLinkProperty that stores
layout parameter settings of the layout for the
link.name - The name of the property.layout - The layout instance to be stored.link - The link 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 IlvGraphLayoutLinkProperty(IlvGraphLayoutLinkProperty source)
IlvGraphLayoutLinkProperty by copying an
existing one.source - The origin of the copy.public IlvGraphLayoutLinkProperty(IlvInputStream stream) throws IOException, IlvReadFileException
IlvGraphLayoutLinkProperty from an
IlvInputStream.stream - The input stream from which the property must be read.IlvReadFileException - if an error occurs while reading.IOExceptionprotected IlvGraphLayoutLinkProperty(IlvInputStream stream, boolean fromSubclass) throws IOException, IlvReadFileException
IlvGraphLayoutLinkProperty from an
IlvInputStream. This method is for internal purpose.stream - The input stream from which the property must be read.fromSubclass - Whether this constructor is called from a subclass.IlvReadFileException - if an error occurs while reading.IOExceptionprotected boolean readProperties(IlvInputStream stream) throws IOException, IlvReadFileException
IlvInputStream. This method
is for internal purpose.stream - The input stream from which the property must be read.IlvReadFileException - if an error occurs while reading.IOExceptionprotected IlvGraphLayout 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 nodeOrLink)
true if the writing of the input node or link 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 node or another link has already been written.
nodeOrLink - A node or link of the same grapher.true if the node or link 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(IlvGraphLayout layout, IlvGraphic link)
layout - The layout instance whose parameters are to be recovered
from this named property.link - The link whose layout parameters are to be recovered from
this named property.public void dispose(IlvGrapherPropertyAdapter adapter)
adapter - The grapher property adapter.IlvGrapherPropertyAdapter.loadParametersFromNamedProperties(IlvGraphLayout),
IlvGrapherPropertyAdapter.removeParametersFromNamedProperties()public void dispose(IlvGrapherAdapter adapter)
dispose(IlvGrapherPropertyAdapter).adapter - The grapher adapter.© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.