Java Code Examples for org.eclipse.draw2d.IFigure#getChildren()
The following examples show how to use
org.eclipse.draw2d.IFigure#getChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntermediateErrorCatchEvent5EditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public EditPolicy getPrimaryDragEditPolicy() { return new BorderItemSelectionEditPolicy() { @Override protected void showPrimarySelection() { super.showPrimarySelection(); hideSelection(); IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); layer.setBackgroundColor(ColorConstants.black); layer.setVisible(true); for (Object f : layer.getChildren()) { ((IFigure) f).setBackgroundColor(ColorConstants.black); ((IFigure) f).setVisible(true); } } @Override protected IFigure createDragSourceFeedbackFigure() { IFigure r = FiguresHelper.getSelectedFigure(resolveSemanticElement().eClass(), -1, -1, null, null); addFeedback(r); return r; } }; }
Example 2
Source File: IntermediateErrorCatchEvent2EditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public EditPolicy getPrimaryDragEditPolicy() { return new BorderItemSelectionEditPolicy() { @Override protected void showPrimarySelection() { super.showPrimarySelection(); hideSelection(); IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); layer.setBackgroundColor(ColorConstants.black); layer.setVisible(true); for (Object f : layer.getChildren()) { ((IFigure) f).setBackgroundColor(ColorConstants.black); ((IFigure) f).setVisible(true); } } @Override protected IFigure createDragSourceFeedbackFigure() { IFigure r = FiguresHelper.getSelectedFigure(resolveSemanticElement().eClass(), -1, -1, null, null); addFeedback(r); return r; } }; }
Example 3
Source File: EditorRulerLayout.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.draw2d.LayoutManager#layout(org.eclipse.draw2d.IFigure) */ public void layout( IFigure container ) { List children = container.getChildren( ); Rectangle rulerSize = container.getClientArea( ); for ( int i = 0; i < children.size( ); i++ ) { IFigure child = (IFigure) children.get( i ); Dimension childSize = child.getPreferredSize( ); int position = ( (Integer) getConstraint( child ) ).intValue( ); if ( ( (EditorRulerFigure) container ).isHorizontal( ) ) { childSize.height = rulerSize.height - 1; Rectangle.SINGLETON.setLocation( position - ( childSize.width / 2 ), rulerSize.y ); } else { childSize.width = rulerSize.width - 1; Rectangle.SINGLETON.setLocation( rulerSize.x, position - ( childSize.height / 2 ) ); } Rectangle.SINGLETON.setSize( childSize ); child.setBounds( Rectangle.SINGLETON ); } }
Example 4
Source File: MultipleLayout.java From birt with Eclipse Public License 1.0 | 6 votes |
public void layout( IFigure container ) { List list = container.getChildren( ); for ( int i = 0; i < list.size( ); i++ ) { Figure child = (Figure)list.get( i ); Dimension dim = child.getPreferredSize(); Rectangle bounds = new Rectangle(container.getClientArea( ).x ,container.getClientArea( ).y,dim.width, dim.height); if (!child.getBounds( ).equals( bounds )) { child.setBounds( bounds ); //container.getBounds( ).width = bounds.width; } } }
Example 5
Source File: IntermediateErrorCatchEvent4EditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public EditPolicy getPrimaryDragEditPolicy() { return new BorderItemSelectionEditPolicy() { @Override protected void showPrimarySelection() { super.showPrimarySelection(); hideSelection(); IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); layer.setBackgroundColor(ColorConstants.black); layer.setVisible(true); for (Object f : layer.getChildren()) { ((IFigure) f).setBackgroundColor(ColorConstants.black); ((IFigure) f).setVisible(true); } } @Override protected IFigure createDragSourceFeedbackFigure() { IFigure r = FiguresHelper.getSelectedFigure(resolveSemanticElement().eClass(), -1, -1, null, null); addFeedback(r); return r; } }; }
Example 6
Source File: BoundaryMessageEvent2EditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public EditPolicy getPrimaryDragEditPolicy() { return new BorderItemSelectionEditPolicy() { @Override protected void showPrimarySelection() { super.showPrimarySelection(); hideSelection(); IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); layer.setBackgroundColor(ColorConstants.black); layer.setVisible(true); for (Object f : layer.getChildren()) { ((IFigure) f).setBackgroundColor(ColorConstants.black); ((IFigure) f).setVisible(true); } } @Override protected IFigure createDragSourceFeedbackFigure() { IFigure r = FiguresHelper.getSelectedFigure(resolveSemanticElement().eClass(), -1, -1, null, null); addFeedback(r); return r; } }; }
Example 7
Source File: BoundarySignalEventEditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public EditPolicy getPrimaryDragEditPolicy() { return new BorderItemSelectionEditPolicy() { @Override protected void showPrimarySelection() { super.showPrimarySelection(); hideSelection(); IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); layer.setBackgroundColor(ColorConstants.black); layer.setVisible(true); for (Object f : layer.getChildren()) { ((IFigure) f).setBackgroundColor(ColorConstants.black); ((IFigure) f).setVisible(true); } } @Override protected IFigure createDragSourceFeedbackFigure() { IFigure r = FiguresHelper.getSelectedFigure(resolveSemanticElement().eClass(), -1, -1, null, null); addFeedback(r); return r; } }; }
Example 8
Source File: SequenceLayout.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { int width = 0; int height = minHeight; for (Object child : container.getChildren()) { if (child instanceof IFigure) { Dimension childSize = ((IFigure) child).getPreferredSize(); height = Math.max(height, childSize.height); width += childSize.width + ILayoutConstants.HSPACE; } } width -= ILayoutConstants.HSPACE; return new Dimension(width, height); }
Example 9
Source File: TableLayout.java From ermasterr with Apache License 2.0 | 5 votes |
private List clearSeparator(final IFigure parent) { for (final Iterator iter = parent.getChildren().iterator(); iter.hasNext();) { final IFigure child = (IFigure) iter.next(); if (separators.contains(child)) { iter.remove(); } } separators.clear(); return parent.getChildren(); }
Example 10
Source File: TableLayout.java From erflute with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private List<IFigure> clearSeparator(IFigure parent) { for (final Iterator<Polyline> iter = parent.getChildren().iterator(); iter.hasNext();) { final IFigure child = iter.next(); if (separators.contains(child)) { iter.remove(); } } separators.clear(); return parent.getChildren(); }
Example 11
Source File: LayoutManager.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected Dimension calculatePreferredSize(IFigure container, int hint, int hint2) { container.validate(); List<IFigure> children = container.getChildren(); Rectangle result = new Rectangle().setLocation(container.getClientArea().getLocation()); for (IFigure child : children) result.union(child.getBounds()); result.resize(container.getInsets().getWidth(), container.getInsets().getHeight()); return result.getSize(); }
Example 12
Source File: CustomGravityConstrainedFlowLayout.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Gets the list of children after applying the layout options of * ignore invisible children & reverse children */ private List<?> getChildren(IFigure container) { List<?> children = new ArrayList(container.getChildren()); if (getIgnoreInvisibleChildren()) { Iterator<?> iter = children.iterator(); while (iter.hasNext()) { IFigure f = (IFigure) iter.next(); if (!f.isVisible()) iter.remove(); } } if (isReversed()) Collections.reverse(children); return children; }
Example 13
Source File: CenterLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { for (final Object child : container.getChildren()) { final Dimension childDimension = ((IFigure) child).getPreferredSize(); return childDimension.getExpanded(PADDING_X * 2, PADDING_Y * 2); } return new Dimension(PADDING_X * 2, PADDING_Y * 2); }
Example 14
Source File: TableLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
void layoutTable( IFigure container ) { List children = container.getChildren( ); int size = children.size( ); //Map map = getOwner( ).getViewer( ).getVisualPartMap( ); for ( int i = 0; i < size; i++ ) { IFigure figure = (IFigure) children.get( i ); FigureInfomation info = figureInfo.get( figure ); int rowNumber = info.rowNumber; int columnNumber = info.columnNumber; int rowSpan = info.rowSpan; int columnSpan = info.columnSpan; int x = getColumnWidth( 1, columnNumber ); int y = getRowHeight( 1, rowNumber ); int width = getColumnWidth( columnNumber, columnNumber + columnSpan ); int height = getRowHeight( rowNumber, rowNumber + rowSpan ); // cellPart.markDirty( true, false ); setBoundsOfChild( container, figure, new Rectangle( x, y, width, height ) ); } }
Example 15
Source File: GraphLayoutManager.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected Dimension calculatePreferredSize(IFigure container, int hint, int hint2) { container.validate(); List<?> children = container.getChildren(); Rectangle result = new Rectangle().setLocation(container.getClientArea().getLocation()); for (int i = 0; i < children.size(); i++) { result.union(((IFigure) children.get(i)).getBounds()); } result.resize(container.getInsets().getWidth(), container.getInsets().getHeight()); return result.getSize(); }
Example 16
Source File: ReportFocusTraverseManager.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Returns the IFigure that will receive focus upon a 'tab' traverse event. * * @param root the {@link LightweightSystem LightweightSystem's} root figure * @param focusOwner the IFigure who currently owns focus * @return the next focusable figure */ public IFigure getNextFocusableFigure(IFigure root, IFigure focusOwner) { boolean found = false; IFigure nextFocusOwner = focusOwner; /* If no Figure currently has focus, * apply focus to root figure's first focusable child */ if (focusOwner == null) { if (root.getChildren().size() != 0) { nextFocusOwner = ((IFigure)root.getChildren().get(0)); if (isFocusEligible(nextFocusOwner)) return nextFocusOwner; } else return null; } while (!found) { IFigure parent = nextFocusOwner.getParent(); /* * Figure traversal is implemented using the pre-order left to right * tree traversal algorithm. * * If the focused sibling has children, traverse to its leftmost child. * If the focused sibling has no children, traverse to the sibling * to its right. * If there is no sibling to the right, go up the tree until a node * with untraversed siblings is found. */ List siblings = parent.getChildren(); int siblingPos = siblings.indexOf(nextFocusOwner); if (nextFocusOwner.getChildren().size() != 0) { nextFocusOwner = ((IFigure)(nextFocusOwner.getChildren().get(0))); if (isFocusEligible(nextFocusOwner)) found = true; } else if (siblingPos < siblings.size() - 1) { nextFocusOwner = ((IFigure)(siblings.get(siblingPos + 1))); if (isFocusEligible(nextFocusOwner)) found = true; } else { boolean untraversedSiblingFound = false; while (!untraversedSiblingFound) { IFigure p = nextFocusOwner.getParent(); IFigure gp = p.getParent(); if (gp != null) { int parentSiblingCount = gp.getChildren().size(); int parentIndex = gp.getChildren().indexOf(p); if (parentIndex < parentSiblingCount - 1) { nextFocusOwner = ((IFigure)p.getParent() .getChildren() .get(parentIndex + 1)); untraversedSiblingFound = true; if (isFocusEligible(nextFocusOwner)) found = true; } else nextFocusOwner = p; } else { nextFocusOwner = null; untraversedSiblingFound = true; found = true; } } } } return nextFocusOwner; }
Example 17
Source File: TableLayout.java From birt with Eclipse Public License 1.0 | 4 votes |
public void layout( IFigure container ) { if ( !isDistroy( ) ) { return; } //if ( !isCalculating ) { helper = new TableBorderHelper( owner ); helper.updateCellBorderInsets( ); } figureInfo.clear( ); data = new WorkingData( ); data.columnWidths = new TableLayoutData.ColumnData[getColumnCount( )]; data.rowHeights = new TableLayoutData.RowData[getRowCount( )]; // initialize the default value of each cell from DE model init( data.columnWidths, data.rowHeights ); // get the figure list of all cell List children = container.getChildren( ); // calculate the minimum width of each cell initMinSize( children ); // be not implemented yet initMergeMinsize( children ); // adjust the cell data with calculated width and height caleLayoutData( container ); // first pass, layout the children. if ( !isCalculating ) { layoutTable( container ); } // reset the row minimum height data. resetRowMinSize( data.rowHeights ); initRowMinSize( children ); initRowMergeMinsize( children ); caleRowData( ); // second pass, layout the container itself. if ( !isCalculating ) { layoutTable( container ); } setConstraint( container, data ); needlayout = false; if ( isCalculating ) { // return; } int containerWidth = getOwner( ).getFigure( ) .getParent( ) .getClientArea( ) .getSize( ).width; if ( containerWidth < 0 ) { Display.getCurrent( ).asyncExec( new Runnable( ) { public void run( ) { if ( isNeedRelayout ) { getOwner( ).reLayout( ); isNeedRelayout = false; } } } ); return; } reselect( ); }
Example 18
Source File: ReportFocusTraverseManager.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Returns the IFigure that will receive focus upon a 'shift-tab' traverse event. * * @param root The {@link LightweightSystem LightweightSystem's} root figure * @param focusOwner The IFigure who currently owns focus * @return the previous focusable figure */ public IFigure getPreviousFocusableFigure(IFigure root, IFigure focusOwner) { IFigure nextFocusOwner = focusOwner; if (focusOwner == null) { if (root.getChildren().size() != 0) { nextFocusOwner = findDeepestRightmostChildOf(root); if (isFocusEligible(nextFocusOwner)) return nextFocusOwner; } else return null; } boolean found = false; while (!found) { IFigure parent = nextFocusOwner.getParent(); /* * At root, return null to indicate traversal * is complete. */ if (parent == null) return null; List siblings = parent.getChildren(); int siblingPos = siblings.indexOf(nextFocusOwner); /* * Figure traversal is implemented using the post-order right to left * tree traversal algorithm. * * Find the rightmost child. * If this child is focusable, return it * If not focusable, traverse to its sibling and repeat. * If there is no sibling, traverse its parent. */ if (siblingPos != 0) { IFigure child = findDeepestRightmostChildOf((IFigure)siblings.get(siblingPos - 1)); if (isFocusEligible(child)) { found = true; nextFocusOwner = child; } else if (child.equals(nextFocusOwner)) { if (isFocusEligible(nextFocusOwner)) found = true; } else nextFocusOwner = child; } else { nextFocusOwner = parent; if (isFocusEligible(nextFocusOwner)) found = true; } } return nextFocusOwner; }
Example 19
Source File: FixTableLayout.java From birt with Eclipse Public License 1.0 | 4 votes |
@Override public void layout( IFigure container ) { if ( !isDistroy( ) ) { return; } ITableLayoutOwner owner = getOwner( ); helper = new TableBorderHelper( owner ); helper.updateCellBorderInsets( ); data = new WorkingData( ); data.columnWidths = new TableLayoutData.ColumnData[getColumnCount( )]; data.rowHeights = new TableLayoutData.RowData[getRowCount( )]; List children = container.getChildren( ); init( data.columnWidths, data.rowHeights ); //put the figure, info key initFigureInfo(children); //set the column caleColumnWidth( ); //debugColumn( ); preCaleRow( ); layoutTable( container ); resetRowMinSize( data.rowHeights ); initRowMinSize( children ); initRowMergeMinsize( children ); caleRowData( ); // second pass, layout the container itself. layoutTable( container ); setConstraint( container, data ); needlayout = false; int containerWidth = getOwner( ).getFigure( ) .getParent( ) .getClientArea( ) .getSize( ).width; if ( containerWidth < 0 ) { Display.getCurrent( ).asyncExec( new Runnable( ) { public void run( ) { getOwner( ).reLayout( ); } } ); return; } reselect( ); }
Example 20
Source File: GridLayout.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * Applies a rectangle-based layout to the container. */ @Override public void layout(IFigure container) { // Get the maximum bounding box we can use for layout out sub-figures. Rectangle limit = container.getClientArea(); // Compute the maximum width/height of each cell. We'll make everything // square. int maxWidth = (limit.width - (columns - 1) * horizontalSpacing) / columns; int maxHeight = (limit.height - (rows - 1) * verticalSpacing) / rows; // Get the size and any vertical/horizontal padding necessary. int size, paddingX = 0, paddingY = 0; if (maxWidth > maxHeight) { // Height-restricted. size = maxHeight; paddingX = (limit.width - size * columns - horizontalSpacing * (columns - 1)) / 2; } else { // Width-restricted. size = maxWidth; paddingY = (limit.height - size * rows - verticalSpacing * (rows - 1)) / 2; } int i, row, column, x, y, w, h; // Loop over the IFigures in the container with this layout. for (Object childObject : container.getChildren()) { IFigure child = (IFigure) childObject; // Get the constraints (and the x, y, w, h offsets from it). GridData constraint = getConstraint(child); Rectangle offsets = constraint.getOffsets(); // Get the index and compute the row and column for the index. i = constraint.getIndex(); row = i / columns; column = i % columns; // Compute the bounds of the cell in the row, column position. x = paddingX + column * (size + horizontalSpacing) + offsets.x; y = paddingY + row * (size + verticalSpacing) + offsets.y; w = size + offsets.width; h = size + offsets.height; // Set the bounds for the child IFigure. child.setBounds(new Rectangle(x, y, w, h)); } return; }