use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.
the class SEFrameChooserController method setHandLocationAction.
protected void setHandLocationAction(final HandLocation handLoc) {
final Demonstration demo = taskApp.getDemonstration();
final boolean mouseHand = demo.getMouseHand();
final DefaultModelGeneratorState initialState = demo.getInitialState();
final HandLocation oldLoc = initialState.getHandLocation(mouseHand);
initialState.setHandLocation(mouseHand, handLoc);
demo.alertInitialStateChange();
undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetHandLocation) {
@Override
public String getPresentationName() {
return setHandLocation;
}
@Override
public void redo() {
super.redo();
initialState.setHandLocation(mouseHand, handLoc);
demo.alertInitialStateChange();
}
@Override
public void undo() {
super.undo();
initialState.setHandLocation(mouseHand, oldLoc);
demo.alertInitialStateChange();
}
});
}
use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.
the class SEFrameChooserController method createSetStartFrameAction.
protected IListenerAction createSetStartFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return Frame.class;
}
public boolean performAction(Object prms) {
final Frame startFrame = (Frame) prms;
if (startFrame != null) {
final Demonstration demo = taskApp.getDemonstration();
final Frame oldStartFrame = demo.getStartFrame();
if (startFrame == oldStartFrame) {
return true;
}
demo.setStartFrame(startFrame);
undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetStartFrame) {
@Override
public String getPresentationName() {
return setStartFrame;
}
@Override
public void redo() {
super.redo();
demo.setStartFrame(startFrame);
}
@Override
public void undo() {
super.undo();
demo.setStartFrame(oldStartFrame);
}
});
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.
the class SEFrameChooserController method setMouseHandAction.
protected void setMouseHandAction(final boolean mouseHand) {
final Demonstration demo = taskApp.getDemonstration();
final boolean oldMouseHand = demo.getMouseHand();
final DefaultModelGeneratorState initialState = demo.getInitialState();
final HandLocation mouseHandLoc = initialState.getHandLocation(oldMouseHand);
demo.setMouseHand(mouseHand);
initialState.setHandLocation(mouseHand, mouseHandLoc);
initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetMouseHand) {
@Override
public String getPresentationName() {
return setMouseHand;
}
@Override
public void redo() {
super.redo();
initialState.setHandLocation(mouseHand, mouseHandLoc);
initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
// Do this last as it will alert
demo.setMouseHand(mouseHand);
}
@Override
public void undo() {
super.undo();
initialState.setHandLocation(oldMouseHand, mouseHandLoc);
initialState.setHandLocation(!oldMouseHand, HandLocation.OnKeyboard);
// Do this last as it will alert
demo.setMouseHand(oldMouseHand);
}
});
}
use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.
the class SNIFACTCmd method setUpTaskApplication.
/**
* Generates a script using the given generator and situates the task
* application in the project.
* Assumes the demonstration in the task application already contains a list
* of script steps.
*/
public static void setUpTaskApplication(Project project, TaskApplication ta, CognitiveModelGenerator gen) {
Design design = ta.getDesign();
Demonstration demo = ta.getDemonstration();
DemoStateManager.getStateManager(project, design).trackEdits(demo);
Script s = new Script(demo, gen);
// Scripts generated by the SNIF-ACT algorithm are not editable!
demo.setEditable(false);
Iterator<AScriptStep> newDemoSteps = demo.getStepsAt(0);
List<DefaultModelGeneratorState> newStepStates = new ArrayList<DefaultModelGeneratorState>();
List<String> errorLines = new ArrayList<String>();
DefaultModelGeneratorState stepState = demo.getInitialState();
while (newDemoSteps.hasNext()) {
AScriptStep newDemoStep = newDemoSteps.next();
stepState = gen.generateScriptSteps(newDemoStep, stepState, errorLines, newStepStates);
}
s.replaceStepStates(0, newStepStates);
ta.setScript(gen, s);
project.setTaskApplication(ta);
}
use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.
the class ResultDisplayPolicy method getTaskApplicationCell.
public static String getTaskApplicationCell(Project project, TaskApplication taskApp, CognitiveModelGenerator gen, boolean forCell, String withSecs) {
if ((gen == null) || (taskApp == null) || ((!taskApp.hasComputedResult()) && (!taskApp.hasComputableScript())) || (taskApp.getScript(gen) == null)) {
// has a TaskApp, but no Script for the current algorithm
return "";
}
Demonstration demo = taskApp.getDemonstration();
IPredictionAlgo alg = taskApp.determineActiveAlgorithm(project);
APredictionResult r = taskApp.getResult(gen, alg);
int resultState = (r == null) ? APredictionResult.NOT_COMPUTED : r.getResultState();
// ?? means the demonstration is invalid or script needs regeneration
if (forCell) {
if (demo.isInvalid() || demo.isObsolete()) {
return "?? ";
}
if ((resultState == APredictionResult.NOT_COMPUTED) || (alg.requiresDemonstration() && !demo.isStartFrameChosen())) {
// No result yet computed for the associated script
return "-- ";
}
if (resultState == APredictionResult.COMPUTATION_IN_PROGRESS) {
// Result is being computed
return "(><) ";
}
if (resultState == APredictionResult.COMPUTE_FAILED) {
// Has a result for this algorithm, but it failed
return "XX ";
}
double timing = getComputationResult(r);
if (timing < 0.0) {
return "~~";
}
updateDigits();
String result = cellNumberFormat.format(timing);
if (CogToolPref.KLM_RESULT_RANGE.getBoolean() && withSecs != null && withSecs.length() > 0) {
result += " (" + cellNumberFormat.format(0.9 * timing);
result += ", " + cellNumberFormat.format(1.1 * timing);
result += ")";
}
result += withSecs;
return result;
// return (timing >= 0.0)
//// ? (cellNumberFormat.format(timing) + withSecs)
// ? (cellNumberFormat.format(timing) + withSecs + " ±10%")
// : "~~";
}
// Long form task application state descriptions, used for tooltips
// "" means no task application or no computable script for alg
// -- / "" means computable, not computed, and demo is valid
// -- / X means not computed and demo is invalid
// -- / ? means not computed and script needs regeneration
// NN / "" means computed and demo is valid
// NN / X means computed and demo is invalid
// NN / ? means computed and script needs regeneration
// ## / "" means computation failed and demo is valid
// ## / X means computation failed and demo is invalid
// ## / ? means computation failed, script needs regeneration
// (><) / ... means result is being computed
// ~~ / ... means result resulted in a negative number (??)
String demoState;
if (demo.isInvalid()) {
// " / X ";
demoState = " / INVALID";
} else if (demo.isObsolete()) {
// " / ? ";
demoState = " / OBSOLETE";
} else {
// " / ";
demoState = "";
}
if ((resultState == APredictionResult.NOT_COMPUTED) || !demo.isStartFrameChosen()) {
// No result yet computed for the associated script
return "NOT COMPUTED" + /* "--" */
demoState;
}
if (resultState == APredictionResult.COMPUTE_FAILED) {
// Has a result for this algo, but it failed
return "COMPUTE FAILED" + /* "##" */
demoState;
}
if (resultState == APredictionResult.COMPUTATION_IN_PROGRESS) {
// Result is being computed
return "BEING COMPUTED" + /* "(><)" */
demoState;
}
double timing = getComputationResult(r);
updateDigits();
return (timing >= 0.0) ? (cellNumberFormat.format(timing) + withSecs + demoState) : ("~~" + demoState);
}
Aggregations