public class IlvGraphLayoutGrapherProperty extends IlvNamedProperty
IlvGraphLayoutGrapherProperty
allows you to
store the global settings of an instance of
IlvGraphLayout
as a named property in the grapher. This
is used by IlvGrapherPropertyAdapter.saveParametersToNamedProperties(IlvGraphLayout,
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 IlvGraphLayout
and
want to save the parameters of your subclass in .ivl
files, you need to create a subclass of this class. The subclass must
provide a constructor with your IlvGraphLayout
subclass
as input and transfer the layout parameters 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 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 MyLayoutGrapherProperty extends IlvGraphLayoutGrapherProperty { String myParameter; public MyLayoutGrapherProperty(String name, MyLayout layout, boolean withDefaults) { super(name, layout, withDefaults); this.myParameter = layout.getMyParameter(); } public MyLayoutGrapherProperty(MyLayoutGrapherProperty source) { super(source); this.myParameter = source.myParameter; } public MyLayoutGrapherProperty(IlvInputStream stream) throws IOException, IlvReadFileException { super(stream); try { this.myParameter = stream.readString("myParameter"); } catch (IlvFieldNotFoundException e) { this.myParameter = myParameterDefaultValue; } } public IlvNamedProperty copy() { return new MyLayoutGrapherProperty(this); } public void write(IlvOutputStream stream) throws IOException { super.write(stream); stream.write("myParameter", this.myParameter); } public void transfer(IlvGraphLayout layout) { super.transfer(layout); ((MyLayout)layout).setMyParameter(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.createLayoutGrapherProperty(String, boolean)
to return
an instance of your new class MyLayoutGrapherProperty
.Modifier | Constructor and Description |
---|---|
|
IlvGraphLayoutGrapherProperty(IlvGraphLayoutGrapherProperty source)
Creates a new
IlvGraphLayoutGrapherProperty by copying an
existing one. |
|
IlvGraphLayoutGrapherProperty(IlvInputStream stream)
Creates a new
IlvGraphLayoutGrapherProperty from an
IlvInputStream . |
protected |
IlvGraphLayoutGrapherProperty(IlvInputStream stream,
boolean fromSubclass)
Creates a new
IlvGraphLayoutGrapherProperty from an
IlvInputStream . |
|
IlvGraphLayoutGrapherProperty(String name,
IlvGraphLayout layout,
boolean withDefaults)
Creates a new
IlvGraphLayoutGrapherProperty that stores
layout parameter settings of the layout . |
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 |
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)
Transfers the layout parameter settings stored in this named property
back to the input layout.
|
void |
write(IlvOutputStream stream)
Writes the property to the output stream.
|
getName
public IlvGraphLayoutGrapherProperty(String name, IlvGraphLayout layout, boolean withDefaults)
IlvGraphLayoutGrapherProperty
that stores
layout parameter settings of the layout
.name
- The name of the property.layout
- The layout instance 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 IlvGraphLayoutGrapherProperty(IlvGraphLayoutGrapherProperty source)
IlvGraphLayoutGrapherProperty
by copying an
existing one.source
- The origin of the copy.public IlvGraphLayoutGrapherProperty(IlvInputStream stream) throws IOException, IlvReadFileException
IlvGraphLayoutGrapherProperty
from an
IlvInputStream
.stream
- The input stream from which the property must be read.IlvReadFileException
- if an error occurs while reading.IOException
protected IlvGraphLayoutGrapherProperty(IlvInputStream stream, boolean fromSubclass) throws IOException, IlvReadFileException
IlvGraphLayoutGrapherProperty
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.IOException
protected 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.IOException
protected 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 IlvNamedProperty
public boolean isPersistent()
true
if the property must be saved to an
.ivl
file.isPersistent
in class IlvNamedProperty
public void write(IlvOutputStream stream) throws IOException
write
in interface IlvPersistentObject
write
in class IlvNamedProperty
stream
- The output stream.IOException
- standard IO error.public void transfer(IlvGraphLayout layout)
layout
- The layout instance whose parameters are to be recovered
from this instance.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, 2018. All Rights Reserved.