Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Plotting one point at a time with JLink

  • To: mathgroup at
  • Subject: [mg36666] Plotting one point at a time with JLink
  • From: Blimbaum Jerry DLPC <BlimbaumJE at>
  • Date: Wed, 18 Sep 2002 02:09:50 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

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 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@setSize[800, 600];
      frame@add[drawArea, ReturnAsJavaObject[BorderLayout`CENTER]];
      frame@pack[]; points = Range[data // Length]
      frame@setSize[800, 600];
      frame@setLocation[200, 200];

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[#];
            				Pause[0.0001];) &, pt];

      					] ]


jerry blimbaum   NSWC  panama city, fl

  • Prev by Date: Re: problems with the definition of a function
  • Next by Date: Re: Checking Programming errors; a ?
  • Previous by thread: Q: argmax
  • Next by thread: JLink and speeding up graphics display by java routine