001: /*
002: * $RCSfile: SceneGraphIO.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.4 $
041: * $Date: 2007/02/09 17:20:27 $
042: * $State: Exp $
043: */
044:
045: package com.sun.j3d.utils.scenegraph.io;
046:
047: /**
048: * Implement this interface in any classes that subclass a Java3D SceneGraphObject
049: * in order to have your class handled correctly by scenegraph.io.
050: *
051: * More information and example code is provided <A href="doc-files/extensibility.html">here.</a>
052: *
053: * Classes that implement this interface MUST have a no-arg constructor
054: */
055: public interface SceneGraphIO {
056:
057: /**
058: * The method is called before writeSGObject and gives the user the chance
059: * to create references to other Nodes and NodeComponents.
060: *
061: * References take the form of a nodeID, of type integer. Every SceneGraphObject
062: * is assigned a unique ID.
063: *
064: * The user must save the reference information in writeSGObject
065: *
066: * @param ref provides methods to create references to a SceneGraphObject
067: */
068: public void createSceneGraphObjectReferences(
069: SceneGraphObjectReferenceControl ref);
070:
071: /**
072: * Within this method the user should restore references to the SceneGraphObjects
073: * whose nodeID's were created with createSceneGraphObjectReferences
074: * This method is called once the all objects in the scenegraph have been loaded.
075: *
076: *
077: * @param ref provides methods to resolve references to a SceneGraphObject
078: */
079: public void restoreSceneGraphObjectReferences(
080: SceneGraphObjectReferenceControl ref);
081:
082: /**
083: * This method should store all the local state of the object and any references
084: * to other SceneGraphObjects into <code>out</code>.
085: *
086: * This is called after data for the parent SceneGraphObject has been written to
087: * the <code>out</code>.
088: *
089: * @param out the output stream
090: */
091: public void writeSceneGraphObject(java.io.DataOutput out)
092: throws java.io.IOException;
093:
094: /**
095: * This is called after the object has been constructed and the superclass SceneGraphObject
096: * data has been read from <code>in</code>.
097: *
098: * The user should restore all state infomation written in writeSGObject
099: *
100: * @param in the input stream
101: */
102: public void readSceneGraphObject(java.io.DataInput in)
103: throws java.io.IOException;
104:
105: /**
106: * Flag indicating for children of this object should be saved
107: *
108: * This method only has an effect if this is a subclass of Group.
109: *
110: * If this returns true then all children of this Group will be saved.
111: *
112: * If it returns false then the children are not saved.
113: */
114: public boolean saveChildren();
115: }
|