List of usage examples for com.jgoodies.forms.layout CellConstraints CENTER
Alignment CENTER
To view the source code for com.jgoodies.forms.layout CellConstraints CENTER.
Click Source Link
From source file:org.deegree.igeo.views.swing.style.SymbolPanel.java
License:Open Source License
private void init() { // init//w ww.j a v a 2 s. c o m // well known markCB = new JComboBox(); markCB.setRenderer(new SymbolRenderer()); markCB.addActionListener(this); editSymbolsBt = new JButton(get("$MD11835")); editSymbolsBt.addActionListener(this); // layout FormLayout fl = new FormLayout("fill:default:grow(1)", "$cpheight, $btheight"); DefaultFormBuilder builder = new DefaultFormBuilder(fl); CellConstraints cc = new CellConstraints(); builder.add(markCB, cc.xy(1, 1, CellConstraints.CENTER, CellConstraints.FILL)); builder.add(editSymbolsBt, cc.xy(1, 2, CellConstraints.CENTER, CellConstraints.CENTER)); add(builder.getPanel()); }
From source file:org.drugis.addis.gui.components.progressgraph.ProgressGraph.java
License:Open Source License
public JPanel createPanel() { final FormLayout layout = new FormLayout(createFormSpec("pref", d_numCols), "p, " + createFormSpec("3dlu, p", d_numTotalRows - 1)); CellConstraints cc = new CellConstraints(); JPanel progressPanel = new JPanel(layout); Dimension cellSize = new Dimension(d_edgeLength, d_arrowSize); Dimension circleSize = new Dimension(d_circleDiameter, d_circleDiameter); for (int i = 0; i < d_numberOfChains; ++i) { int rowIdx = (2 * i) + 1; Task tuningTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.TUNING_CHAIN_PREFIX + i); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(6, rowIdx)); progressPanel.add(new GraphProgressNode(d_gridCellSize, tuningTask), cc.xy(7, rowIdx)); Task simulationTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.SIMULATION_CHAIN_PREFIX + i); progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 2, d_arrowSize), 2, SwingConstants.EAST), cc.xy(9, rowIdx));/* w w w .j av a 2s .c om*/ progressPanel.add(new GraphProgressNode(d_gridCellSize, simulationTask), cc.xy(10, rowIdx)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(11, rowIdx)); } /** Placement needed for the calculated preferred size */ progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.START), centerCell(cc, d_numMainRows, 1)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 2)); Task startTask = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.STARTING_SIMULATION_PHASE); progressPanel.add(new GraphProgressNode(d_gridCellSize, startTask, false), centerCell(cc, d_numMainRows, 3)); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 4)); //NOTE: it is a mystery why numMainRows - 1 is the correct count instead of just numMainRows progressPanel.add( new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())), centerCell(cc, d_numMainRows - 1, 5)); progressPanel.add( new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())), centerCell(cc, d_numMainRows - 1, 12)); Task assessConvergence = d_model.getModel().getActivityTask().getModel() .getStateByName(MCMCModel.CALCULATING_SUMMARIES_PHASE); progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 13)); progressPanel.add(new GraphProgressNode(d_gridCellSize, assessConvergence, false), centerCell(cc, d_numMainRows, 14)); progressPanel.add(new GraphLine(new Dimension(d_arrowSize, 50), 2, SwingConstants.SOUTH), cc.xywh(14, d_numMainRows / 2 + 2, 1, d_numMainRows / 2 + 1, CellConstraints.CENTER, CellConstraints.BOTTOM)); progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.DECISION), cc.xywh(14, d_numMainRows + 2, 1, 1, CellConstraints.CENTER, CellConstraints.CENTER)); progressPanel.add( new GraphLine(new Dimension((int) (d_edgeLength + (d_edgeLength)), d_arrowSize), 2, SwingConstants.EAST), cc.xyw(14, d_numMainRows + 2, 2, CellConstraints.RIGHT, CellConstraints.DEFAULT)); progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.END), cc.xy(16, d_numMainRows + 2)); progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 9, d_arrowSize), 2, SwingConstants.WEST), cc.xyw(10, d_numMainRows + 2, 14 - 7, CellConstraints.LEFT, CellConstraints.DEFAULT)); progressPanel.add(new GraphBar(new Dimension(d_edgeLength * 2, d_barWidth)), cc.xy(9, d_numMainRows + 2)); int totalHeight = (int) progressPanel.getPreferredSize().getHeight(); progressPanel.add( new GraphConnector(new Dimension(d_edgeLength * 2, totalHeight), d_cellHeight + Sizes.DLUY3.getPixelSize(progressPanel), totalHeight - 30, d_numberOfChains), cc.xywh(9, 1, 1, d_numTotalRows)); PanelBuilder builder = new PanelBuilder(new FormLayout("pref", "p")); builder.setDefaultDialogBorder(); builder.add(progressPanel); return builder.getPanel(); }
From source file:org.drugis.addis.gui.components.progressgraph.ProgressGraph.java
License:Open Source License
private static CellConstraints centerCell(CellConstraints cc, int rowSpan, int col) { return cc.xywh(col, 1, 1, rowSpan, CellConstraints.CENTER, CellConstraints.CENTER); }
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 ww.j a v a 2 s.co 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;/*w w w . j a v a 2 s. c o 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 ww.j a v a 2 s . c o m*/ 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 horizontal alignment {@link Action}'s. *//*from w ww.j av a2s . c o m*/ 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. *///from w w w . j a va2s.co m 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.//from www . j ava2s . 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.ja va 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 }); }