Search in sources :

Example 86 with IWidget

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

the class DesignExportToHTML method buildFocusSearch.

/**
	 * Checks whether a copy of the given widget exists in the destination
	 * frame; if so, return the information to the html in a search string.
	 */
protected String buildFocusSearch(IWidget widget, Frame destination) {
    String search = "";
    Iterator<IWidget> widgets = destination.getWidgets().iterator();
    while (widgets.hasNext()) {
        IWidget w = widgets.next();
        if (w.isIdentical(widget)) {
            // TODO: is this the right test?
            search = "?focusID=" + w.getName();
        }
    }
    return search;
}
Also used : IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 87 with IWidget

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

the class FrameEditorMouseState method dynamicResizeWidgets.

/**
     * Utility to help with dynamic resize of selected widgets.
     *
     * @param selectedWFs the set of selected graphical widget figures
     * @param currentScaledX scaled X location of the current mouse position
     * @param currentScaledY scaled Y location of the current mouse position
     * @author mlh/alex
     */
protected void dynamicResizeWidgets(Iterator<FrameEltSelnFig<?>> selectedWFs, double currentScaledX, double currentScaledY) {
    // an origin less then 0.0,0.0
    if (currentScaledX < 0.0) {
        currentScaledX = 0.0;
    }
    if (currentScaledY < 0.0) {
        currentScaledY = 0.0;
    }
    // Deal with any anchoring issues
    if (ui.resizeHandlesUIFig.isTopLeftAnchored()) {
        switch(currentResizeHandleType) {
            case FrameEditorUI.TOP_RIGHT:
                {
                    // Cannot change Y position
                    currentScaledY = initialResizeArea.y;
                    break;
                }
            case FrameEditorUI.BOTTOM_LEFT:
                {
                    // Cannot change X position
                    currentScaledX = initialResizeArea.x;
                    break;
                }
            default:
                {
                    break;
                }
        }
        // Cannot move left of top-left
        if (currentScaledX < initialResizeArea.x) {
            currentScaledX = initialResizeArea.x;
        }
        // Cannot move above of top-left
        if (currentScaledY < initialResizeArea.y) {
            currentScaledY = initialResizeArea.y;
        }
    }
    double newWidth = Math.abs(currentScaledX - mouseFixedResizeX);
    double newHeight = Math.abs(currentScaledY - mouseFixedResizeY);
    double newLeft = Math.min(currentScaledX, mouseFixedResizeX);
    double newTop = Math.min(currentScaledY, mouseFixedResizeY);
    double ratioX = newWidth / initialResizeArea.width;
    double ratioY = newHeight / initialResizeArea.height;
    // Iterate through selected widgets
    while (selectedWFs.hasNext()) {
        FrameEltSelnFig<?> f = selectedWFs.next();
        if (f instanceof GraphicalWidget<?>) {
            GraphicalWidget<?> gw = (GraphicalWidget<?>) f;
            IWidget w = gw.getModel();
            SimpleWidgetGroup group = w.getParentGroup();
            if ((w instanceof TraversableWidget) && (group != null)) {
                dynamicResizeGroup(group, ratioX, ratioY, newLeft, newTop, false);
            } else {
                dynamicResizeWidget(w, gw, ratioX, ratioY, newLeft, newTop);
            }
        } else if (f instanceof FrameEltGroupHalo) {
            dynamicResizeGroup(((FrameEltGroupHalo) f).getModel(), ratioX, ratioY, newLeft, newTop, true);
        }
    }
}
Also used : TraversableWidget(edu.cmu.cs.hcii.cogtool.model.TraversableWidget) GraphicalTraversableWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalTraversableWidget) SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameEltGroupHalo(edu.cmu.cs.hcii.cogtool.uimodel.FrameEltGroupHalo) GraphicalWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalWidget) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 88 with IWidget

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

the class FrameEditorSelectionState method getSelectedWidgetsParent.

/**
     * If all of the selected items are widgets with the same
     * parent SimpleWidgetGroup, return that parent group.
     */
public SimpleWidgetGroup getSelectedWidgetsParent() {
    SimpleWidgetGroup parentGroup = null;
    Iterator<FrameElement> selectedElts = selectedElements.keySet().iterator();
    while (selectedElts.hasNext()) {
        FrameElement elt = selectedElts.next();
        if (elt instanceof IWidget) {
            SimpleWidgetGroup g = ((IWidget) elt).getParentGroup();
            // Can't share a parent if one is null
            if (g == null) {
                return null;
            }
            // If no parent recorded yet, keep track
            if (parentGroup == null) {
                parentGroup = g;
            } else if (parentGroup != g) {
                // if parents don't match, done
                return null;
            }
        } else {
            // Can't share a parent if not all selected elts are widgets
            return null;
        }
    }
    return parentGroup;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 89 with IWidget

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

the class FrameEditorUI method scrollListBoxUp.

/**
     * "Scrolls" the given group up (MUST REVIEW WHEN FINALLY DONE)
     */
public void scrollListBoxUp(SimpleWidgetGroup group) {
    Integer value = (Integer) group.getAttribute(WidgetAttributes.NUM_VISIBLE_ATTR);
    int num = value.intValue();
    if (group.size() > num) {
        IWidget top = (IWidget) group.getAttribute(WidgetAttributes.FIRST_VISIBLE_ATTR);
        int index = group.indexOf(top);
        if (index == 0) {
            return;
        }
        frameUI.getWidgetFigure(top).setVisible(false);
        double height = top.getEltBounds().height;
        for (int i = index + 1; i < index + num; i++) {
            group.get(i).moveElement(0, -height);
        }
    }
}
Also used : Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 90 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget 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

IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)93 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)29 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)20 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)19 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)15 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)15 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)12 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)11 Point (org.eclipse.draw2d.geometry.Point)11 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)10 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)9 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)9 HashSet (java.util.HashSet)8 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)7 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)7 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)7 FrameEditorUI (edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI)7 Iterator (java.util.Iterator)7 EventObject (java.util.EventObject)6