use of cbit.vcell.model.Feature in project vcell by virtualcell.
the class StructurePropertiesPanel method initialize.
/**
* Initialize the class.
*/
private void initialize() {
try {
setName(this.getClass().getName());
setLayout(new GridBagLayout());
nameTextField = new JTextField();
nameTextField.setEditable(false);
nameTextField.addActionListener(eventHandler);
sizeTextField = new JTextField();
sizeTextField.setEditable(false);
voltageLabel = new JLabel("Voltage Variable Name");
voltageTextField = new JTextField();
voltageTextField.setEditable(false);
electrophysiologyLabel = new JLabel("<html><u>Electrophysiology</u></html>");
electrophysiologyExplanationLabel = new JLabel();
positiveFeatureLabel = new JLabel("Positive (inside feature)");
positiveFeatureComboBox = new JComboBox<String>();
negativeFeatureLabel = new JLabel("Negative (outside feature)");
negativeFeatureComboBox = new JComboBox<String>();
annotationTextArea = new javax.swing.JTextArea("", 1, 30);
annotationTextArea.setLineWrap(true);
annotationTextArea.setWrapStyleWord(true);
annotationTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
annotationTextArea.setEditable(false);
int gridy = 0;
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel label = new JLabel("<html><u>Select only one structure to edit properties</u></html>");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(label.getFont().deriveFont(Font.BOLD));
add(label, gbc);
// name
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
label = new JLabel("Structure Name");
add(label, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
add(nameTextField, gbc);
// size
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
label = new JLabel("Size Variable Name");
add(label, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
add(sizeTextField, gbc);
// electrophysiology
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
electrophysiologyLabel.setHorizontalAlignment(SwingConstants.CENTER);
electrophysiologyLabel.setFont(label.getFont().deriveFont(Font.BOLD));
add(electrophysiologyLabel, gbc);
// voltage
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(voltageLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
voltageTextField.setForeground(Color.blue);
add(voltageTextField, gbc);
// positive (feature) voltage
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(positiveFeatureLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
positiveFeatureComboBox.setForeground(Color.blue);
add(positiveFeatureComboBox, gbc);
// negative (feature) voltage
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
add(negativeFeatureLabel, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
negativeFeatureComboBox.setForeground(Color.blue);
add(negativeFeatureComboBox, gbc);
// electrophysiology
gbc = new java.awt.GridBagConstraints();
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 2;
gbc.insets = new java.awt.Insets(0, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
electrophysiologyExplanationLabel.setHorizontalAlignment(SwingConstants.CENTER);
// electrophysiologyExplanationLabel.setFont(label.getFont().deriveFont(Font.BOLD));
add(electrophysiologyExplanationLabel, gbc);
// annotation
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(9, 8, 4, 6);
gbc.anchor = GridBagConstraints.FIRST_LINE_END;
add(new JLabel("Annotation "), gbc);
javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.weighty = 1;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
add(jsp, gbc);
DefaultListCellRenderer comboBoxListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Feature) {
setText(((Structure) value).getName());
}
return this;
}
};
positiveFeatureComboBox.setRenderer(comboBoxListCellRenderer);
negativeFeatureComboBox.setRenderer(comboBoxListCellRenderer);
setBackground(Color.white);
initConnections();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.model.Feature in project vcell by virtualcell.
the class StructurePropertiesPanel method setModel.
public void setModel(Model model) {
fieldModel = model;
DefaultComboBoxModel<String> dataModelPos = new DefaultComboBoxModel<String>();
DefaultComboBoxModel<String> dataModelNeg = new DefaultComboBoxModel<String>();
dataModelPos.addElement("");
dataModelNeg.addElement("");
for (Structure s : model.getStructures()) {
if (s instanceof Feature) {
dataModelPos.addElement(s.getName());
dataModelNeg.addElement(s.getName());
}
}
// fill the comboBoxes with feature names from the model.
positiveFeatureComboBox.setModel(dataModelPos);
// if selected structure is a membrane, if it has +ve/-ve feature set, set the comboBox with that selection.
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
if (fieldModel.getElectricalTopology().getPositiveFeature(membrane) != null) {
positiveFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getPositiveFeature(membrane).getName());
}
}
negativeFeatureComboBox.setModel(dataModelNeg);
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
if (fieldModel.getElectricalTopology().getNegativeFeature(membrane) != null) {
negativeFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getNegativeFeature(membrane).getName());
}
}
}
use of cbit.vcell.model.Feature in project vcell by virtualcell.
the class StructurePropertiesPanel method updateInterface.
/**
* Comment
*/
private void updateInterface() {
boolean bNonNullStructure = structure != null && fieldModel != null;
nameTextField.setEditable(bNonNullStructure);
annotationTextArea.setEditable(bNonNullStructure);
boolean bMembrane = bNonNullStructure && structure instanceof Membrane;
voltageLabel.setVisible(bMembrane);
voltageTextField.setVisible(bMembrane);
electrophysiologyLabel.setVisible(bMembrane);
positiveFeatureLabel.setVisible(bMembrane);
positiveFeatureComboBox.setVisible(bMembrane);
negativeFeatureLabel.setVisible(bMembrane);
negativeFeatureComboBox.setVisible(bMembrane);
electrophysiologyExplanationLabel.setVisible(bMembrane);
if (bNonNullStructure) {
nameTextField.setText(structure.getName());
annotationTextArea.setText(fieldModel.getVcMetaData().getFreeTextAnnotation(structure));
StructureSize structureSize = structure.getStructureSize();
sizeTextField.setText(structureSize.getName() + " [" + structureSize.getUnitDefinition().getSymbolUnicode() + "]");
if (bMembrane) {
Membrane membrane = (Membrane) structure;
MembraneVoltage memVoltage = membrane.getMembraneVoltage();
voltageTextField.setText(memVoltage.getName() + " [" + memVoltage.getUnitDefinition().getSymbolUnicode() + "]");
// if membrane has +ve/-ve feature set, set the comboBox with that selection.
ElectricalTopology electricalTopology = fieldModel.getElectricalTopology();
Feature positiveFeature = electricalTopology.getPositiveFeature(membrane);
if (positiveFeature != null) {
positiveFeatureComboBox.setSelectedItem(positiveFeature.getName());
}
Feature negativeFeature = electricalTopology.getNegativeFeature(membrane);
if (negativeFeature != null) {
negativeFeatureComboBox.setSelectedItem(negativeFeature.getName());
}
this.electrophysiologyExplanationLabel.setText(getExplanationText());
}
} else {
annotationTextArea.setText(null);
nameTextField.setText(null);
sizeTextField.setText(null);
voltageTextField.setText(null);
}
}
use of cbit.vcell.model.Feature in project vcell by virtualcell.
the class ReactionCartoonTool method lineAction.
private void lineAction(ReactionStep reactionStart, Structure endStructure) throws Exception {
Structure startStructure = reactionStart.getStructure();
if (StructureUtil.reactionHereCanHaveParticipantThere(startStructure, endStructure)) {
// if reactionStart is a SimpleRxn OR FluxRxn without a product, add speciesContext as pdt
if ((reactionStart instanceof SimpleReaction) || ((reactionStart instanceof FluxReaction) && !reactionStart.hasProduct())) {
SpeciesContext speciesContext = getModel().createSpeciesContext(endStructure);
reactionStart.addProduct(speciesContext, 1);
positionShapeForObject(endStructure, speciesContext, edgeShape.getEnd());
}
if (((startStructure instanceof Feature && endStructure instanceof Feature) || (startStructure instanceof Membrane && endStructure instanceof Membrane)) && startStructure != endStructure) {
// ============ change kinetics to lumped or warn user ?????????
// reactionStart.setKinetics(new GeneralLumpedKinetics(reactionStart));
}
getReactionCartoon().notifyChangeEvent();
}
}
use of cbit.vcell.model.Feature in project vcell by virtualcell.
the class BioCartoonTool method askUserResolveMembraneConnections.
private static HashMap<ReactionParticipant, Structure> askUserResolveMembraneConnections(Component requester, Structure[] allStructures, Structure currentStruct, Structure fromRxnStruct, Structure toRxnStruct, ReactionParticipant[] copyFromRxParticipantArr, StructureTopology toStructureTopology, StructureTopology structTopology) {
HashMap<ReactionParticipant, Structure> userMap = new HashMap<>();
boolean bMembrane = toRxnStruct instanceof Membrane;
if (!bMembrane) {
for (int i = 0; i < copyFromRxParticipantArr.length; i += 1) {
userMap.put(copyFromRxParticipantArr[i], null);
for (Structure struct : allStructures) {
if (fromRxnStruct.getName().equals(copyFromRxParticipantArr[i].getStructure().getName())) {
userMap.put(copyFromRxParticipantArr[i], toRxnStruct);
}
}
}
// return userMap;
} else {
for (int i = 0; i < copyFromRxParticipantArr.length; i += 1) {
Structure pasteToStruct = currentStruct;
Membrane oldMembr = (Membrane) fromRxnStruct;
pasteToStruct = matchMembraneAdjacentStructure(allStructures, currentStruct, copyFromRxParticipantArr[i].getStructure(), structTopology, toStructureTopology, oldMembr, pasteToStruct);
userMap.put(copyFromRxParticipantArr[i], pasteToStruct);
}
}
JScrollPane jScrollPane = null;
JPanel rxMapperPanel = null;
Hashtable<JLabel, ReactionParticipant> mapLabelToPart = null;
boolean bUnselected;
do {
bUnselected = false;
if (jScrollPane == null) {
rxMapperPanel = new JPanel();
rxMapperPanel.setLayout(new BoxLayout(rxMapperPanel, BoxLayout.Y_AXIS));
// ((BoxLayout)rxMapperPanel.getLayout())
int height = 0;
final int[] widthlabels = new int[] { 0 };
int widthcombo = 0;
mapLabelToPart = new Hashtable<>();
for (ReactionParticipant rxPart : userMap.keySet()) {
if (!bMembrane || (rxPart.getStructure() instanceof Feature)) {
JPanel row = new JPanel();
JLabel rxpartLabel = new JLabel(rxPart.getName());
row.add(rxpartLabel);
mapLabelToPart.put(rxpartLabel, rxPart);
JComboBox<Structure> structJC = new JComboBox<>();
structJC.setRenderer(new ListCellRenderer<Structure>() {
@Override
public Component getListCellRendererComponent(JList<? extends Structure> list, Structure value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
JLabel label = new JLabel(value.getName());
widthlabels[0] = Math.max(widthlabels[0], label.getPreferredSize().width);
return label;
}
});
height += structJC.getPreferredSize().getHeight();
widthcombo = Math.max(widthcombo, structJC.getPreferredSize().width);
try {
Feature dummyFeature = new Feature(DUMMY_CHOOSE);
structJC.addItem(dummyFeature);
} catch (Exception e) {
e.printStackTrace();
}
for (Structure struct : allStructures) {
if (!bMembrane || (struct instanceof Feature)) {
structJC.addItem(struct);
}
}
structJC.setSelectedItem((userMap.get(rxPart) == null ? 0 : userMap.get(rxPart)));
row.add(structJC);
rxMapperPanel.add(row);
}
}
height += 25;
rxMapperPanel.setSize(widthcombo + widthlabels[0], height);
rxMapperPanel.setPreferredSize(new Dimension(widthcombo + widthlabels[0], height));
jScrollPane = new JScrollPane(rxMapperPanel);
jScrollPane.setPreferredSize(new Dimension(150, 100));
}
if (rxMapperPanel.getComponentCount() != 0) {
int result = DialogUtils.showComponentOKCancelDialog(requester, jScrollPane, "Assign Compartments for RX '" + copyFromRxParticipantArr[0].getReactionStep().getName() + "' Participants");
if (result != JOptionPane.OK_OPTION) {
throw UserCancelException.CANCEL_GENERIC;
}
for (int i = 0; i < rxMapperPanel.getComponentCount(); i++) {
JLabel label0 = (JLabel) (((Container) rxMapperPanel.getComponent(i)).getComponent(0));
JComboBox<Structure> struct0 = (JComboBox<Structure>) (((Container) rxMapperPanel.getComponent(i)).getComponent(1));
if (((Structure) struct0.getSelectedItem()).getName().equals(DUMMY_CHOOSE)) {
bUnselected = true;
DialogUtils.showWarningDialog(requester, "Choose a valid compartment for each ReactionParticipant");
break;
}
userMap.put(mapLabelToPart.get(label0), (Structure) struct0.getSelectedItem());
}
}
} while (bUnselected);
return userMap;
}
Aggregations