use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class SEDefaultUI method resetVisibleArea.
public void resetVisibleArea() {
StandardDrawingEditor e = view.getEditor();
e.getLWS().getUpdateManager().performUpdate();
DoubleSize extent = uiModel.getCurrentFrame().getPreferredSize();
e.setMinVisibleArea(PrecisionUtilities.round(extent.width), PrecisionUtilities.round(extent.height), false);
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class DesignEditorFrame method resetFrameSize.
protected void resetFrameSize() {
// Update the size with the preferred size of the contents.
DoubleSize size = computeFrameSize(getScale());
int width = PrecisionUtilities.round(size.width);
int height = PrecisionUtilities.round(size.height);
// Set the initial size to force a repaint call.
// Call super, since we actually want to set the Size.. vs the current
// which will try and resize to the "current size"
// while this is actually a flag to force a paint.
super.setSize(width, height);
super.setPreferredSize(width, height);
// Force this to always take the extra space up by frameWidget Box
if (usesSpeaker) {
height -= speakerBox.getPreferredSize().height;
}
height -= (inputDeviceBox.getPreferredSize().height + inputDeviceBox.getInsets().getHeight());
height -= nameLabel.getPreferredSize().height;
frameWidgetBox.setSize(width, height);
frameWidgetBox.setPreferredSize(width, height);
if (usesSpeaker) {
int insetsWidth = getInsets().getWidth();
int speakerTextWidth = width - insetsWidth - (4 * SPEAKER_DIVIDER_WIDTH) - speakerImgWidth - LISTEN_TIME_WIDTH - 1;
Rectangle layoutConstraint = new Rectangle(speakerImgWidth + SPEAKER_DIVIDER_WIDTH, 0, speakerTextWidth, speakerImgHeight);
speakerLayout.setConstraint(speakerText, layoutConstraint);
layoutConstraint = new Rectangle(speakerImgWidth + SPEAKER_DIVIDER_WIDTH + speakerTextWidth, 0, SPEAKER_DIVIDER_WIDTH, speakerImgHeight);
speakerLayout.setConstraint(divider, layoutConstraint);
layoutConstraint = new Rectangle(speakerImgWidth + (2 * SPEAKER_DIVIDER_WIDTH) + speakerTextWidth, 0, LISTEN_TIME_WIDTH, speakerImgHeight);
speakerLayout.setConstraint(listenTime, layoutConstraint);
layoutConstraint = new Rectangle(speakerImgWidth + (3 * SPEAKER_DIVIDER_WIDTH) + speakerTextWidth + LISTEN_TIME_WIDTH, 0, SPEAKER_DIVIDER_WIDTH, speakerImgHeight);
speakerLayout.setConstraint(timeWestBorder, layoutConstraint);
}
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class DesignEditorFrame method computeFrameSize.
protected DoubleSize computeFrameSize(double zoom) {
// Use scaled versions of min-width & min_height so that
// even if the frame is empty, a scale operation will have an "effect"
double minScale = (scale > 1) ? scale : 1.0;
double width = CogToolPref.MIN_FRAME_WIDTH.getInt() * minScale;
double height = MIN_HEIGHT * minScale;
// Make sure the contents is at least the height of 100, and the
// width of the frame.
DoubleSize frameSize = frameUIModel.getPreferredSize(zoom);
if (frameSize.width > width) {
width = frameSize.width;
}
if (frameSize.height > height) {
height = frameSize.height;
}
if (usesSpeaker) {
height += speakerBox.getPreferredSize().height + speakerBox.getInsets().getHeight();
}
// The input box has a border, which makes it take additional space
height += inputDeviceBox.getPreferredSize().height + inputDeviceBox.getInsets().getHeight();
height += nameLabel.getPreferredSize().height;
return new DoubleSize(width, height);
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class StructureViewUIModel method setUpContents.
protected void setUpContents() {
contents = new ScalableFrameFigure(GraphicsUtil.defaultWidgetColor);
contents.setScale(1.0);
contents.setLayoutManager(new XYLayout());
installFrames();
// Resize to preferred size.
DoubleSize s = getPreferredSize();
contents.setSize(PrecisionUtilities.round(s.width), PrecisionUtilities.round(s.height));
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class FrameEditorMouseState method setDividerBounds.
// dynamicMoveWidgets
protected void setDividerBounds(GraphicalWidget<?> widget, int x, int y) {
double zoom = ui.getZoom();
Rectangle bounds = widget.getBounds();
int originX = bounds.x + (bounds.width / 2);
int originY = bounds.y + (bounds.height / 2);
originX = PrecisionUtilities.round(originX * zoom);
originY = PrecisionUtilities.round(originY * zoom);
double newX = bounds.x;
double newY = bounds.y;
double newH = bounds.height;
double newW = bounds.width;
int heightInc = 0;
int widthInc = 0;
if ((lastClickedWidget instanceof ChildWidget) && (widget instanceof GraphicalParentWidget<?, ?>) && (!(widget instanceof GraphicalMenuItem))) {
AParentWidget parent = (AParentWidget) widget.getModel();
int childrenLoc = parent.getChildrenLocation();
switch(childrenLoc) {
case AParentWidget.CHILDREN_BELOW:
case AParentWidget.CHILDREN_CENTER:
{
if (childrenLoc == AParentWidget.CHILDREN_CENTER) {
newX += newW / 2.0;
newY += newH / 2.0;
} else {
newY += newH;
}
if (parent.hasChildren()) {
IWidget child = parent.getItem(0);
DoubleSize childSize = child.getShape().getSize();
newW = childSize.width;
newH = childSize.height;
Object value = child.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
if (NullSafe.equals(WidgetAttributes.IS_SEPARATOR, value)) {
newH *= FrameEditorUI.SEPARATOR_RATIO;
}
} else if (parent instanceof MenuHeader) {
newW *= FrameEditorUI.MENU_ITEM_RATIO;
}
newH /= 10.0;
newY -= newH / 2.0;
heightInc = 1;
break;
}
case AParentWidget.CHILDREN_RIGHT:
{
newX += newW;
if (parent.hasChildren()) {
DoubleSize childSize = parent.getItem(0).getShape().getSize();
newW = childSize.width;
newH = childSize.height;
}
newW /= 20.0;
newX -= newW / 2.0;
widthInc = 1;
break;
}
}
} else {
switch(widget.getModel().getParentGroup().getOrientation()) {
case SimpleWidgetGroup.HORIZONTAL:
{
if (x > originX) {
newX += newW;
}
newW /= 20.0;
newX -= newW / 2.0;
widthInc = 1;
break;
}
case SimpleWidgetGroup.VERTICAL:
{
if (y > originY) {
newY += newH;
}
newH /= 10.0;
Object value = widget.getModel().getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
if (WidgetAttributes.IS_SEPARATOR.equals(value)) {
newH *= FrameEditorUI.SEPARATOR_RATIO;
}
newY -= newH / 2.0;
heightInc = 1;
break;
}
}
}
newX *= zoom;
newY *= zoom;
double rightX = newX + (newW + widthInc) * zoom;
double bottomY = newY + (newH + heightInc) * zoom;
newW = PrecisionUtilities.round(rightX - newX);
newH = PrecisionUtilities.round(bottomY - newY);
newX = PrecisionUtilities.round(newX);
newY = PrecisionUtilities.round(newY);
dividerLine.setBounds(new Rectangle((int) newX, (int) newY, (int) newW, (int) newH));
dividerLine.setVisible(true);
}
Aggregations