use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ReactionRuleSpecPropertiesPanel method getKineticsTypeComboBox.
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
private JComboBox getKineticsTypeComboBox() {
if (kineticsTypeComboBox == null) {
kineticsTypeComboBox = new JComboBox();
kineticsTypeComboBox.setName("JComboBox1");
kineticsTypeComboBox.setRenderer(new DefaultListCellRenderer() {
private static final String PI = "\u03A0";
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";
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
java.awt.Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
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 RXParticipantResolverPanel method setupRX.
// public void setPasteToModel(Model model) {
// pasteToModel = model;
// }
// public void setFromModel(Model model) {
// fromModel = model;
// }
/**
* Insert the method's description here.
* Creation date: (8/5/2003 2:50:56 PM)
* @param dbfr cbit.vcell.dictionary.ReactionDescription
*/
public void setupRX(ReactionDescription dbfr, Model pasteToModel, Structure pastToStructure) {
resolvedReaction = dbfr;
if (resolvedReaction != null) {
if (speciesAssignmentJCB != null) {
for (int i = 0; i < speciesAssignmentJCB.length; i += 1) {
speciesAssignmentJCB[i].removeActionListener(this);
}
}
if (structureAssignmentJCB != null) {
for (int i = 0; i < structureAssignmentJCB.length; i += 1) {
structureAssignmentJCB[i].removeActionListener(this);
}
}
getReactionCanvas1().setReactionCanvasDisplaySpec(resolvedReaction.toReactionCanvasDisplaySpec());
getRXParticipantsJPanel().removeAll();
// java.awt.Insets zeroInsets = new java.awt.Insets(0,0,0,0);
java.awt.Insets fourInsets = new java.awt.Insets(4, 4, 4, 4);
java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = fourInsets;
gbc.gridx = 0;
gbc.gridy = 0;
javax.swing.JLabel rxjlabel = new javax.swing.JLabel("from RX Elements");
// rxjlabel.setForeground(java.awt.Color.white);
// rxjlabel.setOpaque(true);
// rxjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rxjlabel, gbc);
// gbc.insets = zeroInsets;
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
gbc.gridy = i + 1;
javax.swing.JLabel jlabel = new javax.swing.JLabel(resolvedReaction.getOrigSpeciesContextName(i) + /*+" "+resolvedReaction.getReactionElement(i).getPreferredName()*/
" (" + resolvedReaction.getOrigStructName(i) + ")" + // resolvedReaction.getReactionElement(i).getPreferredName()+
(resolvedReaction.isFluxReaction() && resolvedReaction.getFluxIndexOutside() == i ? " (Outside)" : "") + (resolvedReaction.isFluxReaction() && resolvedReaction.getFluxIndexInside() == i ? " (Inside)" : ""));
// jlabel.setOpaque(true);
// jlabel.setBackground(java.awt.Color.white);
// jlabel.setForeground(java.awt.Color.black);
getRXParticipantsJPanel().add(jlabel, gbc);
}
// gbc.insets = fourInsets;
gbc.gridx = 1;
gbc.gridy = 0;
speciesAssignmentJCB = new javax.swing.JComboBox[resolvedReaction.elementCount()];
DefaultListCellRenderer speciesListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// }
return super.getListCellRendererComponent(list, (value instanceof SpeciesContext ? ((SpeciesContext) value).getName() : value), // (value instanceof Species?((Species)value).getCommonName():value),
index, isSelected, cellHasFocus);
}
};
javax.swing.JLabel rspjlabel = new javax.swing.JLabel("Assign to Model Species");
// rspjlabel.setForeground(java.awt.Color.white);
// rspjlabel.setOpaque(true);
// rspjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rspjlabel, gbc);
// getRXParticipantsJPanel().add(new javax.swing.JLabel("Resolve to Model Species"),gbc);
// speciesOrder = new Species[fromModel.getSpecies().length+1];
// speciesOrder[0] = null;
// for(int j=0;j<fromModel.getSpecies().length;j+= 1){
// speciesOrder[j+1] = fromModel.getSpecies(j);
// }
SpeciesContext[] speciesContextOrder = new SpeciesContext[pasteToModel.getSpeciesContexts().length];
// speciesContextOrder[0] = null;
for (int j = 0; j < pasteToModel.getSpeciesContexts().length; j += 1) {
speciesContextOrder[j] = pasteToModel.getSpeciesContexts(j);
}
ArrayList<JComboBox<Object>> scComboBoxArr = new ArrayList<>();
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
JComboBox jcb = new JComboBox();
scComboBoxArr.add(jcb);
jcb.setRenderer(speciesListCellRenderer);
speciesAssignmentJCB[i] = jcb;
jcb.addItem("New Species");
SpeciesContext initSC = null;
for (int j = 0; j < speciesContextOrder.length; j += 1) {
jcb.addItem(/*"Existing "+*/
speciesContextOrder[j]);
if (resolvedReaction.getOrigSpeciesContextName(i).equals(speciesContextOrder[j].getName())) {
initSC = speciesContextOrder[j];
}
}
if (initSC != null) {
jcb.setSelectedItem(initSC);
}
gbc.gridy = i + 1;
getRXParticipantsJPanel().add(jcb, gbc);
// jcb.setEnabled(false);
}
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
if (speciesAssignmentJCB[i].getSelectedIndex() == 0) {
int matchCount = 0;
SpeciesContext foundSC = null;
for (int j = 0; j < speciesContextOrder.length; j++) {
String structName = speciesContextOrder[j].getStructure().getName();
if (speciesContextOrder[j].getName().endsWith("_" + structName)) {
int structNameLength = ("_" + structName).length();
int tempNameLength = speciesContextOrder[j].getName().length();
String temp = speciesContextOrder[j].getName().substring(0, tempNameLength - structNameLength);
if (resolvedReaction.getOrigSpeciesContextName(i).startsWith(temp)) {
foundSC = speciesContextOrder[j];
matchCount++;
}
}
}
if (matchCount == 1) {
speciesAssignmentJCB[i].setSelectedItem(foundSC);
}
}
}
gbc.gridx = 2;
gbc.gridy = 0;
structureAssignmentJCB = new javax.swing.JComboBox[resolvedReaction.elementCount()];
DefaultListCellRenderer structureListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
return super.getListCellRendererComponent(list, (value instanceof Structure ? ((Structure) value).getName() : value), index, isSelected, cellHasFocus);
}
};
javax.swing.JLabel rstjlabel = new javax.swing.JLabel("Assign to Model Compartment");
// rstjlabel.setForeground(java.awt.Color.white);
// rstjlabel.setOpaque(true);
// rstjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rstjlabel, gbc);
// StructureTopology structTopology = getModel().getStructureTopology();
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
javax.swing.JComboBox jcb = new javax.swing.JComboBox();
jcb.setRenderer(structureListCellRenderer);
structureAssignmentJCB[i] = jcb;
Structure initStruct = null;
for (int j = 0; j < pasteToModel.getStructures().length; j++) {
jcb.addItem(pasteToModel.getStructures()[j]);
if (resolvedReaction.getOrigStructName(i).equals(pasteToModel.getStructures()[j].getName())) {
initStruct = pasteToModel.getStructures()[j];
}
}
if (initStruct != null) {
structureAssignmentJCB[i].setSelectedItem(initStruct);
} else {
structureAssignmentJCB[i].setSelectedItem(pastToStructure);
}
// if(resolvedReaction.isFluxReaction() && resolvedReaction.isFlux(i) && resolvedReaction.getFluxIndexOutside() == i){
// jcb.addItem(structTopology.getOutsideFeature((Membrane)getStructure())/*.getName()*/);
// jcb.setEnabled(false);
// }else if(resolvedReaction.isFluxReaction() && resolvedReaction.isFlux(i) && resolvedReaction.getFluxIndexInside() == i){
// jcb.addItem((structTopology).getInsideFeature((Membrane)getStructure())/*.getName()*/);
// jcb.setEnabled(false);
// }else{
// jcb.addItem(getStructure()/*.getName()*/);
// if(getStructure() instanceof Membrane){
// jcb.addItem(structTopology.getOutsideFeature((Membrane)getStructure())/*.getName()*/);
// jcb.addItem(structTopology.getInsideFeature((Membrane)getStructure())/*.getName()*/);
// }else{
// jcb.setEnabled(false);
// }
// }
gbc.gridy = i + 1;
getRXParticipantsJPanel().add(jcb, gbc);
}
finalNamesJTF = new ArrayList<>();
gbc.gridx = 3;
gbc.gridy = 0;
javax.swing.JLabel finalLabel = new javax.swing.JLabel("Custom Name");
getRXParticipantsJPanel().add(finalLabel, gbc);
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
gbc.gridy = i + 1;
JTextField finalNameJTextField = new JTextField("");
finalNamesJTF.add(finalNameJTextField);
getRXParticipantsJPanel().add(finalNameJTextField, gbc);
}
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
speciesAssignmentJCB[i].addActionListener(this);
structureAssignmentJCB[i].addActionListener(this);
}
}
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ChomboSolverSpecPanel method initialize.
private void initialize() {
setMaximumSize(new Dimension(500, 150));
setPreferredSize(new Dimension(500, 200));
maxBoxSizeComboBox = new JComboBox<Integer>();
int start = 8;
for (int i = 0; i < 9; ++i) {
maxBoxSizeComboBox.addItem(start);
start *= 2;
}
maxBoxSizeComboBox.addItem(0);
blockFactorComboBox = new JComboBox<Integer>();
start = 4;
for (int i = 0; i < 4; ++i) {
blockFactorComboBox.addItem(start);
start *= 2;
}
blockFactorComboBox.setEnabled(false);
checkBoxTagsGrow = new JCheckBox("Tags Grow");
viewLevelFinestRadioButton = new JRadioButton("Finest");
viewLevelUserSelectRadioButton = new JRadioButton("Select");
viewLevelFinestRadioButton.addActionListener(eventHandler);
viewLevelUserSelectRadioButton.addActionListener(eventHandler);
ButtonGroup bg = new ButtonGroup();
bg.add(viewLevelFinestRadioButton);
bg.add(viewLevelUserSelectRadioButton);
viewLevelComboBox = new JComboBox<Integer>();
viewLevelComboBox.setEnabled(false);
viewLevelComboBox.setRenderer(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 != null && (Integer) value <= simulation.getSolverTaskDescription().getChomboSolverSpec().getNumRefinementLevels()) {
int dim = simulation.getMathDescription().getGeometry().getDimension();
ISize xyz = simulation.getSolverTaskDescription().getChomboSolverSpec().getLevelSamplingSize(simulation.getMeshSpecification().getSamplingSize(), (Integer) value);
setText(GuiUtils.getMeshSizeText(dim, xyz, false));
}
return this;
}
});
fillRatioTextField = new JTextField();
fillRatioTextField.addFocusListener(eventHandler);
CollapsiblePanel southPanel = new CollapsiblePanel("Advanced", false);
southPanel.getContentPanel().setLayout(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 4, 4, 1);
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.EAST;
southPanel.getContentPanel().add(new JLabel("Max Box Size"), gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 1, 4, 4);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0.1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
southPanel.getContentPanel().add(maxBoxSizeComboBox, gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 4, 4, 1);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.EAST;
southPanel.getContentPanel().add(new JLabel("Fill Ratio"), gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 1, 4, 4);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
southPanel.getContentPanel().add(fillRatioTextField, gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 4, 4, 1);
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.EAST;
southPanel.getContentPanel().add(new JLabel("Block Factor"), gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 1, 4, 4);
gbc.gridx = 5;
gbc.gridy = gridy;
gbc.weightx = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
southPanel.getContentPanel().add(blockFactorComboBox, gbc);
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 1, 4, 4);
gbc.gridx = 6;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
southPanel.getContentPanel().add(checkBoxTagsGrow, gbc);
JPanel northPanel = new JPanel(new GridBagLayout());
JLabel lbl = new JLabel("<html>Enter Boolean expressions for regions of interest to refine, and set max refinement level desired for each ROI, where each level doubles the mesh resolution.</html>");
gbc = new GridBagConstraints();
gbc.insets = new java.awt.Insets(4, 4, 4, 4);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
northPanel.add(lbl, gbc);
getContentPanel().setLayout(new BorderLayout(0, 2));
getContentPanel().add(southPanel, BorderLayout.SOUTH);
getContentPanel().add(northPanel, BorderLayout.NORTH);
getContentPanel().add(getRefinementPanel(), BorderLayout.CENTER);
maxBoxSizeComboBox.addActionListener(eventHandler);
blockFactorComboBox.addActionListener(eventHandler);
checkBoxTagsGrow.addActionListener(eventHandler);
}
use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class ParameterEstimationRunTaskPanel method initialize.
private void initialize() {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.weighty = 1.0;
gbc.insets = new java.awt.Insets(4, 4, 4, 4);
add(getSolverPanel(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.insets = new Insets(4, 4, 4, 4);
add(getSolutionPanel(), gbc);
JPanel panel = new JPanel(new BorderLayout());
copasiLinkLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
panel.add(copasiLinkLabel, BorderLayout.CENTER);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(0, 8, 4, 0);
add(panel, gbc);
DefaultComboBoxModel<CopasiOptimizationMethodType> model = new DefaultComboBoxModel<CopasiOptimizationMethodType>();
for (CopasiOptimizationMethodType com : CopasiOptimizationMethodType.values()) {
model.addElement(com);
}
getOptimizationMethodComboBox().setModel(model);
getOptimizationMethodComboBox().addActionListener(eventHandler);
getOptimizationMethodComboBox().setSelectedItem(CopasiOptimizationMethodType.EvolutionaryProgram);
getOptimizationMethodComboBox().setRenderer(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 CopasiOptimizationMethodType) {
setText(((CopasiOptimizationMethodType) value).getDisplayName());
}
return this;
}
});
getNumberOfRunComboBox().addActionListener(eventHandler);
getSolveButton().addActionListener(eventHandler);
helpButton.addActionListener(eventHandler);
getPlotButton().addActionListener(eventHandler);
getSaveSolutionAsNewSimButton().addActionListener(eventHandler);
}
use of javax.swing.DefaultListCellRenderer in project knime-core by knime.
the class ColumnSelectionSearchableListPanel method setDefaultCellRenderer.
private void setDefaultCellRenderer() {
m_cellRenderer = new DataColumnSpecListCellRenderer() {
// private static final Font DEFAULT_FONT = new Font() ;
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
final Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
// if (isSelected) {
// return comp;
// }
final DataColumnSpec cspec = (DataColumnSpec) value;
if (m_container.isConfiguredColumn(cspec)) {
Font font2 = new Font(comp.getFont().getName(), Font.ITALIC | Font.BOLD, comp.getFont().getSize());
comp.setFont(font2);
}
if (isInvalid(cspec)) {
setBorder(BorderFactory.createLineBorder(Color.RED, 1));
}
return comp;
}
};
m_columnList.setCellRenderer(new DefaultListCellRenderer() {
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
return m_cellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
}
Aggregations