use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame 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.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorUI method createFrameRecoveryHandler.
protected AlertHandler createFrameRecoveryHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
StructureViewUIModel.FrameRecovery evt = (StructureViewUIModel.FrameRecovery) alert;
if (evt != null) {
DesignEditorFrame frameFigure = evt.getFrameFigure();
selection.deselectFrame(frameFigure);
// If removing the DesignEditorFrame for the
// rename text editor, cancel the rename
// operation and clean up.
cleanupFrameEditor(frameFigure);
}
}
};
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorUI method getFrameDisplayBounds.
public DoubleRectangle getFrameDisplayBounds(Frame f) {
double zoom = structureView.getZoom();
DesignEditorFrame figure = structureView.getFrameFigure(f);
Rectangle r = figure.getBounds();
return new DoubleRectangle(r.x * zoom, r.y * zoom, r.width * zoom, r.height * zoom);
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame 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);
}
});
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorUI method getParameters.
@Override
public Object getParameters(ListenerIdentifier originalLID, ListenerIdentifier transmutedLID, boolean isContextSelection) {
Object parameters = super.getParameters(originalLID, transmutedLID, isContextSelection);
if (parameters != UNSET) {
return parameters;
}
setUpPerformAction(transmutedLID);
DesignEditorSelectionState selnStateToUse = isContextSelection ? contextSelection : selection;
if (transmutedLID == CogToolLID.PasteBackgroundImage) {
return new DesignEditorUI.PasteBackgroundImageParms(selnStateToUse, ClipboardUtil.fetchImageData());
}
// Merged paths for editing widgets, since GRAFFITI crosses both
if ((transmutedLID == DesignEditorLID.ChangeWidgetAction) || (transmutedLID == DesignEditorLID.ChangeDeviceAction)) {
return new DesignEditorUI.ChangeActionParameters(view.getActionProperties(), selnStateToUse);
}
if (transmutedLID == DesignEditorLID.ChangeDelay) {
ActionProperties properties = view.getActionProperties();
return new DesignEditorUI.ChangeDelayParameters(properties.delayInSecs, properties.delayLabel, selnStateToUse);
}
if (transmutedLID == DesignEditorLID.DuplicateFrame) {
return new DesignEditorUI.DuplicateParameters(16.0, 16.0, selnStateToUse);
}
if (transmutedLID == DesignEditorLID.EditTransition) {
return new DesignEditorUI.EditTransitionParameters(selnStateToUse, ActionProperties.UNSET);
}
if (transmutedLID == DesignEditorLID.AlignTop || transmutedLID == DesignEditorLID.AlignBottom || transmutedLID == DesignEditorLID.AlignLeft || transmutedLID == DesignEditorLID.AlignRight || transmutedLID == DesignEditorLID.AlignCenter || transmutedLID == DesignEditorLID.AlignHorizCenter || transmutedLID == DesignEditorLID.AlignVertCenter || transmutedLID == DesignEditorLID.SpaceHorizontally || transmutedLID == DesignEditorLID.SpaceVertically) {
Frame[] frames = selection.getSelectedFrames();
Map<Frame, DoubleRectangle> frameMap = new HashMap<Frame, DoubleRectangle>();
for (Frame frame : frames) {
DesignEditorFrame figure = structureView.getFrameFigure(frame);
Rectangle bounds = figure.getBounds();
frameMap.put(frame, new DoubleRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
}
return frameMap;
}
return selnStateToUse;
}
Aggregations