Search in sources :

Example 1 with DoubleSize

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);
}
Also used : StandardDrawingEditor(edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Example 2 with DoubleSize

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);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 3 with DoubleSize

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);
}
Also used : DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Example 4 with DoubleSize

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));
}
Also used : XYLayout(org.eclipse.draw2d.XYLayout) ScalableFrameFigure(edu.cmu.cs.hcii.cogtool.view.ScalableFrameFigure) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Example 5 with DoubleSize

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);
}
Also used : GraphicalMenuItem(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalMenuItem) MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) GraphicalChildWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget) ChildWidget(edu.cmu.cs.hcii.cogtool.model.ChildWidget) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Aggregations

DoubleSize (edu.cmu.cs.hcii.cogtool.model.DoubleSize)17 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)8 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)4 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)4 StandardDrawingEditor (edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)3 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)3 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)3 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)3 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)2 ScalableFrameFigure (edu.cmu.cs.hcii.cogtool.view.ScalableFrameFigure)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 XYLayout (org.eclipse.draw2d.XYLayout)2 Image (org.eclipse.swt.graphics.Image)2 CogToolWorkThread (edu.cmu.cs.hcii.cogtool.CogToolWorkThread)1 AShape (edu.cmu.cs.hcii.cogtool.model.AShape)1 FrameUIModel (edu.cmu.cs.hcii.cogtool.uimodel.FrameUIModel)1 GraphicalChildWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget)1 GraphicalMenuItem (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalMenuItem)1