use of cbit.plot.SingleXPlot2D in project vcell by virtualcell.
the class ODETimePlotMultipleScansPanel method updateScanParamChoices.
/**
* Insert the method's description here.
* Creation date: (10/18/2005 12:44:06 AM)
*/
private void updateScanParamChoices() {
AsynchClientTask task1 = new AsynchClientTask("get ode results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
int[] jobIndexes = scanChoiceTable.getSelectedRows();
VCSimulationIdentifier vcSimulationIdentifier = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
int plotCount = jobIndexes.length * variableNames.length;
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
double[][] dataValues = new double[plotCount + 1][];
PlotData[] plotDatas = new PlotData[plotCount];
String[] plotNames = new String[plotCount];
int plotIndex = 0;
dataValues[0] = null;
for (int ji = 0; ji < jobIndexes.length; ji++) {
int jobIndex = jobIndexes[ji];
final VCDataIdentifier vcdid = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
ODEDataManager odeDatamanager = ((ODEDataManager) dataManager).createNewODEDataManager(vcdid);
ODESolverResultSet odeSolverResultSet = odeDatamanager.getODESolverResultSet();
if (ji == 0) {
plotPane.setStepViewVisible(simulation.getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver(), odeSolverResultSet.isMultiTrialData());
hashTable.put("bMultiTrial", new Boolean(odeSolverResultSet.isMultiTrialData()));
}
double[] tdata = null;
if (!odeSolverResultSet.isMultiTrialData()) {
int tcol = odeSolverResultSet.findColumn(ReservedVariable.TIME.getName());
tdata = odeSolverResultSet.extractColumn(tcol);
if (dataValues[0] == null) {
dataValues[0] = tdata;
}
}
for (int v = 0; v < variableNames.length; v++) {
String varname = variableNames[v];
int varcol = odeSolverResultSet.findColumn(varname);
double[] vdata = odeSolverResultSet.extractColumn(varcol);
if (!odeSolverResultSet.isMultiTrialData()) {
dataValues[plotIndex + 1] = vdata;
// plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
plotDatas[plotIndex] = new PlotData(tdata, vdata);
// symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
} else {
Point2D[] histogram = ODESolverPlotSpecificationPanel.generateHistogram(vdata);
double[] x = new double[histogram.length];
double[] y = new double[histogram.length];
for (int j = 0; j < histogram.length; j++) {
x[j] = histogram[j].getX();
y[j] = histogram[j].getY();
}
plotDatas[plotIndex] = new PlotData(x, y);
}
plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
plotIndex++;
}
}
hashTable.put("dataValues", dataValues);
hashTable.put("plotDatas", plotDatas);
hashTable.put("plotNames", plotNames);
hashTable.put("symbolTableEntries", symbolTableEntries);
}
};
AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
double[][] dataValues = (double[][]) hashTable.get("dataValues");
PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
String[] plotNames = (String[]) hashTable.get("plotNames");
SymbolTableEntry[] symbolTableEntries = (SymbolTableEntry[]) hashTable.get("symbolTableEntries");
if (plotDatas == null || plotDatas.length == 0 || (plotDatas.length == 1 && plotDatas[0] == null) || plotNames == null) {
plotPane.setPlot2D(null);
return;
}
Plot2D plot2D = null;
if (hashTable.get("bMultiTrial") instanceof Boolean && (Boolean) hashTable.get("bMultiTrial")) {
plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Probability Distribution of Species", "Number of Particles", "" });
} else if (simulation.getSolverTaskDescription().getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
} else {
plot2D = new SingleXPlot2D(symbolTableEntries, null, ReservedVariable.TIME.getName(), plotNames, dataValues);
}
plotPane.setPlot2D(plot2D);
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.plot.SingleXPlot2D in project vcell by virtualcell.
the class PdeTimePlotMultipleVariablesPanel method initialize.
private void initialize() {
VariableType varType = multiTimePlotHelper.getPdeDatacontext().getDataIdentifier().getVariableType();
String varName = multiTimePlotHelper.getPdeDatacontext().getVariableName();
String[] plotNames = new String[pointVector.size()];
final SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotNames.length];
DefaultListModel<String> pointListModel = new DefaultListModel<String>();
for (int i = 0; i < pointVector.size(); i++) {
Coordinate tp = null;
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector.get(i);
tp = ssv.getCurveSelectionInfo().getCurve().getBeginningCoordinate();
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector.get(i);
double midU = ssm.getCurveSelectionInfo().getCurveUfromSelectionU(.5);
tp = ((SampledCurve) ssm.getCurveSelectionInfo().getCurve()).coordinateFromNormalizedU(midU);
}
plotNames[i] = varName + " at P[" + i + "]";
String point = "P[" + i + "] (" + niceCoordinateString(tp) + ")";
pointListModel.addElement(point);
if (multiTimePlotHelper.getsimulation() != null) {
symbolTableEntries[0] = multiTimePlotHelper.getsimulation().getMathDescription().getEntry(varName);
} else {
System.out.println("PdeTimePlotMultipleVariablesPanel.initialize() adding artificial symbol table entries for field data");
SimpleSymbolTable simpleSymbolTable = new SimpleSymbolTable(new String[] { varName });
symbolTableEntries[0] = simpleSymbolTable.getEntry(varName);
}
}
pointJList.setModel(pointListModel);
pointJList.setForeground(variableJList.getForeground());
pointJList.setVisibleRowCount(3);
pointJList.setBackground(getBackground());
pointJList.setSelectionBackground(getBackground());
pointJList.setSelectionForeground(Color.black);
plotPane = new PlotPane();
double[][] plotDatas = tsJobResultsNoStats.getTimesAndValuesForVariable(varName);
Plot2D plot2D = new SingleXPlot2D(symbolTableEntries, multiTimePlotHelper.getDataSymbolMetadataResolver(), ReservedVariable.TIME.getName(), plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
plotPane.setPlot2D(plot2D);
DataIdentifier[] dis = (multiTimePlotHelper.getCopyOfDisplayedDataIdentifiers() != null ? multiTimePlotHelper.getCopyOfDisplayedDataIdentifiers() : DataIdentifier.collectSortedSimilarDataTypes(multiTimePlotHelper.getVariableType(), multiTimePlotHelper.getPdeDatacontext().getDataIdentifiers()));
Arrays.sort(dis, new Comparator<DataIdentifier>() {
public int compare(DataIdentifier o1, DataIdentifier o2) {
int bEqualIgnoreCase = o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
if (bEqualIgnoreCase == 0) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
return bEqualIgnoreCase;
}
});
variableJList.setListData(dis);
initVariableListSelected(variableJList, multiTimePlotHelper.getPdeDatacontext().getDataIdentifier());
variableJList.setCellRenderer(multiTimePlotHelper.getListCellRenderer());
setLayout(new GridBagLayout());
JLabel label = new JLabel("Selected Points");
label.setFont(label.getFont().deriveFont(Font.BOLD));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new java.awt.Insets(15, 10, 4, 4);
add(label, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.gridheight = 4;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new java.awt.Insets(0, 4, 0, 0);
add(plotPane, gbc);
JScrollPane sp = new JScrollPane(pointJList);
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.weighty = 0.5;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new java.awt.Insets(4, 10, 4, 4);
add(sp, gbc);
label = new JLabel("Y Axis");
label.setFont(label.getFont().deriveFont(Font.BOLD));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new java.awt.Insets(4, 10, 4, 4);
add(label, gbc);
sp = new JScrollPane(variableJList);
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 0.2;
gbc.weighty = 1;
gbc.insets = new java.awt.Insets(4, 10, 50, 4);
gbc.fill = java.awt.GridBagConstraints.BOTH;
add(sp, gbc);
variableJList.addListSelectionListener(eventHandler);
multiTimePlotHelper.addPropertyChangeListener(eventHandler);
}
use of cbit.plot.SingleXPlot2D in project vcell by virtualcell.
the class PdeTimePlotMultipleVariablesPanel method showTimePlot.
public void showTimePlot() {
if ((plotChangeTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, plotChangeTimer, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e2) {
showTimePlot();
}
}, "PdeTimePlotMultipleVariablesPanel update...")) != null) {
return;
}
VariableType varType = multiTimePlotHelper.getVariableType();
Object[] selectedValues = variableJList.getSelectedValues();
DataIdentifier[] selectedDataIdentifiers = new DataIdentifier[selectedValues.length];
System.arraycopy(selectedValues, 0, selectedDataIdentifiers, 0, selectedValues.length);
if (selectedDataIdentifiers.length > 1) {
for (DataIdentifier selectedDataIdentifier : selectedDataIdentifiers) {
if (!selectedDataIdentifier.getVariableType().getVariableDomain().equals(varType.getVariableDomain())) {
PopupGenerator.showErrorDialog(this, "Please choose VOLUME variables or MEMBRANE variables only");
variableJList.clearSelection();
variableJList.setSelectedValue(multiTimePlotHelper.getPdeDatacontext().getVariableName(), true);
return;
}
}
}
try {
final int numSelectedVariables = selectedDataIdentifiers.length;
final int numSelectedSpatialPoints = pointVector.size();
int[][] indices = new int[numSelectedVariables][numSelectedSpatialPoints];
//
for (int i = 0; i < numSelectedSpatialPoints; i++) {
for (int v = 0; v < numSelectedVariables; v++) {
if (selectedDataIdentifiers[v].getVariableType().equals(varType)) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector.get(i);
indices[v][i] = ssm.getIndex(0);
}
} else {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector2.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector2.get(i);
indices[v][i] = ssm.getIndex(0);
}
}
}
}
final String[] selectedVarNames = new String[numSelectedVariables];
for (int i = 0; i < selectedVarNames.length; i++) {
selectedVarNames[i] = selectedDataIdentifiers[i].getName();
}
final double[] timePoints = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(selectedVarNames, indices, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
if (!tsjs.getVcDataJobID().isBackgroundTask()) {
throw new RuntimeException("Use getTimeSeries(...) if not a background job");
}
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(PDEDataViewer.StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
AsynchClientTask task2 = new AsynchClientTask("showing time plot", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
int plotCount = numSelectedVariables * numSelectedSpatialPoints;
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
String[] plotNames = new String[plotCount];
double[][] plotDatas = new double[1 + plotCount][];
plotDatas[0] = timePoints;
int plotIndex = 0;
for (int v = 0; v < numSelectedVariables; v++) {
String varName = selectedVarNames[v];
double[][] data = tsJobResultsNoStats.getTimesAndValuesForVariable(varName);
for (int i = 1; i < data.length; i++) {
symbolTableEntries[plotIndex] = multiTimePlotHelper.getsimulation().getMathDescription().getEntry(varName);
plotNames[plotIndex] = varName + " at P[" + (i - 1) + "]";
plotDatas[plotIndex + 1] = data[i];
plotIndex++;
}
}
Plot2D plot2D = new SingleXPlot2D(symbolTableEntries, multiTimePlotHelper.getDataSymbolMetadataResolver(), ReservedVariable.TIME.getName(), plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
plotPane.setPlot2D(plot2D);
}
};
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2 }, false, true, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.plot.SingleXPlot2D in project vcell by virtualcell.
the class ODESolverPlotSpecificationPanel method regeneratePlot2D.
/**
* Comment
*/
private void regeneratePlot2D() throws ExpressionException, ObjectNotFoundException {
if (getMyDataInterface() == null) {
return;
}
if (!getMyDataInterface().isMultiTrialData()) {
if (getXAxisComboBox_frm().getSelectedIndex() < 0) {
return;
} else {
// double[] xData = getOdeSolverResultSet().extractColumn(getPlottableColumnIndices()[getXIndex()]);
// getUnfilteredSortedXAxisNames
double[] xData = getMyDataInterface().extractColumn((String) getXAxisComboBox_frm().getSelectedItem());
double[][] allData = new double[((DefaultListModel) getYAxisChoice().getModel()).size() + 1][xData.length];
String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
allData[0] = xData;
double[] yData = new double[xData.length];
double currParamValue = 0.0;
double deltaParamValue = 0.0;
// Extrapolation calculations!
if (getSensitivityParameter() != null) {
int val = getSensitivityParameterSlider().getValue();
double nominalParamValue = getSensitivityParameter().getConstantValue();
double pMax = nominalParamValue * 1.1;
double pMin = nominalParamValue * 0.9;
int iMax = getSensitivityParameterSlider().getMaximum();
int iMin = getSensitivityParameterSlider().getMinimum();
double slope = (pMax - pMin) / (iMax - iMin);
currParamValue = slope * val + pMin;
deltaParamValue = currParamValue - nominalParamValue;
getMaxLabel().setText(Double.toString(pMax));
getMinLabel().setText(Double.toString(pMin));
getCurLabel().setText(Double.toString(currParamValue));
}
if (!getLogSensCheckbox().getModel().isSelected()) {
// When log sensitivity check box is not selected.
for (int i = 0; i < allData.length - 1; i++) {
// If sensitivity analysis is enabled, extrapolate values for State vars and non-sensitivity functions
if (getSensitivityParameter() != null) {
ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
double[] sens = getSensValues(cd);
yData = getMyDataInterface().extractColumn(cd.getName());
// sens array != null for non-sensitivity state vars and functions, so extrapolate
if (sens != null) {
for (int j = 0; j < sens.length; j++) {
if (Math.abs(yData[j]) > 1e-6) {
// away from zero, exponential extrapolation
allData[i + 1][j] = yData[j] * Math.exp(deltaParamValue * sens[j] / yData[j]);
} else {
// around zero - linear extrapolation
allData[i + 1][j] = yData[j] + sens[j] * deltaParamValue;
}
}
// sens array == null for sensitivity state vars and functions, so don't change their original values
} else {
allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
}
} else {
// No sensitivity analysis case, so do not alter the original values for any variable or function
allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
}
yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
}
} else {
// When log sensitivity checkbox is selected.
// Get sensitivity parameter and its value to compute log sensitivity
Constant sensParam = getSensitivityParameter();
double sensParamValue = sensParam.getConstantValue();
getJLabelSensitivityParameter().setText("Sensitivity wrt Parameter " + sensParam.getName());
//
for (int i = 0; i < allData.length - 1; i++) {
// Finding sensitivity var column for each column in result set.
ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
String sensVarName = null;
ColumnDescription[] allColumnDescriptions = getMyDataInterface().getAllColumnDescriptions();
for (int j = 0; j < allColumnDescriptions.length; j++) {
String obj = "sens_" + cd.getName() + "_wrt_" + sensParam.getName();
if (allColumnDescriptions[j].getName().equals(obj)) {
sensVarName = obj;
break;
}
}
int sensIndex = -1;
if (sensVarName != null) {
for (int j = 0; j < ((DefaultListModel) getYAxisChoice().getModel()).getSize(); j++) {
if (((String) ((DefaultListModel) getYAxisChoice().getModel()).get(j)).equals(sensVarName)) {
sensIndex = j;
break;
}
}
}
yData = getMyDataInterface().extractColumn(cd.getName());
// If sensitivity var exists, compute log sensitivity
if (sensVarName != null) {
double[] sens = getMyDataInterface().extractColumn(sensVarName);
for (int k = 0; k < yData.length; k++) {
// Extrapolated statevars and functions
if (Math.abs(yData[k]) > 1e-6) {
// away from zero, exponential extrapolation
allData[i + 1][k] = yData[k] * Math.exp(deltaParamValue * sens[k] / yData[k]);
} else {
// around zero - linear extrapolation
allData[i + 1][k] = yData[k] + sens[k] * deltaParamValue;
}
// Log sensitivity for the state variables and functions
// default if floating point problems
double logSens = 0.0;
if (Math.abs(yData[k]) > 0) {
double tempLogSens = sens[k] * sensParamValue / yData[k];
if (tempLogSens != Double.NEGATIVE_INFINITY && tempLogSens != Double.POSITIVE_INFINITY && tempLogSens != Double.NaN) {
logSens = tempLogSens;
}
}
if (sensIndex > -1) {
allData[sensIndex + 1][k] = logSens;
}
}
// If sensitivity var does not exist, retain original value of column (var or function).
} else {
if (!cd.getName().startsWith("sens_")) {
allData[i + 1] = yData;
}
}
yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
}
}
String title = "";
String xLabel = (String) getXAxisComboBox_frm().getSelectedItem();
String yLabel = "";
if (yNames.length == 1) {
yLabel = yNames[0];
}
// Update Sensitivity parameter label depending on whether Log sensitivity check box is checked or not.
if (!getLogSensCheckbox().getModel().isSelected()) {
getJLabelSensitivityParameter().setText("");
}
SymbolTableEntry[] symbolTableEntries = null;
if (getSymbolTable() != null && yNames != null && yNames.length > 0) {
symbolTableEntries = new SymbolTableEntry[yNames.length];
for (int i = 0; i < yNames.length; i += 1) {
SymbolTableEntry ste = getSymbolTable().getEntry(yNames[i]);
symbolTableEntries[i] = ste;
}
}
SingleXPlot2D plot2D = new SingleXPlot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), xLabel, yNames, allData, new String[] { title, xLabel, yLabel });
refreshVisiblePlots(plot2D);
// here fire "singleXPlot2D" event, ODEDataViewer's event handler listens to it.
setPlot2D(plot2D);
}
} else // end of none MultitrialData
// multitrial data
{
// a column of data get from ODESolverRestultSet, which is actually the results for a specific variable during multiple trials
double[] rowData = new double[getMyDataInterface().getRowCount()];
PlotData[] plotData = new PlotData[((DefaultListModel) getYAxisChoice().getModel()).size()];
for (int i = 0; i < plotData.length; i++) {
ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
rowData = getMyDataInterface().extractColumn(cd.getName());
Point2D[] histogram = generateHistogram(rowData);
double[] x = new double[histogram.length];
double[] y = new double[histogram.length];
for (int j = 0; j < histogram.length; j++) {
x[j] = histogram[j].getX();
y[j] = histogram[j].getY();
}
plotData[i] = new PlotData(x, y);
}
SymbolTableEntry[] symbolTableEntries = null;
if (getSymbolTable() != null && ((DefaultListModel) getYAxisChoice().getModel()).size() > 0) {
symbolTableEntries = new SymbolTableEntry[((DefaultListModel) getYAxisChoice().getModel()).size()];
for (int i = 0; i < symbolTableEntries.length; i += 1) {
symbolTableEntries[i] = getSymbolTable().getEntry((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
}
}
String title = "Probability Distribution of Species";
String xLabel = "Number of Particles";
String yLabel = "";
String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
((DefaultListModel) getYAxisChoice().getModel()).copyInto(yNames);
Plot2D plot2D = new Plot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), yNames, plotData, new String[] { title, xLabel, yLabel });
refreshVisiblePlots(plot2D);
setPlot2D(plot2D);
}
}
use of cbit.plot.SingleXPlot2D in project vcell by virtualcell.
the class BNGDataPlotPanel method selectionModel1_ValueChanged.
/**
* Comment
*/
private void selectionModel1_ValueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) throws Exception {
int firstIndex = listSelectionEvent.getFirstIndex();
int lastIndex = listSelectionEvent.getLastIndex();
if (firstIndex < 0 || lastIndex < 0) {
return;
}
Object[] selectedValues = getJList1().getSelectedValues();
int numSelected = selectedValues.length;
if (numSelected == 0) {
return;
}
double[][] dataValues = new double[1 + numSelected][];
String[] names = new String[numSelected];
int t_index = fieldOdeSolverResultSet.findColumn("t");
dataValues[0] = fieldOdeSolverResultSet.extractColumn(t_index);
for (int i = 0; i < numSelected; i++) {
names[i] = (String) selectedValues[i];
int index = fieldOdeSolverResultSet.findColumn(names[i]);
dataValues[i + 1] = fieldOdeSolverResultSet.extractColumn(index);
}
boolean[] visibleFlags = new boolean[dataValues.length];
Arrays.fill(visibleFlags, true);
String[] labels = { "", "t", "" };
Plot2D plot2D = new SingleXPlot2D(null, null, "Time", names, dataValues, labels, visibleFlags);
getplotPane().setPlot2D(plot2D);
return;
}
Aggregations