List of usage examples for javax.media.j3d BranchGroup BranchGroup
public BranchGroup()
From source file:AvatarTest.java
protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile, String szSoundFile) {/* w w w . j av a2s . c o m*/ // creates a segment of road 200 x 2 QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2); float[] coordArray = { -ROAD_WIDTH, ROAD_HEIGHT, 0, ROAD_WIDTH, ROAD_HEIGHT, 0, ROAD_WIDTH, ROAD_HEIGHT, ROAD_LENGTH, -ROAD_WIDTH, ROAD_HEIGHT, ROAD_LENGTH }; float[] texArray = { 0, 0, 1, 0, 1, 1, 0, 1 }; quadArray.setCoordinates(0, coordArray, 0, 4); if ((m_nFlags & TEXTURE) == TEXTURE) { quadArray.setTextureCoordinates(0, 0, texArray, 0, 4); setTexture(app, szTextureFile); } Shape3D sh = new Shape3D(quadArray, app); BranchGroup bg = new BranchGroup(); bg.addChild(sh); return bg; }
From source file:SplineAnim.java
private void createInterpolators() { behaviorBranch = new BranchGroup(); // create spline interpolator splineInterpolator = new KBRotPosScaleSplinePathInterpolator(animAlpha, objTransformGroup, yAxis, splineKeyFrames);/*from www .ja v a 2 s . c om*/ splineInterpolator.setSchedulingBounds(bounds); behaviorBranch.addChild(splineInterpolator); // create linear interpolator linearInterpolator = new KBRotPosScaleSplinePathInterpolator(animAlpha, objTransformGroup, yAxis, linearKeyFrames); linearInterpolator.setSchedulingBounds(bounds); behaviorBranch.addChild(linearInterpolator); objTransformGroup.addChild(behaviorBranch); }
From source file:Demo3D.java
/** * Create the subgraph #2/*ww w . ja va2s. c om*/ * * @return javax.media.j3d.BranchGroup brGr2 - the root of the subgraph #2 */ public BranchGroup mySubGraph2() { // Create the BranchGroup node brGr2 of the second subgraph. brGr2 = new BranchGroup(); // A BoundingSphere instance as general bounding region. boundsGen = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Create a Transform3D instance rot1 to perform the necessary // "static rotation" for the desired cube's position. rot1 = new Transform3D(); // Rotation of Pi/2 - arctan(1/sqrt(2)) = 0.955 rad about the // (1,0,-1)-axis passing through the origin. axe_rot = new AxisAngle4f(1.0f, 0.0f, -1.0f, 0.955f); rot1.setRotation(axe_rot); // Create the first TransformGroup node trGr2_1 and attach the // "static rotation" rot1 instance to it. trGr2_1 = new TransformGroup(rot1); // Create and attach a coordinate system to the TransformGroup node // trGr2_1 of the subgraph #2, that is to the cube. coordSyst = new CoordSyst(1.0f, 1.0f, 0.0f, // Color of the x-axis 0.0f, 0.0f, 1.0f, // Color of the y-axis 1.0f, 0.0f, 0.0f, // Color of the z-axis 0.4f); // Lenght of the 3 axes trGr2_1.addChild(coordSyst); // Create the ColorCube (Shape3D) and attach it to the // TransformGroup node trGr2_1 of the subgraph #2. colorCube = new ColorCube(0.5f); trGr2_1.addChild(colorCube); // Create the second TransformGroup node trGr2_2. trGr2_2 = new TransformGroup(); // With the ALLOW_TRANSFORM_WRITE capability, we allow the // modification of the TransformGroup's code by the behavior's // code at run time. trGr2_2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // Attach the first node trGr2_1 to the second node trGr2_2. trGr2_2.addChild(trGr2_1); // Prepare the RotationInterpolator (Behavior) for the // cube's rotation about the y-axis. trans1 = new Transform3D(); // Create the alpha(t) function. rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 10000, 0, 0, 0, 0, 0); // Create the cube's rotation about the y-axis. rotator = new RotationInterpolator(rotationAlpha, trGr2_2, trans1, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(boundsGen); trGr2_2.addChild(rotator); brGr2.addChild(trGr2_2); // Compile the subgraph to optimize the performances. brGr2.compile(); // Return the final version of the BranchGroup node brGr2 return brGr2; }
From source file:ViewProj.java
public BranchGroup createProjViewSG() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); objRoot.setCapability(BranchGroup.ALLOW_DETACH); // setup a transform group to hold the scaled scene TransformGroup objTrans = new TransformGroup(); Transform3D scale = new Transform3D(); scale.set(0.9);//from w ww .j a va 2s . co m objTrans.setTransform(scale); objRoot.addChild(objTrans); // create the clip limits line Point3f[] cpPoints = new Point3f[5]; cpPoints[0] = new Point3f(-1, -1, 0.1f); cpPoints[1] = new Point3f(1, -1, 0.1f); cpPoints[2] = new Point3f(1, 1, 0.1f); cpPoints[3] = new Point3f(-1, 1, 0.1f); cpPoints[4] = cpPoints[0]; int[] cpLength = new int[1]; cpLength[0] = 5; LineStripArray cpLines = new LineStripArray(5, LineArray.COORDINATES, cpLength); cpLines.setCoordinates(0, cpPoints); Appearance cpApp = new Appearance(); ColoringAttributes cpCa = new ColoringAttributes(blue, ColoringAttributes.SHADE_FLAT); cpApp.setColoringAttributes(cpCa); LineAttributes cpLa = new LineAttributes(); Shape3D cpShape = new Shape3D(cpLines, cpApp); objTrans.addChild(cpShape); // transform and render the clip grid points updateProjTrans(); if (numClipGridPts > 0) { // transform the clipGridPts for (int i = 0; i < numClipGridPts; i++) { projectPoint(clipGridPtsVW[i], clipGridPtsProj[i]); } LineArray clipLn = new LineArray(numClipGridPts, LineArray.COORDINATES); clipLn.setCoordinates(0, clipGridPtsProj, 0, numClipGridPts); Appearance clipGridApp = new Appearance(); ColoringAttributes clipCa = new ColoringAttributes(black, ColoringAttributes.SHADE_FLAT); clipGridApp.setColoringAttributes(clipCa); LineAttributes clipLa = new LineAttributes(); Shape3D clipShape = new Shape3D(clipLn, clipGridApp); objTrans.addChild(clipShape); } // set up the circle Appearance circleApp = new Appearance(); ColoringAttributes circleCa = new ColoringAttributes(); circleCa.setColor(red); circleApp.setColoringAttributes(circleCa); PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(PolygonAttributes.CULL_NONE); circleApp.setPolygonAttributes(pa); // transform the circlePts for (int i = 0; i < numCirclePts; i++) { projectPoint(circlePtsVW[i], circlePtsProj[i]); } int[] lineStripLength = new int[1]; lineStripLength[0] = numCirclePts; //LineStripArray circleLineStrip = new LineStripArray(numCirclePts, // LineArray.COORDINATES, lineStripLength); TriangleFanArray circleLineStrip = new TriangleFanArray(numCirclePts, LineArray.COORDINATES, lineStripLength); circleLineStrip.setCoordinates(0, circlePtsProj); Shape3D circleShape = new Shape3D(circleLineStrip, circleApp); objTrans.addChild(circleShape); return objRoot; }
From source file:Demo3D.java
/** * Create the subgraph #3/*from w w w . j a v a2 s. c o m*/ * * @return javax.media.j3d.BranchGroup brGr3 - the root of the subgraph #3 */ public BranchGroup mySubGraph3() { // Create the BranchGroup node brGr3, in other words the root of // the subgraph31 and subgraph32. brGr3 = new BranchGroup(); // To allow the detach/add process of the subgraph 32 from the // BranchGroup node brGr3. brGr3.setCapability(Group.ALLOW_CHILDREN_READ); brGr3.setCapability(Group.ALLOW_CHILDREN_WRITE); brGr3.setCapability(Group.ALLOW_CHILDREN_EXTEND); // A BoundingSphere instance as picking bound region. pickBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 5.0); // A BoundingSphere instance as general bounding region. boundsGen = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Create and attach the subgraph31 with the tetrahedron // to the BranchGroup node brGr3. tetrahedron = new Tetrahedron(1.0f); sceneBuilder31 = new SceneBuilder31(tetrahedron.myTetrahedron()); brGr3.addChild(sceneBuilder31.mySubGraph31()); // Picking of the tetrahedron // Note:It's the instruction: // trGr31.setCapability(TransformGroup.ENABLE_PICK_REPORTING) // in the class SceneBuilder31 that determines if the // tetrahedron is pickable or not. // Pick and translate the tetrahedron parallel to the z-axis if the // mouse pointer is over it. pickZoomBehavior = new PickZoomBehavior(brGr3, canvas3D, pickBounds); // pickZoomBehavior.setEnable(ctrlDown); brGr3.addChild(pickZoomBehavior); // Pick and translate the tetrahedron in the (x-y)-plane if the // mouse pointer is over it. pickTransBehavior = new PickTranslateBehavior(brGr3, canvas3D, pickBounds); // pickTransBehavior.setEnable(ctrlDown); brGr3.addChild(pickTransBehavior); // Pick and rotate the tetrahedron if the mouse pointer is over it. pickRotBehavior = new PickRotateBehavior(brGr3, canvas3D, pickBounds); // pickRotBehavior.setEnable(ctrlDown); brGr3.addChild(pickRotBehavior); // Create the subgraph32 ===> the earth in double rotation. sceneBuilder32 = new SceneBuilder32(); brGr3.addChild(sceneBuilder32.mySubGraph32()); // Create an instance of the AddDetachEarthBehavior class to // allow the detach/add process of the subgraph32. addDetachEarthBehavior = new AddDetachEarthBehavior(this, sceneBuilder32); addDetachEarthBehavior.setSchedulingBounds(boundsGen); brGr3.addChild(addDetachEarthBehavior); // Compile the subgraph to optimize the performances. brGr3.compile(); // Return the final version of the BranchGroup node brGr3 return brGr3; }
From source file:FourByFour.java
/** * Create the scenegraph for the 3D view. *//*from w w w .j ava 2 s . c o m*/ public BranchGroup createScene3D() { // Define colors Color3f white = new Color3f(1.0f, 1.0f, 1.0f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f red = new Color3f(0.80f, 0.20f, 0.2f); Color3f ambient = new Color3f(0.25f, 0.25f, 0.25f); Color3f diffuse = new Color3f(0.7f, 0.7f, 0.7f); Color3f specular = new Color3f(0.9f, 0.9f, 0.9f); Color3f ambientRed = new Color3f(0.2f, 0.05f, 0.0f); Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); // Create the branch group BranchGroup branchGroup = new BranchGroup(); // Create the bounding leaf node BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0); BoundingLeaf boundingLeaf = new BoundingLeaf(bounds); branchGroup.addChild(boundingLeaf); // Create the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); branchGroup.addChild(bg); // Create the ambient light AmbientLight ambLight = new AmbientLight(white); ambLight.setInfluencingBounds(bounds); branchGroup.addChild(ambLight); // Create the directional light Vector3f dir = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight dirLight = new DirectionalLight(white, dir); dirLight.setInfluencingBounds(bounds); branchGroup.addChild(dirLight); // Create the pole appearance Material poleMaterial = new Material(ambient, black, diffuse, specular, 110.f); poleMaterial.setLightingEnable(true); Appearance poleAppearance = new Appearance(); poleAppearance.setMaterial(poleMaterial); // Create the transform group node TransformGroup transformGroup = new TransformGroup(); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); branchGroup.addChild(transformGroup); // Create the poles Poles poles = new Poles(poleAppearance); transformGroup.addChild(poles.getChild()); // Add the position markers to the transform group transformGroup.addChild(positions.getChild()); // Let the positions object know about the transform group positions.setTransformGroup(transformGroup); // Create the mouse pick and drag behavior node PickDragBehavior behavior = new PickDragBehavior(canvas2D, canvas3D, positions, branchGroup, transformGroup); behavior.setSchedulingBounds(bounds); transformGroup.addChild(behavior); return branchGroup; }
From source file:GearTest.java
BranchGroup createBranchEnvironment() { // Create the root of the branch graph BranchGroup branchRoot = new BranchGroup(); // Create a bounds for the background and lights BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); branchRoot.addChild(bgNode);/*w w w. ja va 2 s . c om*/ // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); branchRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); branchRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); branchRoot.addChild(light2); return branchRoot; }
From source file:AppearanceExplorer.java
BranchGroup createGalleon() { java.net.URL galleonURL = null; try {/*from w w w. j a v a 2 s . c om*/ galleonURL = new java.net.URL(codeBaseString + "galleon.obj"); } catch (Exception e) { System.err.println("Exception: " + e); System.exit(1); } int flags = ObjectFile.RESIZE; ObjectFile f = new ObjectFile(flags); Scene s = null; try { s = f.load(galleonURL); } catch (Exception e) { System.err.println(e); System.exit(1); } Group sceneGroup = s.getSceneGroup(); Hashtable namedObjects = s.getNamedObjects(); Enumeration e = namedObjects.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); //System.out.println("name = " + name); Shape3D shape = (Shape3D) namedObjects.get(name); shape.setAppearance(appearance); } BranchGroup retVal = new BranchGroup(); retVal.addChild(s.getSceneGroup()); return retVal; }
From source file:AppearanceExplorer.java
BranchGroup createBeethoven() { java.net.URL beethovenURL = null; try {/*from ww w . jav a 2s. co m*/ beethovenURL = new java.net.URL(codeBaseString + "beethoven.obj"); } catch (Exception e) { System.err.println("Exception: " + e); System.exit(1); } int flags = ObjectFile.RESIZE; ObjectFile f = new ObjectFile(flags); Scene s = null; try { s = f.load(beethovenURL); } catch (Exception e) { System.err.println(e); System.exit(1); } Group sceneGroup = s.getSceneGroup(); Hashtable namedObjects = s.getNamedObjects(); Enumeration e = namedObjects.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); Shape3D shape = (Shape3D) namedObjects.get(name); shape.setAppearance(appearance); } BranchGroup retVal = new BranchGroup(); retVal.addChild(s.getSceneGroup()); return retVal; }
From source file:ViewProj.java
public void init() { setLayout(new BorderLayout()); nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(3);/*ww w. ja v a 2 s. c om*/ GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); JPanel canvasPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); canvasPanel.setLayout(gridbag); canvas = new Canvas3D(config); canvas.setSize(400, 400); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 2; constraints.gridheight = 2; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.BOTH; gridbag.setConstraints(canvas, constraints); canvasPanel.add(canvas); constraints.fill = GridBagConstraints.REMAINDER; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.gridx = 2; constraints.gridy = 0; urCanvas = new Canvas3D(config); urCanvas.setSize(200, 200); gridbag.setConstraints(urCanvas, constraints); canvasPanel.add(urCanvas); constraints.gridx = 2; constraints.gridy = 1; lrCanvas = new Canvas3D(config); lrCanvas.setSize(200, 200); gridbag.setConstraints(lrCanvas, constraints); canvasPanel.add(lrCanvas); add(canvasPanel, BorderLayout.NORTH); SimpleUniverse u = new SimpleUniverse(canvas); urUniverse = new SimpleUniverse(urCanvas); lrUniverse = new SimpleUniverse(lrCanvas); if (isApplication) { offScreenCanvas = new OffScreenCanvas3D(config, true); // set the size of the off-screen canvas based on a scale // of the on-screen size Screen3D sOn = canvas.getScreen3D(); Screen3D sOff = offScreenCanvas.getScreen3D(); Dimension dim = sOn.getSize(); dim.width *= offScreenScale; dim.height *= offScreenScale; sOff.setSize(dim); sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() * offScreenScale); sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() * offScreenScale); // attach the offscreen canvas to the view u.getViewer().getView().addCanvas3D(offScreenCanvas); urOffScreenCanvas = new OffScreenCanvas3D(config, true); // set the size of the off-screen canvas based on a scale // of the on-screen size sOn = urCanvas.getScreen3D(); sOff = urOffScreenCanvas.getScreen3D(); dim = sOn.getSize(); dim.width *= urOffScreenScale; dim.height *= urOffScreenScale; sOff.setSize(dim); sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() * urOffScreenScale); sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() * urOffScreenScale); // attach the offscreen canvas to the view urUniverse.getViewer().getView().addCanvas3D(urOffScreenCanvas); lrOffScreenCanvas = new OffScreenCanvas3D(config, true); // set the size of the off-screen canvas based on a scale // of the on-screen size sOn = lrCanvas.getScreen3D(); sOff = lrOffScreenCanvas.getScreen3D(); dim = sOn.getSize(); dim.width *= lrOffScreenScale; dim.height *= lrOffScreenScale; sOff.setSize(dim); sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() * lrOffScreenScale); sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() * lrOffScreenScale); // attach the offscreen canvas to the view lrUniverse.getViewer().getView().addCanvas3D(lrOffScreenCanvas); } // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. viewingPlatform = u.getViewingPlatform(); viewingPlatform.setNominalViewingTransform(); view = u.getViewer().getView(); view.setFrontClipPolicy(View.VIRTUAL_EYE); view.setBackClipPolicy(View.VIRTUAL_EYE); view.setFrontClipDistance(frontClipDist); view.setBackClipDistance(backClipDist); u.addBranchGraph(scene); // init the clipGridPts arrays for (int i = 0; i < maxClipGridPts; i++) { clipGridPtsVW[i] = new Point3f(); clipGridPtsProj[i] = new Point3f(); } // init the circlePts arrays for (int i = 0; i < numCirclePts; i++) { circlePtsVW[i] = new Point3f(); circlePtsProj[i] = new Point3f(); } // setup the ur canvas urScene = createVWorldViewSG(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. urUniverse.getViewingPlatform().setNominalViewingTransform(); View urView = urUniverse.getViewer().getView(); urView.setProjectionPolicy(View.PARALLEL_PROJECTION); urUniverse.addBranchGraph(urScene); // set up the background on a separate BG so that it can stay there // when we replace the scene SG Background urBgWhite = new Background(white); urBgWhite.setApplicationBounds(infiniteBounds); BranchGroup urBackBG = new BranchGroup(); urBackBG.addChild(urBgWhite); urUniverse.addBranchGraph(urBackBG); // setup the lr canvas lrScene = createProjViewSG(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. lrUniverse.getViewingPlatform().setNominalViewingTransform(); View lrView = lrUniverse.getViewer().getView(); lrView.setProjectionPolicy(View.PARALLEL_PROJECTION); lrUniverse.addBranchGraph(lrScene); // set up the background on a separate BG so that it can stay there // when we replace the scene SG Background lrBgWhite = new Background(white); lrBgWhite.setApplicationBounds(infiniteBounds); BranchGroup lrBackBG = new BranchGroup(); lrBackBG.addChild(lrBgWhite); lrUniverse.addBranchGraph(lrBackBG); // set up the sliders JPanel guiPanel = new JPanel(); guiPanel.setLayout(new GridLayout(0, 2)); FloatLabelJSlider dynamicSlider = new FloatLabelJSlider("Dynamic Offset", 0.1f, 0.0f, 2.0f, dynamicOffset); dynamicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { dynamicOffset = e.getValue(); solidPa.setPolygonOffsetFactor(dynamicOffset); } }); guiPanel.add(dynamicSlider); LogFloatLabelJSlider staticSlider = new LogFloatLabelJSlider("Static Offset", 0.1f, 10000.0f, staticOffset); staticSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { staticOffset = e.getValue(); solidPa.setPolygonOffset(staticOffset); } }); guiPanel.add(staticSlider); // These are declared final here so they can be changed by the // listener routines below. LogFloatLabelJSlider frontClipSlider = new LogFloatLabelJSlider("Front Clip Distance", 0.001f, 10.0f, frontClipDist); final LogFloatLabelJSlider backClipSlider = new LogFloatLabelJSlider("Back Clip Distance", 1.0f, 10000.0f, backClipDist); final LogFloatLabelJSlider backClipRatioSlider = new LogFloatLabelJSlider("Back Clip Ratio", 1.0f, 10000.0f, backClipRatio); frontClipSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { frontClipDist = e.getValue(); view.setFrontClipDistance(frontClipDist); backClipRatio = backClipDist / frontClipDist; backClipRatioSlider.setValue(backClipRatio); updateViewWindows(); } }); guiPanel.add(frontClipSlider); backClipSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { backClipDist = e.getValue(); backClipRatio = backClipDist / frontClipDist; backClipRatioSlider.setValue(backClipRatio); view.setBackClipDistance(backClipDist); updateViewWindows(); } }); guiPanel.add(backClipSlider); backClipRatioSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { backClipRatio = e.getValue(); backClipDist = backClipRatio * frontClipDist; backClipSlider.setValue(backClipDist); updateViewWindows(); } }); guiPanel.add(backClipRatioSlider); FloatLabelJSlider innerSphereSlider = new FloatLabelJSlider("Inner Sphere Scale", 0.001f, 0.90f, 1.0f, innerScale); innerSphereSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { innerScale = e.getValue(); updateInnerScale(); } }); guiPanel.add(innerSphereSlider); JButton mainSnap = new JButton(snapImageString); mainSnap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Point loc = canvas.getLocationOnScreen(); offScreenCanvas.setOffScreenLocation(loc); Dimension dim = canvas.getSize(); dim.width *= offScreenScale; dim.height *= offScreenScale; nf.setMinimumIntegerDigits(3); offScreenCanvas.snapImageFile(outFileBase + nf.format(outFileSeq++), dim.width, dim.height); nf.setMinimumIntegerDigits(0); } }); guiPanel.add(mainSnap); JButton urSnap = new JButton(urSnapImageString); urSnap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Snap UR"); Point loc = urCanvas.getLocationOnScreen(); urOffScreenCanvas.setOffScreenLocation(loc); Dimension dim = urCanvas.getSize(); dim.width *= urOffScreenScale; dim.height *= urOffScreenScale; nf.setMinimumIntegerDigits(3); urOffScreenCanvas.snapImageFile(urOutFileBase + nf.format(urOutFileSeq++), dim.width, dim.height); nf.setMinimumIntegerDigits(0); } }); guiPanel.add(urSnap); JButton lrSnap = new JButton(lrSnapImageString); lrSnap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Snap LR"); Point loc = lrCanvas.getLocationOnScreen(); lrOffScreenCanvas.setOffScreenLocation(loc); Dimension dim = lrCanvas.getSize(); dim.width *= lrOffScreenScale; dim.height *= lrOffScreenScale; nf.setMinimumIntegerDigits(3); lrOffScreenCanvas.snapImageFile(lrOutFileBase + nf.format(lrOutFileSeq++), dim.width, dim.height); nf.setMinimumIntegerDigits(0); } }); guiPanel.add(lrSnap); add(guiPanel, BorderLayout.SOUTH); }