use of net.miginfocom.layout.AC in project cuba by cuba-platform.
the class MigBoxLayoutAdapter method updateLayoutConstraints.
private void updateLayoutConstraints(boolean resetExpanded) {
LC lc = new LC();
// Invisible components will not participate in the layout at all and it will for instance not take up a grid cell
lc.hideMode(2);
// always give all space to components, otherwise align doesn't work
lc.fill();
AC rowConstr = new AC();
AC colConstr = new AC();
if (direction.equals(FlowDirection.X)) {
rowConstr.align("top");
lc.flowX();
if (expandedComponent != null || resetExpanded) {
adjustExpanding(lc, colConstr);
}
} else {
lc.flowY();
if (expandedComponent != null || resetExpanded) {
adjustExpanding(lc, rowConstr);
}
}
lc.setInsets(MigLayoutHelper.makeInsets(margins));
if (!spacing) {
if (direction.equals(FlowDirection.X)) {
lc.gridGapX("0");
} else {
lc.gridGapY("0");
}
}
if (isDebug())
lc.debug(1000);
layout.setLayoutConstraints(lc);
layout.setRowConstraints(rowConstr);
layout.setColumnConstraints(colConstr);
}
use of net.miginfocom.layout.AC in project cuba by cuba-platform.
the class LayoutTest method testTableAndButtons.
private void testTableAndButtons() {
MigLayout mainLayout = new MigLayout();
JPanel mainPanel = new JPanel(mainLayout);
contentPane.add(mainPanel, BorderLayout.CENTER);
mainLayout.setLayoutConstraints("flowy, fillx, insets panel, debug");
MigLayout buttonsLayout = new MigLayout("flowx, filly, insets panel, debug");
JPanel buttonsPanel = new JPanel(buttonsLayout);
buttonsPanel.add(new JButton("button1"));
buttonsPanel.add(new JButton("button2"));
mainPanel.add(buttonsPanel);
MigLayout tableLayout = new MigLayout("flowy, fill, debug");
JPanel tablePanel = new JPanel(tableLayout);
JTable table = new JTable();
table.setModel(new DefaultTableModel(new String[] { "col1", "col2" }, 3));
tablePanel.add(table, "grow");
mainPanel.add(tablePanel);
mainLayout.setComponentConstraints(tablePanel, "grow");
// change fillx to fill
mainLayout.setLayoutConstraints("flowy, fill, insets panel, debug");
// mainLayout.setRowConstraints("[min!][fill]");
AC ac = new AC().size("min!", 0).fill(1);
mainLayout.setRowConstraints(ac);
}
use of net.miginfocom.layout.AC in project cuba by cuba-platform.
the class VclTestApp method createAlignTab.
private Component createAlignTab() {
JPanel box = new JPanel();
box.setFocusable(false);
MigLayout boxLayout = new MigLayout("debug 1000, fill");
box.setLayout(boxLayout);
JPanel panel = new JPanel();
MigLayout layout = new MigLayout("debug 1000, fill");
panel.setLayout(layout);
JLabel label = new JLabel("Label");
CC cc = new CC();
cc.alignX("right").alignY("50%");
panel.add(label);
layout.setComponentConstraints(label, cc);
LC lc = new LC();
// The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.
lc.hideMode(2);
lc.debug(1000);
AC rowConstr = new AC();
AC colConstr = new AC();
lc.fillX();
lc.flowY();
lc.gridGapY("0");
layout.setLayoutConstraints(lc);
layout.setRowConstraints(rowConstr);
layout.setColumnConstraints(colConstr);
box.add(panel, "height 100px, width 100px");
layout.setComponentConstraints(label, cc);
return box;
}
use of net.miginfocom.layout.AC in project cuba by cuba-platform.
the class MigGridLayoutAdapter method update.
@Override
protected void update() {
LC lc = new LC();
lc.setWrapAfter(getColumns());
// The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.
lc.hideMode(2);
lc.fill();
lc.setInsets(MigLayoutHelper.makeInsets(margins));
if (!spacing) {
lc.gridGap("0", "0");
}
if (isDebug())
lc.debug(1000);
layout.setLayoutConstraints(lc);
AC rowConstr = new AC();
// left-top align by default
rowConstr.align("top");
layout.setRowConstraints(rowConstr);
AC colConstr = new AC();
for (int i = 0; i < colCount; i++) {
float ratio = columnRatio[i];
colConstr.grow(ratio, i);
colConstr.shrink(ratio != 0 ? (float) Math.sqrt(1.0f / ratio) : 100.0f, i);
}
layout.setColumnConstraints(colConstr);
}
Aggregations