public boolean hitTest(IFigure target, Point location) { Rectangle b = target.getBounds().getCopy(); target.translateToAbsolute(b); return b.contains(location); }
public void layout(IFigure figure) { Dimension preferredSize = calculatePreferredClientAreaSize(figure); Rectangle r = figure.getClientArea().getCopy(); List children = figure.getChildren(); int nChildren = children.size(); int extraHorizontalSpace = r.width - preferredSize.width; for (Iterator i = children.iterator(); i.hasNext();) { IFigure child = (IFigure) i.next(); Dimension preferredChildSize = child.getPreferredSize(); if (isHorizontal) { int w = preferredChildSize.width + (extraHorizontalSpace / nChildren); child.setBounds(new Rectangle(r.x, r.y, w, Math.max(preferredSize.height, r.height))); r.x += w + spacing; } else { child.setBounds(new Rectangle(r.x, r.y, Math.max(preferredSize.width, r.width), preferredChildSize.height)); r.y += preferredChildSize.height + spacing; } } } }
public void run() { if (remainingTime <= 0) { if (target.getParent() != null) { target.getParent().remove(target); } _isAnimating = false; } else { final Rectangle curBounds = target.getBounds().getCopy(); curBounds.width += widthIncrement; curBounds.height += heightIncrement; curBounds.x += xIncrement; curBounds.y += yIncrement; target.setBounds(curBounds); target.revalidate(); doAnimation(remainingTime-timeIncrement, timeIncrement, widthIncrement, heightIncrement, xIncrement, yIncrement, endPoint, target); } } });
public static final void translateToRelative(IFigure figure, Translatable t) { if (figure.getParent() != null) { translateToRelative(figure.getParent(), t); // figure.getParent().translateToRelative(t); figure.translateFromParent(t); } }
public static final void translateToAbsolute(IFigure figure, Translatable t) { if (figure.getParent() != null) { figure.translateToParent(t); translateToAbsolute(figure.getParent(), t); // figure.getParent().translateToAbsolute(t); } } }
public void setAlignment ( final String alignment ) { try { this.figure.getParent ().setConstraint ( this.figure, BorderContainerController.convert ( Alignment.valueOf ( alignment ) ) ); } catch ( final Exception e ) { this.figure.getParent ().setConstraint ( this.figure, null ); } } }
public void relocate(IFigure target) { Rectangle bounds; if (getReference() instanceof HandleBounds) { bounds = ((HandleBounds) getReference()).getHandleBounds(); } else { bounds = getReference().getBounds(); } Insets referenceInsets = getReference().getInsets(); Rectangle r = new Rectangle(bounds.x + referenceInsets.left, bounds.y + bounds.height, bounds.width - referenceInsets.getWidth(), TableEditConst.HEIGHT); getReference().translateToAbsolute(r); target.translateToRelative(r); target.setBounds(r); relocateChildren(target, getReference()); }
/** * Relocates the target figure to the reference point with possible x and y * offsetting. Uses the target's preferredSize as the new size. */ public void relocate(IFigure target) { Point leftTop = new Point(_referencePoint.x+_xOffset, _referencePoint.y+_yOffset); //figure.translateToAbsolute(leftTop); target.translateToRelative(leftTop); Dimension d = target.getPreferredSize(); Rectangle rect = new Rectangle(leftTop, d); // to avoid enlargemeent if (_intersectFigure != null) { rect = rect.intersect(_intersectFigure.getBounds()); } target.setBounds(rect); }
private Rectangle getInitialMenuBounds(final IFigure target) { Rectangle targetBounds = new PrecisionRectangle(_referenceFigure.getBounds().getResized(-1, -1)); _referenceFigure.translateToAbsolute(targetBounds); target.translateToRelative(targetBounds); return targetBounds; }
public void setPreferredHeight ( final double value ) { final PrecisionDimension dim = new PrecisionDimension (); dim.setPreciseWidth ( getPropertyFigure ().getPreferredSize ().preciseWidth () ); dim.setPreciseHeight ( value ); getPropertyFigure ().setPreferredSize ( dim ); }
/** * Relocates the target using the relative offset locations. * * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure) */ public void relocate(IFigure target) { Rectangle targetBounds = ColumnHelper.getColumnBounds(editPart, target); Dimension targetSize = target.getPreferredSize(); targetBounds.x += (int) (targetBounds.width * relativeX - ((targetSize.width + 1) / 2)); targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height + 1) / 2)); targetBounds.setSize(targetSize); target.setBounds(targetBounds); } }
protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) List children = container.getChildren(); Dimension childSize = child.getPreferredSize(); preferred.width += container.getInsets().getWidth(); preferred.height += container.getInsets().getHeight();
/** * @param editPart * @return a rectangle that bounds the actual visual rectangle of the column represented * by editPart. The editPart's figure normally only maps to the td in the rendered table. * * The rectangle is translated to absolute bounds */ public static Rectangle getAdjustedColumnBoundingRectangle(GraphicalEditPart editPart) { Rectangle bounds = editPart.getFigure().getBounds().getCopy(); if (editPart.getParent() != null) { IFigure figure = ((GraphicalEditPart) editPart.getParent()) .getFigure(); if (figure instanceof CSSFigure) { CSSFigure cssFigure = (CSSFigure) figure; LayoutManager layoutManager = cssFigure.getLayoutManager(); if (layoutManager instanceof CSSTableLayout2) { CSSTableLayout2 tableLayout = (CSSTableLayout2) layoutManager; bounds.y = tableLayout.getHSpacing(); bounds.height = figure.getClientArea().height - tableLayout.getHSpacing() * 2; } } } bounds = new PrecisionRectangle(bounds.getResized(-1, -1)); editPart.getFigure().translateToAbsolute(bounds); return bounds; }
Dimension targetSize = target.getPreferredSize(); += targetBounds.width+4; targetBounds.y -= (targetSize.height / 2) - referenceFigure.getBounds().height/2; targetBounds.setSize(targetSize);
/** * @return null if this is not a table. */ private Rectangle getFeedbackRect() { ITableEditAdapter adapter = getTableEditAdapter(); if (adapter == null) { return null; } IFigure figure = ((GraphicalEditPart) this.getSourceEditPart()) .getFigure(); Rectangle bounds = figure.getBounds(); Insets insets = figure.getInsets(); Rectangle rect; if (_isrow) { int delta = calculateDelta(); rect = new Rectangle(0, adapter.getRowResizeStart(_index) + delta, bounds.width - insets.getWidth(), adapter .getRowResizeWidth()); } else { int delta = calculateDelta(); rect = new Rectangle(adapter.getColumnResizeStart(_index) + delta, 0, adapter.getColumnResizeWidth(), bounds.height - insets.getHeight()); } rect.translate(bounds.x + insets.left, bounds.y + insets.top); figure.translateToAbsolute(rect); getMarqueeRectangleFigure().translateToRelative(rect); return rect; }
protected Dimension getNewTargetSize(IFigure relocateFigure) { return relocateFigure.getPreferredSize(); }
public void relocate(IFigure target) { final Rectangle finalBounds = getFinalMenuBounds(target); target.setBounds(finalBounds); }
public void scrollTo(AbstractGraphicalEditPart topLevel) { Rectangle topLevelBounds = topLevel.getFigure().getBounds(); Rectangle categoryBounds = figure.getBounds(); int scrollValue = scrollpane.getVerticalScrollBar().getValue(); int location = topLevelBounds.y + scrollValue - categoryBounds.y; scrollpane.scrollVerticalTo(location - categoryBounds.height / 2); } }
tableRowHandle.removeAll(); tableRowHandle.setupRows(); List children = target.getChildren(); child.setBounds(rect);