List of usage examples for com.jgoodies.forms.layout FormLayout getRowGroups
public int[][] getRowGroups()
From source file:com.intellij.uiDesigner.actions.GroupRowsColumnsAction.java
License:Apache License
public static boolean isGrouped(final CaptionSelection selection) { FormLayout layout = (FormLayout) selection.getContainer().getLayout(); int[][] groups = selection.isRow() ? layout.getRowGroups() : layout.getColumnGroups(); final int[] indices = selection.getSelection(); for (int[] group : groups) { if (intersect(group, indices)) return true; }/*from w w w. ja v a2s. c o m*/ return false; }
From source file:com.intellij.uiDesigner.actions.GroupRowsColumnsAction.java
License:Apache License
protected void actionPerformed(CaptionSelection selection) { FormLayout layout = (FormLayout) selection.getContainer().getLayout(); int[][] oldGroups = selection.isRow() ? layout.getRowGroups() : layout.getColumnGroups(); int[][] newGroups = new int[oldGroups.length + 1][]; System.arraycopy(oldGroups, 0, newGroups, 0, oldGroups.length); int[] cellsToGroup = getCellsToGroup(selection); newGroups[oldGroups.length] = new int[cellsToGroup.length]; for (int i = 0; i < cellsToGroup.length; i++) { newGroups[oldGroups.length][i] = cellsToGroup[i] + 1; }/*from w w w.j a v a2 s.co m*/ if (selection.isRow()) { layout.setRowGroups(newGroups); } else { layout.setColumnGroups(newGroups); } }
From source file:com.intellij.uiDesigner.actions.UngroupRowsColumnsAction.java
License:Apache License
protected void actionPerformed(CaptionSelection selection) { FormLayout layout = (FormLayout) selection.getContainer().getLayout(); int[][] oldGroups = selection.isRow() ? layout.getRowGroups() : layout.getColumnGroups(); List<int[]> newGroups = new ArrayList<int[]>(); int[] selInts = selection.getSelection(); for (int[] group : oldGroups) { if (!GroupRowsColumnsAction.intersect(group, selInts)) { newGroups.add(group);//from w ww . j a v a2 s .c o m } } int[][] newGroupArray = newGroups.toArray(new int[newGroups.size()][]); if (selection.isRow()) { layout.setRowGroups(newGroupArray); } else { layout.setColumnGroups(newGroupArray); } }
From source file:com.intellij.uiDesigner.make.FormLayoutSourceGenerator.java
License:Apache License
@Override public void generateContainerLayout(final LwContainer component, final FormSourceCodeGenerator generator, final String variable) { FormLayout layout = (FormLayout) component.getLayout(); generator.startMethodCall(variable, "setLayout"); generator.startConstructor(FormLayout.class.getName()); generator.push(FormLayoutUtils.getEncodedColumnSpecs(layout)); generator.push(FormLayoutUtils.getEncodedRowSpecs(layout)); generator.endConstructor();//from w ww . ja v a 2 s . com generator.endMethod(); generateGroups(generator, variable, "setRowGroups", layout.getRowGroups()); generateGroups(generator, variable, "setColumnGroups", layout.getColumnGroups()); }
From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java
License:Apache License
@Override public void writeLayout(final XmlWriter writer, final RadContainer radContainer) { FormLayout layout = (FormLayout) radContainer.getLayout(); for (int i = 1; i <= layout.getRowCount(); i++) { RowSpec rowSpec = layout.getRowSpec(i); writer.startElement(UIFormXmlConstants.ELEMENT_ROWSPEC); try {/*from w w w . j av a 2s . c o m*/ writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_VALUE, FormLayoutUtils.getEncodedSpec(rowSpec)); } finally { writer.endElement(); } } for (int i = 1; i <= layout.getColumnCount(); i++) { ColumnSpec columnSpec = layout.getColumnSpec(i); writer.startElement(UIFormXmlConstants.ELEMENT_COLSPEC); try { writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_VALUE, FormLayoutUtils.getEncodedSpec(columnSpec)); } finally { writer.endElement(); } } writeGroups(writer, UIFormXmlConstants.ELEMENT_ROWGROUP, layout.getRowGroups()); writeGroups(writer, UIFormXmlConstants.ELEMENT_COLGROUP, layout.getColumnGroups()); }
From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java
License:Apache License
@Override public void paintCaptionDecoration(final RadContainer container, final boolean isRow, final int index, final Graphics2D g2d, final Rectangle rc) { // don't paint gap rows/columns with red background if (isGapCell(container, isRow, index)) { g2d.setColor(Color.LIGHT_GRAY); g2d.fillRect(rc.x, rc.y, rc.width, rc.height); }//from w w w .j ava 2 s.c o m if (canCellGrow(container, isRow, index)) { drawGrowMarker(isRow, g2d, rc); } FormLayout layout = (FormLayout) container.getLayout(); int[][] groups = isRow ? layout.getRowGroups() : layout.getColumnGroups(); //noinspection MultipleVariablesInDeclaration boolean haveTopLeft = false, haveTopRight = false, haveTopLine = false; //noinspection MultipleVariablesInDeclaration boolean haveBottomLeft = false, haveBottomRight = false, haveBottomLine = false; boolean inGroup = false; for (int i = 0; i < groups.length; i++) { int minMember = Integer.MAX_VALUE; int maxMember = -1; for (int member : groups[i]) { minMember = Math.min(member - 1, minMember); maxMember = Math.max(member - 1, maxMember); inGroup = inGroup || (member - 1 == index); } if (minMember <= index && index <= maxMember) { if (i % 2 == 0) { haveTopLeft = haveTopLeft || index > minMember; haveTopRight = haveTopRight || index < maxMember; haveTopLine = haveTopLine || inGroup; } else { haveBottomLeft = haveBottomLeft || index > minMember; haveBottomRight = haveBottomRight || index < maxMember; haveBottomLine = haveBottomLine || inGroup; } } } g2d.setColor(PlatformColors.BLUE); drawGroupLine(rc, isRow, g2d, true, haveTopLeft, haveTopRight, haveTopLine); drawGroupLine(rc, isRow, g2d, false, haveBottomLeft, haveBottomRight, haveBottomLine); }
From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java
License:Apache License
@Override public int deleteGridCells(final RadContainer grid, final int cellIndex, final boolean isRow) { int result = 1; FormLayout formLayout = (FormLayout) grid.getLayout(); adjustDeletedCellOrigins(grid, cellIndex, isRow); if (isRow) {// w w w . j a v a2 s.c o m int[][] groupIndices = formLayout.getRowGroups(); groupIndices = removeDeletedCell(groupIndices, cellIndex + 1); formLayout.setRowGroups(groupIndices); formLayout.removeRow(cellIndex + 1); updateGridConstraintsFromCellConstraints(grid); if (formLayout.getRowCount() > 0 && formLayout.getRowCount() % 2 == 0) { int gapRowIndex = (cellIndex >= grid.getGridRowCount()) ? cellIndex - 1 : cellIndex; if (GridChangeUtil.isRowEmpty(grid, gapRowIndex)) { formLayout.removeRow(gapRowIndex + 1); updateGridConstraintsFromCellConstraints(grid); result++; } } } else { int[][] groupIndices = formLayout.getColumnGroups(); groupIndices = removeDeletedCell(groupIndices, cellIndex + 1); formLayout.setColumnGroups(groupIndices); formLayout.removeColumn(cellIndex + 1); updateGridConstraintsFromCellConstraints(grid); if (formLayout.getColumnCount() > 0 && formLayout.getColumnCount() % 2 == 0) { int gapColumnIndex = (cellIndex >= grid.getGridColumnCount()) ? cellIndex - 1 : cellIndex; if (GridChangeUtil.isColumnEmpty(grid, gapColumnIndex)) { formLayout.removeColumn(gapColumnIndex + 1); updateGridConstraintsFromCellConstraints(grid); result++; } } } return result; }
From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java
License:Apache License
private static void resizeSameGroupCells(final int cell, final FormLayout formLayout, final FormSpec newSpec, final boolean isRow) { int[][] groups = isRow ? formLayout.getRowGroups() : formLayout.getColumnGroups(); for (int[] group : groups) { boolean foundGroup = false; for (int groupCell : group) { if (groupCell == cell + 1) { foundGroup = true;// w w w. j a v a 2 s . c om break; } } if (foundGroup) { for (int groupCell : group) { setSpec(formLayout, newSpec, groupCell, isRow); } break; } } }