use of edu.cmu.cs.hcii.cogtool.model.Frame in project cogtool by cogtool.
the class DesignEditorController method setWidgetColorForFrames.
/**
* Sets the widget color on all widgets contained within the given frames
*
* @param frames an array of IFrames
* @param color integer containing new widget color
*/
protected void setWidgetColorForFrames(final Frame[] frames, final int color) {
// save previous data for undo/redo
final Map<Frame, Integer> previousWidgetColorData = getWidgetColorData(frames);
// do operation on all frames
for (Frame frame : frames) {
frame.setWidgetColor(color);
}
// Add the undo edit
IUndoableEdit edit = new AUndoableEdit(DesignEditorLID.SetWidgetColor) {
@Override
public String getPresentationName() {
return setWidgetColor;
}
@Override
public void redo() {
super.redo();
// selected frames
for (Frame frame : frames) {
frame.setWidgetColor(color);
}
}
@Override
public void undo() {
super.undo();
// Iterate through frames, resetting widget colors
// to old values
Iterator<Entry<Frame, Integer>> colorEntryIterator = previousWidgetColorData.entrySet().iterator();
while (colorEntryIterator.hasNext()) {
Entry<Frame, Integer> colorEntry = colorEntryIterator.next();
Frame f = colorEntry.getKey();
int oldColor = colorEntry.getValue().intValue();
f.setWidgetColor(oldColor);
}
}
};
undoMgr.addEdit(edit);
for (Frame frame : frames) {
UndoManager frameMgr = UndoManager.getUndoManager(frame, project);
frameMgr.addEdit(edit);
}
}
use of edu.cmu.cs.hcii.cogtool.model.Frame in project cogtool by cogtool.
the class BalsamiqButtonAPIConverter method parseTransition.
/** Helper function used by parseWidget
* This method is used to parse the href tag that is a link from a widget
* to another frame
*
* @param destinationFrameName the name of the frame that the transition
* is going to
* @param widget the widget that the transition starts from
*/
protected void parseTransition(String destFrameFileName, Widget widget) {
String frameName = (destFrameFileName.lastIndexOf(".") == -1) ? destFrameFileName : destFrameFileName.substring(0, destFrameFileName.lastIndexOf('.'));
/* getFrame() returns the frame for the specified string. If the string is null then
a null frame is returned. */
Frame destinationFrame = (frameName != null) ? getFrame(frameName) : null;
if (destinationFrame != null) {
//Default Mouse Click Transition
//TODO: MAKE SURE THE MOUSE IS A DEVICE. check which devices are allowed and then make an action from there
AAction action = new ButtonAction(MouseButtonState.Left, MousePressType.Click, AAction.NONE);
//Create the transition and add it to the widget
Transition t = new Transition(widget, destinationFrame, action);
if (t != null) {
widget.addTransition(t);
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.Frame in project cogtool by cogtool.
the class BalsamiqButtonAPIConverter method importDesign.
/** The new design is created and added to the project window.
* This method must be implemented by the user.
*
* @param inputFile the specified directory or file
* @param design The newly created design. The design is passed to
* the converter file so that frames may be added to it.
*
* @see the new design in the project window.
*/
public void importDesign(File inputFile, Design newDesign) {
this.design = newDesign;
designName = this.design.getName();
designPathName = inputFile.getParent();
try {
parseBalsamiqFile(inputFile);
int minFrameWidth = DesignUtil.getFrameMinWidth();
int minFrameHeight = DesignUtil.getFrameMinHeight();
double frameScale = DesignUtil.getFrameScaleFactor();
/*The frame situator spaces out the frames in the design window */
DesignUtil.IFrameSituator frameSituator = new DesignUtil.ByRowFrameSituator(0.0, 0.0, 16.0, 16.0, minFrameWidth, minFrameHeight, CogToolPrefs.getFramesPerRow(), frameScale);
//they were inserted is needed in order to keep a consistent behavior
for (Frame frame : visitedFrames) {
frameSituator.situateNextFrame(frame);
}
} catch (IOException e) {
throw new RcvrImportException("importDesign() has encountered an exception " + e);
}
}
use of edu.cmu.cs.hcii.cogtool.model.Frame in project cogtool by cogtool.
the class DesignEditorController method copyFrames.
protected void copyFrames(Frame[] frames) {
try {
// Passing the set of frames as part of purpose allows us
// to copy only those transitions that link those frames.
ObjectSaver s = CogToolClipboard.startClipboardSave(CogToolClipboard.CopyFrames, frames, CogToolClipboard.SAVE_TO_CLIPBOARD);
for (Frame frame : frames) {
s.saveObject(frame);
}
s.finish();
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (IllegalStateException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Copying Frames", error);
}
}
use of edu.cmu.cs.hcii.cogtool.model.Frame in project cogtool by cogtool.
the class DesignEditorController method createCopyFrameAction.
protected IListenerAction createCopyFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
FrameSelectionState seln = (FrameSelectionState) prms;
Frame[] frames = seln.getSelectedFrames();
if ((frames != null) && (frames.length > 0)) {
copyFrames(frames);
if (frames.length == 1) {
interaction.setStatusMessage(FRAME_COPIED);
} else {
interaction.setStatusMessage(FRAMES_COPIED);
}
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
Aggregations