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);
}
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();
}
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();
}
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;
}
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);
}
});
}
Aggregations