use of javax.swing.JRadioButton in project sldeditor by robward-scisys.
the class FieldConfigTimePeriod method createUIPanel.
/**
* Creates the ui panel.
*
* @param fieldPanel the field panel
* @param panelData the panel
* @param index the index
* @param title the title
* @return the int
*/
private void createUIPanel(FieldPanel fieldPanel, TimePeriodPanel panelData, int index, String title) {
panelData.panel = new JPanel();
panelData.panel.setLayout(null);
int row = 0;
panelData.dateRadioButton = new JRadioButton();
panelData.dateRadioButton.setBounds(2, getRowY(row), 20, BasePanel.WIDGET_HEIGHT);
panelData.dateRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateFields(panelData);
}
});
panelData.panel.add(panelData.dateRadioButton);
panelData.buttonGroup.add(panelData.dateRadioButton);
JDatePanelImpl datePanel = new JDatePanelImpl(panelData.dateModel);
panelData.datePicker = new JDatePickerImpl(datePanel);
int xPos = getXPos();
panelData.datePicker.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(panelData.datePicker);
panelData.dateModel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
// Time picker
SpinnerDateModel model = new SpinnerDateModel();
Calendar calendar = Calendar.getInstance();
model.setValue(calendar.getTime());
panelData.timePicker = new JSpinner(model);
panelData.timePicker.setBounds(panelData.datePicker.getX() + panelData.datePicker.getWidth() + 10, getRowY(row), (int) (BasePanel.WIDGET_STANDARD_WIDTH * 0.75), BasePanel.WIDGET_HEIGHT);
panelData.timePicker.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
panelData.panel.add(panelData.timePicker);
panelData.timeEditor = new JSpinner.DateEditor(panelData.timePicker, "HH:mm:ss");
panelData.timePicker.setEditor(panelData.timeEditor);
DateFormatter formatter = (DateFormatter) panelData.timeEditor.getTextField().getFormatter();
formatter.setAllowsInvalid(false);
formatter.setOverwriteMode(true);
//
// Date
//
row++;
panelData.durationRadioButton = new JRadioButton();
panelData.durationRadioButton.setBounds(2, getRowY(row), 20, BasePanel.WIDGET_HEIGHT);
panelData.durationRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateFields(panelData);
}
});
panelData.panel.add(panelData.durationRadioButton);
panelData.buttonGroup.add(panelData.durationRadioButton);
panelData.dateCheckbox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.date"));
panelData.dateCheckbox.setBounds(20, getRowY(row), 55, BasePanel.WIDGET_HEIGHT);
panelData.dateCheckbox.setSelected(true);
panelData.dateCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean enabled = panelData.dateCheckbox.isSelected();
panelData.yearSpinner.setEnabled(enabled);
panelData.monthSpinner.setEnabled(enabled);
panelData.daySpinner.setEnabled(enabled);
}
});
panelData.panel.add(panelData.dateCheckbox);
int x = xPos + BasePanel.WIDGET_X_START - 10;
// Year
JLabel yearLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.year"));
yearLbl.setHorizontalAlignment(SwingConstants.LEADING);
yearLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(yearLbl);
panelData.yearSpinner = new JSpinner();
x = x + 40;
int spinnerWidth = (int) (BasePanel.WIDGET_STANDARD_WIDTH * 0.4);
panelData.yearSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(panelData.yearSpinner);
panelData.yearSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
// Month
x = x + spinnerWidth + 2;
JLabel monthLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.month"));
monthLbl.setHorizontalAlignment(SwingConstants.LEADING);
monthLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(monthLbl);
x = x + 40;
panelData.monthSpinner = new JSpinner();
panelData.monthSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(panelData.monthSpinner);
panelData.monthSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
// Day
x = x + spinnerWidth + 2;
JLabel dayLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.day"));
dayLbl.setHorizontalAlignment(SwingConstants.LEADING);
dayLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(dayLbl);
x = x + 40;
panelData.daySpinner = new JSpinner();
panelData.daySpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(panelData.daySpinner);
panelData.daySpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
//
// Time
//
row++;
panelData.timeCheckbox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.time"));
panelData.timeCheckbox.setBounds(20, getRowY(row), 55, BasePanel.WIDGET_HEIGHT);
panelData.timeCheckbox.setSelected(true);
panelData.timeCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean enabled = panelData.timeCheckbox.isSelected();
panelData.hourSpinner.setEnabled(enabled);
panelData.minuteSpinner.setEnabled(enabled);
panelData.secondSpinner.setEnabled(enabled);
}
});
panelData.panel.add(panelData.timeCheckbox);
x = xPos + BasePanel.WIDGET_X_START - 10;
// Hours
JLabel hoursLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.hours"));
hoursLbl.setHorizontalAlignment(SwingConstants.LEADING);
hoursLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(hoursLbl);
panelData.hourSpinner = new JSpinner();
x = x + 40;
panelData.hourSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.hourSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
panelData.panel.add(panelData.hourSpinner);
// Minutes
x = x + spinnerWidth + 2;
JLabel minuteLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.minutes"));
minuteLbl.setHorizontalAlignment(SwingConstants.LEADING);
minuteLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(minuteLbl);
x = x + 40;
panelData.minuteSpinner = new JSpinner();
panelData.minuteSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.minuteSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
panelData.panel.add(panelData.minuteSpinner);
// Seconds
x = x + spinnerWidth + 2;
JLabel secondLabel = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.seconds"));
secondLabel.setHorizontalAlignment(SwingConstants.LEADING);
secondLabel.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
panelData.panel.add(secondLabel);
x = x + 40;
panelData.secondSpinner = new JSpinner();
panelData.secondSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
panelData.secondSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueUpdated();
}
});
panelData.panel.add(panelData.secondSpinner);
fieldPanel.add(panelData.panel);
panelData.panel.setBounds(0, index * ((row * BasePanel.WIDGET_HEIGHT) + 50), BasePanel.FIELD_PANEL_WIDTH, (row + 2) * BasePanel.WIDGET_HEIGHT);
Dimension preferredSize = new Dimension((int) panelData.panel.getPreferredSize().getWidth(), (row + 2) * BasePanel.WIDGET_HEIGHT);
panelData.panel.setPreferredSize(preferredSize);
panelData.panel.setBorder(BorderFactory.createTitledBorder(title));
}
use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.
the class PrefsColor method makeRadioButton.
//
JRadioButton makeRadioButton(String s) {
JRadioButton btn = new JRadioButton(s);
btn.addActionListener(ctrlListener);
btn.setActionCommand(s);
buttonGroup.add(btn);
return btn;
}
use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.
the class ImportTablePanel method initComponents.
private void initComponents() {
attrTypeButtonGroup = new ButtonGroup();
nodeRadioButton = new JRadioButton("Node");
edgeRadioButton = new JRadioButton("Edge");
networkRadioButton = new JRadioButton("Network");
ontologyComboBox = new JComboBox<>();
browseOntologyButton = new JButton("Browse...");
annotationComboBox = new JComboBox<>();
browseAnnotationButton = new JButton("Browse...");
targetDataSourceTextField = new JTextField();
selectAttributeFileButton = new JButton();
mappingAttributeComboBox = new JComboBox<>();
delimiterLabel = new JLabel("Delimiter:");
delimiterLabel.setHorizontalAlignment(JLabel.RIGHT);
commaCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>,<font></b> <font size=-2>(comma)</font><html>");
semicolonCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>;<font></b> <font size=-2>(semicolon)</font><html>");
spaceCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>SPACE<font></b><html>");
tabCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>TAB<font></b><html>");
otherCheckBox = new JCheckBox("Other:");
otherDelimiterTextField = new JTextField();
defaultInteractionTextField = new JTextField();
attributeFileLabel = new JLabel();
attrTypeButtonGroup.add(nodeRadioButton);
attrTypeButtonGroup.add(edgeRadioButton);
attrTypeButtonGroup.add(networkRadioButton);
/*
* Set tooltips options.
*/
ToolTipManager tp = ToolTipManager.sharedInstance();
tp.setInitialDelay(40);
tp.setDismissDelay(50000);
if (importType == ONTOLOGY_IMPORT) {
/*
* Data Source Panel Layouts.
*/
nodeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
nodeRadioButton.setMargin(new Insets(0, 0, 0, 0));
nodeRadioButton.setSelected(true);
nodeRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
edgeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
edgeRadioButton.setMargin(new Insets(0, 0, 0, 0));
edgeRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
networkRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
networkRadioButton.setMargin(new Insets(0, 0, 0, 0));
networkRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
}
if (importType == ONTOLOGY_IMPORT) {
panelBuilder = new OntologyPanelBuilder(this, factory, serviceRegistrar);
panelBuilder.buildPanel();
}
if ((importType == TABLE_IMPORT) || (importType == NETWORK_IMPORT)) {
// titleIconLabel.setIcon(SPREADSHEET_ICON_LARGE.getIcon());
attributeFileLabel.setText("Input File");
selectAttributeFileButton.setText("Select File(s)");
selectAttributeFileButton.addActionListener((ActionEvent evt) -> {
try {
setPreviewPanel();
} catch (Exception e) {
JOptionPane.showMessageDialog(serviceRegistrar.getService(CySwingApplication.class).getJFrame(), "<html>Could not read selected file.<p>See <b>Help->Error Dialog</b> for further details.</html>", "Error", JOptionPane.ERROR_MESSAGE);
logger.warn("Could not read selected file.", e);
}
});
}
/*
* Layout data for advanced panel
*/
if (importType == ONTOLOGY_IMPORT) {
mappingAttributeComboBox.setEnabled(true);
mappingAttributeComboBox.addActionListener((ActionEvent evt) -> {
updateTypes(getPreviewPanel().getFileType());
setKeyList();
});
}
final ChangeListener delimitersChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
otherDelimiterTextField.setEnabled(otherCheckBox.isSelected());
try {
if (!updating)
updatePreview();
} catch (IOException e) {
logger.error("Error on ChangeEvent of checkbox " + ((JCheckBox) evt.getSource()).getText(), e);
}
}
};
commaCheckBox.addChangeListener(delimitersChangeListener);
semicolonCheckBox.addChangeListener(delimitersChangeListener);
spaceCheckBox.addChangeListener(delimitersChangeListener);
tabCheckBox.addChangeListener(delimitersChangeListener);
otherCheckBox.addChangeListener(delimitersChangeListener);
otherDelimiterTextField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent evt) {
}
@Override
public void keyReleased(KeyEvent evt) {
try {
if (otherCheckBox.isSelected())
updatePreview();
} catch (IOException e) {
logger.error("Error on otherDelimiterTextField.keyReleased", e);
}
}
@Override
public void keyTyped(KeyEvent evt) {
}
});
defaultInteractionTextField.setText(TypeUtil.DEFAULT_INTERACTION);
defaultInteractionTextField.setToolTipText("<html>If <b>Default Interaction</b>" + " is selected, this value will be used for <i>Interaction Type</i><br></html>");
globalLayout();
if (basicPanel != null)
basicPanel.repaint();
this.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
getPreviewPanel().disposeEditDialog();
}
});
}
use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.
the class PrefsText method getFunctionPanel.
private AntiAliasedPanel getFunctionPanel() {
if (fFunctionPanel == null) {
VBox p = new VBox("Components", true, false);
AntiAliasedPanel.setSizes(p, new Dimension(240, 220));
for (int currTrait = 0; currTrait < kNumTextTraits; currTrait++) {
fRadioButtons[currTrait] = new JRadioButton(kTraitNames[currTrait]);
fRadioButtons[currTrait].setToolTipText(kTraitTooltips[currTrait]);
final int trait = currTrait;
fRadioButtons[currTrait].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeCurrentTarget(trait);
}
});
// fRadioButtons[currTrait].setFont(panelFont);
btnGroup.add(fRadioButtons[currTrait]);
p.add(new HBox(true, true, fRadioButtons[currTrait]));
}
fRadioButtons[0].setSelected(true);
fBtnSetAllTT = new JButton("Use For All");
fBtnSetAllTT.setToolTipText("Assign the current font information to nodes, edges, annotations, and legends");
fBtnSetAllTT.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateAllTraits();
}
});
// fBtnSetAllTT.setFont(panelFont);
p.addSpacer();
p.add(fBtnSetAllTT);
p.addSpacer();
p.add(Box.createVerticalGlue());
p.addSpacer();
fFunctionPanel = p;
}
return fFunctionPanel;
}
use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.
the class AbstractChartEditor method updateOrientation.
protected void updateOrientation() {
final Orientation orientation = chart.get(ORIENTATION, Orientation.class, Orientation.VERTICAL);
final JRadioButton orientRd = orientation == Orientation.HORIZONTAL ? getHorizontalRd() : getVerticalRd();
getOrientationGrp().setSelected(orientRd.getModel(), true);
}
Aggregations