Search in sources :

Example 11 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorSelectionState method getSelectedFrames.

public Frame[] getSelectedFrames() {
    Frame[] frames = new Frame[selectedFrames.size()];
    Iterator<DesignEditorFrame> frameIterator = selectedFrames.values().iterator();
    int i = 0;
    while (frameIterator.hasNext()) {
        DesignEditorFrame frameHolder = frameIterator.next();
        frames[i++] = frameHolder.getFrame();
    }
    return frames;
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)

Example 12 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorUI method createFrameRecoveryHandler.

protected AlertHandler createFrameRecoveryHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            StructureViewUIModel.FrameRecovery evt = (StructureViewUIModel.FrameRecovery) alert;
            if (evt != null) {
                DesignEditorFrame frameFigure = evt.getFrameFigure();
                selection.deselectFrame(frameFigure);
                // If removing the DesignEditorFrame for the
                // rename text editor, cancel the rename
                // operation and clean up.
                cleanupFrameEditor(frameFigure);
            }
        }
    };
}
Also used : StructureViewUIModel(edu.cmu.cs.hcii.cogtool.uimodel.StructureViewUIModel) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 13 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame 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 14 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorUI method setFrameChangeHandlers.

protected void setFrameChangeHandlers(final Design design) {
    design.addHandler(this, NameChangeAlert.class, renameHandler);
    AlertHandler frameChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.FrameChange chg = (Design.FrameChange) alert;
            if (chg != null) {
                updateView(false);
                Frame frame = (Frame) chg.element;
                if (chg.isAdd) {
                    DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
                    // A newly created frame should be selected.
                    delayedFrameSelection.addToSelection(frame, frameFigure);
                } else {
                    delayedFrameSelection.removeFromSelection(frame);
                }
                delayedRepainting.requestRepaint(REPAINT_ALL);
            }
        }
    };
    design.addHandler(this, Design.FrameChange.class, frameChangeHandler);
    frameChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.FrameSetChange chg = (Design.FrameSetChange) alert;
            if (chg != null) {
                updateView(false);
                if (chg.isAdd) {
                    for (Frame frame : chg.frames) {
                        DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
                        // A newly created frame should be selected.
                        delayedFrameSelection.addToSelection(frameFigure.getFrame(), frameFigure);
                    }
                    delayedRepainting.requestRepaint(REPAINT_ALL);
                } else {
                    for (Frame frame : chg.frames) {
                        delayedFrameSelection.removeFromSelection(frame);
                    }
                }
            }
        }
    };
    design.addHandler(this, Design.FrameSetChange.class, frameChangeHandler);
    design.addHandler(this, Design.DeviceTypeChange.class, new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Set<DeviceType> deviceTypeSet = design.getDeviceTypes();
            int deviceTypes = DeviceType.buildDeviceSet(deviceTypeSet);
            view.resetDeviceTypes(deviceTypes);
        }
    });
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Set(java.util.Set) ActionSet(edu.cmu.cs.hcii.cogtool.view.ActionSet) ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 15 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame 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)

Aggregations

DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)18 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)8 IFigure (org.eclipse.draw2d.IFigure)5 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)4 EventObject (java.util.EventObject)4 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)3 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)3 GraphicalSource (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource)3 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)3 Iterator (java.util.Iterator)3 Point (org.eclipse.draw2d.geometry.Point)3 ActionPropertySet (edu.cmu.cs.hcii.cogtool.view.ActionPropertySet)2 InteractionFigure (edu.cmu.cs.hcii.cogtool.view.InteractionFigure)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)1 FrameSelectionChange (edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange)1 GraphicalChildWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget)1 GraphicalParentWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget)1