de.grogra.imp3d.io
public abstract class SceneGraphExport extends FilterBase implements SceneTree.Visitor
View3D to another representation (usually, this
is a file representation for which this class provides a set of
useful methods). The export is done via the creation of an
intermediate SceneTree in the method
createSceneTree(View3D).| Modifier and Type | Class and Description |
|---|---|
static interface |
SceneGraphExport.NodeExport
This interface is used to export a leaf of the
SceneTree to the destination. |
static interface |
SceneGraphExport.ObjectExport
This interface is used to export an object (as an attribute of
a node of the scene tree) to the destination.
|
FilterSource.MetaDataKey<V>| Modifier and Type | Field and Description |
|---|---|
protected ObjectList |
files
The list of files which have been created by this export.
|
item, sourceAUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URLDEFAULT_VALUE, EMPTY_MAP| Constructor and Description |
|---|
SceneGraphExport(FilterItem item,
FilterSource source)
Delegates to
FilterBase.FilterBase(FilterItem, FilterSource). |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
beginGroup(SceneTree.InnerNode group)
This method is invoked at the beginning of every inner node
group which has more than one child. |
protected abstract SceneTree |
createSceneTree(View3D scene)
The implementation of this method creates the scene tree which is
to be exported by this export.
|
protected abstract void |
endGroup(SceneTree.InnerNode group)
This method is invoked at the end of every inner node
group which has more than one child. |
boolean |
export(java.lang.Object object)
This method is invoked for some attribute value in
order to export the value.
|
protected void |
export(SceneTree.Leaf node,
SceneTree.InnerNode transform)
This method is invoked for every leaf of the scene tree in
order to export this leaf.
|
java.lang.Object |
getDirectory()
This method returns the base directory within
getFileSystem() to use for the export. |
SceneGraphExport.NodeExport |
getExportFor(java.lang.Object object,
boolean asNode)
This method is used to obtain an instance of
NodeExport
capable of exporting the object of a
SceneTree.Leaf. |
SceneGraphExport.ObjectExport |
getExportForObject(java.lang.Object object)
This method is used to obtain an instance of
ObjectExport
capable of exporting the object (which is some attribute
value). |
java.lang.Object |
getFile(java.lang.String name)
This method creates a file in
getDirectory(). |
java.util.Collection |
getFiles()
Returns the list of files which have been created during export.
|
FileSystem |
getFileSystem()
This method returns the file system to use for the export.
|
GraphState |
getGraphState()
Returns the graph state which is used for export.
|
java.io.OutputStream |
getOutputStream(java.lang.Object file) |
java.lang.String |
getPath(FileObjectItem file) |
java.lang.String |
getPath(java.lang.Object file)
Returns the path of a file of this export's file system
(
getFileSystem()) as a string. |
View3D |
getView()
Returns the view which defines the scene to export.
|
protected java.lang.Object |
initDirectory()
Determines the directory to use.
|
protected FileSystem |
initFileSystem()
Determines the file system to use.
|
void |
visit(SceneTree.Leaf leaf)
Informs the visitor that a leaf is visited.
|
void |
visitEnter(SceneTree.InnerNode node)
Informs the visitor that an inner node has been entered.
|
void |
visitLeave(SceneTree.InnerNode node)
Informs the visitor that an inner node has been left.
|
protected void |
write()
Exports the scene of the view.
|
get, getFilter, getFlavor, getImpl, getMetaData, getRegistry, getSource, getSystemId, initProgressMonitor, setFlavor, setMetaData, setMetaData, setProgress, setSystemId, toString, toURLprotected ObjectList files
public SceneGraphExport(FilterItem item, FilterSource source)
FilterBase.FilterBase(FilterItem, FilterSource).
The source is expected to be an ObjectSource representing
an instance of View3D.item - the defining FilterItemsource - the data sourceprotected abstract void beginGroup(SceneTree.InnerNode group) throws java.io.IOException
group which has more than one child. Its children
will be processed until the corresponding method
endGroup(de.grogra.imp3d.objects.SceneTree.InnerNode) is invoked. The export should write
the hierarchy and transformation information of the group.group - the groupjava.io.IOExceptionprotected abstract SceneTree createSceneTree(View3D scene)
scene - the view which defines the scene to exportprotected abstract void endGroup(SceneTree.InnerNode group) throws java.io.IOException
group which has more than one child. Its children
have been processed completely.group - the groupjava.io.IOExceptionbeginGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)public boolean export(java.lang.Object object)
throws java.io.IOException
This implementation obtains an SceneGraphExport.ObjectExport via
getExportForObject(Object) and, if successful,
uses this to export the value.
object - object to exportjava.io.IOExceptionprotected void export(SceneTree.Leaf node, SceneTree.InnerNode transform) throws java.io.IOException
transform is non-null, this means that
node is the only child of transform
and the transformation of transform has to be
exported together with the node.
This implementation obtains a SceneGraphExport.NodeExport via
getExportFor(Object, boolean) and, if successful,
uses this to export the leaf.
node - a leaf of the scene treetransform - transformation of nodejava.io.IOExceptionbeginGroup(de.grogra.imp3d.objects.SceneTree.InnerNode),
endGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)public java.lang.Object getDirectory()
throws java.io.IOException
getFileSystem() to use for the export.
On first invocation, the directory is obtained from
initDirectory().java.io.IOExceptionpublic SceneGraphExport.NodeExport getExportFor(java.lang.Object object, boolean asNode)
NodeExport
capable of exporting the object of a
SceneTree.Leaf. If no such export
is defined, null is returned.
This implementation looks for an export defined in the registry:
As name, the name of the class of object is chosen,
the export is searched as a child of FilterBase.item.
object - object of the original scene graphasNode - is object a node or an edge?nullpublic SceneGraphExport.ObjectExport getExportForObject(java.lang.Object object)
ObjectExport
capable of exporting the object (which is some attribute
value). If no such export is defined, null is returned.
This implementation looks for an export defined in the registry:
As name, the name of the class of object is chosen,
the export is searched as a child of FilterBase.item.
object - object to exportnullpublic java.lang.Object getFile(java.lang.String name)
throws java.io.IOException
getDirectory(). The file
name is based ob name: E.g., if name
is test.png, the actual name could be something like
test123.png. It is ensured that no file will be returned
twice during a single export.name - name for filejava.io.IOExceptionpublic java.util.Collection getFiles()
public FileSystem getFileSystem() throws java.io.IOException
initFileSystem().java.io.IOExceptionpublic GraphState getGraphState()
public java.io.OutputStream getOutputStream(java.lang.Object file)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getPath(FileObjectItem file) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getPath(java.lang.Object file)
throws java.io.IOException
getFileSystem()) as a string.file - file of this export's file systemfilejava.io.IOExceptionpublic View3D getView() throws java.io.IOException
ObjectSource representing
an instance of View3D.java.io.IOExceptionprotected java.lang.Object initDirectory()
throws java.io.IOException
getDirectory().java.io.IOExceptionprotected FileSystem initFileSystem() throws java.io.IOException
getFileSystem().java.io.IOExceptionpublic void visit(SceneTree.Leaf leaf)
SceneTree.Visitorvisit in interface SceneTree.Visitorleaf - the leaf being visitedpublic void visitEnter(SceneTree.InnerNode node)
SceneTree.VisitorvisitEnter in interface SceneTree.Visitornode - the node being enteredpublic void visitLeave(SceneTree.InnerNode node)
SceneTree.VisitorvisitLeave in interface SceneTree.Visitornode - the node being leftprotected void write()
throws java.io.IOException
createSceneTree(View3D), then it lets this
export instance visit the created scene tree. During visit, the
methods beginGroup(de.grogra.imp3d.objects.SceneTree.InnerNode), endGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)
and export(SceneTree.Leaf, SceneTree.InnerNode) are invoked; these have to be
implemented to perform the actual export to the destination.java.io.IOException