Refactored visualizer to support vdescriptor
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<dependency>
|
||||
<groupId>ch.psi</groupId>
|
||||
<artifactId>ch.psi.fda.core</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -56,13 +56,11 @@ import com.google.inject.Injector;
|
||||
|
||||
import sun.misc.Signal;
|
||||
import sun.misc.SignalHandler;
|
||||
import ch.psi.fda.aq.VisualizationMapper;
|
||||
import ch.psi.fda.aq.XScanDescriptor;
|
||||
import ch.psi.fda.edescriptor.EDescriptor;
|
||||
import ch.psi.fda.gui.ProgressPanel;
|
||||
import ch.psi.fda.gui.ScrollableFlowPanel;
|
||||
import ch.psi.fda.install.ApplicationConfigurator;
|
||||
import ch.psi.fda.model.v1.Configuration;
|
||||
import ch.psi.fda.vdescriptor.VDescriptor;
|
||||
import ch.psi.fda.visualizer.Visualizer;
|
||||
import ch.psi.jcae.ChannelService;
|
||||
import ch.psi.jcae.impl.DefaultChannelService;
|
||||
@@ -189,15 +187,17 @@ public class AcquisitionMain {
|
||||
|
||||
|
||||
EDescriptor edescriptor = null;
|
||||
VDescriptor vdescriptor = null;
|
||||
ServiceLoader<DescriptorProvider> providers = ServiceLoader.load(DescriptorProvider.class);
|
||||
for (DescriptorProvider provider : providers) {
|
||||
try{
|
||||
provider.load(file);
|
||||
edescriptor = provider.getEDescriptor();
|
||||
vdescriptor = provider.getVDescriptor();
|
||||
break;
|
||||
}
|
||||
catch(Exception e){
|
||||
logger.log(Level.FINEST, provider.getClass().getName()+ " is not able to read provided descriptor files", e);
|
||||
logger.log(Level.INFO, provider.getClass().getName()+ " is not able to read provided descriptor files", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,25 +218,11 @@ public class AcquisitionMain {
|
||||
|
||||
Visualizer visualizer = null;
|
||||
|
||||
if(edescriptor instanceof XScanDescriptor){
|
||||
XScanDescriptor d = (XScanDescriptor) edescriptor;
|
||||
Configuration c = d.getConfiguration();
|
||||
|
||||
// Only register data visualization task/processor if there are visualizations
|
||||
if(c.getVisualization().size()>0 && !nogui){
|
||||
|
||||
visualizer = new Visualizer(VisualizationMapper.mapVisualizations(c.getVisualization()));
|
||||
b.register(visualizer);
|
||||
|
||||
// TODO eventually set update on delimiter/dim boundary here
|
||||
|
||||
// If there is a continous dimension only update plot at the end of a line
|
||||
if(c.getScan() != null && c.getScan().getCdimension()!=null){
|
||||
visualizer.setUpdateAtStreamElement(false);
|
||||
visualizer.setUpdateAtStreamDelimiter(true);
|
||||
visualizer.setUpdateAtEndOfStream(true);
|
||||
}
|
||||
}
|
||||
// Only register data visualization task/processor if there are visualizations
|
||||
if(vdescriptor.getPlots().size()>0 && !nogui){
|
||||
visualizer = new Visualizer(vdescriptor);
|
||||
b.register(visualizer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package ch.psi.fda.aq;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ch.psi.fda.model.v1.ArrayDetector;
|
||||
import ch.psi.fda.model.v1.ContinuousPositioner;
|
||||
import ch.psi.fda.model.v1.Detector;
|
||||
import ch.psi.fda.model.v1.LinearPositioner;
|
||||
import ch.psi.fda.model.v1.Positioner;
|
||||
import ch.psi.fda.model.v1.PseudoPositioner;
|
||||
import ch.psi.fda.model.v1.Visualization;
|
||||
import ch.psi.fda.visualizer.SeriesDataFilter;
|
||||
import ch.psi.fda.visualizer.XYSeriesArrayDataFilter;
|
||||
import ch.psi.fda.visualizer.XYSeriesDataFilter;
|
||||
import ch.psi.fda.visualizer.XYZSeriesArrayDataFilter;
|
||||
import ch.psi.fda.visualizer.XYZSeriesDataFilter;
|
||||
import ch.psi.plot.xyz.MatrixPlot;
|
||||
import ch.psi.plot.xyz.MatrixPlotData;
|
||||
|
||||
public class VisualizationMapper {
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve id string of the passed object
|
||||
* @param object
|
||||
* @return Id string of object
|
||||
*/
|
||||
private static String getId(Object object){
|
||||
String id;
|
||||
if(object instanceof Positioner){
|
||||
id = ((Positioner)object).getId();
|
||||
}
|
||||
else if (object instanceof Detector){
|
||||
id = ((Detector)object).getId();
|
||||
}
|
||||
else if (object instanceof ch.psi.fda.model.v1.Manipulation){
|
||||
id = ((ch.psi.fda.model.v1.Manipulation)object).getId();
|
||||
}
|
||||
// For testing purposes
|
||||
else if(object instanceof String){
|
||||
id = (String) object;
|
||||
}
|
||||
else{
|
||||
throw new RuntimeException("Unable to identify id of object reference "+object);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of visualizations into a list of data filters which can be applied to the data stream
|
||||
*
|
||||
* @param vl
|
||||
* @return
|
||||
*/
|
||||
public static List<SeriesDataFilter> mapVisualizations(List<Visualization> vl){
|
||||
List<SeriesDataFilter> filters = new ArrayList<SeriesDataFilter>();
|
||||
|
||||
for(Visualization v: vl){
|
||||
if(v instanceof ch.psi.fda.model.v1.LinePlot){
|
||||
ch.psi.fda.model.v1.LinePlot lp = (ch.psi.fda.model.v1.LinePlot) v;
|
||||
|
||||
// Create plot for visualization
|
||||
ch.psi.plot.xy.LinePlot plot = new ch.psi.plot.xy.LinePlot(lp.getTitle());
|
||||
|
||||
// Create data filter for visualization
|
||||
String idX = getId(lp.getX());
|
||||
|
||||
List<Object> l = lp.getY();
|
||||
for(Object o: l){
|
||||
String idY = getId(o);
|
||||
XYSeriesDataFilter filter = new XYSeriesDataFilter(idX, idY, plot);
|
||||
filter.setSeriesName(idY);
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
else if(v instanceof ch.psi.fda.model.v1.LinePlotArray){
|
||||
// Array visualization
|
||||
ch.psi.fda.model.v1.LinePlotArray lp = (ch.psi.fda.model.v1.LinePlotArray) v;
|
||||
|
||||
// Create plot for visualization
|
||||
ch.psi.plot.xy.LinePlot plot = new ch.psi.plot.xy.LinePlot(lp.getTitle());
|
||||
|
||||
// Create data filter for visualization
|
||||
List<Object> l = lp.getY();
|
||||
for(Object o: l){
|
||||
String idY = getId(o);
|
||||
|
||||
XYSeriesArrayDataFilter filter = new XYSeriesArrayDataFilter(idY, plot);
|
||||
filter.setMaxSeries(lp.getMaxSeries()*lp.getY().size()); // Workaround - keep for each array max series
|
||||
filter.setOffset(lp.getOffset());
|
||||
filter.setSize(lp.getSize());
|
||||
filter.setSeriesName(idY);
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
else if(v instanceof ch.psi.fda.model.v1.MatrixPlot){
|
||||
|
||||
// MatrixPlot does currently not support RegionPositioners because of the
|
||||
// plotting problems this would cause. If regions of the positioner have different
|
||||
// step sizes it is not easily possible (without (specialized) rasterization) to plot the data.
|
||||
|
||||
ch.psi.fda.model.v1.MatrixPlot mp = (ch.psi.fda.model.v1.MatrixPlot) v;
|
||||
|
||||
|
||||
double minX, maxX;
|
||||
int nX;
|
||||
double minY, maxY;
|
||||
int nY;
|
||||
|
||||
String idX, idY, idZ;
|
||||
|
||||
// X Axis
|
||||
if(mp.getX() instanceof LinearPositioner){
|
||||
LinearPositioner linp = ((LinearPositioner)mp.getX());
|
||||
idX = linp.getId();
|
||||
|
||||
minX = (Math.min(linp.getStart(), linp.getEnd()));
|
||||
maxX = (Math.max(linp.getStart(), linp.getEnd()));
|
||||
nX = ((int) Math.floor((Math.abs(maxX-minX))/linp.getStepSize()) + 1);
|
||||
}
|
||||
else if(mp.getX() instanceof PseudoPositioner){
|
||||
PseudoPositioner pp = ((PseudoPositioner)mp.getX());
|
||||
idX = pp.getId();
|
||||
minX = (1); // Count starts at 1
|
||||
maxX = (pp.getCounts());
|
||||
nX = (pp.getCounts());
|
||||
}
|
||||
else if(mp.getX() instanceof ContinuousPositioner){
|
||||
ContinuousPositioner conp = ((ContinuousPositioner)mp.getX());
|
||||
idX = conp.getId();
|
||||
|
||||
minX = (Math.min(conp.getStart(), conp.getEnd()));
|
||||
maxX = (Math.max(conp.getStart(), conp.getEnd()));
|
||||
nX = ((int) Math.floor((Math.abs(maxX-minX))/conp.getStepSize()) + 1);
|
||||
}
|
||||
else{
|
||||
// Fail as we cannot determine the min, max and number of steps
|
||||
throw new RuntimeException(mp.getX().getClass().getName()+" is not supported as x-axis of a MatrixPlot");
|
||||
}
|
||||
|
||||
// Y Axis
|
||||
if(mp.getY() instanceof LinearPositioner){
|
||||
LinearPositioner linp = ((LinearPositioner)mp.getY());
|
||||
idY = linp.getId();
|
||||
minY = (Math.min(linp.getStart(), linp.getEnd()));
|
||||
maxY = (Math.max(linp.getStart(), linp.getEnd()));
|
||||
nY = ((int) Math.floor((Math.abs(maxY-minY))/linp.getStepSize()) + 1);
|
||||
}
|
||||
else if(mp.getY() instanceof PseudoPositioner){
|
||||
PseudoPositioner pp = ((PseudoPositioner)mp.getY());
|
||||
idY = pp.getId();
|
||||
minY = (1); // Count starts at 1
|
||||
maxY = (pp.getCounts());
|
||||
nY = (pp.getCounts());
|
||||
}
|
||||
else{
|
||||
// Fail as we cannot determine the min, max and number of steps
|
||||
throw new RuntimeException(mp.getY().getClass().getName()+" is not supported as y-axis of a MatrixPlot");
|
||||
}
|
||||
|
||||
// Z Dimension
|
||||
idZ = getId(mp.getZ());
|
||||
|
||||
// Create plot for visualization
|
||||
MatrixPlotData data = new MatrixPlotData(minX, maxX, nX, minY, maxY, nY);
|
||||
MatrixPlot plot = new MatrixPlot(mp.getTitle(), data);
|
||||
|
||||
XYZSeriesDataFilter filter = new XYZSeriesDataFilter(idX, idY, idZ, plot);
|
||||
filters.add(filter);
|
||||
}
|
||||
else if(v instanceof ch.psi.fda.model.v1.MatrixPlotArray){
|
||||
// Support for 2D waveform plots
|
||||
ch.psi.fda.model.v1.MatrixPlotArray mp = (ch.psi.fda.model.v1.MatrixPlotArray) v;
|
||||
|
||||
// Get size of the array detector
|
||||
int arraySize = 0;
|
||||
Object o = mp.getZ();
|
||||
if(o instanceof ArrayDetector){
|
||||
ArrayDetector ad = (ArrayDetector) o;
|
||||
arraySize = ad.getArraySize();
|
||||
}
|
||||
else{
|
||||
// Workaround
|
||||
arraySize = mp.getSize(); // of array is from a manipulation the size is not known. Then the size will indicate the size of the array to display
|
||||
}
|
||||
|
||||
int offset = mp.getOffset();
|
||||
// Determine size for array
|
||||
int size = mp.getSize();
|
||||
if(size>0 && offset+size<arraySize){
|
||||
size = mp.getSize();
|
||||
}
|
||||
else{
|
||||
size=arraySize-offset;
|
||||
}
|
||||
|
||||
|
||||
double minY, maxY;
|
||||
int nY;
|
||||
|
||||
double minX = offset;
|
||||
double maxX = offset+size-1;
|
||||
int nX = size;
|
||||
|
||||
String idY, idZ;
|
||||
|
||||
// Y Axis
|
||||
if(mp.getY() instanceof LinearPositioner){
|
||||
LinearPositioner linp = ((LinearPositioner)mp.getY());
|
||||
idY = linp.getId();
|
||||
|
||||
minY = (Math.min(linp.getStart(), linp.getEnd()));
|
||||
maxY = (Math.max(linp.getStart(), linp.getEnd()));
|
||||
nY = ((int) Math.floor((Math.abs(maxY-minY))/linp.getStepSize()) + 1);
|
||||
}
|
||||
else if(mp.getY() instanceof PseudoPositioner){
|
||||
PseudoPositioner pp = ((PseudoPositioner)mp.getY());
|
||||
idY = pp.getId();
|
||||
minY = (1); // Count starts at 1
|
||||
maxY = (pp.getCounts());
|
||||
nY = (pp.getCounts());
|
||||
}
|
||||
else if(mp.getY() instanceof ContinuousPositioner){
|
||||
ContinuousPositioner conp = ((ContinuousPositioner)mp.getY());
|
||||
idY = conp.getId();
|
||||
|
||||
minY = (Math.min(conp.getStart(), conp.getEnd()));
|
||||
maxY = (Math.max(conp.getStart(), conp.getEnd()));
|
||||
nY = ((int) Math.floor((Math.abs(maxY-minY))/conp.getStepSize()) + 1);
|
||||
}
|
||||
else{
|
||||
// Fail as we cannot determine the min, max and number of steps
|
||||
throw new RuntimeException(mp.getY().getClass().getName()+" is not supported as x-axis of a MatrixPlot");
|
||||
}
|
||||
|
||||
|
||||
// Z Dimension
|
||||
idZ = getId(mp.getZ());
|
||||
|
||||
// Create plot for visualization
|
||||
MatrixPlotData data = new MatrixPlotData(minX, maxX, nX, minY, maxY, nY);
|
||||
MatrixPlot plot = new MatrixPlot(mp.getTitle(), data);
|
||||
|
||||
XYZSeriesArrayDataFilter filter = new XYZSeriesArrayDataFilter(idY, idZ, offset, size, plot);
|
||||
filters.add(filter);
|
||||
}
|
||||
else{
|
||||
// Visualization type (currently) not supported
|
||||
throw new RuntimeException(v.getClass().getName()+" is not supported as visualization type");
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ public class XScanDescriptorProvider implements DescriptorProvider {
|
||||
@Override
|
||||
public void load(File... files) {
|
||||
|
||||
|
||||
if(files.length<1 || files[0]==null){
|
||||
throw new IllegalArgumentException("There need to be at lease one file specified");
|
||||
}
|
||||
@@ -78,11 +77,16 @@ public class XScanDescriptorProvider implements DescriptorProvider {
|
||||
c.setNumberOfExecution(1);
|
||||
}
|
||||
|
||||
edescriptor = new XScanDescriptor(c);
|
||||
vdescriptor = mapVisualizations(c.getVisualization());
|
||||
this.edescriptor = new XScanDescriptor(c);
|
||||
this.vdescriptor = mapVisualizations(c.getVisualization());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a vdescriptor out of the scan description
|
||||
* @param vl
|
||||
* @return
|
||||
*/
|
||||
private VDescriptor mapVisualizations(List<Visualization> vl){
|
||||
VDescriptor vd = new VDescriptor();
|
||||
|
||||
@@ -113,8 +117,8 @@ public class XScanDescriptorProvider implements DescriptorProvider {
|
||||
String idY = getId(o);
|
||||
|
||||
// TODO Need to actually check if minX of
|
||||
lineplot.setMinX(lp.getOffset());
|
||||
lineplot.setMaxX(lp.getOffset()+lp.getSize());
|
||||
lineplot.setMinX(new Double(lp.getOffset()));
|
||||
lineplot.setMaxX(new Double(lp.getOffset()+lp.getSize()));
|
||||
lineplot.getData().add(new YSeries(idY));
|
||||
}
|
||||
}
|
||||
@@ -320,7 +324,7 @@ public class XScanDescriptorProvider implements DescriptorProvider {
|
||||
|
||||
@Override
|
||||
public VDescriptor getVDescriptor() {
|
||||
return null;
|
||||
return vdescriptor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ import com.google.common.eventbus.Subscribe;
|
||||
import ch.psi.fda.messages.DataMessage;
|
||||
import ch.psi.fda.messages.EndOfStreamMessage;
|
||||
import ch.psi.fda.messages.StreamDelimiterMessage;
|
||||
import ch.psi.fda.vdescriptor.Series;
|
||||
import ch.psi.fda.vdescriptor.VDescriptor;
|
||||
import ch.psi.fda.vdescriptor.XYSeries;
|
||||
import ch.psi.fda.vdescriptor.XYZSeries;
|
||||
import ch.psi.fda.vdescriptor.YSeries;
|
||||
import ch.psi.fda.vdescriptor.YZSeries;
|
||||
import ch.psi.plot.Plot;
|
||||
import ch.psi.plot.xy.LinePlot;
|
||||
import ch.psi.plot.xy.XYSeriesCollectionP;
|
||||
@@ -56,8 +62,61 @@ public class Visualizer {
|
||||
|
||||
private boolean first = true;
|
||||
|
||||
public Visualizer(List<SeriesDataFilter> filters){
|
||||
this.filters = filters;
|
||||
public Visualizer(VDescriptor vdescriptor){
|
||||
filters = new ArrayList<SeriesDataFilter>();
|
||||
|
||||
for(ch.psi.fda.vdescriptor.Plot vplot: vdescriptor.getPlots()){
|
||||
if(vplot instanceof ch.psi.fda.vdescriptor.LinePlot){
|
||||
ch.psi.fda.vdescriptor.LinePlot lp = (ch.psi.fda.vdescriptor.LinePlot) vplot;
|
||||
|
||||
// Create plot for visualization
|
||||
ch.psi.plot.xy.LinePlot plot = new ch.psi.plot.xy.LinePlot(lp.getTitle());
|
||||
|
||||
for(Series s: lp.getData()){
|
||||
if(s instanceof XYSeries){
|
||||
XYSeries sxy = (XYSeries)s;
|
||||
XYSeriesDataFilter filter = new XYSeriesDataFilter(sxy.getX(), sxy.getY(), plot);
|
||||
filter.setSeriesName(sxy.getY());
|
||||
filters.add(filter);
|
||||
}
|
||||
else if(s instanceof YSeries){
|
||||
YSeries sy = (YSeries)s;
|
||||
|
||||
XYSeriesArrayDataFilter filter = new XYSeriesArrayDataFilter(sy.getY(), plot);
|
||||
// filter.setMaxSeries(lp.getMaxSeries()*lp.getY().size()); // Workaround - keep for each array max series
|
||||
// filter.setOffset(lp.getOffset());
|
||||
// filter.setSize(lp.getSize());
|
||||
filter.setSeriesName(sy.getY());
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(vplot instanceof ch.psi.fda.vdescriptor.MatrixPlot){
|
||||
|
||||
// MatrixPlot does currently not support RegionPositioners because of the
|
||||
// plotting problems this would cause. If regions of the positioner have different
|
||||
// step sizes it is not easily possible (without (specialized) rasterization) to plot the data.
|
||||
|
||||
ch.psi.fda.vdescriptor.MatrixPlot lp = (ch.psi.fda.vdescriptor.MatrixPlot) vplot;
|
||||
MatrixPlotData data = new MatrixPlotData(lp.getMinX(), lp.getMaxX(), lp.getnX(), lp.getMinY(), lp.getMaxY(), lp.getnY());
|
||||
MatrixPlot plot = new MatrixPlot(lp.getTitle(), data);
|
||||
|
||||
for(Series s: lp.getData()){
|
||||
if(s instanceof XYZSeries){
|
||||
XYZSeries sxyz = (XYZSeries) s;
|
||||
filters.add(new XYZSeriesDataFilter(sxyz.getX(), sxyz.getY(), sxyz.getZ(), plot));
|
||||
|
||||
}
|
||||
else if(s instanceof YZSeries){
|
||||
YZSeries syz = (YZSeries) s;
|
||||
XYZSeriesArrayDataFilter filter = new XYZSeriesArrayDataFilter(syz.getY(), syz.getZ(), 0, 0, plot);
|
||||
filters.add(filter);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,9 +223,10 @@ public class Visualizer {
|
||||
try{
|
||||
double[] data = (double[]) message.getData(xyzfilter.getIdZ());
|
||||
double y = (Double) message.getData(xyzfilter.getIdY());
|
||||
int offset = xyzfilter.getOffset();
|
||||
int size = xyzfilter.getSize();
|
||||
for(int i=offset;i<offset+size; i++){
|
||||
// int offset = xyzfilter.getOffset();
|
||||
// int size = xyzfilter.getSize();
|
||||
// for(int i=offset;i<offset+size; i++){
|
||||
for(int i=0;i<data.length; i++){
|
||||
((MatrixPlot)xyzfilter.getPlot()).getData().addData(i, y, data[i]);
|
||||
}
|
||||
// Update data if update by point is enabled
|
||||
|
||||
@@ -37,8 +37,10 @@ import ch.psi.fda.messages.DataMessage;
|
||||
import ch.psi.fda.messages.EndOfStreamMessage;
|
||||
import ch.psi.fda.messages.Metadata;
|
||||
import ch.psi.fda.messages.StreamDelimiterMessage;
|
||||
import ch.psi.plot.xy.LinePlot;
|
||||
import ch.psi.plot.xyz.MatrixPlotData;
|
||||
import ch.psi.fda.vdescriptor.VDescriptor;
|
||||
import ch.psi.fda.vdescriptor.XYSeries;
|
||||
import ch.psi.fda.vdescriptor.XYZSeries;
|
||||
import ch.psi.fda.vdescriptor.YSeries;
|
||||
|
||||
/**
|
||||
* All test cases in this test class are meant to be executed manually Remove @Ignore
|
||||
@@ -66,12 +68,22 @@ public class DataVisualizerTest {
|
||||
|
||||
EventBus bus = new EventBus();
|
||||
|
||||
List<SeriesDataFilter> list = new ArrayList<>();
|
||||
list.add(new XYSeriesDataFilter("id1", "id2", new LinePlot("One")));
|
||||
list.add(new XYSeriesDataFilter("id1", "id3", new LinePlot("Two")));
|
||||
// List<SeriesDataFilter> list = new ArrayList<>();
|
||||
// list.add(new XYSeriesDataFilter(, new LinePlot("One")));
|
||||
// list.add(new XYSeriesDataFilter("id1", "id3", new LinePlot("Two")));
|
||||
|
||||
VDescriptor vdescriptor = new VDescriptor();
|
||||
|
||||
ch.psi.fda.vdescriptor.LinePlot plot = new ch.psi.fda.vdescriptor.LinePlot("One");
|
||||
plot.getData().add(new XYSeries("id1", "id2"));
|
||||
vdescriptor.getPlots().add(plot);
|
||||
|
||||
plot = new ch.psi.fda.vdescriptor.LinePlot("Two");
|
||||
plot.getData().add(new XYSeries("id1", "id3"));
|
||||
vdescriptor.getPlots().add(plot);
|
||||
|
||||
// Create visualizer
|
||||
Visualizer visualizer = new Visualizer(list);
|
||||
Visualizer visualizer = new Visualizer(vdescriptor);
|
||||
bus.register(visualizer);
|
||||
|
||||
JFrame f = new JFrame();
|
||||
@@ -112,11 +124,14 @@ public class DataVisualizerTest {
|
||||
|
||||
EventBus bus = new EventBus();
|
||||
|
||||
List<SeriesDataFilter> list = new ArrayList<>();
|
||||
list.add(new XYSeriesArrayDataFilter("id1", new LinePlot("One")));
|
||||
|
||||
VDescriptor vdescriptor = new VDescriptor();
|
||||
|
||||
ch.psi.fda.vdescriptor.LinePlot plot = new ch.psi.fda.vdescriptor.LinePlot("One");
|
||||
plot.getData().add(new YSeries("id1"));
|
||||
vdescriptor.getPlots().add(plot);
|
||||
|
||||
// Create visualizer
|
||||
Visualizer visualizer = new Visualizer(list);
|
||||
Visualizer visualizer = new Visualizer(vdescriptor);
|
||||
bus.register(visualizer);
|
||||
|
||||
JFrame f = new JFrame();
|
||||
@@ -154,8 +169,8 @@ public class DataVisualizerTest {
|
||||
@Test
|
||||
public void testRun2D() throws InterruptedException {
|
||||
|
||||
int nx = 1000;
|
||||
int ny = 1000;
|
||||
double nx = 1000;
|
||||
double ny = 1000;
|
||||
|
||||
List<Metadata> metadata = new ArrayList<>();
|
||||
metadata.add(new Metadata("id1"));
|
||||
@@ -165,12 +180,24 @@ public class DataVisualizerTest {
|
||||
// EventBus bus = new AsyncEventBus(Executors.newFixedThreadPool(1));
|
||||
EventBus bus = new EventBus();
|
||||
|
||||
List<SeriesDataFilter> list = new ArrayList<>();
|
||||
list.add(new XYSeriesDataFilter("id2", "id3", new LinePlot("Line")));
|
||||
list.add(new XYZSeriesDataFilter("id1", "id2", "id3", new ch.psi.plot.xyz.MatrixPlot("Matrix", new MatrixPlotData(1, nx, nx, 1, ny, ny))));
|
||||
|
||||
VDescriptor vdescriptor = new VDescriptor();
|
||||
|
||||
ch.psi.fda.vdescriptor.LinePlot lplot = new ch.psi.fda.vdescriptor.LinePlot("One");
|
||||
lplot.getData().add(new XYSeries("id2", "id3"));
|
||||
vdescriptor.getPlots().add(lplot);
|
||||
|
||||
ch.psi.fda.vdescriptor.MatrixPlot mplot = new ch.psi.fda.vdescriptor.MatrixPlot("One");
|
||||
mplot.setMinX(1.0);
|
||||
mplot.setMaxX(nx);
|
||||
mplot.setnX((int)nx);
|
||||
mplot.setMinY(1.0);
|
||||
mplot.setMaxY(ny);
|
||||
mplot.setnY((int)ny);
|
||||
mplot.getData().add(new XYZSeries("id1", "id2", "id3"));
|
||||
vdescriptor.getPlots().add(mplot);
|
||||
|
||||
// Create visualizer
|
||||
Visualizer visualizer = new Visualizer(list);
|
||||
Visualizer visualizer = new Visualizer(vdescriptor);
|
||||
bus.register(visualizer);
|
||||
|
||||
JFrame f = new JFrame();
|
||||
|
||||
Reference in New Issue
Block a user