use of javax.swing.GroupLayout.ParallelGroup in project cytoscape-impl by cytoscape.
the class AttributeEditorPanel method initComponents.
private void initComponents() {
listDelimiterLabel = new JLabel("List Delimiter:");
listDelimiterLabel.putClientProperty("JComponent.sizeVariant", "small");
typeButtonGroup = new ButtonGroup();
dataTypeButtonGroup = new ButtonGroup();
final List<JToggleButton> dataTypeBtnList = new ArrayList<>();
dataTypeBtnList.add(stringButton = createDataTypeButton(TYPE_STRING));
dataTypeBtnList.add(integerButton = createDataTypeButton(TYPE_INTEGER));
dataTypeBtnList.add(longButton = createDataTypeButton(TYPE_LONG));
dataTypeBtnList.add(floatingPointButton = createDataTypeButton(TYPE_FLOATING));
dataTypeBtnList.add(booleanButton = createDataTypeButton(TYPE_BOOLEAN));
dataTypeBtnList.add(stringListButton = createDataTypeButton(TYPE_STRING_LIST));
dataTypeBtnList.add(integerListButton = createDataTypeButton(TYPE_INTEGER_LIST));
dataTypeBtnList.add(longListButton = createDataTypeButton(TYPE_LONG_LIST));
dataTypeBtnList.add(floatingPointListButton = createDataTypeButton(TYPE_FLOATING_LIST));
dataTypeBtnList.add(booleanListButton = createDataTypeButton(TYPE_BOOLEAN_LIST));
setStyles(dataTypeBtnList);
final GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(false);
final SequentialGroup typeHGroup = layout.createSequentialGroup();
final ParallelGroup typeVGroup = layout.createParallelGroup(CENTER, false);
for (SourceColumnSemantic type : availableTypes) {
final JToggleButton btn = createTypeButton(type);
typeHGroup.addComponent(btn, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE);
typeVGroup.addComponent(btn);
}
setStyles(new ArrayList<JToggleButton>(typeButtons.values()));
final JLabel typeLabel = new JLabel("Meaning:");
typeLabel.putClientProperty("JComponent.sizeVariant", "small");
final JLabel dataTypeLabel = new JLabel("Data Type:");
dataTypeLabel.putClientProperty("JComponent.sizeVariant", "small");
layout.setHorizontalGroup(layout.createParallelGroup(CENTER, true).addComponent(getAttributeNameTextField(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(typeLabel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addGroup(typeHGroup).addComponent(dataTypeLabel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(stringButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(integerButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(longButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(floatingPointButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(booleanButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(stringListButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(integerListButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(longListButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(floatingPointListButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(booleanListButton, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(listDelimiterLabel).addPreferredGap(ComponentPlacement.RELATED).addComponent(getListDelimiterComboBox(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(getOtherTextField(), 12, 36, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(getAttributeNameTextField(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(typeLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(typeVGroup).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(dataTypeLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(CENTER).addComponent(stringButton).addComponent(integerButton).addComponent(longButton).addComponent(floatingPointButton).addComponent(booleanButton)).addGroup(layout.createParallelGroup(CENTER).addComponent(stringListButton).addComponent(integerListButton).addComponent(longListButton).addComponent(floatingPointListButton).addComponent(booleanListButton)).addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(CENTER).addComponent(listDelimiterLabel).addComponent(getListDelimiterComboBox(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(getOtherTextField(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE))));
}
use of javax.swing.GroupLayout.ParallelGroup in project com.revolsys.open by revolsys.
the class GroupLayouts method makeColumns.
public static void makeColumns(final Container container, final GroupLayout groupLayout, final int columnCount) {
final int componentCount = container.getComponentCount();
final int numRows = (int) Math.ceil(componentCount / (double) columnCount);
final SequentialGroup horizontalGroup = groupLayout.createSequentialGroup();
groupLayout.setHorizontalGroup(horizontalGroup);
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
final ParallelGroup columnGroup = groupLayout.createParallelGroup(Alignment.LEADING);
horizontalGroup.addGroup(columnGroup);
for (int rowIndex = 0; rowIndex < numRows; rowIndex++) {
final int componentIndex = rowIndex * columnCount + columnIndex;
if (componentIndex < componentCount) {
final Component component = container.getComponent(componentIndex);
columnGroup.addComponent(component, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
}
}
}
final SequentialGroup verticalGroup = groupLayout.createSequentialGroup();
groupLayout.setVerticalGroup(verticalGroup);
for (int rowIndex = 0; rowIndex < numRows; rowIndex++) {
final ParallelGroup rowGroup = groupLayout.createParallelGroup(Alignment.BASELINE);
verticalGroup.addGroup(rowGroup);
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
final int componentIndex = rowIndex * columnCount + columnIndex;
if (componentIndex < componentCount) {
final Component component = container.getComponent(componentIndex);
rowGroup.addComponent(component, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
}
}
}
}
use of javax.swing.GroupLayout.ParallelGroup in project cytoscape-impl by cytoscape.
the class CompositeTransformerPanel method updateLayout.
@Override
public void updateLayout() {
removeAll();
final ParallelGroup checkBoxGroup = layout.createParallelGroup(Alignment.LEADING);
final ParallelGroup viewGroup = layout.createParallelGroup(Alignment.LEADING);
final Group columns = layout.createParallelGroup(Alignment.LEADING, true).addGroup(layout.createSequentialGroup().addGap(4).addGroup(checkBoxGroup).addGap(4).addGroup(viewGroup));
final Group rows = layout.createSequentialGroup();
int separatorHeight = 5;
viewGroup.addComponent(separator);
rows.addComponent(separator, separatorHeight, separatorHeight, separatorHeight);
for (Transformer<CyNetwork, CyIdentifiable> transformer : model) {
final TransformerElementViewModel<TransformerPanel> viewModel = viewModels.get(transformer);
if (viewModel.view instanceof CompositeFilterPanel) {
CompositeFilterPanel<?> panel = (CompositeFilterPanel<?>) viewModel.view;
panel.updateLayout();
}
checkBoxGroup.addGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup().addComponent(viewModel.deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addGap(4).addComponent(viewModel.handle, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)).addGap(4).addComponent(viewModel.warnIcon, Alignment.CENTER));
viewGroup.addComponent(viewModel.view, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addComponent(viewModel.separator);
rows.addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(ViewUtil.INTERNAL_VERTICAL_PADDING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(viewModel.deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addComponent(viewModel.handle, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(4).addComponent(viewModel.warnIcon))).addComponent(viewModel.view, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
rows.addComponent(viewModel.separator, separatorHeight, separatorHeight, separatorHeight);
}
columns.addComponent(addButton);
rows.addGap(ViewUtil.INTERNAL_VERTICAL_PADDING).addComponent(addButton);
layout.setHorizontalGroup(columns);
layout.setVerticalGroup(rows);
}
use of javax.swing.GroupLayout.ParallelGroup in project cytoscape-api by cytoscape.
the class CyToolTip method init.
private void init() {
final Color bg = new Color(UIManager.getColor("Table.foreground").getRGB());
final Color fg = new Color(UIManager.getColor("Table.background").getRGB());
final JPanel content = new JPanel();
content.setBackground(bg);
int w = icon != null ? icon.getIconWidth() : 0;
final GroupLayout layout = new GroupLayout(content);
content.setLayout(layout);
layout.setAutoCreateContainerGaps(false);
layout.setAutoCreateGaps(true);
final ParallelGroup hGroup = layout.createParallelGroup(icon != null ? CENTER : LEADING, true);
final SequentialGroup vGroup = layout.createSequentialGroup();
layout.setHorizontalGroup(layout.createSequentialGroup().addGap(2).addGroup(hGroup).addGap(2));
layout.setVerticalGroup(layout.createSequentialGroup().addGap(icon != null ? 2 : 4).addGroup(vGroup).addGap(4));
if (icon != null) {
if (icon.getIconWidth() > 20)
w = icon.getIconWidth();
JLabel lbl = new JLabel(icon);
if (// In case the image is animated
icon instanceof ImageIcon)
((ImageIcon) icon).setImageObserver(lbl);
addComponent(lbl, hGroup, vGroup, w);
}
if (desc != null) {
JLabel lbl = new JLabel(desc);
lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
lbl.setForeground(fg);
addComponent(lbl, hGroup, vGroup, w);
}
if (longDesc != null && !longDesc.equalsIgnoreCase(desc)) {
// Don't show the same text twice!
JTextArea ta = new JTextArea(longDesc);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
ta.setEditable(false);
ta.setForeground(fg);
ta.setBackground(bg);
JScrollPane sp = new JScrollPane(ta);
// We cannot have scroll bars here, because it's a tool tip,
// so users would not be able to interact with the bars.
sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
sp.setBackground(bg);
sp.getViewport().setBackground(bg);
sp.setBorder(BorderFactory.createEmptyBorder());
addComponent(sp, hGroup, vGroup, w);
}
adjustSize(content);
setLayout(new BorderLayout());
add(content, BorderLayout.CENTER);
}
use of javax.swing.GroupLayout.ParallelGroup in project cytoscape-api by cytoscape.
the class LookAndFeelUtil method createOkCancelPanel.
/**
* Use this method to include a help button in the bottom left corner.
* @param helpStr can be a full url, a lookup, or a help page name
*/
public static JPanel createOkCancelPanel(final JButton okBtn, final JButton cancelBtn, String helpStr, JComponent... otherComponents) {
final JPanel panel = new JPanel();
final GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateContainerGaps(false);
layout.setAutoCreateGaps(true);
final SequentialGroup hg = layout.createSequentialGroup();
final ParallelGroup vg = layout.createParallelGroup(Alignment.CENTER, false);
if (helpStr != null && !helpStr.trim().isEmpty()) {
final JButton helpButton = createHelpButton(helpStr);
hg.addComponent(helpButton);
vg.addComponent(helpButton);
}
if (otherComponents != null) {
for (int i = 0; i < otherComponents.length; i++) {
final JComponent c = otherComponents[i];
hg.addComponent(c);
vg.addComponent(c);
}
}
hg.addGap(0, 0, Short.MAX_VALUE);
final JButton btn1 = isMac() ? cancelBtn : okBtn;
final JButton btn2 = isMac() ? okBtn : cancelBtn;
if (btn1 != null) {
hg.addComponent(btn1);
vg.addComponent(btn1);
}
if (btn2 != null) {
hg.addComponent(btn2);
vg.addComponent(btn2);
}
layout.setHorizontalGroup(hg);
layout.setVerticalGroup(vg);
if (okBtn != null && cancelBtn != null)
equalizeSize(okBtn, cancelBtn);
return panel;
}
Aggregations