Thank you!

That was the trouble!

Thanks again.

Luigi

Edward A. Lee wrote:

> 
> The only possibility that occurs to me is that the method
> plot.export(out_image) is getting executed before the last
> plot.addPoint() is executed.  To test this theory,
> try placing at least plot.export(out_image) in the event
> thread, using code like this:
> 
>                 Runnable doExport = new Runnable() {
>                     public void run() {
>                         plot.export(out_image);
>                     }
>                 };
>                 try {
>                     SwingUtilities.invokeLater(doExport);
>                 } catch (InterruptedException ex) {
>                     // Ignore InterruptedException.
>                     // Other exceptions should not occur.
>                 }
> 
> To do this, out_image will have to be declared "final".
> 
> The reason for this is that add_point's action is deferred to
> execute in the event thread.  It is arguable that probably export()
> should be as well...
> 
> Edward
> 
> 
> At 12:23 PM 7/1/2002 +0200, Luigi Paioro wrote:
> 
>> Hello to everybody!
>>
>> I'm using the PtPlot classes to plot some dynamic charts that are 
>> elaborated by a Java Servlet. I don't know why, but if I plot more 
>> time the same dataset (and also not the same!), my Plot losts some 
>> points... but not always the same number... it seems that the 
>> addPoint(...) method fails over a random number of points added.
>>
>> My plot cames from a POST method on my servlet that make a query on a 
>> database and plot the result adding the values of the two columns 
>> selected:
>>
>> Plot plot = new Plot();
>>
>> plot.setButtons(false);
>> plot.setConnected(false);
>> plot.setImpulses(false);
>> plot.setBars(false);
>> plot.setMarksStyle("various");
>> plot.setBackground(Color.white);
>>
>> Statement stmt = null;
>> ResultSet result = null;
>>
>> stmt = Cnn.createStatement();
>> result = stmt.executeQuery(sql);
>>
>> while (result.next()) {
>>         int i = result.findColumn(fieldx1);
>>         int j = result.findColumn(fieldy1);
>>         String sx = result.getString(i);
>>         String sy = result.getString(j);
>>         double x = (Double.valueOf(sx)).doubleValue();
>>         double y = (Double.valueOf(sy)).doubleValue();
>>         plot.addPoint(0, x, y, false);
>> }
>>
>> fieldx1 and fieldy1 come from the HTML form... they are just the 
>> column name, and the sql string is the SQL statement.
>>
>> In the end I send an EPS to the browser OutputStream:
>>
>> OutputStream out_image = response.getOutputStream();
>> response.setContentType("application/postscript");
>> plot.export(out_image);
>>
>> It's a simple code, but if I run it more times, it losts some 
>> points... it seems that the servlet cannot plot more points than a 
>> break point that variates each time. Note that it is not a SQL 
>> trouble: the query works fine!
>>
>> What about this?
>>
>> Thank, Luigi.
>>
>> -- 
>>
>> Dr. Luigi Paioro
>>
>> C.N.R. - I.A.S.F.
>>
>> Consiglio Nazionale delle Ricerche
>>
>> Istituto di Astrofisica Spaziale e
>> Fisica Cosmica "G.P.S. Occhialini"
>>
>> via Bassini 15, I-20133 Milano, Italy
>>
>> e.mail: [EMAIL PROTECTED]
>> phone:  +39 02 23699349
>> fax:    +39 02 2666017
>>
>>
>> ---------------------------------------------------------------------------- 
>>
>> Posted to the ptolemy-hackers mailing list.  Please send administrative
>> mail for this list to: [EMAIL PROTECTED]
> 
> 
> ------------
> Edward A. Lee, Professor
> 518 Cory Hall, UC Berkeley, Berkeley, CA 94720
> phone: 510-642-0455, fax: 510-642-2739
> [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
> 



-- 

Dr. Luigi Paioro

C.N.R. - I.A.S.F.

Consiglio Nazionale delle Ricerche

Istituto di Astrofisica Spaziale e
Fisica Cosmica "G.P.S. Occhialini"

via Bassini 15, I-20133 Milano, Italy

e.mail: [EMAIL PROTECTED]
phone:  +39 02 23699349
fax:    +39 02 2666017


----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to