comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java @ 1820:d562772a418e

CrossSectionApp: Re-enabled dumping data to disk. flys-artifacts/trunk@3149 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 03 Nov 2011 10:14:51 +0000
parents 595c404523a6
children 94871b7ce9e9
comparison
equal deleted inserted replaced
1819:dabd2ac83159 1820:d562772a418e
58 import org.jfree.chart.axis.NumberAxis; 58 import org.jfree.chart.axis.NumberAxis;
59 59
60 import org.jfree.chart.plot.PlotOrientation; 60 import org.jfree.chart.plot.PlotOrientation;
61 import org.jfree.chart.plot.XYPlot; 61 import org.jfree.chart.plot.XYPlot;
62 62
63 import org.jfree.data.xy.DefaultXYDataset;
64 import org.jfree.data.xy.XYDataset;
65 import org.jfree.data.xy.XYSeries; 63 import org.jfree.data.xy.XYSeries;
66 import org.jfree.data.xy.XYSeriesCollection; 64 import org.jfree.data.xy.XYSeriesCollection;
67 65
68 import org.jfree.ui.ApplicationFrame; 66 import org.jfree.ui.ApplicationFrame;
69 import org.jfree.ui.RefineryUtilities; 67 import org.jfree.ui.RefineryUtilities;
353 351
354 return new ChartPanel(chart); 352 return new ChartPanel(chart);
355 } 353 }
356 354
357 protected void dumpData() { 355 protected void dumpData() {
358 }
359 /*
360 protected void dumpData() {
361 356
362 CrossSectionLineItem csli = 357 CrossSectionLineItem csli =
363 (CrossSectionLineItem)crossSectionLinesCB.getSelectedItem(); 358 (CrossSectionLineItem)crossSectionLinesCB.getSelectedItem();
364 359
365 if (csli == null) { 360 if (csli == null) {
366 return; 361 return;
367 } 362 }
368 363
369 CrossSectionLine line = csli.line; 364
370 365 double km = Math.round(csli.km.doubleValue() * 1000d)/1000d;
371 double km = Math.round(line.getKm().doubleValue() * 1000d)/1000d;
372 366
373 String kmS = String.valueOf(km).replace(".", "-"); 367 String kmS = String.valueOf(km).replace(".", "-");
374 368
375 int i = 1; 369 int i = 1;
376 File file = new File("cross-section-" + kmS + ".txt"); 370 File file = new File("cross-section-" + kmS + ".txt");
378 file = new File("cross-section-" + kmS + "[" + (i++) + "].txt"); 372 file = new File("cross-section-" + kmS + "[" + (i++) + "].txt");
379 } 373 }
380 374
381 System.err.println("dump points to file '" + file + "'"); 375 System.err.println("dump points to file '" + file + "'");
382 376
383 List<CrossSectionPoint> points = line.getPoints();
384
385 PrintWriter out = null; 377 PrintWriter out = null;
386 378
387 MathContext mc = new MathContext(3); 379 MathContext mc = new MathContext(3);
388 380
389 try { 381 try {
390 out = 382 out =
391 new PrintWriter( 383 new PrintWriter(
392 new FileWriter(file)); 384 new FileWriter(file));
393 385
394 for (CrossSectionPoint point: points) { 386 for (Pair<CrossSection, CrossSectionLine> pair: csli.lines) {
395 out.println( 387 out.println("# " + pair.getA().getDescription());
396 point.getX().round(mc) + " " + 388 for (CrossSectionPoint point: pair.getB().getPoints()) {
397 point.getY().round(mc)); 389 out.println(
390 point.getX().round(mc) + " " +
391 point.getY().round(mc));
392 }
398 } 393 }
399 394
400 out.flush(); 395 out.flush();
401 } 396 }
402 catch (IOException ioe) { 397 catch (IOException ioe) {
406 if (out != null) { 401 if (out != null) {
407 out.close(); 402 out.close();
408 } 403 }
409 } 404 }
410 } 405 }
411 */
412 406
413 public void generateWaterLevels( 407 public void generateWaterLevels(
414 List<Point2D> points, 408 List<Point2D> points,
415 XYSeriesCollection collection 409 XYSeriesCollection collection
416 ) { 410 ) {

http://dive4elements.wald.intevation.org