use of java.awt.Label in project bioformats by openmicroscopy.
the class FilePatternDialog method rebuild.
private void rebuild(GenericDialog gd) {
// rebuild dialog to organize things more nicely
Vector checkboxes = gd.getCheckboxes();
Vector fields = gd.getStringFields();
final ArrayList<Label> labels = new ArrayList<Label>();
for (Component c : gd.getComponents()) {
if (c instanceof Label) {
labels.add((Label) c);
}
}
final String cols = "pref, 3dlu, pref, 3dlu, pref";
final StringBuilder sb = new StringBuilder("pref, 3dlu, pref");
for (int s = 1; s < fields.size(); s++) {
sb.append(", 3dlu, pref");
}
final String rows = sb.toString();
final PanelBuilder builder = new PanelBuilder(new FormLayout(cols, rows));
final CellConstraints cc = new CellConstraints();
int row = 1;
if (checkboxes.size() > 2 && fields.size() > 2) {
builder.add((Component) labels.get(0), cc.xyw(1, row, 5));
row += 2;
builder.add((Component) checkboxes.get(0), cc.xy(1, row));
for (int i = 0; i < fields.size() - 2; i++) {
builder.add((Component) labels.get(i + 1), cc.xy(3, row));
builder.add((Component) fields.get(i), cc.xy(5, row));
row += 2;
}
}
builder.add((Component) checkboxes.get(checkboxes.size() - 2), cc.xy(1, row));
builder.add((Component) labels.get(labels.size() - 2), cc.xy(3, row));
builder.add((Component) fields.get(fields.size() - 2), cc.xy(5, row));
row += 2;
builder.add((Component) checkboxes.get(checkboxes.size() - 1), cc.xy(1, row));
builder.add((Component) labels.get(labels.size() - 1), cc.xy(3, row));
builder.add((Component) fields.get(fields.size() - 1), cc.xy(5, row));
row += 2;
final JPanel masterPanel = builder.getPanel();
gd.removeAll();
GridBagLayout gdl = (GridBagLayout) gd.getLayout();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 3;
gbc.gridheight = fields.size();
gdl.setConstraints(masterPanel, gbc);
gd.add(masterPanel);
// HACK: workaround for JPanel in a Dialog
gd.setBackground(Color.white);
}
use of java.awt.Label in project bioformats by openmicroscopy.
the class MainDialog method rebuildDialog.
// -- Helper methods --
/**
* Fancies up the importer dialog to look much nicer.
*/
private void rebuildDialog(GenericDialog gd) {
// extract GUI components from dialog and add listeners
List<Checkbox> boxes = null;
List<Choice> choices = null;
List<Label> labels = null;
Label colorModeLabel = null;
Label roisModeLabel = null;
Label stackFormatLabel = null;
Label stackOrderLabel = null;
Component[] c = gd.getComponents();
if (c != null) {
boxes = new ArrayList<Checkbox>();
choices = new ArrayList<Choice>();
labels = new ArrayList<Label>();
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof Checkbox) {
Checkbox item = (Checkbox) c[i];
item.addFocusListener(this);
item.addItemListener(this);
item.addMouseListener(this);
boxes.add(item);
} else if (c[i] instanceof Choice) {
Choice item = (Choice) c[i];
item.addFocusListener(this);
item.addItemListener(this);
item.addMouseListener(this);
choices.add(item);
} else if (c[i] instanceof Label)
labels.add((Label) c[i]);
}
int boxIndex = 0, choiceIndex = 0, labelIndex = 0;
autoscaleBox = boxes.get(boxIndex++);
colorModeChoice = choices.get(choiceIndex++);
colorModeLabel = labels.get(labelIndex++);
concatenateBox = boxes.get(boxIndex++);
cropBox = boxes.get(boxIndex++);
groupFilesBox = boxes.get(boxIndex++);
ungroupFilesBox = boxes.get(boxIndex++);
openAllSeriesBox = boxes.get(boxIndex++);
// quiet
boxIndex++;
// recordBox = boxes.get(boxIndex++);
showMetadataBox = boxes.get(boxIndex++);
showOMEXMLBox = boxes.get(boxIndex++);
showROIsBox = boxes.get(boxIndex++);
roisModeChoice = choices.get(choiceIndex++);
roisModeLabel = labels.get(labelIndex++);
specifyRangesBox = boxes.get(boxIndex++);
splitZBox = boxes.get(boxIndex++);
splitTBox = boxes.get(boxIndex++);
splitCBox = boxes.get(boxIndex++);
stackFormatChoice = choices.get(choiceIndex++);
stackFormatLabel = labels.get(labelIndex++);
stackOrderChoice = choices.get(choiceIndex++);
stackOrderLabel = labels.get(labelIndex++);
swapDimsBox = boxes.get(boxIndex++);
virtualBox = boxes.get(boxIndex++);
stitchTilesBox = boxes.get(boxIndex++);
}
verifyOptions(null);
// TODO: The info table and focus logic could be split into
// its own class, rather than being specific to this dialog.
// associate information for each option
infoTable = new HashMap<Component, String>();
infoTable.put(autoscaleBox, options.getAutoscaleInfo());
infoTable.put(colorModeChoice, options.getColorModeInfo());
infoTable.put(colorModeLabel, options.getColorModeInfo());
infoTable.put(concatenateBox, options.getConcatenateInfo());
infoTable.put(cropBox, options.getCropInfo());
infoTable.put(groupFilesBox, options.getGroupFilesInfo());
infoTable.put(ungroupFilesBox, options.getUngroupFilesInfo());
infoTable.put(openAllSeriesBox, options.getOpenAllSeriesInfo());
// infoTable.put(recordBox, options.getRecordInfo());
infoTable.put(showMetadataBox, options.getShowMetadataInfo());
infoTable.put(showOMEXMLBox, options.getShowOMEXMLInfo());
infoTable.put(showROIsBox, options.getShowROIsInfo());
infoTable.put(roisModeChoice, options.getROIsModeInfo());
infoTable.put(roisModeLabel, options.getROIsModeInfo());
infoTable.put(specifyRangesBox, options.getSpecifyRangesInfo());
infoTable.put(splitZBox, options.getSplitFocalPlanesInfo());
infoTable.put(splitTBox, options.getSplitTimepointsInfo());
infoTable.put(splitCBox, options.getSplitChannelsInfo());
infoTable.put(stackFormatChoice, options.getStackFormatInfo());
infoTable.put(stackFormatLabel, options.getStackFormatInfo());
infoTable.put(stackOrderChoice, options.getStackOrderInfo());
infoTable.put(stackOrderLabel, options.getStackOrderInfo());
infoTable.put(swapDimsBox, options.getSwapDimensionsInfo());
infoTable.put(virtualBox, options.getVirtualInfo());
infoTable.put(stitchTilesBox, options.getStitchTilesInfo());
// rebuild dialog using FormLayout to organize things more nicely
String cols = // first column
"pref, 3dlu, pref:grow, " + // second column
"10dlu, pref, 3dlu, pref:grow, " + // third column
"10dlu, fill:150dlu";
String rows = // Stack viewing | Metadata viewing
"pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + // Dataset organization | Memory management
"9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + "3dlu, pref, " + // Color options | Split into separate windows
"9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref";
// TODO: Change "Use virtual stack" and "Record modifications to virtual
// stack" checkboxes to "Stack type" choice with options:
// "Normal", "Virtual" or "Smart virtual"
PanelBuilder builder = new PanelBuilder(new FormLayout(cols, rows));
CellConstraints cc = new CellConstraints();
// populate 1st column
int row = 1;
builder.addSeparator("Stack viewing", cc.xyw(1, row, 3));
row += 2;
builder.add(stackFormatLabel, cc.xy(1, row));
builder.add(stackFormatChoice, cc.xy(3, row));
row += 2;
builder.add(stackOrderLabel, cc.xy(1, row));
builder.add(stackOrderChoice, cc.xy(3, row));
row += 6;
builder.addSeparator("Dataset organization", cc.xyw(1, row, 3));
row += 2;
builder.add(groupFilesBox, xyw(cc, 1, row, 3));
row += 2;
builder.add(ungroupFilesBox, xyw(cc, 1, row, 3));
row += 2;
builder.add(swapDimsBox, xyw(cc, 1, row, 3));
row += 2;
builder.add(openAllSeriesBox, xyw(cc, 1, row, 3));
row += 2;
builder.add(concatenateBox, xyw(cc, 1, row, 3));
row += 2;
builder.add(stitchTilesBox, xyw(cc, 1, row, 3));
row += 2;
builder.addSeparator("Color options", cc.xyw(1, row, 3));
row += 2;
builder.add(colorModeLabel, cc.xy(1, row));
builder.add(colorModeChoice, cc.xy(3, row));
row += 2;
builder.add(autoscaleBox, xyw(cc, 1, row, 3));
row += 2;
// populate 2nd column
row = 1;
builder.addSeparator("Metadata viewing", cc.xyw(5, row, 3));
row += 2;
builder.add(showMetadataBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(showOMEXMLBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(showROIsBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(roisModeLabel, cc.xy(5, row));
builder.add(roisModeChoice, cc.xy(7, row));
row += 2;
builder.addSeparator("Memory management", cc.xyw(5, row, 3));
row += 2;
builder.add(virtualBox, xyw(cc, 5, row, 3));
row += 2;
// builder.add(recordBox, xyw(cc, 5, row, 3));
// row += 2;
builder.add(specifyRangesBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(cropBox, xyw(cc, 5, row, 3));
row += 4;
builder.addSeparator("Split into separate windows", cc.xyw(5, row, 3));
row += 2;
builder.add(splitCBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(splitZBox, xyw(cc, 5, row, 3));
row += 2;
builder.add(splitTBox, xyw(cc, 5, row, 3));
// row += 4;
// information section
builder.addSeparator("Information", cc.xy(9, 1));
// row += 2;
infoPane = new JEditorPane();
infoPane.setContentType("text/html");
infoPane.setEditable(false);
infoPane.setText("<html>" + INFO_DEFAULT);
builder.add(new JScrollPane(infoPane), cc.xywh(9, 3, 1, row));
// row += 2;
gd.removeAll();
gd.add(builder.getPanel());
WindowTools.addScrollBars(gd);
// HACK: workaround for JPanel in a Dialog
gd.setBackground(Color.white);
}
use of java.awt.Label in project jadx by skylot.
the class ADBDialog method initUI.
private void initUI() {
pathTextField = new JTextField();
portTextField = new JTextField();
hostTextField = new JTextField();
JPanel adbPanel = new JPanel(new BorderLayout(5, 5));
adbPanel.add(new JLabel(NLS.str("adb_dialog.path")), BorderLayout.WEST);
adbPanel.add(pathTextField, BorderLayout.CENTER);
JPanel portPanel = new JPanel(new BorderLayout(5, 0));
portPanel.add(new JLabel(NLS.str("adb_dialog.port")), BorderLayout.WEST);
portPanel.add(portTextField, BorderLayout.CENTER);
JPanel hostPanel = new JPanel(new BorderLayout(5, 0));
hostPanel.add(new JLabel(NLS.str("adb_dialog.addr")), BorderLayout.WEST);
hostPanel.add(hostTextField, BorderLayout.CENTER);
JPanel wrapperPanel = new JPanel(new GridLayout(1, 2, 5, 0));
wrapperPanel.add(hostPanel);
wrapperPanel.add(portPanel);
adbPanel.add(wrapperPanel, BorderLayout.SOUTH);
procTree = new JTree();
JScrollPane scrollPane = new JScrollPane(procTree);
scrollPane.setMinimumSize(new Dimension(100, 150));
scrollPane.setBorder(BorderFactory.createLineBorder(Color.black));
procTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
procTreeRoot = new DefaultMutableTreeNode(NLS.str("adb_dialog.device_node"));
procTreeModel = new DefaultTreeModel(procTreeRoot);
procTree.setModel(procTreeModel);
procTree.setRowHeight(-1);
Font font = mainWindow.getSettings().getFont();
procTree.setFont(font.deriveFont(font.getSize() + 1.f));
procTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
processSelected(e);
}
}
});
procTree.setCellRenderer(new DefaultTreeCellRenderer() {
private static final long serialVersionUID = -1111111202103170735L;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof DeviceTreeNode || value == procTreeRoot) {
setIcon(ICON_DEVICE);
} else {
setIcon(ICON_PROCESS);
}
return c;
}
});
JPanel btnPane = new JPanel();
BoxLayout boxLayout = new BoxLayout(btnPane, BoxLayout.LINE_AXIS);
btnPane.setLayout(boxLayout);
tipLabel = new Label(NLS.str("adb_dialog.waiting"));
btnPane.add(tipLabel);
JButton refreshBtn = new JButton(NLS.str("adb_dialog.refresh"));
JButton startServerBtn = new JButton(NLS.str("adb_dialog.start_server"));
JButton launchAppBtn = new JButton(NLS.str("adb_dialog.launch_app"));
btnPane.add(launchAppBtn);
btnPane.add(startServerBtn);
btnPane.add(refreshBtn);
refreshBtn.addActionListener(e -> {
clear();
procTreeRoot.removeAllChildren();
procTreeModel.reload(procTreeRoot);
SwingUtilities.invokeLater(this::connectToADB);
});
startServerBtn.addActionListener(e -> startADBServer());
launchAppBtn.addActionListener(e -> launchApp());
JPanel mainPane = new JPanel(new BorderLayout(5, 5));
mainPane.add(adbPanel, BorderLayout.NORTH);
mainPane.add(scrollPane, BorderLayout.CENTER);
mainPane.add(btnPane, BorderLayout.SOUTH);
mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
getContentPane().add(mainPane);
pack();
setSize(800, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setModalityType(ModalityType.MODELESS);
}
use of java.awt.Label in project jadx by skylot.
the class SetValueDialog method initUI.
private void initUI() {
JTextField valField = new JTextField();
TextStandardActions.attach(valField);
JPanel valPane = new JPanel(new BorderLayout(5, 5));
valPane.add(new JLabel(NLS.str("set_value_dialog.label_value")), BorderLayout.WEST);
valPane.add(valField, BorderLayout.CENTER);
JPanel btnPane = new JPanel();
btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.LINE_AXIS));
JButton setValueBtn = new JButton(NLS.str("set_value_dialog.btn_set"));
btnPane.add(new Label());
btnPane.add(setValueBtn);
UiUtils.addKeyBinding(valField, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "set value", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
setValueBtn.doClick();
}
});
JPanel typePane = new JPanel();
typePane.setLayout(new BoxLayout(typePane, BoxLayout.LINE_AXIS));
java.util.List<JRadioButton> rbs = new ArrayList<>(6);
rbs.add(new JRadioButton("int"));
rbs.add(new JRadioButton("String"));
rbs.add(new JRadioButton("long"));
rbs.add(new JRadioButton("float"));
rbs.add(new JRadioButton("double"));
rbs.add(new JRadioButton("Object id"));
// select int radio
rbs.get(0).setSelected(true);
ButtonGroup rbGroup = new ButtonGroup();
rbs.forEach(rbGroup::add);
rbs.forEach(typePane::add);
JPanel mainPane = new JPanel(new BorderLayout(5, 5));
mainPane.add(typePane, BorderLayout.NORTH);
mainPane.add(valPane, BorderLayout.CENTER);
mainPane.add(btnPane, BorderLayout.SOUTH);
mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
getContentPane().add(mainPane);
this.setTitle(NLS.str("set_value_dialog.title"));
pack();
setSize(480, 160);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setModalityType(ModalityType.MODELESS);
UiUtils.addEscapeShortCutToDispose(this);
setValueBtn.addActionListener(new AbstractAction() {
private static final long serialVersionUID = -1111111202103260220L;
@Override
public void actionPerformed(ActionEvent e) {
boolean ok;
try {
Entry<ArgType, Object> type = getType();
if (type != null) {
ok = mainWindow.getDebuggerPanel().getDbgController().modifyRegValue(valNode, type.getKey(), type.getValue());
} else {
UiUtils.showMessageBox(mainWindow, NLS.str("set_value_dialog.sel_type"));
return;
}
} catch (JadxRuntimeException except) {
UiUtils.showMessageBox(mainWindow, except.getMessage());
return;
}
if (ok) {
dispose();
} else {
UiUtils.showMessageBox(mainWindow, NLS.str("set_value_dialog.neg_msg"));
}
}
private Entry<ArgType, Object> getType() {
String val = valField.getText();
for (JRadioButton rb : rbs) {
if (rb.isSelected()) {
switch(rb.getText()) {
case "int":
return new SimpleEntry<>(ArgType.INT, Integer.valueOf(val));
case "String":
return new SimpleEntry<>(ArgType.STRING, val);
case "long":
return new SimpleEntry<>(ArgType.LONG, Long.valueOf(val));
case "float":
return new SimpleEntry<>(ArgType.FLOAT, Float.valueOf(val));
case "double":
return new SimpleEntry<>(ArgType.DOUBLE, Double.valueOf(val));
case "Object id":
return new SimpleEntry<>(ArgType.OBJECT, Long.valueOf(val));
default:
throw new JadxRuntimeException("Unexpected type: " + rb.getText());
}
}
}
return null;
}
});
}
use of java.awt.Label in project propane by ruby-processing.
the class PSurfaceAWT method placePresent.
// public void placeFullScreen(boolean hideStop) {
@Override
public void placePresent(int stopColor) {
setFullFrame();
// After the pack(), the screen bounds are gonna be 0s
// frame.setBounds(screenRect); // already called in setFullFrame()
canvas.setBounds((screenRect.width - sketchWidth) / 2, (screenRect.height - sketchHeight) / 2, sketchWidth, sketchHeight);
if (stopColor != 0) {
Label label = new Label("stop");
label.setForeground(new Color(stopColor, false));
label.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(java.awt.event.MouseEvent e) {
sketch.exit();
}
});
frame.add(label);
Dimension labelSize = label.getPreferredSize();
// sometimes shows up truncated on mac
// System.out.println("label width is " + labelSize.width);
labelSize = new Dimension(100, labelSize.height);
label.setSize(labelSize);
label.setLocation(20, screenRect.height - labelSize.height - 20);
}
// if (sketch.getGraphics().displayable()) {
// setVisible(true);
// }
}
Aggregations