List of usage examples for com.jgoodies.forms.layout CellConstraints DEFAULT
Alignment DEFAULT
To view the source code for com.jgoodies.forms.layout CellConstraints DEFAULT.
Click Source Link
From source file:org.eclipse.wb.internal.swing.FormLayout.model.CellConstraintsSupport.java
License:Open Source License
/** * Adds the horizontal alignment {@link Action}'s. *///www . j a v a 2 s . c om public void fillHorizontalAlignmentMenu(IMenuManager manager) { manager.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_haDefault, "default.gif", true, CellConstraints.DEFAULT)); manager.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_haLeft, "left.gif", true, CellConstraints.LEFT)); manager.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_haCenter, "center.gif", true, CellConstraints.CENTER)); manager.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_haRight, "right.gif", true, CellConstraints.RIGHT)); manager.add(new SetAlignmentAction(ModelMessages.CellConstraintsSupport_haFill, "fill.gif", true, CellConstraints.FILL)); }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.CellConstraintsSupport.java
License:Open Source License
/** * Adds the vertical alignment {@link Action}'s. *///w w w . j av a 2 s . c om 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 horizontal alignment./* ww w.j av a 2 s . co m*/ */ private static CellConstraints.Alignment getHorizontalAlignment(List<ComponentGroup> columns, ComponentInGroup componentInGroup, GeneralLayoutData generalLayoutData) { if (generalLayoutData.horizontalAlignment != null) { // from general layout data CellConstraints.Alignment alignment = GeneralLayoutData .getRealValue(FormLayoutInfo.m_horizontalAlignmentMap, generalLayoutData.horizontalAlignment); if (alignment != null && alignment != CellConstraints.DEFAULT) { return alignment; } } // calculate IAbstractComponentInfo component = componentInGroup.getComponent(); // prepare begin/end column ComponentGroup beginColumn = GridConvertionHelper.getBeginForComponent(columns, componentInGroup); ComponentGroup endColumn = GridConvertionHelper.getEndForComponent(columns, componentInGroup); int columnLeft = beginColumn.getMin(); int columnRight = endColumn.getMax(); int columnCenter = columnLeft + (columnRight - columnLeft) / 2; Rectangle bounds = component.getBounds(); Dimension prefSize = component.getPreferredSize(); int bl = bounds.x; int br = bounds.right(); // int leftOffset = Math.abs(bl - columnLeft); int rightOffset = Math.abs(columnRight - br); // prepare how much location of two sides will be changed for each alignment int leftDelta = leftOffset + Math.abs(columnLeft + prefSize.width - br); int rightDelta = rightOffset + Math.abs(columnRight - prefSize.width - bl); int fillDelta = leftOffset + rightOffset; int centerDelta = Math.abs(bl - (columnCenter - prefSize.width / 2)) + Math.abs(br - (columnCenter + prefSize.width / 2)); // set alignment return getAlignment(new int[] { leftDelta, centerDelta, rightDelta, fillDelta }, new Alignment[] { CellConstraints.LEFT, CellConstraints.CENTER, CellConstraints.RIGHT, 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 va 2s .c om */ 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 w w . ja va2 s. c o m } // 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_h() throws Exception { Property property = m_subProperties[4]; assertEquals("h alignment", property.getTitle()); assertFalse(property.isModified());/* w ww. j a v a 2s.com*/ assertEquals(CellConstraints.DEFAULT, property.getValue()); // set value { String expectedSource = StringUtils.replace(m_lastEditor.getSource(), "1, 2", "1, 2, right, default"); property.setValue(CellConstraints.RIGHT); assertEditor(expectedSource, m_lastEditor); } // reset value { String expectedSource = StringUtils.replace(m_lastEditor.getSource(), "1, 2, right, default", "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_property_align_v() throws Exception { Property property = m_subProperties[5]; assertEquals("v alignment", property.getTitle()); assertFalse(property.isModified());/* w w w.j ava 2s.c o 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); ///*www . j av a2 s .c o m*/ 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.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormLayoutTest.java
License:Open Source License
/** * Add component from other container.//from w w w .j a v a 2 s .c o m */ public void test_ADD() throws Exception { ContainerInfo panel = parseContainer("public class Test extends JPanel {", " public Test() {", " setLayout(new FormLayout(new ColumnSpec[] {", " FormFactory.DEFAULT_COLSPEC,", " FormFactory.DEFAULT_COLSPEC,},", " new RowSpec[] {", " FormFactory.DEFAULT_ROWSPEC,", " FormFactory.DEFAULT_ROWSPEC,}));", " {", " JPanel panel = new JPanel();", " add(panel, '1, 1');", " {", " JButton button = new JButton();", " panel.add(button);", " }", " }", " }", "}"); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); ContainerInfo innerPanel = (ContainerInfo) panel.getChildrenComponents().get(0); ComponentInfo button = innerPanel.getChildrenComponents().get(0); // add panel.startEdit(); layout.command_ADD(button, 2, false, 2, false); { CellConstraintsSupport constraints = FormLayoutInfo.getConstraints(button); assertEquals(2, ReflectionUtils.getFieldInt(constraints, "x")); assertEquals(2, ReflectionUtils.getFieldInt(constraints, "y")); assertEquals(1, ReflectionUtils.getFieldInt(constraints, "width")); assertEquals(1, ReflectionUtils.getFieldInt(constraints, "height")); assertEquals(CellConstraints.DEFAULT, ReflectionUtils.getFieldObject(constraints, "alignH")); assertEquals(CellConstraints.DEFAULT, ReflectionUtils.getFieldObject(constraints, "alignV")); } // check source assertEditor("public class Test extends JPanel {", " public Test() {", " setLayout(new FormLayout(new ColumnSpec[] {", " FormFactory.DEFAULT_COLSPEC,", " FormFactory.DEFAULT_COLSPEC,},", " new RowSpec[] {", " FormFactory.DEFAULT_ROWSPEC,", " FormFactory.DEFAULT_ROWSPEC,}));", " {", " JPanel panel = new JPanel();", " add(panel, '1, 1');", " }", " {", " JButton button = new JButton();", " add(button, '2, 2');", " }", " }", "}"); }
From source file:org.jdesktop.swingx.demo.ContactPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Peter Weishapl xTextField2 = new JXTextField(); xTextField1 = new JXTextField(); xTextField3 = new JXTextField(); label1 = new JLabel(); xFormattedTextField1 = new JXFormattedTextField(); xTextField4 = new JXTextField(); separator1 = new JSeparator(); xTextArea1 = new JXTextArea(); CellConstraints cc = new CellConstraints(); //======== this ======== setBackground(Color.white);//from ww w . j a v a 2s . c o m setBorder(Borders.DLU4_BORDER); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- xTextField2 ---- xTextField2.setPrompt("Prefix"); xTextField2.setFont(xTextField2.getFont().deriveFont(xTextField2.getFont().getStyle() | Font.BOLD, xTextField2.getFont().getSize() + 2f)); add(xTextField2, cc.xy(1, 1)); //---- xTextField1 ---- xTextField1.setPrompt("First Name"); xTextField1.setPromptForeground(Color.red); xTextField1.setToolTipText("You must enter a first name."); xTextField1.setFont(xTextField1.getFont().deriveFont(xTextField1.getFont().getStyle() | Font.BOLD, xTextField1.getFont().getSize() + 2f)); add(xTextField1, cc.xy(3, 1)); //---- xTextField3 ---- xTextField3.setPrompt("Last Name"); xTextField3.setPromptFontStyle(null); xTextField3.setFont(xTextField3.getFont().deriveFont(xTextField3.getFont().getStyle() | Font.BOLD, xTextField3.getFont().getSize() + 2f)); add(xTextField3, cc.xy(5, 1)); //---- label1 ---- label1.setText("Birthdate:"); add(label1, cc.xy(9, 1)); //---- xFormattedTextField1 ---- xFormattedTextField1.setPrompt("MM/dd/yy"); add(xFormattedTextField1, cc.xy(11, 1)); //---- xTextField4 ---- xTextField4.setPrompt("Company"); add(xTextField4, cc.xywh(1, 3, 11, 1, CellConstraints.LEFT, CellConstraints.DEFAULT)); add(separator1, cc.xywh(1, 7, 11, 1)); //---- xTextArea1 ---- xTextArea1.setPrompt("Notes"); add(xTextArea1, cc.xywh(1, 9, 11, 1)); // JFormDesigner - End of component initialization //GEN-END:initComponents }