use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.
the class FrameEditorMouseState method getInsertIndex.
protected int getInsertIndex(IWidget widgetModel, int x, int y) {
double zoom = ui.getZoom();
DoubleRectangle widgetBds = widgetModel.getEltBounds();
double centerX = widgetBds.x + (widgetBds.width / 2);
double centerY = widgetBds.y + (widgetBds.height / 2);
int originX = PrecisionUtilities.round(centerX * zoom);
int originY = PrecisionUtilities.round(centerY * zoom);
SimpleWidgetGroup group = widgetModel.getParentGroup();
int index = 0;
if (group != null) {
index = group.indexOf(widgetModel);
switch(group.getOrientation()) {
case SimpleWidgetGroup.HORIZONTAL:
{
if (x > originX) {
index++;
}
break;
}
case SimpleWidgetGroup.VERTICAL:
{
if (y > originY) {
index++;
}
break;
}
default:
{
index++;
}
}
}
return index;
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.
the class FrameEditorMouseState method dynamicResizeWidget.
protected void dynamicResizeWidget(IWidget widget, GraphicalWidget<?> gw, double ratioX, double ratioY, double newLeft, double newTop) {
DoubleRectangle bds = widget.getEltBounds();
double newX = ratioX * (bds.x - initialResizeArea.x) + newLeft;
double newY = ratioY * (bds.y - initialResizeArea.y) + newTop;
ui.setGraphicalWidgetBounds(newX, newY, ratioX * bds.width, ratioY * bds.height, gw);
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle 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.model.DoubleRectangle 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;
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleRectangle in project cogtool by cogtool.
the class FrameEditorUI method getSelectedWidgetArea.
public DoubleRectangle getSelectedWidgetArea() {
DoubleRectangle r = null;
Iterator<FrameElement> selectedElts = selection.getSelectedElementsIterator();
while (selectedElts.hasNext()) {
FrameElement elt = selectedElts.next();
DoubleRectangle bds = null;
if (elt instanceof IWidget) {
IWidget w = (IWidget) elt;
SimpleWidgetGroup wg = w.getParentGroup();
bds = (wg != null) ? wg.getGroupBounds() : w.getEltBounds();
} else if (elt instanceof FrameElementGroup) {
bds = ((FrameElementGroup) elt).getGroupBounds();
}
if (bds != null) {
if (r == null) {
r = new DoubleRectangle(bds);
} else {
r = r.union(bds);
}
}
}
return r;
}
Aggregations