Example usage for com.jgoodies.forms.layout CellConstraints BOTTOM

List of usage examples for com.jgoodies.forms.layout CellConstraints BOTTOM

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints BOTTOM.

Prototype

Alignment BOTTOM

To view the source code for com.jgoodies.forms.layout CellConstraints BOTTOM.

Click Source Link

Document

Put the component in the bottom.

Usage

From source file:org.eclipse.wb.internal.swing.FormLayout.gef.FormSelectionEditPolicy.java

License:Open Source License

@Override
public void performRequest(Request request) {
    if (request instanceof KeyRequest) {
        KeyRequest keyRequest = (KeyRequest) request;
        if (keyRequest.isPressed()) {
            char c = keyRequest.getCharacter();
            // horizontal
            if (c == 'd') {
                setAlignment(true, CellConstraints.DEFAULT);
            } else if (c == 'l') {
                setAlignment(true, CellConstraints.LEFT);
            } else if (c == 'f') {
                setAlignment(true, CellConstraints.FILL);
            } else if (c == 'c') {
                setAlignment(true, CellConstraints.CENTER);
            } else if (c == 'r') {
                setAlignment(true, CellConstraints.RIGHT);
            }/*from  w  w  w.jav  a  2s . c o m*/
            // vertical
            if (c == 'D') {
                setAlignment(false, CellConstraints.DEFAULT);
            } else if (c == 't') {
                setAlignment(false, CellConstraints.TOP);
            } else if (c == 'F') {
                setAlignment(false, CellConstraints.FILL);
            } else if (c == 'm') {
                setAlignment(false, CellConstraints.CENTER);
            } else if (c == 'b') {
                setAlignment(false, CellConstraints.BOTTOM);
            }
        }
    }
}

From source file:org.eclipse.wb.internal.swing.FormLayout.model.CellConstraintsAssistantPage.java

License:Open Source License

public CellConstraintsAssistantPage(Composite parent, FormLayoutInfo layout, List<ObjectInfo> objects) {
    super(parent, objects);
    m_layout = layout;/* ww w .  jav a  2  s. co m*/
    GridLayoutFactory.create(this).columns(3);
    // horizontal alignments
    {
        Group horizontalGroup = addChoiceProperty(this, "h alignment",
                ModelMessages.CellConstraintsAssistantPage_horizontalGroup,
                new Object[][] {
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_haDefault,
                                CellConstraints.DEFAULT },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_haLeft,
                                CellConstraints.LEFT },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_haCenter,
                                CellConstraints.CENTER },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_haRight,
                                CellConstraints.RIGHT },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_haFill,
                                CellConstraints.FILL } });
        GridDataFactory.modify(horizontalGroup).fill();
    }
    // vertical alignments
    {
        Group verticalGroup = addChoiceProperty(this, "v alignment",
                ModelMessages.CellConstraintsAssistantPage_verticalGroup,
                new Object[][] {
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_vaDefault,
                                CellConstraints.DEFAULT },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_vaTop, CellConstraints.TOP },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_vaCenter,
                                CellConstraints.CENTER },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_vaBottom,
                                CellConstraints.BOTTOM },
                        new Object[] { ModelMessages.CellConstraintsAssistantPage_vaFill,
                                CellConstraints.FILL } });
        GridDataFactory.modify(verticalGroup).fill();
    }
    // grid
    {
        Group gridGroup = addIntegerProperties(this, ModelMessages.CellConstraintsAssistantPage_gridGroup,
                new String[][] { { "grid x", ModelMessages.CellConstraintsAssistantPage_gridX },
                        { "grid y", ModelMessages.CellConstraintsAssistantPage_gridY },
                        { "grid width", ModelMessages.CellConstraintsAssistantPage_gridWidth },
                        { "grid height", ModelMessages.CellConstraintsAssistantPage_gridHeight } });
        GridDataFactory.modify(gridGroup).fill();
    }
}

From source file:org.eclipse.wb.internal.swing.FormLayout.model.CellConstraintsSupport.java

License:Open Source License

/**
 * @return the small {@link Image} that represents horizontal/vertical alignment.
 *///from  w  w  w.  ja  va 2s  .  com
public Image getSmallAlignmentImage(boolean horizontal) {
    if (horizontal) {
        if (alignH == CellConstraints.LEFT) {
            return Activator.getImage("alignment/h/left.gif");
        } else if (alignH == CellConstraints.CENTER) {
            return Activator.getImage("alignment/h/center.gif");
        } else if (alignH == CellConstraints.RIGHT) {
            return Activator.getImage("alignment/h/right.gif");
        } else if (alignH == CellConstraints.FILL) {
            return Activator.getImage("alignment/h/fill.gif");
        } else {
            return null;
        }
    } else {
        if (alignV == CellConstraints.TOP) {
            return Activator.getImage("alignment/v/top.gif");
        } else if (alignV == CellConstraints.CENTER) {
            return Activator.getImage("alignment/v/center.gif");
        } else if (alignV == CellConstraints.BOTTOM) {
            return Activator.getImage("alignment/v/bottom.gif");
        } else if (alignV == CellConstraints.FILL) {
            return Activator.getImage("alignment/v/fill.gif");
        } else {
            return null;
        }
    }
}

From source file:org.eclipse.wb.internal.swing.FormLayout.model.CellConstraintsSupport.java

License:Open Source License

/**
 * Adds the vertical alignment {@link Action}'s.
 *///from   ww  w .j a v  a  2s .com
public void fillVerticalAlignmentMenu(IMenuManager manager2) {
    manager2.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_vaDefault, "default.gif", false,
            CellConstraints.DEFAULT));
    manager2.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_vaTop, "top.gif", false,
            CellConstraints.TOP));
    manager2.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_vaCenter, "center.gif", false,
            CellConstraints.CENTER));
    manager2.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_vaBottom, "bottom.gif", false,
            CellConstraints.BOTTOM));
    manager2.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_vaFill, "fill.gif", false,
            CellConstraints.FILL));
}

From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormLayoutConverter.java

License:Open Source License

/**
 * Calculate vertical alignment.//from ww w  . j a v a  2 s.c  o m
 */
private static CellConstraints.Alignment getVerticalAlignment(List<ComponentGroup> rows,
        ComponentInGroup componentInGroup, GeneralLayoutData generalLayoutData) {
    if (generalLayoutData.verticalAlignment != null) {
        // from general layout data
        CellConstraints.Alignment alignment = GeneralLayoutData
                .getRealValue(FormLayoutInfo.m_verticalAlignmentMap, generalLayoutData.verticalAlignment);
        if (alignment != null && alignment != CellConstraints.DEFAULT) {
            return alignment;
        }
    }
    // calculate
    IAbstractComponentInfo component = componentInGroup.getComponent();
    // prepare begin/end row
    ComponentGroup beginRow = GridConvertionHelper.getBeginForComponent(rows, componentInGroup);
    ComponentGroup endRow = GridConvertionHelper.getEndForComponent(rows, componentInGroup);
    Rectangle bounds = component.getBounds();
    Dimension prefSize = component.getPreferredSize();
    int bt = bounds.y;
    int bb = bounds.bottom();
    int rowTop = beginRow.getMin();
    int rowBottom = endRow.getMax();
    int rowCenter = rowTop + (rowBottom - rowTop) / 2;
    //
    int topOffset = bt - rowTop;
    int bottomOffset = rowBottom - bb;
    // prepare how much location of two sides will be changed for each alignment
    int topDelta = topOffset + Math.abs(rowTop + prefSize.height - bb);
    int bottomDelta = bottomOffset + Math.abs(rowBottom - prefSize.height - bt);
    int fillDelta = topOffset + bottomOffset;
    int centerDelta = Math.abs(bt - (rowCenter - prefSize.height / 2))
            + Math.abs(bb - (rowCenter + prefSize.height / 2));
    // set alignment
    return getAlignment(new int[] { topDelta, centerDelta, bottomDelta, fillDelta }, new Alignment[] {
            CellConstraints.TOP, CellConstraints.CENTER, CellConstraints.BOTTOM, CellConstraints.FILL });
}

From source file:org.eclipse.wb.internal.swing.FormLayout.model.SelectionActionsSupport.java

License:Open Source License

@Override
public void addSelectionActions(List<ObjectInfo> objects, List<Object> actions) throws Exception {
    if (objects.isEmpty()) {
        return;/*from  w ww .j  a va2  s .  com*/
    }
    // prepare constraints
    List<CellConstraintsSupport> constraints = Lists.newArrayList();
    for (ObjectInfo object : objects) {
        // check object
        if (!(object instanceof ComponentInfo) || object.getParent() != m_layout.getContainer()) {
            return;
        }
        // add data info
        ComponentInfo component = (ComponentInfo) object;
        constraints.add(FormLayoutInfo.getConstraints(component));
    }
    // create horizontal actions
    actions.add(new Separator());
    addAlignmentAction(actions, constraints, true, "default.gif",
            ModelMessages.SelectionActionsSupport_haDefault, CellConstraints.DEFAULT);
    addAlignmentAction(actions, constraints, true, "left.gif", ModelMessages.SelectionActionsSupport_haLeft,
            CellConstraints.LEFT);
    addAlignmentAction(actions, constraints, true, "center.gif", ModelMessages.SelectionActionsSupport_haCenter,
            CellConstraints.CENTER);
    addAlignmentAction(actions, constraints, true, "right.gif", ModelMessages.SelectionActionsSupport_haRight,
            CellConstraints.RIGHT);
    addAlignmentAction(actions, constraints, true, "fill.gif", ModelMessages.SelectionActionsSupport_haFill,
            CellConstraints.FILL);
    // create vertical actions
    actions.add(new Separator());
    addAlignmentAction(actions, constraints, false, "default.gif",
            ModelMessages.SelectionActionsSupport_vaDefault, CellConstraints.DEFAULT);
    addAlignmentAction(actions, constraints, false, "top.gif", ModelMessages.SelectionActionsSupport_haTop,
            CellConstraints.TOP);
    addAlignmentAction(actions, constraints, false, "center.gif",
            ModelMessages.SelectionActionsSupport_vaCenter, CellConstraints.CENTER);
    addAlignmentAction(actions, constraints, false, "bottom.gif",
            ModelMessages.SelectionActionsSupport_vaBottom, CellConstraints.BOTTOM);
    addAlignmentAction(actions, constraints, false, "fill.gif", ModelMessages.SelectionActionsSupport_vaFill,
            CellConstraints.FILL);
}

From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.CellConstraintsSupportTest.java

License:Open Source License

public void test_property_align_v() throws Exception {
    Property property = m_subProperties[5];
    assertEquals("v alignment", property.getTitle());
    assertFalse(property.isModified());// w ww . j  a v a2 s  .  co  m
    assertEquals(CellConstraints.DEFAULT, property.getValue());
    // set value
    {
        String expectedSource = StringUtils.replace(m_lastEditor.getSource(), "1, 2", "1, 2, default, bottom");
        property.setValue(CellConstraints.BOTTOM);
        assertEditor(expectedSource, m_lastEditor);
    }
    // reset value
    {
        String expectedSource = StringUtils.replace(m_lastEditor.getSource(), "1, 2, default, bottom", "1, 2");
        property.setValue(Property.UNKNOWN_VALUE);
        assertEditor(expectedSource, m_lastEditor);
    }
}

From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.CellConstraintsSupportTest.java

License:Open Source License

public void test_getSmallAlignmentImage() throws Exception {
    check_getSmallAlignmentImage(CellConstraints.DEFAULT, true, false);
    check_getSmallAlignmentImage(CellConstraints.LEFT, true, true);
    check_getSmallAlignmentImage(CellConstraints.CENTER, true, true);
    check_getSmallAlignmentImage(CellConstraints.RIGHT, true, true);
    check_getSmallAlignmentImage(CellConstraints.FILL, true, true);
    ///*from w ww.  ja  v a  2s  .  c  om*/
    check_getSmallAlignmentImage(CellConstraints.DEFAULT, false, false);
    check_getSmallAlignmentImage(CellConstraints.TOP, false, true);
    check_getSmallAlignmentImage(CellConstraints.CENTER, false, true);
    check_getSmallAlignmentImage(CellConstraints.BOTTOM, false, true);
    check_getSmallAlignmentImage(CellConstraints.FILL, false, true);
}

From source file:org.mbari.aved.ui.classifier.ClassImageDirectorySynopsisView.java

License:Open Source License

private void init() {
    this.setLayout(new FormLayout("center:pref:grow", "center:pref:grow, max(20dlu;pref)"));

    CellConstraints ccMain = new CellConstraints();
    BeanAdapter modelAdapter = new BeanAdapter(model);
    JLabel mainLabel = new JLabel(model.getName());

    mainLabel.setFont(new Font("Serif", Font.BOLD, 24));
    mainLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    mainLabel.setBorder(BorderFactory.createEmptyBorder());
    labelPanel = new JPanel();
    labelPanel.add(mainLabel);//from  ww  w. j a va 2s .  c  om
    this.add(labelPanel, ccMain.xy(1, 1));

    JLabel dir = BasicComponentFactory.createLabel(modelAdapter.getValueModel("name"));

    bottomPanel = new JPanel(new FormLayout("2dlu, left:pref, fill:2dlu:grow, right:pref, 2dlu", "pref, pref"));

    CellConstraints cc = new CellConstraints();

    bottomPanel.add(dir, cc.xy(2, 2));

    final JLabel fileCount = new JLabel("Files: " + model.getFileList().size());

    model.addPropertyChangeListener("fileList", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    fileCount.setText("Files: " + model.getFileList().size());
                    fileCount.repaint();
                }
            });
        }
    });
    bottomPanel.add(fileCount, cc.xy(4, 2));

    if (getQuickKey() != 0) {
        bottomPanel.add(new JLabel("QuickKey = " + getQuickKey()), cc.xywh(2, 1, 3, 1));
    }

    this.add(bottomPanel, ccMain.xy(1, 2, CellConstraints.FILL, CellConstraints.BOTTOM));
}

From source file:presentation.start.GuiTabStart.java

License:Open Source License

private void initialize() {
    FormLayout layout = new FormLayout("250:grow, 10, 180:grow, 30, 190", // columns 
            "10, t:130, pref, pref"); // rows
    PanelBuilder builder = new PanelBuilder(this, layout);
    builder.setDefaultDialogBorder();/*  w ww .  j a va  2s .c o m*/
    CellConstraints cc = new CellConstraints();

    builder.add(this.getPanelClient(), cc.xy(1, 2));
    builder.add(this.getPanelInfo(), cc.xyw(3, 2, 3));
    builder.add(this.getPanelNews(), cc.xyw(1, 3, 5));
    builder.add(this.getPanelWarn(), cc.xyw(1, 4, 4));
    builder.add(new JLabel(this.getImageLogo()),
            cc.xywh(5, 4, 1, 1, CellConstraints.CENTER, CellConstraints.BOTTOM));
}