|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.grogra.pf.io.FilterBase de.grogra.imp3d.io.SceneGraphExport
public abstract class SceneGraphExport
This base class is used to export the 3D scene graph of a
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)
.
Nested Class Summary | |
---|---|
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. |
Nested classes/interfaces inherited from interface de.grogra.pf.io.FilterSource |
---|
FilterSource.MetaDataKey<V> |
Nested classes/interfaces inherited from interface de.grogra.util.Map |
---|
Map.Chain |
Field Summary | |
---|---|
protected ObjectList |
files
The list of files which have been created by this export. |
Fields inherited from class de.grogra.pf.io.FilterBase |
---|
item, source |
Fields inherited from interface de.grogra.pf.io.FilterSource |
---|
AUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URL |
Fields inherited from interface de.grogra.util.Map |
---|
DEFAULT_VALUE, EMPTY_MAP |
Constructor Summary | |
---|---|
SceneGraphExport(FilterItem item,
FilterSource source)
Delegates to FilterBase.FilterBase(FilterItem, FilterSource) . |
Method Summary | |
---|---|
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. |
Methods inherited from class de.grogra.pf.io.FilterBase |
---|
get, getFilter, getFlavor, getImpl, getMetaData, getRegistry, getSource, getSystemId, initProgressMonitor, setFlavor, setMetaData, setMetaData, setProgress, setSystemId, toString, toURL |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ObjectList files
Constructor Detail |
---|
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 FilterItem
source
- the data sourceMethod Detail |
---|
protected 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 group
java.io.IOException
protected abstract SceneTree createSceneTree(View3D scene)
scene
- the view which defines the scene to export
protected 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 group
java.io.IOException
beginGroup(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 export
java.io.IOException
protected 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 node
java.io.IOException
beginGroup(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.IOException
public 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?
null
public 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 export
null
public 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 file
java.io.IOException
public java.util.Collection getFiles()
public FileSystem getFileSystem() throws java.io.IOException
initFileSystem()
.
java.io.IOException
public GraphState getGraphState()
public java.io.OutputStream getOutputStream(java.lang.Object file) throws java.io.IOException
java.io.IOException
public java.lang.String getPath(FileObjectItem file) throws java.io.IOException
java.io.IOException
public java.lang.String getPath(java.lang.Object file) throws java.io.IOException
getFileSystem()
) as a string.
file
- file of this export's file system
file
java.io.IOException
public View3D getView() throws java.io.IOException
ObjectSource
representing
an instance of View3D
.
java.io.IOException
protected java.lang.Object initDirectory() throws java.io.IOException
getDirectory()
.
java.io.IOException
protected FileSystem initFileSystem() throws java.io.IOException
getFileSystem()
.
java.io.IOException
public void visit(SceneTree.Leaf leaf)
SceneTree.Visitor
visit
in interface SceneTree.Visitor
leaf
- the leaf being visitedpublic void visitEnter(SceneTree.InnerNode node)
SceneTree.Visitor
visitEnter
in interface SceneTree.Visitor
node
- the node being enteredpublic void visitLeave(SceneTree.InnerNode node)
SceneTree.Visitor
visitLeave
in interface SceneTree.Visitor
node
- 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
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |