use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ObservableTableModel method updateObservableTypeComboBox.
protected void updateObservableTypeComboBox() {
@SuppressWarnings("unchecked") JComboBox<RbmObservable.ObservableType> typeComboBoxCellEditor = (JComboBox<RbmObservable.ObservableType>) getObservableTypeComboBoxEditor().getComponent();
if (typeComboBoxCellEditor == null) {
typeComboBoxCellEditor = new JComboBox<RbmObservable.ObservableType>();
}
DefaultComboBoxModel<RbmObservable.ObservableType> aModel = new DefaultComboBoxModel<RbmObservable.ObservableType>();
for (RbmObservable.ObservableType ot : RbmObservable.ObservableType.values()) {
aModel.addElement(ot);
}
DefaultListCellRenderer defaultListCellRenderer = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setHorizontalTextPosition(SwingConstants.LEFT);
if (value instanceof RbmObservable.ObservableType) {
setText(((RbmObservable.ObservableType) value).name());
}
return this;
}
};
typeComboBoxCellEditor.setRenderer(defaultListCellRenderer);
typeComboBoxCellEditor.setModel(aModel);
typeComboBoxCellEditor.setSelectedIndex(0);
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ParameterEstimationPanel method getAnalysisTaskComboBox.
private javax.swing.JComboBox getAnalysisTaskComboBox() {
if (taskComboBox == null) {
taskComboBox = new javax.swing.JComboBox();
taskComboBox.setRenderer(new DefaultListCellRenderer() {
public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof AnalysisTask) {
AnalysisTask analysisTask = (AnalysisTask) value;
setText(analysisTask.getName());
} else {
setText((value == null) ? "" : value.toString());
}
return this;
}
});
taskComboBox.setEnabled(false);
analysisTaskComboBoxModel = new AnalysisTaskComboBoxModel();
taskComboBox.setModel(analysisTaskComboBoxModel);
}
return taskComboBox;
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ReactionRuleKineticsPropertiesPanel method getKineticsTypeComboBox.
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
private JComboBox<RateLawType> getKineticsTypeComboBox() {
if (kineticsTypeComboBox == null) {
kineticsTypeComboBox = new JComboBox();
kineticsTypeComboBox.setName("JComboBox1");
kineticsTypeComboBox.setRenderer(new DefaultListCellRenderer() {
private static final String PI = "\u03A0";
private static final String MU = "\u03BC";
private static final String SQUARED = "\u00B2";
private static final String PIs = "<strong>\u03A0</strong>";
private static final String PIsb = "<strong><big>\u03A0</big></strong>";
private static final String pi = "\u03C0";
private static final String MULT = "\u22C5";
private static final String MICROMOLAR = MU + "M";
private static final String SQUAREMICRON = MU + "m" + SQUARED;
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
java.awt.Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == RateLawType.Saturable) {
String str = "<html>Saturable";
str += "</html>";
setText(str);
} else if (value == RateLawType.MichaelisMenten) {
String str = "<html>";
if (reactionRule != null && reactionRule.getStructure() instanceof Feature) {
str += "Henri-Michaelis-Menten (Irreversible) [" + MICROMOLAR + "/s]";
} else if (reactionRule != null && reactionRule.getStructure() instanceof Membrane) {
str += "Henri-Michaelis-Menten (Irreversible) [molecules/(" + SQUAREMICRON + " s)]";
}
str += "</html>";
setText(str);
} else if (value == RateLawType.MassAction) {
String str = "<html>Mass Action ( for each reaction: ";
str += "Kf" + MULT + PIs + " <small>reactants</small> - Kr" + MULT + PIs + " <small>products</small> )</html>";
setText(str);
}
return component;
}
});
}
return kineticsTypeComboBox;
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ReactionPropertiesPanel method getKineticsTypeComboBox.
private javax.swing.JComboBox getKineticsTypeComboBox() {
if (kineticsTypeComboBox == null) {
try {
kineticsTypeComboBox = new javax.swing.JComboBox();
kineticsTypeComboBox.setName("JComboBox1");
kineticsTypeComboBox.setRenderer(new DefaultListCellRenderer() {
private static final String MU = "\u03BC";
private static final String MICROMOLAR = MU + "M";
private static final String SQUARED = "\u00B2";
private static final String SQUAREMICRON = MU + "m" + SQUARED;
private static final String MICRON = MU + "m";
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
java.awt.Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof KineticsDescription) {
KineticsDescription kineticsDescription = (KineticsDescription) value;
setText(kineticsDescription.getDescription());
if (reactionStep != null) {
if (reactionStep instanceof SimpleReaction) {
if (reactionStep.getStructure() instanceof Feature) {
if (kineticsDescription.equals(KineticsDescription.General)) {
setText("General [" + MICROMOLAR + "/s]");
} else if (kineticsDescription.equals(KineticsDescription.MassAction)) {
setText("Mass Action [" + MICROMOLAR + "/s] (recommended for stochastic application)");
} else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
setText("General [molecules/s]");
} else if (kineticsDescription.equals(KineticsDescription.HMM_irreversible)) {
setText("Henri-Michaelis-Menten (Irreversible) [" + MICROMOLAR + "/s]");
} else if (kineticsDescription.equals(KineticsDescription.HMM_reversible)) {
setText("Henri-Michaelis-Menten (Reversible) [" + MICROMOLAR + "/s]");
} else {
setText(kineticsDescription.getDescription());
}
} else if (reactionStep.getStructure() instanceof Membrane) {
if (kineticsDescription.equals(KineticsDescription.General)) {
setText("General [molecules/(" + SQUAREMICRON + " s)]");
} else if (kineticsDescription.equals(KineticsDescription.MassAction)) {
setText("Mass Action [molecules/(" + SQUAREMICRON + " s)]");
} else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
setText("General [molecules/s)]");
} else if (kineticsDescription.equals(KineticsDescription.HMM_irreversible)) {
setText("Henri-Michaelis-Menten (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
} else if (kineticsDescription.equals(KineticsDescription.HMM_reversible)) {
setText("Henri-Michaelis-Menten (Reversible) [molecules/(" + SQUAREMICRON + " s)]");
} else if (kineticsDescription.equals(KineticsDescription.Macroscopic_irreversible)) {
setText("Macroscopic (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
} else if (kineticsDescription.equals(KineticsDescription.Microscopic_irreversible)) {
setText("Microscopic (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
}
}
} else if (reactionStep instanceof FluxReaction) {
if (kineticsDescription.equals(KineticsDescription.General)) {
setText("General Flux Density (" + MICROMOLAR + "-" + MICRON + "/s)");
} else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
setText("General Flux (molecules/s)");
} else if (kineticsDescription.equals(KineticsDescription.GeneralCurrent)) {
setText("General Current Density (pA/" + SQUAREMICRON + ")");
} else if (kineticsDescription.equals(KineticsDescription.GeneralCurrentLumped)) {
setText("General Current (pA)");
} else if (kineticsDescription.equals(KineticsDescription.GHK)) {
setText("Goldman-Hodgkin-Katz Current Density (pA/" + SQUAREMICRON + ") - permeability in " + MICRON + "/s");
} else if (kineticsDescription.equals(KineticsDescription.Nernst)) {
setText("Nernst Current Density (pA/" + SQUAREMICRON + ") - conductance in nS/" + SQUAREMICRON);
} else if (kineticsDescription.equals(KineticsDescription.GeneralPermeability)) {
setText("General Permeability (" + MICROMOLAR + "-" + MICRON + "/s) - permeability in " + MICRON + "/s");
}
}
}
}
return component;
}
});
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return kineticsTypeComboBox;
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class PDEExportDataPanel method getROISelections.
/**
* Return the JListSelections property value.
* @return javax.swing.JList
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JList<Object> getROISelections() {
if (ivjJListSelections == null) {
try {
ivjJListSelections = new javax.swing.JList<Object>();
ivjJListSelections.setName("JListSelections");
ivjJListSelections.setBounds(0, 0, 160, 120);
ivjJListSelections.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
ivjJListSelections.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
// System.out.println(value.getClass().getName()+" "+value);
String curveDescr = "";
if (value instanceof SpatialSelectionMembrane) {
curveDescr = ((SpatialSelectionMembrane) value).getSelectionSource().getDescription() + " (" + ((SpatialSelectionMembrane) value).getSelectionSource().getBeginningCoordinate() + ")";
} else if (value instanceof SpatialSelectionVolume) {
curveDescr = ((SpatialSelectionVolume) value).getCurveSelectionInfo().getCurve().getDescription() + " (" + ((SpatialSelectionVolume) value).getCurveSelectionInfo().getCurve().getBeginningCoordinate() + ")";
} else {
curveDescr = value.toString();
}
return super.getListCellRendererComponent(list, curveDescr, index, isSelected, cellHasFocus);
}
});
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJListSelections;
}
Aggregations