diff --git a/ch.psi.plot/pom.xml b/ch.psi.plot/pom.xml index e4e1526..7054861 100644 --- a/ch.psi.plot/pom.xml +++ b/ch.psi.plot/pom.xml @@ -55,12 +55,12 @@ i.snapshots Artifactory Snapshots - http://slsyoke1/artifactory/libs-snapshots-local + http://yoke/artifactory/libs-snapshots-local i.releases Atrifactory Releases - http://slsyoke1/artifactory/libs-releases-local + http://yoke/artifactory/libs-releases-local \ No newline at end of file diff --git a/ch.psi.plot/src/main/java/ch/psi/plot/xy/LinePlot.java b/ch.psi.plot/src/main/java/ch/psi/plot/xy/LinePlot.java index 7418e05..ffe6c37 100644 --- a/ch.psi.plot/src/main/java/ch/psi/plot/xy/LinePlot.java +++ b/ch.psi.plot/src/main/java/ch/psi/plot/xy/LinePlot.java @@ -179,6 +179,8 @@ public class LinePlot implements Plot { // Up arrow chartPanel.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), moveUpKey); chartPanel.getActionMap().put(moveUpKey, new AbstractAction() { + // Default serial id + private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { moverOverPlot(new XYDataItem(0.0, ((NumberAxis)chart.getXYPlot().getRangeAxis()).getTickUnit().getSize())); @@ -188,6 +190,8 @@ public class LinePlot implements Plot { // Down arrow chartPanel.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),moveDownKey); chartPanel.getActionMap().put(moveDownKey, new AbstractAction() { + // Default serial id + private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { moverOverPlot(new XYDataItem(0.0, - ((NumberAxis)chart.getXYPlot().getRangeAxis()).getTickUnit().getSize())); @@ -197,6 +201,8 @@ public class LinePlot implements Plot { // Right arrow chartPanel.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),moveRightKey); chartPanel.getActionMap().put(moveRightKey, new AbstractAction() { + // Default serial id + private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { moverOverPlot(new XYDataItem(((NumberAxis)chart.getXYPlot().getDomainAxis()).getTickUnit().getSize(), 0.0)); @@ -206,6 +212,8 @@ public class LinePlot implements Plot { // Left arrow chartPanel.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),moveLeftKey); chartPanel.getActionMap().put(moveLeftKey, new AbstractAction() { + // Default serial id + private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { moverOverPlot(new XYDataItem(- ((NumberAxis)chart.getXYPlot().getDomainAxis()).getTickUnit().getSize(), 0.0)); diff --git a/ch.psi.plot/src/main/java/ch/psi/plot/xyz/DynamicXYZDataset.java b/ch.psi.plot/src/main/java/ch/psi/plot/xyz/DynamicXYZDataset.java new file mode 100644 index 0000000..6d8e4ce --- /dev/null +++ b/ch.psi.plot/src/main/java/ch/psi/plot/xyz/DynamicXYZDataset.java @@ -0,0 +1,409 @@ +/** + * + * Copyright 2011 Paul Scherrer Institute. All rights reserved. + * + * This code is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This code is distributed in the hope that it will be useful, but without any + * warranty; without even the implied warranty of merchantability or fitness for + * a particular purpose. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + * + */ +package ch.psi.plot.xyz; + +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetGroup; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.RectangleAnchor; + +/** + * Dynamic dataset + * @author ebner + * + */ +public class DynamicXYZDataset implements XYZDataset{ + + private final double xResolution; + private final double yResolution; + private final double incX; + private final double incY; + + private final NumberAxis xAxis = new NumberAxis(); + private double xLowerBound = Double.NaN; + private double xUpperBound = Double.NaN; + private final NumberAxis yAxis = new NumberAxis(); + private double yLowerBound = Double.NaN; + private double yUpperBound = Double.NaN; + private double zLowerBound = Double.NaN; + + + private double zUpperBound = Double.NaN; + + private final XYBlockRenderer renderer = new XYBlockRenderer(); + + + private final List listeners = new ArrayList(); + private List items = new ArrayList(); + + /** + * Default constructor + */ + public DynamicXYZDataset(){ + xResolution = 1.0; + yResolution = 1.0; + incX = xResolution/2; + incY = yResolution/2; + + xAxis.setRange(xLowerBound, xUpperBound); + yAxis.setRange(yLowerBound, yUpperBound); + + renderer.setBlockWidth(xResolution); // If this is not set the default block size is 1 + renderer.setBlockHeight(yResolution); // If this is not set the default block size is 1 + renderer.setBlockAnchor(RectangleAnchor.CENTER); + renderer.setBaseCreateEntities(false); + } + + /** + * Add datapoint + * @param x + * @param y + * @param z + */ + public void addData(double x, double y, double z){ + items.add(new DynamicXYZDataset.Vector(x,y,z)); + + // Update axis + + +// if(Double.isNaN(xLowerBound) && Double.isNaN(xUpperBound)){ +// xLowerBound = x-incX; +// xUpperBound = x+incX; +// xAxis.setRange(xLowerBound, xUpperBound); +// } +// else{ +// if(x>(xUpperBound+incX)){ +// xUpperBound = x+incX; +// xAxis.setUpperBound(xUpperBound); +// } +// else if(x(yUpperBound+incY)){ +// yUpperBound = y+incY; +// yAxis.setUpperBound(yUpperBound); +// } +// else if(yzUpperBound){ +// zUpperBound = z; +// } +// else if(z. + * + */ +package ch.psi.plot.xyz; + +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetGroup; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.RectangleAnchor; + +/** + * Dynamic dataset + * @author ebner + * + */ +public class DynamicXYZDatasetList implements XYZDataset{ + + private final double xResolution; + private final double yResolution; + private final double incX; + private final double incY; + + private final NumberAxis xAxis = new NumberAxis(); + private double xLowerBound = Double.NaN; + private double xUpperBound = Double.NaN; + private final NumberAxis yAxis = new NumberAxis(); + private double yLowerBound = Double.NaN; + private double yUpperBound = Double.NaN; + private double zLowerBound = Double.NaN; + + + private double zUpperBound = Double.NaN; + + private final XYBlockRenderer renderer = new XYBlockRenderer(); + + + private final List listeners = new ArrayList(); + private List xitems = new ArrayList(100000); + private List yitems = new ArrayList(100000); + private List zitems = new ArrayList(100000); + + /** + * Default constructor + */ + public DynamicXYZDatasetList(){ + xResolution = 1.0; + yResolution = 1.0; + incX = xResolution/2; + incY = yResolution/2; + + xAxis.setRange(0, 100); + yAxis.setRange(0, 100); + + renderer.setBlockWidth(xResolution); // If this is not set the default block size is 1 + renderer.setBlockHeight(yResolution); // If this is not set the default block size is 1 + renderer.setBlockAnchor(RectangleAnchor.CENTER); +// renderer.setBaseCreateEntities(true, false); +// renderer.setBaseCreateEntities(false); + } + + /** + * Add datapoint + * @param x + * @param y + * @param z + */ + public void addData(Double x, Double y, Double z){ + System.out.println(x +" "+ y +" "+ z); + xitems.add(x); + yitems.add(y); + zitems.add(z); +// items.add(new DynamicXYZDatasetList.Vector(x,y,z)); + + // Update axis + +// final double xv = x.doubleValue(); +// final double yv = y.doubleValue(); +// final double zv = z.doubleValue(); +// +// if(Double.isNaN(xLowerBound) && Double.isNaN(xUpperBound)){ +// xLowerBound = xv-incX; +// xUpperBound = xv+incX; +// xAxis.setRange(xLowerBound, xUpperBound); +// } +// else{ +// if(xv>(xUpperBound+incX)){ +// xUpperBound = xv+incX; +// xAxis.setUpperBound(xUpperBound); +// } +// else if(xv(yUpperBound+incY)){ +// yUpperBound = yv+incY; +// yAxis.setUpperBound(yUpperBound); +// } +// else if(yvzUpperBound){ +// zUpperBound = zv; +// } +// else if(zv. + * + */ +package ch.psi.plot.xyz; + +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetGroup; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.RectangleAnchor; + +/** + * Dynamic dataset + * @author ebner + * + */ +public class DynamicXYZDatasetNumber implements XYZDataset{ + + private final double xResolution; + private final double yResolution; + private final double incX; + private final double incY; + + private final NumberAxis xAxis = new NumberAxis(); + private double xLowerBound = Double.NaN; + private double xUpperBound = Double.NaN; + private final NumberAxis yAxis = new NumberAxis(); + private double yLowerBound = Double.NaN; + private double yUpperBound = Double.NaN; + private double zLowerBound = Double.NaN; + + + private double zUpperBound = Double.NaN; + + private final XYBlockRenderer renderer = new XYBlockRenderer(); + + + private final List listeners = new ArrayList(); + private List items = new ArrayList(); + + /** + * Default constructor + */ + public DynamicXYZDatasetNumber(){ + xResolution = 1.0; + yResolution = 1.0; + incX = xResolution/2; + incY = yResolution/2; + + xAxis.setRange(xLowerBound, xUpperBound); + yAxis.setRange(yLowerBound, yUpperBound); + + renderer.setBlockWidth(xResolution); // If this is not set the default block size is 1 + renderer.setBlockHeight(yResolution); // If this is not set the default block size is 1 + renderer.setBlockAnchor(RectangleAnchor.CENTER); + renderer.setBaseCreateEntities(false); + } + + /** + * Add datapoint + * @param x + * @param y + * @param z + */ + public void addData(Number x, Number y, Number z){ + items.add(new DynamicXYZDatasetNumber.Vector(x,y,z)); + + // Update axis + + final double xv = x.doubleValue(); + final double yv = y.doubleValue(); + final double zv = z.doubleValue(); + + if(Double.isNaN(xLowerBound) && Double.isNaN(xUpperBound)){ + xLowerBound = xv-incX; + xUpperBound = xv+incX; + xAxis.setRange(xLowerBound, xUpperBound); + } + else{ + if(xv>(xUpperBound+incX)){ + xUpperBound = xv+incX; + xAxis.setUpperBound(xUpperBound); + } + else if(xv(yUpperBound+incY)){ + yUpperBound = yv+incY; + yAxis.setUpperBound(yUpperBound); + } + else if(yvzUpperBound){ + zUpperBound = zv; + } + else if(zv= 1M + */ + private void showTooltip(){ + //Tooltips are quit expensive + DecimalFormat dm = new DecimalFormat("0.##########"); + XYZToolTipGenerator xYZToolTipGenerator = new StandardXYZToolTipGenerator("{0}: ({1} / {2} / {3})", dm, dm, dm); + + chart.getXYPlot().getRenderer().setBaseToolTipGenerator(xYZToolTipGenerator); + ((XYBlockRenderer)chart.getXYPlot().getRenderer()).setBaseCreateEntities(true); + } + + /** + * Clear Tooltips + */ + private void hideTooltip(){ + //Tooltips are quit expensive + ((XYBlockRenderer)chart.getXYPlot().getRenderer()).setBaseToolTipGenerator(null); + ((XYBlockRenderer)chart.getXYPlot().getRenderer()).setBaseCreateEntities(false); + + } + + + /** + * Adapt the lower and upper color map scale to the min and max data values of the currently selected region + * Need to be called AFTER the chart panel is created + */ + public void adaptColorMapScale(){ + if(!Double.isNaN(data.getzLowerBound()) && !Double.isNaN(data.getzUpperBound())){ + setColorScale(data.getzLowerBound(),data.getzUpperBound()); + } + } + + /** + * Set the min and max of color map scale to scaleMin and scaleMax + * @param scaleMin min value of scale + * @param scaleMax max value of scale + */ + public void setColorScale(double scaleMin, double scaleMax){ + + // Create scale for legend + LookupPaintScale legendScale = new LookupPaintScale(scaleMin, scaleMax, Color.GRAY); + setScaleColors(legendScale, scaleMin, scaleMax); + + // Create legend + PaintScaleLegend legend = new PaintScaleLegend(legendScale, new NumberAxis()); + legend.setPadding(new RectangleInsets(5, 5, 5, 5)); + // Width of the legend (colorbar) + legend.setStripWidth(20); + // Position of the legend + legend.setPosition(RectangleEdge.RIGHT); + // Remove background paint/color + legend.setBackgroundPaint(null); + + // Add legend to plot panel + chart.clearSubtitles(); + chart.addSubtitle(legend); + + + //We need a second scale for rendering only, where the 'infinities' are in correct color + LookupPaintScale rendererScale = new LookupPaintScale(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Color.GRAY); + setScaleColors(rendererScale, scaleMin, scaleMax); + // Make the paint scale range from - to + infinity + if (grayScale) { + rendererScale.add(Double.NEGATIVE_INFINITY, ColorManager.getGrayForValue(scaleMin, scaleMin, scaleMax)); + rendererScale.add(Double.POSITIVE_INFINITY, ColorManager.getGrayForValue(scaleMax, scaleMin, scaleMax)); + } else { + rendererScale.add(Double.NEGATIVE_INFINITY, ColorManager.getColourForValue(scaleMin, scaleMin, scaleMax)); + rendererScale.add(Double.POSITIVE_INFINITY, ColorManager.getColourForValue(scaleMax, scaleMin, scaleMax)); + } + ((XYBlockRenderer) chart.getXYPlot().getRenderer()).setPaintScale(rendererScale); + } + + /** + * Set the colors for the colored Paint Scale (either single color or temperature color) + * @param paintScale + * @param scaleMin + * @param scaleMax + */ + private void setScaleColors(PaintScale paintScale, double scaleMin, double scaleMax){ + if (grayScale) { + for (int i = 0; i < 256; i++) { + double value = scaleMin + (i / 255.0) * (scaleMax - scaleMin); + ((LookupPaintScale) paintScale).add(value, ColorManager.getGrayForValue(value, scaleMin, scaleMax)); + } + } + else { + for (int i = 0; i < 256; i++) { + double value = scaleMin + (i / 255.0) * (scaleMax - scaleMin); + ((LookupPaintScale) paintScale).add(value, ColorManager.getColourForValue(value, scaleMin, scaleMax)); + } + } + } + + + + /** + * Get plot data + * @return + */ + public DynamicXYZDatasetList getData() { + return data; + } + + /** + * Get the chart panel + * @return + */ + @Override + public ChartPanel getChartPanel() { + if(chartPanel == null){ + + XYPlot plot = new XYPlot(data, data.getxAxis(), data.getyAxis(), data.getRenderer()); + + + // Remove background paint/color + plot.setBackgroundPaint(null); + + // Set the maximum zoom out to the initial zoom rate This also + // provides a workaround for dynamic plots because there zoom out does not work correctly (zoom out to infinity) +// plot.getRangeAxis().addChangeListener(new AxisChangeListener() { +// @Override +// public void axisChanged(AxisChangeEvent event) { +// ValueAxis axis = ((ValueAxis)event.getAxis()); +// if(axis.getLowerBound() < data.getyLowerBound() || axis.getUpperBound() > data.getyUpperBound()){ +// Range range = new Range(data.getyLowerBound(), data.getyUpperBound()); +// axis.setRange(range, true, false); +// } +// } +// }); +// plot.getDomainAxis().addChangeListener(new AxisChangeListener() { +// @Override +// public void axisChanged(AxisChangeEvent event) { +// ValueAxis axis = ((ValueAxis)event.getAxis()); +// if(axis.getLowerBound() < data.getxLowerBound() || axis.getUpperBound() > data.getxUpperBound()){ +// Range range = new Range(data.getxLowerBound(), data.getxUpperBound()); +// axis.setRange(range, true, false); +// } +// } +// }); + + + + chart = new JFreeChart(title, plot); + + //Remove the series label (also called legend) + chart.removeLegend(); + //AntiAliasing is used to speed up rendering +// chart.setAntiAlias(false); + + // Init PaintScale + setColorScale(0,1); + + + + //Create the Chartpanel where the chart will be plotted + chartPanel = new ChartPanel(chart); + + chartPanel.setPreferredSize(new java.awt.Dimension(chartPanelWidth, chartPanelHeight)); + + //All interactive menu items + adaptContextMenu(chartPanel); + } + + + return chartPanel; + } + + /* (non-Javadoc) + * @see ch.psi.plot.Plot#update() + */ + @Override + public void update() { + chart.fireChartChanged(); + adaptColorMapScale(); + } + + /* (non-Javadoc) + * @see ch.psi.plot.Plot#getChart() + */ + @Override + public JFreeChart getChart() { + return chart; + } +} diff --git a/ch.psi.plot/src/test/java/DualAxisChart.java b/ch.psi.plot/src/test/java/DualAxisChart.java index 8c78b8f..70d0ff2 100644 --- a/ch.psi.plot/src/test/java/DualAxisChart.java +++ b/ch.psi.plot/src/test/java/DualAxisChart.java @@ -18,7 +18,9 @@ import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; public class DualAxisChart extends ApplicationFrame { - + // Default serial id + private static final long serialVersionUID = 1L; + final String team1 = "1st Team"; final String team2 = "2nd Team"; diff --git a/ch.psi.plot/src/test/java/DualAxisChart2.java b/ch.psi.plot/src/test/java/DualAxisChart2.java index fb95135..df351f5 100644 --- a/ch.psi.plot/src/test/java/DualAxisChart2.java +++ b/ch.psi.plot/src/test/java/DualAxisChart2.java @@ -17,6 +17,8 @@ import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; public class DualAxisChart2 extends ApplicationFrame { + // Default serial id + private static final long serialVersionUID = 1L; final String team1 = "1st Team"; final String team2 = "2nd Team"; diff --git a/ch.psi.plot/src/test/java/ch/psi/plot/xyz/MatrixPlot2Test.java b/ch.psi.plot/src/test/java/ch/psi/plot/xyz/MatrixPlot2Test.java new file mode 100644 index 0000000..bd449b3 --- /dev/null +++ b/ch.psi.plot/src/test/java/ch/psi/plot/xyz/MatrixPlot2Test.java @@ -0,0 +1,212 @@ +/** + * + * Copyright 2010 Paul Scherrer Institute. All rights reserved. + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but without any warranty; without even the implied warranty of + * merchantability or fitness for a particular purpose. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + * + */ + +package ch.psi.plot.xyz; + +import java.util.Random; +import java.util.logging.Logger; + +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +//import ch.psi.sls.xasec.data.DataSet; +//import ch.psi.sls.xasec.data.DataSetUtils; +import ch.psi.plot.xyz.MatrixPlot; +import ch.psi.plot.xyz.MatrixPlotData; +import ch.psi.plot.xyz.generator.DataGenerator; +import ch.psi.plot.xyz.generator.Sinus2D; +import ch.psi.plot.xyz.generator.XYZGenerator; + + +/** + * Test case for MatrixPlot class + * @author ebner + * + */ +public class MatrixPlot2Test { + + // Get Logger + private static final Logger logger = Logger.getLogger(MatrixPlot2Test.class.getName()); + + private final long timeToClose = 7200000; // 2 hours + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + /** + * Test case for MatrixPlot (getting data from a generator) + * @throws InterruptedException + */ + @Test + public void testMatrixPlot() throws InterruptedException { + double startX = 0; + double stepSizeX = 1; + int stepsX = 50; + double startY = 0; + double stepSizeY = 1; + int stepsY = 50; + + final DynamicXYZDatasetList data = new DynamicXYZDatasetList(); + + final XYZGenerator generator = new XYZGenerator(new Sinus2D(2,4), startX, stepSizeX, stepsX, startY, stepSizeY, stepsY, false); + final MatrixPlot2 plot = new MatrixPlot2("Matrix Plot Test", data); + + final JFrame frame = new JFrame(""); + frame.setContentPane(plot.getChartPanel()); + frame.pack(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Close application if frame is closed + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + Thread t = new Thread(new Runnable() { + + @Override + public void run() { +// for(int t=0;t<200;t++){ +// // Reset generator +// generator.reset(); + +// int count = 0; + double[] xyz; + while((xyz=generator.getNewPoint())!=null){ + data.addData(xyz[0], xyz[1], xyz[2]); + + try { + Thread.sleep(10); + } catch (InterruptedException e) { + } + + // or set matrixChart.setNotify(false); in MatrixPlot Line 431 ... +// if(count==10){ +// plot.update(); +// count=0; +// } +// else{ +// count++; +// } + } + System.out.println("Generator done"); + +// } + + } + }); + t.start(); + + Thread.sleep(timeToClose); + } + + @Test + public void testPlotConverterGeneratorMatrixPlot() throws InterruptedException { + DataGenerator generator = new DataGenerator(new Sinus2D(2,4)); + generator.generateData(); + + MatrixPlot plot = new MatrixPlot("Matrix Plot Test", generator.getData()); + +// converter.generateData(); +//// Thread t = new Thread(converter); +//// t.start(); + + final JFrame frame = new JFrame(""); + frame.setContentPane(plot.getChartPanel()); + frame.pack(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Close application if frame is closed + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + + Thread.sleep(timeToClose); + } + + @Test + public void testPlotMatrixPlot() throws InterruptedException { + MatrixPlotData data = new MatrixPlotData(-10, -1, 10, -10, -1, 10); + + Random r = new Random(); + + for (double i = data.getMinX(); i <= data.getMaxX(); i++) { + for (double t = data.getMinY(); t <= data.getMaxY(); t++) { + data.addData(i, t, r.nextDouble() * 10); + } + } + + MatrixPlot plot = new MatrixPlot("Matrix Plot Test", data); + final JFrame frame = new JFrame(""); + frame.setContentPane(plot.getChartPanel()); + frame.pack(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Close application if frame is closed + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + Thread.sleep(timeToClose); + } + + + @Test + public void testPlotMatrixPlot2() throws InterruptedException { + MatrixPlotData data = new MatrixPlotData(-11.5, -11.0, 6, -10.5, -10.0, 6); + + Random r = new Random(); + + for (double i = data.getMinX(); i <= data.getMaxX(); i=i+0.1) { + for (double t = data.getMinY(); t <= data.getMaxY(); t=t+0.1) { + logger.info("Add data: "+i+" "+t); + if(t==data.getMinY()){ + continue; + } + data.addData(i, t, r.nextDouble() * 10); + } + } + + MatrixPlot plot = new MatrixPlot("Matrix Plot Test", data); + final JFrame frame = new JFrame(""); + frame.setContentPane(plot.getChartPanel()); + frame.pack(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Close application if frame is closed + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + Thread.sleep(timeToClose); + } +}