use of javax.swing.DefaultListCellRenderer in project vcell by virtualcell.
the class KineticsTypeTemplatePanel 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;
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;
if (getKinetics() != null && getKinetics().getReactionStep() != null) {
if (getKinetics().getReactionStep().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 (getKinetics().getReactionStep().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 {
setText(kineticsDescription.getDescription());
}
}
} else {
setText(kineticsDescription.getDescription());
}
}
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 MultisourcePlotPane method getJList1.
/**
* Return the JList1 property value.
* @return javax.swing.JList
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JList<DataReference> getJList1() {
if (ivjJList1 == null) {
try {
ivjJList1 = new javax.swing.JList<DataReference>();
ivjJList1.setName("JList1");
ivjJList1.setBounds(0, 0, 255, 480);
ivjJList1.setCellRenderer(new ListCellRenderer<DataReference>() {
DefaultListCellRenderer defaultListCellRenderer = new DefaultListCellRenderer();
private Boolean isEvenMatchedSet(int index0) {
if (ivjJList1.getModel().getSize() == 0) {
return null;
}
if (getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount == null) {
// create matched set group counts (this happens 1 time)
int masterMatchCount = 0;
for (int i = 0; i < ivjJList1.getModel().getSize(); i++) {
DataSource dataSource = getmultisourcePlotListModel().getSortedDataReferences().get(i).dataReference.getDataSource();
if (dataSource instanceof DataSource.DataSourceReferenceData) {
if (i != ivjJList1.getModel().getSize() - 1) {
SortDataReferenceHelper mySortDataReferenceHelper = getmultisourcePlotListModel().getSortedDataReferences().get(i);
SortDataReferenceHelper potentialMatchSortDataReferenceHelper = getmultisourcePlotListModel().getSortedDataReferences().get(i + 1);
if (potentialMatchSortDataReferenceHelper.getReferenceDataMappingSpec() != null && mySortDataReferenceHelper != null && potentialMatchSortDataReferenceHelper.getReferenceDataMappingSpec().getReferenceDataColumnName().equals(mySortDataReferenceHelper.dataReference.getIdentifier())) {
mySortDataReferenceHelper.matchCount = masterMatchCount;
potentialMatchSortDataReferenceHelper.matchCount = masterMatchCount;
masterMatchCount++;
} else {
mySortDataReferenceHelper.matchCount = -1;
}
} else {
getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount = -1;
}
} else if (getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount == null) {
getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount = -1;
}
}
}
if (getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount == -1) {
// not part of matched set
return null;
}
return getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount % 2 == 0;
}
@Override
public Component getListCellRendererComponent(JList<? extends DataReference> list, DataReference value, int index, boolean isSelected, boolean cellHasFocus) {
Component comp = defaultListCellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
try {
if (bGroupingListSorter && comp instanceof JLabel) {
if (isSelected) {
comp.setBackground(getJList1().getSelectionBackground());
comp.setForeground(getJList1().getSelectionForeground());
} else {
Boolean evenMatch = isEvenMatchedSet(index);
comp.setBackground(evenMatch == null || evenMatch ? getJList1().getBackground() : DefaultScrollTableCellRenderer.everyOtherRowColor);
comp.setForeground(getJList1().getForeground());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return comp;
}
});
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJList1;
}
use of javax.swing.DefaultListCellRenderer in project pcgen by PCGen.
the class ExportDialog method initComponents.
private void initComponents() {
characterBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
CharacterFacade character = (CharacterFacade) value;
return super.getListCellRendererComponent(list, character.getNameRef().get(), index, isSelected, cellHasFocus);
}
});
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fileList.addListSelectionListener(this);
exportButton.setDefaultCapable(true);
getRootPane().setDefaultButton(exportButton);
partyBox.setActionCommand(PARTY_COMMAND);
exportBox.setActionCommand(EXPORT_TO_COMMAND);
exportButton.setActionCommand(EXPORT_COMMAND);
closeButton.setActionCommand(CLOSE_COMMAND);
exportBox.addActionListener(this);
partyBox.addActionListener(this);
exportButton.addActionListener(this);
closeButton.addActionListener(this);
exportButton.setEnabled(false);
progressBar.setStringPainted(true);
progressBar.setString("Loading Templates");
progressBar.setIndeterminate(true);
setTitle("Export a PC or Party");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
UIPropertyContext context = UIPropertyContext.createContext("ExportDialog");
String defaultOSType = context.getProperty(UIPropertyContext.DEFAULT_OS_TYPE);
if (defaultOSType != null) {
for (SheetFilter filter : SheetFilter.values()) {
if (defaultOSType.equals(filter.toString())) {
exportBox.setSelectedItem(filter);
}
}
}
}
use of javax.swing.DefaultListCellRenderer in project jabref by JabRef.
the class FindUnlinkedFilesDialog method createFileTypesCombobox.
/**
* Initialises the combobox that contains the available file types which
* bibtex entries can be created of.
*/
private void createFileTypesCombobox() {
List<FileFilter> fileFilterList = creatorManager.getFileFilterList();
Vector<FileFilter> vector = new Vector<>();
for (FileFilter fileFilter : fileFilterList) {
vector.add(fileFilter);
}
comboBoxFileTypeSelection = new JComboBox<>(vector);
comboBoxFileTypeSelection.setRenderer(new DefaultListCellRenderer() {
/* (non-Javadoc)
* @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
*/
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof EntryFromFileCreator) {
EntryFromFileCreator creator = (EntryFromFileCreator) value;
if (creator.getExternalFileType() != null) {
label.setIcon(creator.getExternalFileType().getIcon());
}
}
return label;
}
});
}
use of javax.swing.DefaultListCellRenderer in project jabref by JabRef.
the class FieldFormatterCleanupsPanel method getSelectorPanel.
/**
* This panel contains the two comboboxes and the Add button
* @return Returns the created JPanel
*/
private JPanel getSelectorPanel() {
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref:grow, 4dlu, left:pref:grow, 4dlu, fill:pref:grow, 4dlu, right:pref", "fill:pref:grow, 2dlu, pref, 2dlu"));
List<String> fieldNames = InternalBibtexFields.getAllPublicAndInternalFieldNames();
fieldNames.add(BibEntry.KEY_FIELD);
Collections.sort(fieldNames);
String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]);
selectFieldCombobox = new JComboBox<>(allPlusKey);
selectFieldCombobox.setEditable(true);
builder.add(selectFieldCombobox).xy(1, 1);
List<String> formatterNames = Cleanups.getAvailableFormatters().stream().map(Formatter::getName).collect(Collectors.toList());
List<String> formatterDescriptions = Cleanups.getAvailableFormatters().stream().map(Formatter::getDescription).collect(Collectors.toList());
formattersCombobox = new JComboBox<>(formatterNames.toArray());
formattersCombobox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if ((-1 < index) && (index < formatterDescriptions.size()) && (value != null)) {
setToolTipText(formatterDescriptions.get(index));
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
formattersCombobox.addItemListener(e -> updateDescription());
builder.add(formattersCombobox).xy(3, 1);
addButton = new JButton(Localization.lang("Add"));
addButton.addActionListener(e -> {
FieldFormatterCleanup newAction = getFieldFormatterCleanup();
if (newAction == null) {
return;
}
((CleanupActionsListModel) actionsList.getModel()).addCleanupAction(newAction);
});
builder.add(addButton).xy(5, 1);
return builder.getPanel();
}
Aggregations