Search in sources :

Example 26 with DoubleRectangle

use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.

the class FrameEditorMouseState method getInsertIndex.

protected int getInsertIndex(IWidget widgetModel, int x, int y) {
    double zoom = ui.getZoom();
    DoubleRectangle widgetBds = widgetModel.getEltBounds();
    double centerX = widgetBds.x + (widgetBds.width / 2);
    double centerY = widgetBds.y + (widgetBds.height / 2);
    int originX = PrecisionUtilities.round(centerX * zoom);
    int originY = PrecisionUtilities.round(centerY * zoom);
    SimpleWidgetGroup group = widgetModel.getParentGroup();
    int index = 0;
    if (group != null) {
        index = group.indexOf(widgetModel);
        switch(group.getOrientation()) {
            case SimpleWidgetGroup.HORIZONTAL:
                {
                    if (x > originX) {
                        index++;
                    }
                    break;
                }
            case SimpleWidgetGroup.VERTICAL:
                {
                    if (y > originY) {
                        index++;
                    }
                    break;
                }
            default:
                {
                    index++;
                }
        }
    }
    return index;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 27 with DoubleRectangle

use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.

the class FrameEditorMouseState method dynamicResizeWidget.

protected void dynamicResizeWidget(IWidget widget, GraphicalWidget<?> gw, double ratioX, double ratioY, double newLeft, double newTop) {
    DoubleRectangle bds = widget.getEltBounds();
    double newX = ratioX * (bds.x - initialResizeArea.x) + newLeft;
    double newY = ratioY * (bds.y - initialResizeArea.y) + newTop;
    ui.setGraphicalWidgetBounds(newX, newY, ratioX * bds.width, ratioY * bds.height, gw);
}
Also used : DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)

Example 28 with DoubleRectangle

use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.

the class DesignEditorUI method getFrameDisplayBounds.

public DoubleRectangle getFrameDisplayBounds(Frame f) {
    double zoom = structureView.getZoom();
    DesignEditorFrame figure = structureView.getFrameFigure(f);
    Rectangle r = figure.getBounds();
    return new DoubleRectangle(r.x * zoom, r.y * zoom, r.width * zoom, r.height * zoom);
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)

Example 29 with DoubleRectangle

use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.

the class DesignEditorUI method getParameters.

@Override
public Object getParameters(ListenerIdentifier originalLID, ListenerIdentifier transmutedLID, boolean isContextSelection) {
    Object parameters = super.getParameters(originalLID, transmutedLID, isContextSelection);
    if (parameters != UNSET) {
        return parameters;
    }
    setUpPerformAction(transmutedLID);
    DesignEditorSelectionState selnStateToUse = isContextSelection ? contextSelection : selection;
    if (transmutedLID == CogToolLID.PasteBackgroundImage) {
        return new DesignEditorUI.PasteBackgroundImageParms(selnStateToUse, ClipboardUtil.fetchImageData());
    }
    // Merged paths for editing widgets, since GRAFFITI crosses both
    if ((transmutedLID == DesignEditorLID.ChangeWidgetAction) || (transmutedLID == DesignEditorLID.ChangeDeviceAction)) {
        return new DesignEditorUI.ChangeActionParameters(view.getActionProperties(), selnStateToUse);
    }
    if (transmutedLID == DesignEditorLID.ChangeDelay) {
        ActionProperties properties = view.getActionProperties();
        return new DesignEditorUI.ChangeDelayParameters(properties.delayInSecs, properties.delayLabel, selnStateToUse);
    }
    if (transmutedLID == DesignEditorLID.DuplicateFrame) {
        return new DesignEditorUI.DuplicateParameters(16.0, 16.0, selnStateToUse);
    }
    if (transmutedLID == DesignEditorLID.EditTransition) {
        return new DesignEditorUI.EditTransitionParameters(selnStateToUse, ActionProperties.UNSET);
    }
    if (transmutedLID == DesignEditorLID.AlignTop || transmutedLID == DesignEditorLID.AlignBottom || transmutedLID == DesignEditorLID.AlignLeft || transmutedLID == DesignEditorLID.AlignRight || transmutedLID == DesignEditorLID.AlignCenter || transmutedLID == DesignEditorLID.AlignHorizCenter || transmutedLID == DesignEditorLID.AlignVertCenter || transmutedLID == DesignEditorLID.SpaceHorizontally || transmutedLID == DesignEditorLID.SpaceVertically) {
        Frame[] frames = selection.getSelectedFrames();
        Map<Frame, DoubleRectangle> frameMap = new HashMap<Frame, DoubleRectangle>();
        for (Frame frame : frames) {
            DesignEditorFrame figure = structureView.getFrameFigure(frame);
            Rectangle bounds = figure.getBounds();
            frameMap.put(frame, new DoubleRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
        }
        return frameMap;
    }
    return selnStateToUse;
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) HashMap(java.util.HashMap) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) EventObject(java.util.EventObject)

Example 30 with DoubleRectangle

use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.

the class FrameEditorUI method getSelectedWidgetArea.

public DoubleRectangle getSelectedWidgetArea() {
    DoubleRectangle r = null;
    Iterator<FrameElement> selectedElts = selection.getSelectedElementsIterator();
    while (selectedElts.hasNext()) {
        FrameElement elt = selectedElts.next();
        DoubleRectangle bds = null;
        if (elt instanceof IWidget) {
            IWidget w = (IWidget) elt;
            SimpleWidgetGroup wg = w.getParentGroup();
            bds = (wg != null) ? wg.getGroupBounds() : w.getEltBounds();
        } else if (elt instanceof FrameElementGroup) {
            bds = ((FrameElementGroup) elt).getGroupBounds();
        }
        if (bds != null) {
            if (r == null) {
                r = new DoubleRectangle(bds);
            } else {
                r = r.union(bds);
            }
        }
    }
    return r;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)31 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)13 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)9 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)6 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)5 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)5 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)5 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)5 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)4 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)4 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)4 CogToolLID (edu.cmu.cs.hcii.cogtool.CogToolLID)3 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)3 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)3 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)3 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)3 IDesignUndoableEdit (edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit)2 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)2