@Override public void showSizeOnDropFeedback(CreateRequest request, IFigure feedback, Insets insets) { Point p = new Point(request.getLocation().getCopy()); feedback.translateToRelative(p); Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle(p, size).expand(insets)); }
@Override public void relocate(IFigure target) { Rectangle bounds; if (reference instanceof HandleBounds) { bounds = new PrecisionRectangle(((HandleBounds) reference).getHandleBounds()); } else { bounds = new PrecisionRectangle(reference.getBounds()); // authorized rectangle without handle bounds is smaller: if the icon would be exactly on // one of the corners, // it would trigger an enlargement of the figure, followed by a reposition, i.e. an endless // loop. bounds.x++; bounds.y++; bounds.width -= 2; bounds.height -= 2; } reference.translateToAbsolute(bounds); target.translateToRelative(bounds); Point pTR = bounds.getTopRight(); Point pTL = bounds.getTopLeft(); Point pDecoration = new Point(pTR); int decorationX = pTR.x - target.getSize().width - rightMargin; if (decorationX > pTL.x) { // only set position, if it is inside the figure, i.e. bigger than left margin pDecoration.setX(decorationX); } else { pDecoration.setX(pTL.x); } target.setLocation(pDecoration); }
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { IFigure feedback = getDragSourceFeedbackFigure(); PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy()); getHostFigure().translateToAbsolute(rect); rect.translate(request.getMoveDelta()); rect.resize(request.getSizeDelta()); IFigure f = getHostFigure(); Dimension min = f.getMinimumSize().getCopy(); Dimension max = f.getMaximumSize().getCopy(); IMapMode mmode = MapModeUtil.getMapMode(f); min.height = mmode.LPtoDP(min.height); min.width = mmode.LPtoDP(min.width); max.height = mmode.LPtoDP(max.height); max.width = mmode.LPtoDP(max.width); if (min.width > rect.width) rect.width = min.width; else if (max.width < rect.width) rect.width = max.width; if (min.height > rect.height) rect.height = min.height; else if (max.height < rect.height) rect.height = max.height; feedback.translateToRelative(rect); feedback.setBounds(rect); }
private void processStaleConnections() { Iterator<Connection> iter = staleConnections.iterator(); if (iter.hasNext() && connectionToPaths == null) { connectionToPaths = new HashMap<Connection, Path>(); hookAll(); } while (iter.hasNext()) { Connection conn = (Connection) iter.next(); Path path = (Path) connectionToPaths.get(conn); if (path == null) { path = new Path(conn); connectionToPaths.put(conn, path); algorithm.addPath(path); } List<?> constraint = (List<?>) getConstraint(conn); if (constraint == null) { constraint = Collections.EMPTY_LIST; } Point start = conn.getSourceAnchor().getReferencePoint().getCopy(); Point end = conn.getTargetAnchor().getReferencePoint().getCopy(); container.translateToRelative(start); container.translateToRelative(end); path.setStartPoint(start); path.setEndPoint(end); if (!constraint.isEmpty()) { PointList bends = new PointList(constraint.size()); for (int i = 0; i < constraint.size(); i++) { Bendpoint bp = (Bendpoint) constraint.get(i); bends.addPoint(bp.getLocation()); } path.setBendPoints(bends); } else { path.setBendPoints(null); } isDirty |= path.isDirty; } staleConnections.clear(); }
public boolean didClickTextControl(Point requestLoc) { IFigure figure = getTextControl(); if (figure != null) { figure.translateToRelative(requestLoc); return figure.containsPoint(requestLoc); } return false; }
@Override public void showChangeBoundsFeedback( AbstractWidgetModel widgetModel, PrecisionRectangle bounds, IFigure feedbackFigure, ChangeBoundsRequest request) { feedbackFigure.translateToRelative(bounds); feedbackFigure.setBounds(bounds); }
/* * (non-Javadoc) * * @see * org.eclipse.birt.report.designer.internal.ui.editors.schematic.tools. * TableDragGuideTracker#getMarqueeSelectionRectangle() */ protected Rectangle getMarqueeSelectionRectangle() { IFigure figure = getCrosstabTableEditPart().getFigure(); Insets insets = figure.getInsets(); int value = getLocation().x - getStartLocation().x; value = getTrueValueAbsolute(value); Point p = getStartLocation().getCopy(); figure.translateToAbsolute(p); figure.translateToRelative(p); Rectangle bounds = figure.getBounds().getCopy(); figure.translateToAbsolute(bounds); return new Rectangle( value + p.x, bounds.y + insets.top, 2, bounds.height - (insets.top + insets.bottom)); }
@Override public void relocate(final IFigure targetFigure) { final Rectangle referenceBox = getReferenceBox().getCopy(); getReferenceFigure().translateToAbsolute(referenceBox); targetFigure.translateToRelative(referenceBox); final Rectangle targetFigureBounds = new Rectangle( referenceBox .getBottomLeft() .getTranslated( new Dimension( (int) (relativeX * referenceBox.width) + absoluteX + referenceBox.width - targetFigure.getBounds().width, (int) (relativeY * referenceBox.height) + absoluteY - targetFigure.getPreferredSize().height)), targetFigure.getPreferredSize()); targetFigure.setBounds(targetFigureBounds); }
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { IFigure feedback = getDragSourceFeedbackFigure(); PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy()); getHostFigure().translateToAbsolute(rect); // Only enable horizontal dragging on lifelines(except lifelines that are result of a create // message). // https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688 if (this.getHost() instanceof LifelineEditPart) { LifelineEditPart lifelineEP = (LifelineEditPart) this.getHost(); if (!SequenceUtil.isCreateMessageEndLifeline(lifelineEP)) { request.getMoveDelta().y = 0; } } rect.translate(request.getMoveDelta()); rect.resize(request.getSizeDelta()); IFigure f = getHostFigure(); Dimension min = f.getMinimumSize().getCopy(); Dimension max = f.getMaximumSize().getCopy(); IMapMode mmode = MapModeUtil.getMapMode(f); min.height = mmode.LPtoDP(min.height); min.width = mmode.LPtoDP(min.width); max.height = mmode.LPtoDP(max.height); max.width = mmode.LPtoDP(max.width); if (min.width > rect.width) rect.width = min.width; else if (max.width < rect.width) rect.width = max.width; if (min.height > rect.height) rect.height = min.height; else if (max.height < rect.height) rect.height = max.height; feedback.translateToRelative(rect); feedback.setBounds(rect); }
public static Rectangle fixMessageBounds( Rectangle newBounds, Request cvr, LifelineEditPart host) { Object oc1 = getFirstElement( cvr.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION)); Object oc2 = getFirstElement( cvr.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)); if (oc1 != null && oc2 != null && (oc1 instanceof MessageOccurrenceSpecification || oc2 instanceof MessageOccurrenceSpecification)) { Point start = null, end = null; Rectangle bounds = null; if (oc1 instanceof InteractionFragment) { start = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc1, true); } if (oc2 instanceof InteractionFragment) { end = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc2, true); } if (start != null && end != null) { bounds = (start.y < end.y) ? new Rectangle(start, end) : new Rectangle(end, start); } if (bounds != null) { IFigure parentFigure = host.getFigure(); Point parentFigDelta = parentFigure.getBounds().getLocation().getCopy().negate(); parentFigure.translateToRelative(bounds); bounds.translate(parentFigDelta); if (bounds.y != newBounds.y || newBounds.height != bounds.height) { newBounds.y = bounds.y; newBounds.height = bounds.height; } } } return newBounds; }