Search in sources :

Example 1 with Locator

use of org.eclipse.draw2d.Locator in project archi by archimatetool.

the class AbstractTextControlContainerFigure method setUI.

@Override
protected void setUI() {
    setLayoutManager(new DelegatingLayout());
    Locator textLocator = new Locator() {

        public void relocate(IFigure target) {
            Rectangle bounds = calculateTextControlBounds();
            if (bounds == null) {
                bounds = getBounds().getCopy();
            }
            translateFromParent(bounds);
            target.setBounds(bounds);
        }
    };
    fTextControl = createTextControl(textLocator);
    Locator mainLocator = new Locator() {

        public void relocate(IFigure target) {
            Rectangle bounds = getBounds().getCopy();
            translateFromParent(bounds);
            target.setBounds(bounds);
        }
    };
    add(getMainFigure(), mainLocator);
    // Have to add this if we want Animation to work on figures!
    AnimationUtil.addFigureForAnimation(getMainFigure());
}
Also used : Locator(org.eclipse.draw2d.Locator) DelegatingLayout(org.eclipse.draw2d.DelegatingLayout) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with Locator

use of org.eclipse.draw2d.Locator in project archi by archimatetool.

the class CanvasBlockFigure method setUI.

@Override
protected void setUI() {
    setLayoutManager(new DelegatingLayout());
    Locator mainLocator = new Locator() {

        public void relocate(IFigure target) {
            Rectangle bounds = getBounds().getCopy();
            translateFromParent(bounds);
            target.setBounds(bounds);
        }
    };
    FlowPage flowPage = new FlowPage();
    BlockFlow block = new BlockFlow();
    fTextFlow = new TextFlow();
    fTextFlow.setLayoutManager(new ParagraphTextLayout(fTextFlow, ParagraphTextLayout.WORD_WRAP_HARD));
    block.add(fTextFlow);
    flowPage.add(block);
    Figure textWrapperFigure = new Figure();
    textWrapperFigure.setLayoutManager(new GridLayout());
    textWrapperFigure.add(flowPage, new GridData(SWT.CENTER, SWT.CENTER, true, true));
    add(textWrapperFigure, mainLocator);
    fTextPositionDelegate = new TextPositionDelegate(textWrapperFigure, flowPage, getDiagramModelObject());
    // This last
    add(getMainFigure(), mainLocator);
    // Have to add this if we want Animation to work on figures!
    AnimationUtil.addFigureForAnimation(getMainFigure());
    fIconicDelegate = new IconicDelegate(getDiagramModelObject());
    fIconicDelegate.updateImage();
}
Also used : DelegatingLayout(org.eclipse.draw2d.DelegatingLayout) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure) AbstractContainerFigure(com.archimatetool.editor.diagram.figures.AbstractContainerFigure) Figure(org.eclipse.draw2d.Figure) Locator(org.eclipse.draw2d.Locator) FlowPage(org.eclipse.draw2d.text.FlowPage) GridLayout(org.eclipse.draw2d.GridLayout) BlockFlow(org.eclipse.draw2d.text.BlockFlow) GridData(org.eclipse.draw2d.GridData) TextFlow(org.eclipse.draw2d.text.TextFlow) TextPositionDelegate(com.archimatetool.editor.diagram.figures.TextPositionDelegate) ParagraphTextLayout(org.eclipse.draw2d.text.ParagraphTextLayout) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with Locator

use of org.eclipse.draw2d.Locator in project whole by wholeplatform.

the class WholeNonResizableEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_ADD))
        if (targetFeedback == null) {
            targetFeedback = new AbstractHandle((GraphicalEditPart) getHost(), new Locator() {

                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds().getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {

                {
                    setBorder(new LineBorder(ColorConstants.lightGray, 1));
                }

                protected DragTracker createDragTracker() {
                    return null;
                }
            };
            addFeedback(targetFeedback);
        }
}
Also used : Locator(org.eclipse.draw2d.Locator) HandleBounds(org.eclipse.gef.handles.HandleBounds) LineBorder(org.eclipse.draw2d.LineBorder) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with Locator

use of org.eclipse.draw2d.Locator in project whole by wholeplatform.

the class WholeResizableEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_ADD))
        if (targetFeedback == null) {
            targetFeedback = new AbstractHandle((GraphicalEditPart) getHost(), new Locator() {

                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds().getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {

                {
                    setBorder(new LineBorder(ColorConstants.lightGray, 1));
                }

                protected DragTracker createDragTracker() {
                    return null;
                }
            };
            addFeedback(targetFeedback);
        }
}
Also used : Locator(org.eclipse.draw2d.Locator) HandleBounds(org.eclipse.gef.handles.HandleBounds) LineBorder(org.eclipse.draw2d.LineBorder) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with Locator

use of org.eclipse.draw2d.Locator in project archi by archimatetool.

the class AbstractDiagramConnectionFigure method setLabelLocator.

private void setLabelLocator(int position) {
    Locator locator = null;
    switch(position) {
        case IDiagramModelConnection.CONNECTION_TEXT_POSITION_SOURCE:
            locator = new ArchiConnectionEndpointLocator(this, false);
            break;
        case IDiagramModelConnection.CONNECTION_TEXT_POSITION_MIDDLE:
            locator = new ConnectionLocator(this, ConnectionLocator.MIDDLE);
            break;
        case IDiagramModelConnection.CONNECTION_TEXT_POSITION_TARGET:
            locator = new ArchiConnectionEndpointLocator(this, true);
            break;
    }
    setConstraint(getConnectionLabel(), locator);
}
Also used : Locator(org.eclipse.draw2d.Locator) ConnectionLocator(org.eclipse.draw2d.ConnectionLocator) ConnectionLocator(org.eclipse.draw2d.ConnectionLocator)

Aggregations

Locator (org.eclipse.draw2d.Locator)6 IFigure (org.eclipse.draw2d.IFigure)5 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 DelegatingLayout (org.eclipse.draw2d.DelegatingLayout)3 LineBorder (org.eclipse.draw2d.LineBorder)2 AbstractHandle (org.eclipse.gef.handles.AbstractHandle)2 HandleBounds (org.eclipse.gef.handles.HandleBounds)2 AbstractContainerFigure (com.archimatetool.editor.diagram.figures.AbstractContainerFigure)1 TextPositionDelegate (com.archimatetool.editor.diagram.figures.TextPositionDelegate)1 ConnectionLocator (org.eclipse.draw2d.ConnectionLocator)1 Figure (org.eclipse.draw2d.Figure)1 GridData (org.eclipse.draw2d.GridData)1 GridLayout (org.eclipse.draw2d.GridLayout)1 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)1 BlockFlow (org.eclipse.draw2d.text.BlockFlow)1 FlowPage (org.eclipse.draw2d.text.FlowPage)1 ParagraphTextLayout (org.eclipse.draw2d.text.ParagraphTextLayout)1 TextFlow (org.eclipse.draw2d.text.TextFlow)1