Search in sources :

Example 6 with InteractionFigure

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

the class FrameEditorMouseState method dynamicReorderWidget.

protected void dynamicReorderWidget(int x, int y, boolean duplicate) {
    int dx = x - lastX;
    int dy = y - lastY;
    Point frameOrigin = reorderFigure.getLocation();
    frameOrigin.x += dx;
    frameOrigin.y += dy;
    reorderFigure.setLocation(frameOrigin);
    GraphicalWidget<?> curWidgetFig = ui.widgetLocatedAtXY(x, y);
    PotentialFigure potential = ui.potentialWidgetUnderXY(x, y);
    ui.resizeHandlesUIFig.hide();
    dividerLine.setVisible(false);
    if ((curWidgetFig != null) && ui.areCompatible(lastClickedWidget, curWidgetFig.getModel()) && (duplicate || reorderAllowed(curWidgetFig.getModel()))) {
        boolean isChildWidget = lastClickedWidget instanceof ChildWidget;
        boolean changedWidget = curWidgetFig.getModel() != lastClickedWidget;
        lastHoveredWidget = curWidgetFig;
        // If the dragged widget is not a child, it won't make sense to
        // drag it onto a potential figure
        // MLHQ: How do you know this cast will succeed?
        ui.hideNonhaloSupport(!isChildWidget, changedWidget, (GraphicalTraversableWidget<?>) curWidgetFig);
        setDividerBounds(curWidgetFig, x, y);
        if (lastClickedWidget instanceof ChildWidget) {
            if (curWidgetFig instanceof GraphicalChildWidget<?, ?>) {
                GraphicalChildWidget<?, ?> child = (GraphicalChildWidget<?, ?>) curWidgetFig;
                child.getParentFigure().openChildren();
            }
            if (curWidgetFig instanceof GraphicalParentWidget<?, ?>) {
                if (changedWidget) {
                    ((GraphicalParentWidget<?, ?>) curWidgetFig).openChildren();
                }
            }
        }
    } else if (potential != null) {
        GraphicalTraversableWidget<?> owner = ui.getPotentialFigureOwner();
        if (owner instanceof GraphicalChildWidget<?, ?>) {
            ((GraphicalChildWidget<?, ?>) owner).getParentFigure().openChildren();
        }
        ui.potentialUIFig.setSelection(potential);
    } else {
        if (withinReorder(x, y)) {
            setDividerBounds(lastHoveredWidget, x, y);
            if (lastHoveredWidget instanceof GraphicalChildWidget<?, ?>) {
                GraphicalChildWidget<?, ?> gcw = (GraphicalChildWidget<?, ?>) lastHoveredWidget;
                gcw.getParentFigure().openChildren();
            }
        } else if ((lastClickedWidget instanceof ChildWidget) || !duplicate) {
            ui.hideNondynamicSupport(true, false);
            InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
            drawLayer.setCursor(NOT_ALLOWED_CURSOR);
        }
    }
}
Also used : Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) GraphicalChildWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget) ChildWidget(edu.cmu.cs.hcii.cogtool.model.ChildWidget) GraphicalTraversableWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalTraversableWidget) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) PotentialFigure(edu.cmu.cs.hcii.cogtool.view.PotentialFigure) GraphicalChildWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget) GraphicalParentWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure)

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