use of cbit.plot.gui.PlotPane in project vcell by virtualcell.
the class ODETimePlotMultipleScansPanel method initialize.
/**
* Insert the method's description here.
* Creation date: (10/17/2005 11:37:52 PM)
* @exception org.vcell.util.DataAccessException The exception description.
*/
private void initialize() {
setLayout(new BorderLayout());
int scanCount = simulation.getScanCount();
plotPane = new PlotPane();
add(plotPane, BorderLayout.CENTER);
JPanel parameterPanel = new JPanel();
parameterPanel.setLayout(new BorderLayout());
JLabel label = new JLabel();
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setText("<html><b><u>Choose one or more Parameter Value Sets </u></b></html>");
label.setBorder(BorderFactory.createEmptyBorder(10, 4, 10, 4));
parameterPanel.add(label, BorderLayout.NORTH);
String[] scanParams = simulation.getMathOverrides().getScannedConstantNames();
Arrays.sort(scanParams);
class ScanChoicesTableModel extends javax.swing.table.AbstractTableModel {
String[] columnNames;
Double[][] rowData;
ScanChoicesTableModel(Double[][] argData, String[] argNames) {
columnNames = argNames;
rowData = argData;
}
public String getColumnName(int column) {
if (column == 0) {
return JOB_PLOT_NAME;
}
return columnNames[column - 1].toString();
}
public int getRowCount() {
return rowData.length;
}
public int getColumnCount() {
return columnNames.length + 1;
}
public Object getValueAt(int row, int col) {
if (col == 0) {
return new Integer(row);
}
return rowData[row][col - 1];
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return Number.class;
}
}
;
Double[][] values = new Double[scanCount][scanParams.length];
for (int i = 0; i < scanCount; i++) {
for (int j = 0; j < scanParams.length; j++) {
Expression scanConstantExp = simulation.getMathOverrides().getActualExpression(scanParams[j], i);
try {
values[i][j] = scanConstantExp.evaluateConstant();
} catch (DivideByZeroException e1) {
e1.printStackTrace();
} catch (ExpressionException e1) {
e1.printStackTrace();
}
}
}
ScanChoicesTableModel tm = new ScanChoicesTableModel(values, scanParams);
scanChoiceTable = new JTable(tm);
scanChoiceTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane scr = new JScrollPane(scanChoiceTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scr.setPreferredSize(new java.awt.Dimension(100, Math.min(150, scanChoiceTable.getPreferredSize().height + scanChoiceTable.getTableHeader().getPreferredSize().height + 5)));
parameterPanel.add(scr, BorderLayout.CENTER);
parameterPanel.setBorder(BorderFactory.createEtchedBorder());
TableColumn col = scanChoiceTable.getColumnModel().getColumn(0);
int width = 50;
col.setMinWidth(width);
col.setMaxWidth(width);
col.setPreferredWidth(width);
// put things together
add(parameterPanel, BorderLayout.SOUTH);
scanChoiceTable.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
updateScanParamChoices();
}
}
});
// scanChoiceTable.getSelectionModel().setSelectionInterval(0,0);
}
use of cbit.plot.gui.PlotPane in project vcell by virtualcell.
the class ConfidenceIntervalPlotPanel method getPlotPane.
private PlotPane getPlotPane() {
if (plotPane == null) {
plotPane = new PlotPane();
plotPane.setBackground(Color.white);
}
return plotPane;
}
use of cbit.plot.gui.PlotPane 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.gui.PlotPane in project vcell by virtualcell.
the class MultisourcePlotPane method getplotPane.
/**
* Return the plotPane property value.
* @return cbit.plot.PlotPane
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private PlotPane getplotPane() {
if (ivjplotPane == null) {
try {
ivjplotPane = new PlotPane();
ivjplotPane.setName("plotPane");
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
return ivjplotPane;
}
use of cbit.plot.gui.PlotPane in project vcell by virtualcell.
the class DisplayImageOp method displayImage.
public void displayImage(final Image image, String title, WindowListener listener) {
final ImagePlaneManagerPanel imagePanel = new ImagePlaneManagerPanel();
double[] doublePixels = image.getDoublePixels();
double minPixel = Double.MAX_VALUE;
double maxPixel = -Double.MAX_VALUE;
for (int i = 0; i < doublePixels.length; i++) {
double pixel = doublePixels[i];
doublePixels[i] = pixel;
minPixel = Math.min(minPixel, pixel);
maxPixel = Math.max(maxPixel, pixel);
}
Range newRange = new Range(minPixel, maxPixel);
SourceDataInfo source = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, doublePixels, image.getExtent(), image.getOrigin(), newRange, 0, image.getNumX(), 1, image.getNumY(), image.getNumX(), image.getNumZ(), image.getNumX() * image.getNumY());
imagePanel.setDisplayAdapterServicePanelVisible(true);
imagePanel.setCurveValueProvider(new CurveValueProvider() {
@Override
public void curveAdded(Curve curve) {
System.out.println("called curveAdded(" + curve + "), do nothing for now");
}
@Override
public void curveRemoved(Curve curve) {
System.out.println("called curveRemoved(" + curve + ")");
}
@Override
public String getCurveValue(CurveSelectionInfo csi) {
System.out.println("called getCurveValue(CurveSelectionInfo " + csi);
return null;
}
@Override
public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
System.out.println("called getInitialCurveSelection(tool=" + tool + ", coord=" + wc + ")");
return null;
}
@Override
public boolean isAddControlPointOK(int tool, Coordinate wc, Curve addedToThisCurve) {
System.out.println("called isAddControlPointOK");
return true;
}
@Override
public boolean providesInitalCurve(int tool, Coordinate wc) {
System.out.println("called providesInitialCurve(tool=" + tool + " (TOOL_LINE=" + CurveEditorTool.TOOL_LINE + "), coord=" + wc);
return false;
}
@Override
public void setDescription(Curve curve) {
System.out.println("called setDescription(" + curve + ")");
curve.setDescription(CurveValueProvider.DESCRIPTION_VOLUME);
}
@Override
public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
System.out.println("called find ChomboCurveSelectionInfoForPoint(coord=" + ci + ")");
return null;
}
});
DisplayAdapterService das = imagePanel.getDisplayAdapterServicePanel().getDisplayAdapterService();
das.setValueDomain(null);
das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createGraySpecialColors(), DisplayAdapterService.GRAY);
das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), DisplayAdapterService.BLUERED);
das.setActiveColorModelID(DisplayAdapterService.BLUERED);
final JFrame jframe = new JFrame();
jframe.setTitle(title);
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints imageConstraints = new GridBagConstraints();
imageConstraints.gridx = 0;
imageConstraints.gridy = 0;
imageConstraints.weightx = 1.0;
imageConstraints.weighty = 1.0;
imageConstraints.fill = GridBagConstraints.BOTH;
panel.add(imagePanel, imageConstraints);
JButton plotButton = new JButton("plot");
plotButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Curve curve = imagePanel.getCurveRenderer().getSelection().getCurve();
VariableType variableType = VariableType.VOLUME;
Curve samplerCurve = curve.getSampledCurve();
samplerCurve.setDescription(curve.getDescription());
VCImage vcImage = new VCImageUncompressed(null, new byte[image.getISize().getXYZ()], image.getExtent(), image.getISize().getX(), image.getISize().getY(), image.getISize().getZ());
int dimension = 1 + (image.getISize().getY() > 0 ? 1 : 0) + (image.getISize().getZ() > 0 ? 1 : 0);
RegionImage regionImage = new RegionImage(vcImage, dimension, image.getExtent(), image.getOrigin(), RegionImage.NO_SMOOTHING);
CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(image.getOrigin(), image.getExtent(), image.getISize(), regionImage);
SpatialSelectionVolume ssVolume = new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), variableType, mesh);
String varName = "var";
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[] { new VolVariable(varName, null) };
PlotData plotData = getLineScan(ssVolume, image, mesh);
PlotPane plotPane = new PlotPane();
DataSymbolMetadataResolver resolver = null;
Plot2D plot2D = new Plot2D(symbolTableEntries, resolver, new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
plotPane.setPlot2D(plot2D);
DialogUtils.showComponentCloseDialog(jframe, plotPane, "plot");
} catch (ImageException | IOException | DataAccessException | MathException e1) {
e1.printStackTrace();
}
}
});
GridBagConstraints plotButtonConstraints = new GridBagConstraints();
plotButtonConstraints.gridx = 0;
plotButtonConstraints.gridy = 1;
panel.add(plotButton, plotButtonConstraints);
jframe.getContentPane().add(panel);
jframe.setSize(500, 500);
jframe.addWindowListener(listener);
jframe.setVisible(true);
imagePanel.setSourceDataInfo(source);
}
Aggregations