use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class SEFrameChooserUI method showContextMenu.
@Override
public void showContextMenu(int x, int y) {
DesignEditorFrame f = structureView.getFrameAtXY(x, y);
if (f != null) {
performAction(CogToolLID.SetStartFrame, f.getFrame());
// this.selection.setSelectedFrame(f.getFrame());
setViewEnabledState(ListenerIdentifierMap.ALL);
view.showPositionalMenu();
} else {
view.showStandardMenu();
}
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorMouseState method dealWithMouseDragged.
@Override
protected boolean dealWithMouseDragged(IFigure figure, int button, int eventX, int eventY, int state) {
boolean goForward = super.dealWithMouseDragged(figure, button, eventX, eventY, state);
if (goForward && mouseDown) {
StandardDrawingEditor editor = ui.getViewEditor();
// Update VIEW to ensure ME point is visible.
// If outside of the visible canvas, up-click should cancel!
stopMouseDragTimer = true;
stopDynamic = editor.movePointNearEdge(eventX, eventY, updateDelta);
switch(getMouseState()) {
case PotentialMovingFrame:
case PotentialMovingSelection:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
setMouseState(MovingFrames);
// fall through!
}
case MovingFrames:
{
updateDynamicMove(eventX, eventY, false);
break;
}
case PotentialTogglingSelection:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
setMouseState(TogglingSelection);
// fall through!
}
case TogglingSelection:
{
updateDynamicSelectionArea(eventX, eventY);
break;
}
case PotentialSelectingFrames:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
setMouseState(SelectingFrames);
// fall through!
}
case SelectingFrames:
{
updateDynamicSelectionArea(eventX, eventY);
break;
}
case PotentialCreatingTransition:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
// Do not allow transitions from menu headers or submenus
IFigure target = ui.structureView.getFigureAtXY(mouseDownX, mouseDownY, StructureViewUIModel.SOURCE_ONLY);
if ((target instanceof GraphicalParentWidget<?, ?>) && (((GraphicalParentWidget<?, ?>) target).canHaveChildren())) {
break;
}
setMouseState(CreatingTransition);
// Ensures proper default action
selection.deselectAll();
// fall through!
}
case CreatingTransition:
{
dynamicTransition(eventX, eventY);
DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
if (targetFigure != potentialTarget) {
if (potentialTarget != null) {
potentialTarget.dynamicHighlight(false);
}
potentialTarget = targetFigure;
if (potentialTarget != null) {
potentialTarget.dynamicHighlight(true);
}
}
break;
}
case PotentialSelectTransition:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
handleMousePressed(StructureViewUIModel.NO_TRANSITION);
switch(getMouseState()) {
case PotentialMovingFrame:
{
setMouseState(MovingFrames);
updateDynamicMove(eventX, eventY, false);
break;
}
case PotentialSelectingFrames:
{
setMouseState(SelectingFrames);
updateDynamicSelectionArea(eventX, eventY);
break;
}
case PotentialCreatingTransition:
{
setMouseState(CreatingTransition);
dynamicTransition(eventX, eventY);
break;
}
}
break;
}
case PotentialToggleTransition:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
handleMousePressed(StructureViewUIModel.NO_TRANSITION);
setMouseState(TogglingSelection);
updateDynamicSelectionArea(eventX, eventY);
break;
}
case PotentialChangeTarget:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
setMouseState(ChangingTarget);
Point start = hitTransition.getStart();
hitTransition.setVisible(false);
double zoom = ui.getZoom();
double startX = start.x * zoom;
double startY = start.y * zoom;
ensureDynamicTransition(PrecisionUtilities.round(startX), PrecisionUtilities.round(startY));
// fall through!
}
case ChangingTarget:
{
dynamicTransitionTarget(eventX, eventY);
DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
if (targetFigure != potentialTarget) {
if (potentialTarget != null) {
potentialTarget.dynamicHighlight(false);
}
potentialTarget = targetFigure;
if (potentialTarget != null) {
potentialTarget.dynamicHighlight(true);
}
}
break;
}
case PotentialChangeSource:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
setMouseState(ChangingSource);
hitTransition.setVisible(false);
ensureDynamicTransition(mouseDownX, mouseDownY);
Point endPt = hitTransition.getEnd();
double zoom = ui.getZoom();
double endX = endPt.x * zoom;
double endY = endPt.y * zoom;
dynamicTransitionTarget(PrecisionUtilities.round(endX), PrecisionUtilities.round(endY));
break;
}
case ChangingSource:
{
dynamicTransitionSource(eventX, eventY);
GraphicalSource<?> sourceFigure = ui.structureView.getSourceAtXY(eventX, eventY);
InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
if (sourceFigure != null) {
drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.DRAW_CURSOR));
} else {
drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.SELECT_CURSOR));
}
break;
}
case PotentialDuplicatingFrame:
{
if (withinHysteresis(eventX, eventY)) {
break;
}
duplicatingDynamic = new ArrayList<RectangleFigure>();
//populate this from selection state
double zoom = ui.getZoom();
Iterator<DesignEditorFrame> selectedFrames = selection.getSelectedFrameFigures();
while (selectedFrames.hasNext()) {
RectangleFigure rect = new RectangleFigure();
DesignEditorFrame currFrame = selectedFrames.next();
//set size of new rectangle object
Rectangle frameSize = currFrame.getBounds();
frameSize.height = PrecisionUtilities.round(frameSize.height / zoom);
frameSize.width = PrecisionUtilities.round(frameSize.width / zoom);
frameSize.x = PrecisionUtilities.round(frameSize.x * zoom);
frameSize.y = PrecisionUtilities.round(frameSize.y * zoom);
rect.setBounds(frameSize);
//add new rectangle object to the array list
duplicatingDynamic.add(rect);
//display the new rectangle object
showSelectionArea(rect);
}
setMouseState(DuplicatingFrames);
// fall through!
}
case DuplicatingFrames:
{
updateDynamicDuplicate(eventX, eventY);
break;
}
}
// Repeating timer for causing events to repeat.
if ((updateDelta.x != 0) || (updateDelta.y != 0)) {
if (rootFigure == null) {
rootFigure = ui.getViewEditor().getInteractionFigure();
}
stopMouseDragTimer = false;
// Determine the new point the mouse "moved" too.
mouseDragTask.setNextMousePosition(eventX + updateDelta.x, eventY + updateDelta.y, button, state);
// Queue the event for 0.1 sec.
WindowUtil.GLOBAL_DISPLAY.timerExec(100, mouseDragTask);
}
}
lastX = eventX;
lastY = eventY;
cleanup();
return goForward;
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorMouseState method updateDynamicMove.
protected void updateDynamicMove(int x, int y, boolean updateModel) {
double zoom = ui.getZoom();
double dx = (x / zoom) - scaledMouseDownX;
double dy = (y / zoom) - scaledMouseDownY;
Iterator<DesignEditorFrame> frameFigs = selection.getSelectedFrameFigures();
while (frameFigs.hasNext()) {
DesignEditorFrame frameFig = frameFigs.next();
DoublePoint frameOrigin = frameFig.getFrame().getFrameOrigin();
double newX = frameOrigin.x + dx;
double newY = frameOrigin.y + dy;
// Prevent the frame from moving past 0,0
if (newX < 0) {
newX = 0;
}
if (newY < 0) {
newY = 0;
}
ui.setFigureOrigin(frameFig, newX, newY);
}
ui.performRepaintUpdates();
if (updateModel) {
ui.performAction(DesignEditorLID.MoveFrames, new DesignEditorUI.MoveParameters(dx, dy, selection));
}
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame 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;
}
use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.
the class DesignEditorUI method createFrameSelectionHandler.
protected AlertHandler createFrameSelectionHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
FrameSelectionChange evt = (FrameSelectionChange) alert;
ActionPropertySet actionProps = view.getActionPropertySet();
if (evt != null) {
if (evt.changedFrameFigure != null) {
evt.changedFrameFigure.setSelected(evt.selected);
// Handle property sheet selection
Frame[] selectedFrames = selection.getSelectedFrames();
int selectedFrameCount = selectedFrames.length;
if (selectedFrameCount > 0) {
actionProps.setComposite(ActionPropertySet.FRAME);
if (selectedFrameCount == 1) {
actionProps.setFrameName(selectedFrames[0]);
}
} else {
actionProps.setComposite(ActionSet.USE_NONE);
}
actionProps.enableFrameName(selectedFrameCount == 1);
} else {
actionProps.setComposite(ActionSet.USE_NONE);
Iterator<DesignEditorFrame> frameFigures = selection.getSelectedFrameFigures();
while (frameFigures.hasNext()) {
DesignEditorFrame frameFigure = frameFigures.next();
frameFigure.setSelected(evt.selected);
}
}
// Repaint the frame contents
delayedRepainting.requestRepaint(REPAINT_ALL);
}
}
};
}
Aggregations