Search in sources :

Example 11 with Frame

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

the class DesignCmd method addDevice.

protected static void addDevice(Design design, DeviceType devType, Set<DeviceType> existingDevices) {
    if (!existingDevices.contains(devType)) {
        Iterator<Frame> frames = design.getFrames().iterator();
        while (frames.hasNext()) {
            Frame frame = frames.next();
            frame.addInputDevice(devType);
        }
    }
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame)

Example 12 with Frame

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

the class StructureViewUIModel method installFrames.

/**
     * Create visible representations for the frames and transitions of
     * a design.
     *
     * @author mlh
     */
protected void installFrames() {
    // Create frame representations first
    Iterator<Frame> frames = design.getFrames().iterator();
    while (frames.hasNext()) {
        Frame frame = frames.next();
        installFrame(frame);
    }
    // Then, create transitions
    frames = design.getFrames().iterator();
    while (frames.hasNext()) {
        Frame frame = frames.next();
        installFrameTransitions(frame);
    }
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame)

Example 13 with Frame

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

the class StructureViewUIModel method installFrame.

/**
     * Creates the visible representation of a frame, installing
     * the "postage stamp" version, the devices, and the transitions
     * connecting sources to their corresponding destination frames.
     *
     * @param frame the model of the Frame to install
     * @return the <code>IFigure</code> representing the frame's visible
     *         representation
     * @author mlh
     */
protected DesignEditorFrame installFrame(Frame frame) {
    frame.addHandler(this, NameChangeAlert.class, frameNameChangeHandler);
    // Create the figure for the frame
    // For the handlers below, we need the frame figure in order to
    // fetch the figure corresponding to each "modified" source.
    final DesignEditorFrame frameFig = new DesignEditorFrame(frame, showToolTips, sourceRolloverCursor);
    frameFig.addWidgetShapeChangeHandler(shapeChangeHandler);
    frameFig.addWidgetRecoveryHandler(widgetRecoveryHandler);
    frameFig.addOriginChangeHandler(new OriginChangeHandler(frameFig));
    // Whenever a transition is added or removed from a source,
    // the transition's visible representation must be added or
    // removed as well.
    final AlertHandler transitionHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            TransitionSource.TransitionChange chg = (TransitionSource.TransitionChange) alert;
            if (chg != null) {
                GraphicalSource<?> sourceFigure = frameFig.getSourceFigure((TransitionSource) alert.getSource());
                if (chg.isAdd) {
                    installSourceTransition((Transition) chg.element, sourceFigure);
                } else {
                    uninstallSourceTransition((Transition) chg.element, sourceFigure);
                }
            }
        }
    };
    frameFig.addTransitionChangeHandler(transitionHandler);
    // When a widget is added to or removed from this frame during the
    // editing of this frame (see frame editing), install or remove the
    // visible representations of the widget's transitions.
    AlertHandler widgetHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Frame.WidgetChange chg = (Frame.WidgetChange) alert;
            IWidget chgWidget = chg.getChangeElement();
            if (chg != null) {
                if (chg.action == Frame.WidgetChange.ELEMENT_DELETE) {
                    chgWidget.removeHandler(TransitionSource.TransitionChange.class, transitionHandler);
                } else if (chg.action == Frame.WidgetChange.ELEMENT_ADD) {
                    installSourceTransitions(frameFig, chgWidget);
                    chgWidget.addHandler(frameFig, TransitionSource.TransitionChange.class, transitionHandler);
                }
                // At the end of all widget Change Events, refresh.
                contents.repaint();
            }
        }
    };
    frameFig.addWidgetChangeHandler(widgetHandler);
    // Record the correspondence between the given frame and its figure.
    installedFrames.put(frame, frameFig);
    // Install the visible representation of the frame.
    contents.add(frameFig);
    return frameFig;
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 14 with Frame

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

the class FrameEditorUI method addBackgroundImageHandler.

/**
     * Registers a listener that enables/disables the
     * "remove background image" menu item as necessary.
     *
     * Also enable or disabled the capture Background button.
     * TODO: when capture background becomes a menu item, add to setEnabled
     */
protected void addBackgroundImageHandler() {
    AlertHandler backgroundEnabler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            // Checks to see if the frame has a background.
            // if so enable remove background and capture background
            // buttons.
            boolean enable = (frame.getBackgroundImage() == null) ? MenuUtil.DISABLED : MenuUtil.ENABLED;
            // Enable or disabled the remove background menu item
            setEnabled(CogToolLID.RemoveBackgroundImage, ListenerIdentifierMap.ALL, enable);
            // Enable or disabled the capture background button
            view.setIsBackgroundAvailable(enable);
        }
    };
    frame.addHandler(this, Frame.BackgroundImageChange.class, backgroundEnabler);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 15 with Frame

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

the class DesignEditorMouseState method dealWithMouseDoubleClicked.

@Override
protected boolean dealWithMouseDoubleClicked(IFigure figure, int button, int x, int y, int state) {
    boolean goForward = super.dealWithMouseDoubleClicked(figure, button, x, y, state);
    ui.confirmRenameFrame();
    if (goForward) {
        IFigure target = ui.structureView.getFigureAtXY(x, y, StructureViewUIModel.FRAME_LABEL);
        if (target instanceof DesignEditorFrame.FrameLabel) {
            DesignEditorFrame.FrameLabel frameLabel = (DesignEditorFrame.FrameLabel) target;
            ui.initiateFrameRename(frameLabel.getFrameFigure());
        } else if (target instanceof DesignEditorFrame) {
            Frame frame = ((DesignEditorFrame) target).getFrame();
            ui.performAction(DesignEditorLID.EditFrame, new SingleFrameSelection(frame));
        }
    }
    setMouseState(MouseUp);
    cleanup();
    return goForward;
}
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) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Frame (edu.cmu.cs.hcii.cogtool.model.Frame)68 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)12 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)10 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)10 EventObject (java.util.EventObject)9 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)8 FrameSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState)8 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)8 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)8 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)7 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)7 IOException (java.io.IOException)6 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)5 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)5 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)5 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)4 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)4 Design (edu.cmu.cs.hcii.cogtool.model.Design)4 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)4 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)4