use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class DesignExportToHTML method buildFocusSearch.
/**
* Checks whether a copy of the given widget exists in the destination
* frame; if so, return the information to the html in a search string.
*/
protected String buildFocusSearch(IWidget widget, Frame destination) {
String search = "";
Iterator<IWidget> widgets = destination.getWidgets().iterator();
while (widgets.hasNext()) {
IWidget w = widgets.next();
if (w.isIdentical(widget)) {
// TODO: is this the right test?
search = "?focusID=" + w.getName();
}
}
return search;
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorMouseState method dynamicResizeWidgets.
/**
* Utility to help with dynamic resize of selected widgets.
*
* @param selectedWFs the set of selected graphical widget figures
* @param currentScaledX scaled X location of the current mouse position
* @param currentScaledY scaled Y location of the current mouse position
* @author mlh/alex
*/
protected void dynamicResizeWidgets(Iterator<FrameEltSelnFig<?>> selectedWFs, double currentScaledX, double currentScaledY) {
// an origin less then 0.0,0.0
if (currentScaledX < 0.0) {
currentScaledX = 0.0;
}
if (currentScaledY < 0.0) {
currentScaledY = 0.0;
}
// Deal with any anchoring issues
if (ui.resizeHandlesUIFig.isTopLeftAnchored()) {
switch(currentResizeHandleType) {
case FrameEditorUI.TOP_RIGHT:
{
// Cannot change Y position
currentScaledY = initialResizeArea.y;
break;
}
case FrameEditorUI.BOTTOM_LEFT:
{
// Cannot change X position
currentScaledX = initialResizeArea.x;
break;
}
default:
{
break;
}
}
// Cannot move left of top-left
if (currentScaledX < initialResizeArea.x) {
currentScaledX = initialResizeArea.x;
}
// Cannot move above of top-left
if (currentScaledY < initialResizeArea.y) {
currentScaledY = initialResizeArea.y;
}
}
double newWidth = Math.abs(currentScaledX - mouseFixedResizeX);
double newHeight = Math.abs(currentScaledY - mouseFixedResizeY);
double newLeft = Math.min(currentScaledX, mouseFixedResizeX);
double newTop = Math.min(currentScaledY, mouseFixedResizeY);
double ratioX = newWidth / initialResizeArea.width;
double ratioY = newHeight / initialResizeArea.height;
// Iterate through selected widgets
while (selectedWFs.hasNext()) {
FrameEltSelnFig<?> f = selectedWFs.next();
if (f instanceof GraphicalWidget<?>) {
GraphicalWidget<?> gw = (GraphicalWidget<?>) f;
IWidget w = gw.getModel();
SimpleWidgetGroup group = w.getParentGroup();
if ((w instanceof TraversableWidget) && (group != null)) {
dynamicResizeGroup(group, ratioX, ratioY, newLeft, newTop, false);
} else {
dynamicResizeWidget(w, gw, ratioX, ratioY, newLeft, newTop);
}
} else if (f instanceof FrameEltGroupHalo) {
dynamicResizeGroup(((FrameEltGroupHalo) f).getModel(), ratioX, ratioY, newLeft, newTop, true);
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorSelectionState method getSelectedWidgetsParent.
/**
* If all of the selected items are widgets with the same
* parent SimpleWidgetGroup, return that parent group.
*/
public SimpleWidgetGroup getSelectedWidgetsParent() {
SimpleWidgetGroup parentGroup = null;
Iterator<FrameElement> selectedElts = selectedElements.keySet().iterator();
while (selectedElts.hasNext()) {
FrameElement elt = selectedElts.next();
if (elt instanceof IWidget) {
SimpleWidgetGroup g = ((IWidget) elt).getParentGroup();
// Can't share a parent if one is null
if (g == null) {
return null;
}
// If no parent recorded yet, keep track
if (parentGroup == null) {
parentGroup = g;
} else if (parentGroup != g) {
// if parents don't match, done
return null;
}
} else {
// Can't share a parent if not all selected elts are widgets
return null;
}
}
return parentGroup;
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorUI method scrollListBoxUp.
/**
* "Scrolls" the given group up (MUST REVIEW WHEN FINALLY DONE)
*/
public void scrollListBoxUp(SimpleWidgetGroup group) {
Integer value = (Integer) group.getAttribute(WidgetAttributes.NUM_VISIBLE_ATTR);
int num = value.intValue();
if (group.size() > num) {
IWidget top = (IWidget) group.getAttribute(WidgetAttributes.FIRST_VISIBLE_ATTR);
int index = group.indexOf(top);
if (index == 0) {
return;
}
frameUI.getWidgetFigure(top).setVisible(false);
double height = top.getEltBounds().height;
for (int i = index + 1; i < index + num; i++) {
group.get(i).moveElement(0, -height);
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget 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