Plotting one point at a time with JLink
- To: mathgroup at smc.vnet.net
- Subject: [mg36666] Plotting one point at a time with JLink
- From: Blimbaum Jerry DLPC <BlimbaumJE at ncsc.navy.mil>
- Date: Wed, 18 Sep 2002 02:09:50 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
A while back someone asked if Mathematica could plot data one point at a time....most answers were no, with one exception, where someone showed how to use the same Graphic Cell repeatedly....here is some Mathematica, JLink program that will do just that... << JLink` InstallJava[CommandLine -> "c:\\j2sdk1.4.1\\bin\\java.exe"] (* or set command line to where your java.exe is *) UseFrontEndForRendering = False; createWindow[] := Module[{frame}, frame = JavaNew["com.wolfram.jlink.MathFrame", "Drawing Sine Wave Animation One Point at a Time"]; drawArea = JavaNew["com.wolfram.jlink.MathCanvas"]; drawArea@setUsesFE[UseFrontEndForRendering]; drawArea@setSize[800, 600]; JavaBlock[frame@setLayout[JavaNew["java.awt.BorderLayout"]]; frame@add[drawArea, ReturnAsJavaObject[BorderLayout`CENTER]]; frame@pack[]; points = Range[data // Length] frame@setSize[800, 600]; frame@setLocation[200, 200]; JavaShow[frame]]; frame ] data = Table[{x, Sin[x]}, {x, -0.0000000000001, 2 Pi, .1}]; frame[n_] := ListPlot[Take[data, {1, n}], PlotRange -> {{0, 2 Pi}, {-1.5, 1.5}}, PlotStyle -> {PointSize[.005], Hue[0]}, DisplayFunction -> Identity] drawPoints[ptNow_] := Show[frame[ptNow], AspectRatio -> Automatic]; points = Range[data // Length]; AnimationPlot[pt_List] := JavaBlock[ Block[{frm}, frm = createWindow[]; Map[(obj = drawPoints[#]; drawArea@setMathCommand["obj"]; drawArea@repaintNow[]; Pause[0.0001];) &, pt]; ] ] AnimationPlot[points] jerry blimbaum NSWC panama city, fl