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