Search in sources :

Example 61 with Frame

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

the class DesignExportToHTML method warningStrings.

public String warningStrings(Design d) {
    StringBuilder result = new StringBuilder();
    for (Frame frame : d.getFrames()) {
        for (IWidget widget : frame.getWidgets()) {
            WidgetType type = widget.getWidgetType();
            if (widget.isStandard()) {
                if (WidgetType.Button.equals(type)) {
                    if (!widget.isRendered()) {
                        String title = widget.getTitle();
                        if (title == null || title.length() == 0) {
                            result.append("Frame \"");
                            result.append(frame.getName());
                            result.append("\" contains a hidden hot-spot button at widget \"");
                            result.append(widget.getName());
                            result.append("\".\n");
                        }
                    }
                }
            }
        }
    }
    return (result.length() > 0 ? result.toString() : null);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 62 with Frame

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

the class DesignExportToHTML method buildIndexPage.

/**
	 * Build an index page from the design. This is done by creating a table
	 * that has 2 columns of thumbnails. Each thumbnail starts with the frame's
	 * title then has the frame's image. Device's are ignored.
	 */
protected String buildIndexPage() {
    // Iterate over all frames alphabetically
    Iterator<Frame> iter = NamedObjectUtil.getSortedList(design.getFrames()).iterator();
    // HTML buffer
    StringBuilder html = new StringBuilder();
    html.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
    html.append("<html>\n");
    html.append("<head>\n");
    html.append("<title>");
    html.append(design.getName());
    html.append("</title>\n");
    html.append("</head>\n");
    html.append("<body>\n");
    // Add a set of instructions.
    html.append("<h3>");
    html.append("<div align=center>");
    html.append(L10N.get("WB.InstructionsHeader", "Instructions:"));
    html.append(L10N.get("WB.Instructions", "<br>Select a start frame from the list of options " + "and you will see the interface you created.<br>" + "To interact with the interface, type on the" + " keyboard or left-click, right-click or hover on" + " the widgets. If the action is defined, it will" + " show you the results. If the action is not" + " defined, a generic message will appear saying" + " that this action does not help accomplish the goal."));
    html.append("</h3>");
    html.append("</div>");
    html.append("<table border=1>\n");
    // use the counter to determine when to put in a new row on the table
    int i = 0;
    while (iter.hasNext()) {
        Frame frame = iter.next();
        //                // if not the first line, close the last row
        if (i != 0) {
            html.append("</tr>\n");
        }
        html.append("<tr>\n");
        //            }
        html.append("<td>\n");
        // Build the table cell for each frame.
        html.append("<a href='" + getFrameURL(frame, ".html") + "'>");
        html.append("<div>");
        html.append(frame.getName());
        html.append("</div><div align=right>");
        // TODO do something smarter for the images.
        // Ideally I would want to crop, but HTML does not have a crop that
        // I know of, so I will need to get the size, and resize it
        //            DoubleRectangle rect = frame.getBackgroundBounds();
        //            double scale = 1.0;
        //            if (rect != null) {
        //                if (rect.width > rect.height) {
        //                    // get x scale factor
        //                    scale = 100.0 / rect.width;
        //                }
        //                else {
        //                    scale = 100.0 / rect.height;
        //                }
        //
        //                html.append("<img src='" + getFrameImageURL(frame) + "' width=");
        //                html.append(rect.width * scale);
        //                html.append(" height=");
        //                html.append(rect.height * scale);
        //                html.append("/>");
        //            }
        //            else {
        //                html.append("<img src='" + getFrameImageURL(frame) + "' />");
        //            }
        html.append("</a>");
        html.append("</div>");
        html.append("</td>");
        i++;
    }
    html.append("</tr>\n");
    html.append("</table>\n");
    html.append("</body>\n");
    html.append("</html>\n");
    return html.toString();
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 63 with Frame

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

the class SEDefaultUI method dispose.

@Override
public void dispose() {
    removeTaskGroupHandlers(project.getUndertakings().iterator());
    task.removeAllHandlers(this);
    design.removeAllHandlers(this);
    Iterator<Frame> iter = design.getFrames().iterator();
    while (iter.hasNext()) {
        Frame frame = iter.next();
        frame.removeAllHandlers(this);
    }
    super.dispose();
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame)

Example 64 with Frame

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

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

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