use of edu.cmu.cs.hcii.cogtool.view.InteractionFigure in project cogtool by cogtool.
the class FrameEditorMouseState method dynamicReorderWidget.
protected void dynamicReorderWidget(int x, int y, boolean duplicate) {
int dx = x - lastX;
int dy = y - lastY;
Point frameOrigin = reorderFigure.getLocation();
frameOrigin.x += dx;
frameOrigin.y += dy;
reorderFigure.setLocation(frameOrigin);
GraphicalWidget<?> curWidgetFig = ui.widgetLocatedAtXY(x, y);
PotentialFigure potential = ui.potentialWidgetUnderXY(x, y);
ui.resizeHandlesUIFig.hide();
dividerLine.setVisible(false);
if ((curWidgetFig != null) && ui.areCompatible(lastClickedWidget, curWidgetFig.getModel()) && (duplicate || reorderAllowed(curWidgetFig.getModel()))) {
boolean isChildWidget = lastClickedWidget instanceof ChildWidget;
boolean changedWidget = curWidgetFig.getModel() != lastClickedWidget;
lastHoveredWidget = curWidgetFig;
// If the dragged widget is not a child, it won't make sense to
// drag it onto a potential figure
// MLHQ: How do you know this cast will succeed?
ui.hideNonhaloSupport(!isChildWidget, changedWidget, (GraphicalTraversableWidget<?>) curWidgetFig);
setDividerBounds(curWidgetFig, x, y);
if (lastClickedWidget instanceof ChildWidget) {
if (curWidgetFig instanceof GraphicalChildWidget<?, ?>) {
GraphicalChildWidget<?, ?> child = (GraphicalChildWidget<?, ?>) curWidgetFig;
child.getParentFigure().openChildren();
}
if (curWidgetFig instanceof GraphicalParentWidget<?, ?>) {
if (changedWidget) {
((GraphicalParentWidget<?, ?>) curWidgetFig).openChildren();
}
}
}
} else if (potential != null) {
GraphicalTraversableWidget<?> owner = ui.getPotentialFigureOwner();
if (owner instanceof GraphicalChildWidget<?, ?>) {
((GraphicalChildWidget<?, ?>) owner).getParentFigure().openChildren();
}
ui.potentialUIFig.setSelection(potential);
} else {
if (withinReorder(x, y)) {
setDividerBounds(lastHoveredWidget, x, y);
if (lastHoveredWidget instanceof GraphicalChildWidget<?, ?>) {
GraphicalChildWidget<?, ?> gcw = (GraphicalChildWidget<?, ?>) lastHoveredWidget;
gcw.getParentFigure().openChildren();
}
} else if ((lastClickedWidget instanceof ChildWidget) || !duplicate) {
ui.hideNondynamicSupport(true, false);
InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
drawLayer.setCursor(NOT_ALLOWED_CURSOR);
}
}
}
Aggregations