From a4681c797ef3f606e2c050e63439bc1467601e19 Mon Sep 17 00:00:00 2001 From: paulby Date: Thu, 1 Mar 2007 23:25:28 +0000 Subject: Fix issue 453, add support of SceneGraphObject name field Issue number: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@154 9497e636-51bd-65ba-982d-a4982e1767a5 --- .../utils/scenegraph/io/retained/Controller.java | 3 ++- .../javax/media/j3d/SceneGraphObjectState.java | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java index 38b6204..60b03be 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java @@ -113,8 +113,9 @@ public abstract class Controller extends java.lang.Object { SceneGraphIO interface 2) Add missing duplicateOnCloneTree flag (bug 4690159) + * 3 = Java3D 1.5.1 1) Add support for SceneGraphObject Name field */ - protected int outputFileVersion = 2; + protected int outputFileVersion = 3; /** * When running the application within webstart this may not be the diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SceneGraphObjectState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SceneGraphObjectState.java index 8a49aa9..dba35e7 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SceneGraphObjectState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SceneGraphObjectState.java @@ -134,6 +134,7 @@ public abstract class SceneGraphObjectState { } writeUserData( out ); + writeString(node.getName(), out); writeCapabilities( out ); } @@ -179,6 +180,9 @@ public abstract class SceneGraphObjectState { symbol = control.getSymbolTable().createSymbol( this, node, nodeID ); readUserData( in ); + if (control.getCurrentFileVersion()>2) { + node.setName(readString(in)); + } readCapabilities( in ); } @@ -503,4 +507,22 @@ public abstract class SceneGraphObjectState { node = null; } + /** + * Read and return a possibly null string + */ + protected String readString(DataInput in) throws IOException { + if (in.readBoolean()) + return (in.readUTF()); + return null; + } + + /** + * Write a possibly null string to the stream + */ + protected void writeString(String str, DataOutput out) throws IOException { + out.writeBoolean(str!=null); + if (str!=null) + out.writeUTF(str); + } + } -- cgit v1.2.3