summaryrefslogtreecommitdiffstats
path: root/src/classes/share/com/sun/j3d
diff options
context:
space:
mode:
authorKen Mc Neill <[email protected]>2007-11-14 16:40:03 +0000
committerKen Mc Neill <[email protected]>2007-11-14 16:40:03 +0000
commitf33bb86c78d0732c84c45f279fab666a0424fcbb (patch)
tree01002ac022cb10b43ce7dbd744e5e5e37721ec34 /src/classes/share/com/sun/j3d
parent6e5c0fe3186e48df85c7ab132158b32c980d0b2c (diff)
Issue number: 483
Submitted by: lamer47 Reviewed by: kcr git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@175 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src/classes/share/com/sun/j3d')
-rw-r--r--src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Font3DState.java195
-rw-r--r--src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Text3DState.java92
2 files changed, 156 insertions, 131 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Font3DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Font3DState.java
index 47cf22e..e144fe0 100644
--- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Font3DState.java
+++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Font3DState.java
@@ -41,7 +41,6 @@
* $Date$
* $State$
*/
-
package com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d;
import javax.media.j3d.Font3D;
@@ -61,103 +60,121 @@ import java.awt.geom.GeneralPath;
public class Font3DState extends NodeComponentState {
- private Font font=null;
- private double tesselationTolerance=0.0D;
- private FontExtrusion extrudePath=null;
+ private Font font = null;
+ private double tesselationTolerance = 0.0D;
+ private FontExtrusion extrudePath = null;
- public Font3DState( SymbolTableData symbol, Controller control ) {
- super( symbol, control );
+ public Font3DState(SymbolTableData symbol, Controller control) {
+ super(symbol, control);
}
- public void writeConstructorParams( DataOutput out ) throws IOException {
- super.writeConstructorParams( out );
-
- out.writeUTF( font.getFontName() );
- out.writeInt( font.getStyle() );
- out.writeInt( font.getSize() );
-
- out.writeDouble( tesselationTolerance );
-
- if ( extrudePath!=null ) {
- Shape shape = extrudePath.getExtrusionShape();
- if ( shape != null ) {
- PathIterator shapePath = shape.getPathIterator( null );
- float[] coords = new float[ 6 ];
- int segType;
- int points;
- while ( !(shapePath.isDone()) ) {
- // Get type of current path segment and associated coordinates
- segType = shapePath.currentSegment( coords );
- out.writeInt( segType );
-
- // Write out relevant coordinates
- points = 0;
- if ( segType==PathIterator.SEG_MOVETO) points = 1;
- else if ( segType==PathIterator.SEG_LINETO ) points = 1;
- else if (segType==PathIterator.SEG_QUADTO ) points = 2;
- else if (segType==PathIterator.SEG_CUBICTO ) points = 3;
-
- for (int i=0;i<points;i++ ) {
- out.writeFloat( coords[ i*2+0 ] );
- out.writeFloat( coords[ i*2+1 ] );
- }
-
- // Next segment
- if ( !(shapePath.isDone()) ) shapePath.next();
- }
- }
- // Flag for end of path definition
- out.writeInt( Integer.MIN_VALUE );
- out.writeDouble( extrudePath.getTessellationTolerance() );
- } else out.writeInt( Integer.MIN_VALUE );
+ public void writeConstructorParams(DataOutput out) throws IOException {
+ super.writeConstructorParams(out);
+
+ // issue 483: init the node
+ Font3D font3D = (Font3D) node;
+ font = font3D.getFont();
+
+ out.writeUTF(font.getFontName());
+ out.writeInt(font.getStyle());
+ out.writeInt(font.getSize());
+ out.writeDouble(font3D.getTessellationTolerance());
+
+ // issue 483
+ extrudePath = new FontExtrusion();
+ font3D.getFontExtrusion(extrudePath);
+ if (extrudePath.getExtrusionShape() == null) {
+ extrudePath = null;
+ }
+
+ if (extrudePath != null) {
+ Shape shape = extrudePath.getExtrusionShape();
+ if (shape != null) {
+ PathIterator shapePath = shape.getPathIterator(null);
+ float[] coords = new float[6];
+ int segType;
+ int points;
+ while (!(shapePath.isDone())) {
+ // Get type of current path segment and associated
+ // coordinates
+ segType = shapePath.currentSegment(coords);
+ out.writeInt(segType);
+
+ // Write out relevant coordinates
+ points = 0;
+ if (segType == PathIterator.SEG_MOVETO)
+ points = 1;
+ else if (segType == PathIterator.SEG_LINETO)
+ points = 1;
+ else if (segType == PathIterator.SEG_QUADTO)
+ points = 2;
+ else if (segType == PathIterator.SEG_CUBICTO)
+ points = 3;
+
+ for (int i = 0; i < points; i++) {
+ out.writeFloat(coords[i * 2 + 0]);
+ out.writeFloat(coords[i * 2 + 1]);
+ }
+
+ // Next segment
+ if (!(shapePath.isDone()))
+ shapePath.next();
+ }
+ }
+ // Flag for end of path definition
+ out.writeInt(Integer.MIN_VALUE);
+ out.writeDouble(extrudePath.getTessellationTolerance());
+
+ } else {
+ out.writeInt(Integer.MIN_VALUE);
+ }
}
- public void readConstructorParams( DataInput in ) throws IOException {
- super.readConstructorParams( in );
-
- String fontName = in.readUTF();
- int style = in.readInt();
- int size = in.readInt();
- font = new Font( fontName, style, size );
-
- tesselationTolerance = in.readDouble();
-
- GeneralPath shape = null;
- int segType = in.readInt();
- while ( segType!=Integer.MIN_VALUE ) {
- if ( shape==null ) shape = new GeneralPath();
-
- if ( segType==PathIterator.SEG_MOVETO) {
- shape.moveTo( in.readFloat(), in.readFloat() );
- } else if ( segType==PathIterator.SEG_LINETO ) {
- shape.lineTo( in.readFloat(), in.readFloat() );
- } else if ( segType==PathIterator.SEG_QUADTO ) {
- shape.quadTo( in.readFloat(), in.readFloat(),
- in.readFloat(), in.readFloat() );
- } else if ( segType==PathIterator.SEG_CUBICTO ) {
- shape.curveTo( in.readFloat(), in.readFloat(),
- in.readFloat(), in.readFloat(),
- in.readFloat(), in.readFloat() );
- } else if ( segType==PathIterator.SEG_CLOSE ) {
- shape.closePath();
- }
-
- segType = in.readInt();
- }
- if ( shape!=null ) extrudePath = new FontExtrusion( shape, in.readDouble() );
- else extrudePath = null;
+ public void readConstructorParams(DataInput in) throws IOException {
+ super.readConstructorParams(in);
+
+ String fontName = in.readUTF();
+ int style = in.readInt();
+ int size = in.readInt();
+ font = new Font(fontName, style, size);
+
+ tesselationTolerance = in.readDouble();
+
+ GeneralPath shape = null;
+ int segType = in.readInt();
+ while (segType != Integer.MIN_VALUE) {
+ if (shape == null)
+ shape = new GeneralPath();
+
+ if (segType == PathIterator.SEG_MOVETO) {
+ shape.moveTo(in.readFloat(), in.readFloat());
+ } else if (segType == PathIterator.SEG_LINETO) {
+ shape.lineTo(in.readFloat(), in.readFloat());
+ } else if (segType == PathIterator.SEG_QUADTO) {
+ shape.quadTo(in.readFloat(), in.readFloat(), in.readFloat(), in
+ .readFloat());
+ } else if (segType == PathIterator.SEG_CUBICTO) {
+ shape.curveTo(in.readFloat(), in.readFloat(), in.readFloat(),
+ in.readFloat(), in.readFloat(), in.readFloat());
+ } else if (segType == PathIterator.SEG_CLOSE) {
+ shape.closePath();
+ }
+
+ segType = in.readInt();
+ }
+ if (shape != null)
+ extrudePath = new FontExtrusion(shape, in.readDouble());
+ else
+ extrudePath = null;
}
- public SceneGraphObject createNode( Class j3dClass ) {
- return createNode( j3dClass, new Class[] { Font.class,
- Double.TYPE,
- FontExtrusion.class },
- new Object[] { font,
- new Double( tesselationTolerance ),
- extrudePath } );
+ public SceneGraphObject createNode(Class j3dClass) {
+ return createNode(j3dClass, new Class[] { Font.class, Double.TYPE,
+ FontExtrusion.class }, new Object[] { font,
+ new Double(tesselationTolerance), extrudePath });
}
protected SceneGraphObject createNode() {
- return new Font3D( font, tesselationTolerance, extrudePath );
+ return new Font3D(font, tesselationTolerance, extrudePath);
}
}
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Text3DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Text3DState.java
index a009301..2457ec8 100644
--- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Text3DState.java
+++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Text3DState.java
@@ -44,70 +44,78 @@
package com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d;
-import java.io.IOException;
import java.io.DataInput;
import java.io.DataOutput;
-import javax.media.j3d.Text3D;
-import javax.media.j3d.SceneGraphObject;
+import java.io.IOException;
+
import javax.media.j3d.Font3D;
-import javax.media.j3d.BoundingBox;
+import javax.media.j3d.Text3D;
import javax.vecmath.Point3f;
+
import com.sun.j3d.utils.scenegraph.io.retained.Controller;
import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData;
public class Text3DState extends GeometryState {
-
+
private int font3d;
-
- public Text3DState(SymbolTableData symbol,Controller control) {
- super( symbol, control );
-
- if (node!=null) {
- font3d = control.getSymbolTable().addReference( ((Text3D)node).getFont3D() );
+ private String string;
+
+ public Text3DState(SymbolTableData symbol, Controller control) {
+ super(symbol, control);
+
+ if (node != null) {
+ font3d = control.getSymbolTable().addReference(
+ ((Text3D) node).getFont3D());
}
}
-
- public void writeObject( DataOutput out ) throws IOException {
- super.writeObject( out );
-
- out.writeInt( ((Text3D)node).getAlignment() );
- out.writeFloat( ((Text3D)node).getCharacterSpacing() );
- out.writeInt( font3d );
-
- out.writeInt( ((Text3D)node).getPath() );
-
+
+ public void writeObject(DataOutput out) throws IOException {
+ super.writeObject(out);
+
+ out.writeInt(((Text3D) node).getAlignment());
+ out.writeFloat(((Text3D) node).getCharacterSpacing());
+ out.writeInt(font3d);
+
+ out.writeInt(((Text3D) node).getPath());
+
Point3f pos = new Point3f();
- ((Text3D)node).getPosition( pos );
- control.writePoint3f( out, pos );
-
- out.writeUTF( ((Text3D)node).getString() );
+ ((Text3D) node).getPosition(pos);
+ control.writePoint3f(out, pos);
+
+ out.writeUTF(((Text3D) node).getString());
}
-
- public void readObject( DataInput in ) throws IOException {
- super.readObject( in );
-
- ((Text3D)node).setAlignment( in.readInt() );
- ((Text3D)node).setCharacterSpacing( in.readFloat() );
+
+ public void readObject(DataInput in) throws IOException {
+ super.readObject(in);
+
+ ((Text3D) node).setAlignment(in.readInt());
+ ((Text3D) node).setCharacterSpacing(in.readFloat());
font3d = in.readInt();
- ((Text3D)node).setPath( in.readInt() );
- ((Text3D)node).setPosition( control.readPoint3f(in ));
- ((Text3D)node).setString( in.readUTF() );
+ ((Text3D) node).setPath(in.readInt());
+ ((Text3D) node).setPosition(control.readPoint3f(in));
+ // issue 483: must wait until the Font3D is set in buildGraph()
+ string = in.readUTF();
+ // old: ((Text3D)node).setString( in.readUTF() );
}
/**
- * Called when this component reference count is incremented.
- * Allows this component to update the reference count of any components
- * that it references.
+ * Called when this component reference count is incremented. Allows this
+ * component to update the reference count of any components that it
+ * references.
*/
public void addSubReference() {
- control.getSymbolTable().incNodeComponentRefCount( font3d );
+ control.getSymbolTable().incNodeComponentRefCount(font3d);
}
-
+
public void buildGraph() {
- ((Text3D)node).setFont3D( ((Font3D)control.getSymbolTable().getJ3dNode( font3d )) );
- super.buildGraph(); // Must be last call in method
+ ((Text3D) node).setFont3D(((Font3D) control.getSymbolTable()
+ .getJ3dNode(font3d)));
+ // issue 483
+ ((Text3D) node).setString(string);
+
+ super.buildGraph(); // Must be last call in method
}
-
+
protected javax.media.j3d.SceneGraphObject createNode() {
return new Text3D();
}