/** * Sets the geometric bounds of a node. * @param bounds the bounding object for a node * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setBounds(Bounds bounds) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_BOUNDS_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Node1")); ((NodeRetained)this.retained).setBounds(bounds); }
if (item.isLive()) { if (locale != root) { return false;
@Override public void readObject( DataInput in ) throws IOException { super.readObject(in); ((Node)node).setBounds( control.readBounds(in) ); ((Node)node).setPickable( in.readBoolean() ); ((Node)node).setCollidable( in.readBoolean() ); ((Node)node).setBoundsAutoCompute( in.readBoolean() ); }
Node node1 = new Node(this, SWT.NONE, "node 1"); node1.setBounds(25, 25, 50, 50); Node node2 = new Node(this, SWT.NONE, "node 2"); node2.setBounds(35, 35, 60, 60); node2.setBackground(new Color(Display.getCurrent(), 75, 75, 75)); // Use moveAbove(null) to move node2 above all its siblings node2.moveAbove(node1);
@Override public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); control.writeBounds( out, ((Node)node).getBounds() ); out.writeBoolean( ((Node)node).getPickable() ); out.writeBoolean( ((Node)node).getCollidable() ); out.writeBoolean( ((Node)node).getBoundsAutoCompute() ); }
if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Node8")); if (!isLive()) { if (isCompiled()) throw new RestrictedAccessException(J3dI18N.getString("Node7"));
/** * Retrieves the locale to which this node is attached. If the * node is not part of a live scene graph, null is returned. * * @return the locale to which this node is attached. * * @exception CapabilityNotSetException if appropriate capability is * not set and this node is part of live scene graph * @exception IllegalSharingException if the node is a descendant * of a SharedGroup node. * * @since Java 3D 1.4 */ public Locale getLocale() { if (!isLive()) { return null; } if(!this.getCapability(ALLOW_LOCALE_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("Node17")); } return ((NodeRetained)this.retained).getLocale(); }
/** * Returns the bounding object of a node. * @return the node's bounding object * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception SceneGraphCycleException if there is a cycle in the * scene graph */ public Bounds getBounds() { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_BOUNDS_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("Node2")); } } else { // this will throw a SceneGraphCycleException if there is // a cycle checkForCycle(); } return ((NodeRetained)this.retained).getBounds(); }
private static Point3d getViewPosInLocal(final View view, final Node node) { if (node == null) return null; if (!node.isLive()) return null; // get viewplatforms's location in virutal world final Canvas3D canvas = view.getCanvas3D(0); canvas.getCenterEyeInImagePlate(viewPosition); canvas.getImagePlateToVworld(t); t.transform(viewPosition); // get parent transform node.getLocalToVworld(parentInv); parentInv.invert(); // transform the eye position into the parent's coordinate system parentInv.transform(viewPosition); return viewPosition; }
boolean allowDanglingReferences) { if (!isLiveOrCompiled()) { checkForCycle(); Node n = cloneTree(forceDuplicate, referenceTable.objectHashtable);
@Override public String toString() { return node.toString(); } }
public void displayCase(Image3DUniverse univ, int caseNo) { System.out.println("Case no " + caseNo); int threshold = 120; BranchGroup scene = univ.getScene(); for(int i = scene.numChildren()-1; i >= 1 ; i--) { if (scene.getChild(i) instanceof BranchGroup) if (scene.getChild(i).getCapability(BranchGroup.ALLOW_DETACH)) scene.removeChild(i); } System.out.println("Nr. of contents:" + univ.getContents().size()); univ.removeAllContents(); createCase(caseNo); Volume volume = new Volume(image); List l = MCCube.getTriangles(volume, threshold); univ.addTriangleMesh(l, RED, "case" + caseNo); for(int z = 0; z < data.length; z++) { for(int y = 0; y < 2; y++) { for(int x = 0; x < 2; x++) { if(((int)data[z][y*2+x]&0xff)>=threshold) { addVertex(univ, RED, x, y, z); } else { addVertex(univ, GREY, x, y, z); } } } } }
/** * checks for cycles in the scene graph */ void checkForCycle() { if (visited) { throw new SceneGraphCycleException(J3dI18N.getString("Node15")); } visited = true; Node parent = getParent(); if (parent != null) { parent.checkForCycle(); } visited = false; }
/** * Duplicates all the nodes of the specified sub-graph. For Group Nodes * the group node is duplicated via a call to <code>cloneNode</code> * and then <code>cloneTree</code> * is called for each child node. For Leaf Nodes, component * data can either be duplicated or be made a reference to the original * data. Leaf Node cloneTree behavior is determined by the * <code>duplicateOnCloneTree</code> flag found in every Leaf Node's * component data class and by the <code>forceDuplicate</code> paramter. * @param referenceTable table that stores the mapping between * original and cloned nodes. All previous values in the * referenceTable will be cleared before the clone is made. * @return a reference to the cloned sub-graph. * @exception DanglingReferenceException When a dangling reference is * discovered during the cloneTree operation. * @exception RestrictedAccessException if this object is part of live * or compiled scene graph * @exception SceneGraphCycleException if there is a cycle in the * scene graph * @see NodeComponent#setDuplicateOnCloneTree * @since Java 3D 1.2 */ public Node cloneTree(NodeReferenceTable referenceTable) { return cloneTree(referenceTable, false, false); }
duplicateAttributes(originalNode, forceDuplicate);
this.nodeHashtable = nodeHashtable; try { l = cloneNode(forceDuplicate); } catch (RuntimeException e) { this.nodeHashtable = null;
/** * Retrieves the local coordinates to virtual world coordinates * transform for the particular path in the scene graph ending with * this node. This is the composite * of all transforms in the scene graph from the root down to * <code>this</code> node via the specified Link nodes. It is * only valid for nodes that are part of a live scene graph. * @param path the specific path from the node to the Locale * @param t the object that will receive the local coordinates to * Vworld coordinates transform. * @exception RestrictedAccessException if the node is <em>not</em> * part of a live scene graph * @exception CapabilityNotSetException if appropriate capability is * not set and this node is part of live scene graph * @exception IllegalArgumentException if the specified path does * not contain a valid Locale, or if the last node in the path is * different from this node * @exception IllegalSharingException if the node is not a descendant * of a SharedGroup node. */ public void getLocalToVworld(SceneGraphPath path, Transform3D t) { if (!isLive()) { throw new RestrictedAccessException(J3dI18N.getString("Node7")); } if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Node8")); ((NodeRetained)this.retained).getLocalToVworld(path,t); }
/** * return the eye's position in <node>'s coordinate space */ private static Point3d getViewPosInLocal(final View view, final Node node) { if (node == null) return null; if (!node.isLive()) return null; // get viewplatforms's location in virutal world final Canvas3D canvas = view.getCanvas3D(0); canvas.getCenterEyeInImagePlate(viewPosition); canvas.getImagePlateToVworld(t); t.transform(viewPosition); // get parent transform node.getLocalToVworld(parentInv); parentInv.invert(); // transform the eye position into the parent's coordinate system parentInv.transform(viewPosition); return viewPosition; }
/** * Returns a hash number based on the data values in this * object. Two different SceneGraphPath objects with identical data * values (ie, returns true for trans.equals(SceneGraphPath) ) will * return the same hash number. Two Paths with different data members * may return the same hash value, although this is not likely. * @return the integer hash value */ @Override public int hashCode() { HashKey key = new HashKey(250); // NOTE: Needed to add interior != null because this method is called // by object.toString() when interior is null. if(interior != null && item != null) { for(int i=0; i<interior.length; i++) { key.append(LinkRetained.plus).append( item.toString() ); } } return( key.hashCode() + transform.hashCode() ); }
if (!pickNode.getCapability(Shape3D.ALLOW_GEOMETRY_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("PickInfo0")); if (!pickNode.getCapability(Morph.ALLOW_GEOMETRY_ARRAY_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("PickInfo6"));