Search in sources :

Example 1 with InteractionFigure

use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.

the class FrameEditorMouseState method resetPrevCursor.

protected void resetPrevCursor() {
    InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
    drawLayer.setCursor(prevCursor);
}
Also used : InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure)

Example 2 with InteractionFigure

use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.

the class FrameEditorUI method addEventListeners.

/**
     * Add the important event listeners to the contents.
     *
     * Includes both the Mouse & Mouse Motion listeners as well as the Keyboard
     *
     */
protected void addEventListeners() {
    // Add them to the contents.
    InteractionFigure interactionLayer = view.getEditor().getInteractionFigure();
    // let mouseState handle delete key events
    interactionLayer.addKeyListener(mouseState);
    getShell().addShellListener(new ShellAdapter() {

        @Override
        public void shellDeactivated(ShellEvent e) {
            mouseState.cancelDynamicOperation();
        }
    });
}
Also used : ShellAdapter(org.eclipse.swt.events.ShellAdapter) ShellEvent(org.eclipse.swt.events.ShellEvent) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure)

Example 3 with InteractionFigure

use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.

the class DesignEditorMouseState method dealWithMouseDragged.

@Override
protected boolean dealWithMouseDragged(IFigure figure, int button, int eventX, int eventY, int state) {
    boolean goForward = super.dealWithMouseDragged(figure, button, eventX, eventY, state);
    if (goForward && mouseDown) {
        StandardDrawingEditor editor = ui.getViewEditor();
        // Update VIEW to ensure ME point is visible.
        // If outside of the visible canvas, up-click should cancel!
        stopMouseDragTimer = true;
        stopDynamic = editor.movePointNearEdge(eventX, eventY, updateDelta);
        switch(getMouseState()) {
            case PotentialMovingFrame:
            case PotentialMovingSelection:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(MovingFrames);
                // fall through!
                }
            case MovingFrames:
                {
                    updateDynamicMove(eventX, eventY, false);
                    break;
                }
            case PotentialTogglingSelection:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(TogglingSelection);
                // fall through!
                }
            case TogglingSelection:
                {
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialSelectingFrames:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(SelectingFrames);
                // fall through!
                }
            case SelectingFrames:
                {
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialCreatingTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    // Do not allow transitions from menu headers or submenus
                    IFigure target = ui.structureView.getFigureAtXY(mouseDownX, mouseDownY, StructureViewUIModel.SOURCE_ONLY);
                    if ((target instanceof GraphicalParentWidget<?, ?>) && (((GraphicalParentWidget<?, ?>) target).canHaveChildren())) {
                        break;
                    }
                    setMouseState(CreatingTransition);
                    // Ensures proper default action
                    selection.deselectAll();
                // fall through!
                }
            case CreatingTransition:
                {
                    dynamicTransition(eventX, eventY);
                    DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
                    if (targetFigure != potentialTarget) {
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(false);
                        }
                        potentialTarget = targetFigure;
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(true);
                        }
                    }
                    break;
                }
            case PotentialSelectTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    handleMousePressed(StructureViewUIModel.NO_TRANSITION);
                    switch(getMouseState()) {
                        case PotentialMovingFrame:
                            {
                                setMouseState(MovingFrames);
                                updateDynamicMove(eventX, eventY, false);
                                break;
                            }
                        case PotentialSelectingFrames:
                            {
                                setMouseState(SelectingFrames);
                                updateDynamicSelectionArea(eventX, eventY);
                                break;
                            }
                        case PotentialCreatingTransition:
                            {
                                setMouseState(CreatingTransition);
                                dynamicTransition(eventX, eventY);
                                break;
                            }
                    }
                    break;
                }
            case PotentialToggleTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    handleMousePressed(StructureViewUIModel.NO_TRANSITION);
                    setMouseState(TogglingSelection);
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialChangeTarget:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(ChangingTarget);
                    Point start = hitTransition.getStart();
                    hitTransition.setVisible(false);
                    double zoom = ui.getZoom();
                    double startX = start.x * zoom;
                    double startY = start.y * zoom;
                    ensureDynamicTransition(PrecisionUtilities.round(startX), PrecisionUtilities.round(startY));
                // fall through!
                }
            case ChangingTarget:
                {
                    dynamicTransitionTarget(eventX, eventY);
                    DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
                    if (targetFigure != potentialTarget) {
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(false);
                        }
                        potentialTarget = targetFigure;
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(true);
                        }
                    }
                    break;
                }
            case PotentialChangeSource:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(ChangingSource);
                    hitTransition.setVisible(false);
                    ensureDynamicTransition(mouseDownX, mouseDownY);
                    Point endPt = hitTransition.getEnd();
                    double zoom = ui.getZoom();
                    double endX = endPt.x * zoom;
                    double endY = endPt.y * zoom;
                    dynamicTransitionTarget(PrecisionUtilities.round(endX), PrecisionUtilities.round(endY));
                    break;
                }
            case ChangingSource:
                {
                    dynamicTransitionSource(eventX, eventY);
                    GraphicalSource<?> sourceFigure = ui.structureView.getSourceAtXY(eventX, eventY);
                    InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
                    if (sourceFigure != null) {
                        drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.DRAW_CURSOR));
                    } else {
                        drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.SELECT_CURSOR));
                    }
                    break;
                }
            case PotentialDuplicatingFrame:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    duplicatingDynamic = new ArrayList<RectangleFigure>();
                    //populate this from selection state
                    double zoom = ui.getZoom();
                    Iterator<DesignEditorFrame> selectedFrames = selection.getSelectedFrameFigures();
                    while (selectedFrames.hasNext()) {
                        RectangleFigure rect = new RectangleFigure();
                        DesignEditorFrame currFrame = selectedFrames.next();
                        //set size of new rectangle object
                        Rectangle frameSize = currFrame.getBounds();
                        frameSize.height = PrecisionUtilities.round(frameSize.height / zoom);
                        frameSize.width = PrecisionUtilities.round(frameSize.width / zoom);
                        frameSize.x = PrecisionUtilities.round(frameSize.x * zoom);
                        frameSize.y = PrecisionUtilities.round(frameSize.y * zoom);
                        rect.setBounds(frameSize);
                        //add new rectangle object to the array list
                        duplicatingDynamic.add(rect);
                        //display the new rectangle object
                        showSelectionArea(rect);
                    }
                    setMouseState(DuplicatingFrames);
                // fall through!
                }
            case DuplicatingFrames:
                {
                    updateDynamicDuplicate(eventX, eventY);
                    break;
                }
        }
        // Repeating timer for causing events to repeat.
        if ((updateDelta.x != 0) || (updateDelta.y != 0)) {
            if (rootFigure == null) {
                rootFigure = ui.getViewEditor().getInteractionFigure();
            }
            stopMouseDragTimer = false;
            // Determine the new point the mouse "moved" too.
            mouseDragTask.setNextMousePosition(eventX + updateDelta.x, eventY + updateDelta.y, button, state);
            // Queue the event for 0.1 sec.
            WindowUtil.GLOBAL_DISPLAY.timerExec(100, mouseDragTask);
        }
    }
    lastX = eventX;
    lastY = eventY;
    cleanup();
    return goForward;
}
Also used : RectangleFigure(org.eclipse.draw2d.RectangleFigure) StandardDrawingEditor(edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) GraphicalSource(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with InteractionFigure

use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.

the class FrameEditorMouseState method dealWithMouseDragged.

/**
     * Parameterized mouse drags so they can be scaled programatically.
     *
     * Handles mouse drags: moves the viewable area as needed
     *
     * @param figure ignored
     * @param mouseX the location the mouse is pointing to
     * @param mouseY the location the mouse is pointing to
     * @param button the buttons pressed
     * @param state the modifiers being held down
     */
@Override
protected boolean dealWithMouseDragged(IFigure figure, int button, int mouseX, int mouseY, int state) {
    boolean goForward = super.dealWithMouseDragged(figure, button, mouseX, mouseY, state);
    if (goForward && isMouseDownValid) {
        // Get the StandardEditor for handling visuals & scrolling
        StandardDrawingEditor editor = ui.getViewEditor();
        // Update VIEW to ensure mouse point is visible.
        // If outside of the visible canvas, up-click should cancel!
        stopMouseDragTimer = true;
        stopDynamic = editor.movePointNearEdge(mouseX, mouseY, updateDelta);
        double zoom = ui.getZoom();
        // The current mouse down position (scaled)
        double currentScaledX = mouseX / zoom;
        double currentScaledY = mouseY / zoom;
        Iterator<FrameEltSelnFig<?>> selectedEltFigs = selection.getSelectedFigures();
        InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
        // Else this is a new widget
        switch(getMouseState()) {
            // Perform move-related states
            case PotentialMovingWidget:
            case PotentialMovingSelection:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    ui.hideNondynamicSupport(false);
                    prevCursor = drawLayer.getCursor();
                    drawLayer.setCursor(SELECT_CURSOR);
                    setMouseState(MovingWidgets);
                // fall through!
                }
            case MovingWidgets:
                {
                    dynamicMoveWidgets(selectedEltFigs, currentScaledX, currentScaledY);
                    ui.repaintEditor();
                    break;
                }
            case PotentialReorderWidget:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    prevCursor = drawLayer.getCursor();
                    ui.hideNondynamicSupport(false, false);
                    setUpReorderFigures();
                    prevCursor = drawLayer.getCursor();
                    drawLayer.setCursor(SELECT_CURSOR);
                    setMouseState(ReorderWidget);
                // fall through!
                }
            case ReorderWidget:
                {
                    dynamicReorderWidget(mouseX, mouseY, false);
                    break;
                }
            case PotentialResizingWidget:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    ui.hideNondynamicSupport(true);
                    // Iterate through selected widgets XYZZY openChildren in a loop???
                    while (selectedEltFigs.hasNext()) {
                        FrameEltSelnFig<?> gw = selectedEltFigs.next();
                        if (gw instanceof GraphicalTraversableWidget<?>) {
                            if (gw instanceof GraphicalChildWidget<?, ?>) {
                                ((GraphicalChildWidget<?, ?>) gw).getParentFigure().openChildren();
                            }
                        }
                    }
                    setMouseState(ResizingWidget);
                // fall through!
                }
            // Perform a drag resize of selected widget
            case ResizingWidget:
                {
                    dynamicResizeWidgets(selectedEltFigs, currentScaledX, currentScaledY);
                    ui.repaintEditor();
                    break;
                }
            // Create a new widget
            case PotentialCreatingWidget:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    setMouseState(CreatingWidget);
                // fall through!
                }
            case CreatingWidget:
                {
                    redrawTemporaryWidget(currentScaledX, currentScaledY, false);
                    break;
                }
            // Sweeping a region for toggling selection
            case PotentialTogglingSelection:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    setMouseState(TogglingSelection);
                // fall through!
                }
            case TogglingSelection:
                {
                    redrawTemporaryWidget(currentScaledX, currentScaledY, true);
                    break;
                }
            case PotentialDuplicatingWidget:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    ui.hideNondynamicSupport(false, false);
                    duplicatingDynamic = new ArrayList<RectangleFigure>();
                    Iterator<FrameEltSelnFig<?>> selectedFigs = selection.getSelectedFigures();
                    while (selectedFigs.hasNext()) {
                        FrameEltSelnFig<?> currFig = selectedFigs.next();
                        if (currFig instanceof FrameEltGroupHalo) {
                            showSelectionArea(new RectangleFigure(), currFig.getBounds());
                        } else if (!(currFig instanceof GraphicalChildWidget<?, ?>)) {
                            Rectangle widgetBds = new Rectangle(currFig.getBounds());
                            // Must scale widget figure's bounds to zoom factor
                            widgetBds.height = PrecisionUtilities.round(widgetBds.height * zoom);
                            widgetBds.width = PrecisionUtilities.round(widgetBds.width * zoom);
                            widgetBds.x = PrecisionUtilities.round(widgetBds.x * zoom);
                            widgetBds.y = PrecisionUtilities.round(widgetBds.y * zoom);
                            //display the new rectangle object
                            showSelectionArea(new RectangleFigure(), widgetBds);
                        }
                    }
                    setMouseState(DuplicatingWidgets);
                // fall through!
                }
            case DuplicatingWidgets:
                {
                    updateDynamicDuplicate(mouseX, mouseY);
                    break;
                }
            case PotentialInsertDuplicateWidget:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    ui.hideNondynamicSupport(false, false);
                    prevCursor = drawLayer.getCursor();
                    setUpReorderFigures();
                    prevCursor = drawLayer.getCursor();
                    drawLayer.setCursor(DRAW_CURSOR);
                    setMouseState(InsertDuplicateWidget);
                // fall through!
                }
            case InsertDuplicateWidget:
                {
                    dynamicReorderWidget(mouseX, mouseY, true);
                    break;
                }
            case PotentialMovingGridButtons:
                {
                    if (withinHysteresis(mouseX, mouseY)) {
                        return true;
                    }
                    GraphicalWidget<?> gw = ui.getPotentialFigureOwner();
                    GridButton owner = (GridButton) gw.getModel();
                    DoublePoint start = owner.getShape().getOrigin();
                    GridButtonGroup gbg = (GridButtonGroup) owner.getParentGroup();
                    movedGridButtons = gbg.getMovedButtons(moveIsVertical, start.x, start.y);
                    minX = start.x - owner.getHorizSpace();
                    minY = start.y - owner.getVertSpace();
                    prevCursor = drawLayer.getCursor();
                    if (moveIsVertical) {
                        drawLayer.setCursor(MOVE_VERT_CURSOR);
                    } else {
                        drawLayer.setCursor(MOVE_HORIZ_CURSOR);
                    }
                    setMouseState(MovingGridButtons);
                // fall through!
                }
            case MovingGridButtons:
                {
                    dynamicMoveGridButtons(currentScaledX, currentScaledY);
                    break;
                }
        }
        // Repeating timer for causing events to repeat.
        if ((updateDelta.x != 0) || (updateDelta.y != 0)) {
            if (rootFigure == null) {
                rootFigure = ui.getViewEditor().getInteractionFigure();
            }
            stopMouseDragTimer = false;
            // Determine the new point the mouse "moved" too.
            mouseDragTask.setNextMousePosition(mouseX + updateDelta.x, mouseY + updateDelta.y, button, state);
            // Queue the event for 0.1 sec.
            WindowUtil.GLOBAL_DISPLAY.timerExec(100, mouseDragTask);
        }
    }
    lastX = mouseX;
    lastY = mouseY;
    updateDynamic();
    return goForward;
}
Also used : RectangleFigure(org.eclipse.draw2d.RectangleFigure) ArrayList(java.util.ArrayList) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) FrameEltSelnFig(edu.cmu.cs.hcii.cogtool.uimodel.FrameEltSelnFig) FrameEltGroupHalo(edu.cmu.cs.hcii.cogtool.uimodel.FrameEltGroupHalo) GraphicalWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalWidget) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure) GridButton(edu.cmu.cs.hcii.cogtool.model.GridButton) StandardDrawingEditor(edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor) Iterator(java.util.Iterator) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) GraphicalChildWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget) GridButtonGroup(edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)

Example 5 with InteractionFigure

use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.

the class DesignEditorMouseState method dealWithMouseReleased.

@Override
protected boolean dealWithMouseReleased(IFigure figure, int button, int x, int y, int state) {
    boolean goForward = super.dealWithMouseReleased(figure, button, x, y, state);
    // Clear any mouse drag timer, that may be running
    stopMouseDragTimer = true;
    if (goForward) {
        // This must be done before the hideAllMenuItems!
        IFigure figureAtXY = ui.structureView.getFigureAtXY(mouseDownX, mouseDownY, StructureViewUIModel.SOURCE_ONLY);
        // Record the mouse down position.
        // Convert mouse coordinates into model coordinates
        double zoom = ui.getZoom();
        double scaledMouseUpX = x / zoom;
        double scaledMouseUpY = y / zoom;
        DesignEditorFrame frameAtXY = ui.structureView.getFrameAtXY(mouseDownX, mouseDownY);
        if (frameAtXY != null) {
            frameAtXY.hideAllChildren();
            ui.resetHiddenTransitionSources();
        }
        int leftX = PrecisionUtilities.round((scaledMouseUpX < scaledMouseDownX) ? scaledMouseUpX : scaledMouseDownX);
        int topY = PrecisionUtilities.round((scaledMouseUpY < scaledMouseDownY) ? scaledMouseUpY : scaledMouseDownY);
        int width = PrecisionUtilities.round((scaledMouseUpX < scaledMouseDownX) ? (scaledMouseDownX - scaledMouseUpX + 1) : (scaledMouseUpX - scaledMouseDownX + 1));
        int height = PrecisionUtilities.round((scaledMouseUpY < scaledMouseDownY) ? (scaledMouseDownY - scaledMouseUpY + 1) : (scaledMouseUpY - scaledMouseDownY + 1));
        Rectangle selectionBox = new Rectangle(leftX, topY, width, height);
        switch(getMouseState()) {
            case PotentialMovingFrame:
                {
                    // set on mouse down.
                    break;
                }
            case PotentialMovingSelection:
                {
                    DesignEditorFrame frameFig = ui.structureView.getFrameAtXY(mouseDownX, mouseDownY);
                    selection.setSelectedFrame(frameFig);
                    break;
                }
            case PotentialSelectingFrames:
                {
                    break;
                }
            case PotentialCreatingTransition:
                {
                    if (figureAtXY instanceof GraphicalParentWidget<?, ?>) {
                        GraphicalParentWidget<?, ?> parentToOpen = (GraphicalParentWidget<?, ?>) figureAtXY;
                        if (!parentToOpen.canHaveChildren()) {
                            parentToOpen = ((GraphicalChildWidget<?, ?>) parentToOpen).getParentFigure();
                        }
                        parentToOpen.openChildren();
                        ui.resetHiddenTransitionSources();
                    }
                    break;
                }
            case MovingFrames:
                {
                    updateDynamicMove(x, y, true);
                    break;
                }
            case PotentialTogglingSelection:
                {
                    dynamicSelectionArea.setVisible(false);
                    DesignEditorFrame frameFig = ui.structureView.getFrameAtXY(mouseDownX, mouseDownY);
                    if (frameFig != null) {
                        if (selection.isFrameSelected(frameFig.getFrame())) {
                            selection.deselectFrame(frameFig);
                        } else {
                            if (selection.getSelectedTransitionCount() > 0) {
                                selection.deselectAll();
                            }
                            selection.selectFrame(frameFig);
                        }
                    }
                    break;
                }
            case TogglingSelection:
                {
                    dynamicSelectionArea.setVisible(false);
                    Iterator<DesignEditorFrame> frameFigures = ui.structureView.getAllFrameFigures();
                    while (frameFigures.hasNext()) {
                        DesignEditorFrame frameFig = frameFigures.next();
                        Frame frame = frameFig.getFrame();
                        if (frameFig.intersects(selectionBox)) {
                            if (selection.isFrameSelected(frame)) {
                                selection.deselectFrame(frameFig);
                            } else {
                                if (selection.getSelectedTransitionCount() > 0) {
                                    selection.deselectAll();
                                }
                                selection.selectFrame(frameFig);
                            }
                        }
                    }
                    break;
                }
            case SelectingFrames:
                {
                    dynamicSelectionArea.setVisible(false);
                    Iterator<DesignEditorFrame> frameFigures = ui.structureView.getAllFrameFigures();
                    while (frameFigures.hasNext()) {
                        DesignEditorFrame frameFig = frameFigures.next();
                        if (frameFig.intersects(selectionBox)) {
                            selection.selectFrame(frameFig);
                        }
                    }
                    break;
                }
            case CreatingTransition:
                {
                    stopDynamicTransition();
                    if (potentialTarget != null) {
                        potentialTarget.dynamicHighlight(false);
                        potentialTarget = null;
                    }
                    if (potentialTransitionSource != null) {
                        DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(x, y);
                        TransitionSource source = potentialTransitionSource.getModel();
                        Frame target = (targetFigure != null) ? targetFigure.getFrame() : (Frame) null;
                        // Convert mouse coordinates into model coordinates
                        DesignEditorUI.NewTransitionParameters prms = new DesignEditorUI.NewTransitionParameters(source, target, scaledMouseUpX, scaledMouseUpY);
                        ui.performAction(DesignEditorLID.NewTransition, prms);
                    }
                    break;
                }
            case PotentialSelectTransition:
            case PotentialChangeTarget:
            case PotentialChangeSource:
                {
                    selection.setSelectedTransition(hitTransition);
                    Transition transition = hitTransition.getTransition();
                    ui.getInteraction().setTransitionStatusMessage(transition);
                    hitTransition = null;
                    break;
                }
            case PotentialToggleTransition:
                {
                    Transition transition = hitTransition.getTransition();
                    if (selection.isTransitionSelected(transition)) {
                        selection.deselectTransition(hitTransition);
                    } else {
                        if (selection.getSelectedFrameCount() > 0) {
                            selection.deselectAll();
                        }
                        selection.selectTransition(hitTransition);
                    }
                    hitTransition = null;
                    break;
                }
            case ChangingTarget:
                {
                    stopDynamicTransition();
                    if (potentialTarget != null) {
                        potentialTarget.dynamicHighlight(false);
                        potentialTarget = null;
                    }
                    DesignEditorFrame newTargetFigure = ui.structureView.getFrameAtXY(x, y);
                    if (newTargetFigure != null) {
                        Transition transition = hitTransition.getTransition();
                        DesignEditorUI.ChangeTargetParameters prms = new DesignEditorUI.ChangeTargetParameters(transition, newTargetFigure.getFrame());
                        ui.performAction(DesignEditorLID.ChangeTarget, prms);
                        ui.getInteraction().setTransitionStatusMessage(transition);
                    }
                    hitTransition.setVisible(true);
                    break;
                }
            case ChangingSource:
                {
                    stopDynamicTransition();
                    InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
                    drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.SELECT_CURSOR));
                    GraphicalSource<?> newSourceFigure = ui.structureView.getSourceAtXY(x, y);
                    hitTransition.setVisible(true);
                    if (newSourceFigure != null) {
                        Transition transition = hitTransition.getTransition();
                        DesignEditorUI.ChangeSourceParameters prms = new DesignEditorUI.ChangeSourceParameters(transition, newSourceFigure.getModel());
                        ui.performAction(DesignEditorLID.ChangeSource, prms);
                        ui.getInteraction().setTransitionStatusMessage(transition);
                    }
                    hitTransition = null;
                    break;
                }
            case PotentialDuplicatingFrame:
                {
                    DesignEditorFrame frameFig = ui.structureView.getFrameAtXY(mouseDownX, mouseDownY);
                    selection.setSelectedFrame(frameFig);
                    break;
                }
            case DuplicatingFrames:
                {
                    double dx = scaledMouseUpX - scaledMouseDownX;
                    double dy = scaledMouseUpY - scaledMouseDownY;
                    // Remove all the rectangle figures from the display, clear the list
                    clearRectFigures();
                    DesignEditorUI.DuplicateParameters prm = new DesignEditorUI.DuplicateParameters(dx, dy, selection);
                    ui.performAction(DesignEditorLID.DuplicateFrame, prm);
                    break;
                }
        }
    }
    setMouseState(MouseUp);
    mouseDown = false;
    cleanup();
    return goForward;
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalSource(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure) TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Iterator(java.util.Iterator) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) GraphicalParentWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget) GraphicalChildWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

InteractionFigure (edu.cmu.cs.hcii.cogtool.view.InteractionFigure)6 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)4 GraphicalChildWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget)3 Iterator (java.util.Iterator)3 Point (org.eclipse.draw2d.geometry.Point)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)2 GraphicalParentWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget)2 GraphicalSource (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource)2 StandardDrawingEditor (edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor)2 ArrayList (java.util.ArrayList)2 IFigure (org.eclipse.draw2d.IFigure)2 RectangleFigure (org.eclipse.draw2d.RectangleFigure)2 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)1 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)1 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)1