use of cbit.vcell.export.server.RasterSpecs in project vcell by virtualcell.
the class PDEDataViewer method sendTimeSeriesImageJ.
// private Hashtable<String, JLabel> sendTimeSeriesLabels = new Hashtable<>();
// @Override
// public void exportMessage(ExportEvent event) {
// super.exportMessage(event);
// if(sendTimeSeriesLabels.size() > 0){
// JLabel messgLabel = sendTimeSeriesLabels.values().iterator().next();
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// messgLabel.setText(event.getMessageData().toString());
// }
// });
// }
// }
private void sendTimeSeriesImageJ() {
final JPanel mainJPanel = new JPanel();
BoxLayout mainBL = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
mainJPanel.setLayout(mainBL);
final boolean[] response = new boolean[] { false };
MiniTimePanel timeJPanel = new MiniTimePanel();
final JLabel messgLabel = new JLabel("time points to export:" + (timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1));
JRadioButton slicebtn = new JRadioButton("Slice " + getPDEDataContextPanel1().getSlice() + " only");
slicebtn.setSelected(true);
JPanel messageAndSlicePanel = null;
if (getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3) {
messageAndSlicePanel = new JPanel();
((FlowLayout) messageAndSlicePanel.getLayout()).setAlignment(FlowLayout.LEFT);
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButton allslicebtn = new JRadioButton("All slices");
buttonGroup.add(slicebtn);
buttonGroup.add(allslicebtn);
messageAndSlicePanel.add(messgLabel);
messageAndSlicePanel.add(slicebtn);
messageAndSlicePanel.add(allslicebtn);
}
ActionListener okAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((Double) timeJPanel.jcb_time_begin.getSelectedItem()).compareTo((Double) timeJPanel.jcb_time_end.getSelectedItem()) > 0) {
PopupGenerator.showErrorDialog(PDEDataViewer.this, "Selected 'Begin Time' must be less than or equal to 'End Time'");
return;
}
response[0] = true;
BeanUtils.disposeParentWindow(mainJPanel);
}
};
ActionListener cancelAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
BeanUtils.disposeParentWindow(mainJPanel);
}
};
final OkCancelSubPanel okCancelJPanel = new OkCancelSubPanel(okAction, cancelAction);
ActionListener rangeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int range = timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1;
okCancelJPanel.okButton.setEnabled(range > 0);
messgLabel.setText((range < 0 ? "Error: begin time must be < end time" : "time points to export:" + (range)));
}
};
timeJPanel.jcb_time_end.addActionListener(rangeListener);
timeJPanel.jcb_time_begin.addActionListener(rangeListener);
okCancelJPanel.okButton.setEnabled(true);
mainJPanel.add(timeJPanel);
mainJPanel.add((messageAndSlicePanel == null ? messgLabel : messageAndSlicePanel));
mainJPanel.add(okCancelJPanel);
Frame dialogOwner = JOptionPane.getFrameForComponent(this);
JOptionPane inputDialog = new JOptionPane(mainJPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[0]);
final JDialog d = inputDialog.createDialog(dialogOwner, "'" + getSimulationModelInfo().getContextName() + "':'" + getSimulationModelInfo().getSimulationName() + "':'" + getPdeDataContext().getVariableName() + "'");
d.setResizable(true);
d.setModal(true);
d.pack();
d.setVisible(true);
// }
if (!response[0]) {
return;
}
ExportSpecs exportSpecs = new ExportSpecs(getPdeDataContext().getVCDataIdentifier(), ExportFormat.IMAGEJ, new VariableSpecs(new String[] { getPdeDataContext().getDataIdentifier().getName() }, ExportConstants.VARIABLE_MULTI), new TimeSpecs(timeJPanel.jcb_time_begin.getSelectedIndex(), timeJPanel.jcb_time_end.getSelectedIndex(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE), new GeometrySpecs(null, getPDEDataContextPanel1().getNormalAxis(), getPDEDataContextPanel1().getSlice(), (slicebtn.isSelected() ? ExportConstants.GEOMETRY_SLICE : ExportConstants.GEOMETRY_FULL)), new RasterSpecs(ExportConstants.NRRD_BY_VARIABLE, false), getSimulationModelInfo().getSimulationName(), getSimulationModelInfo().getContextName());
getDataViewerManager().startExport(this, ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext(), exportSpecs);
}
Aggregations