Search in sources :

Example 16 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.

the class InteractionDrawingEditor method resizeContents.

public void resizeContents(int width, int height, boolean resizeMin) {
    // Get the size of the view in unscaled coordinates
    Rectangle viewSize = contents.getChildrenUtilizedAreaScaled();
    // We need the TOTAL size starting from 0,0. Not just the actual size.
    int viewUIWidth = viewSize.width + viewSize.x;
    int viewUIHeight = viewSize.height + viewSize.y;
    // If the area grows, then we want to use the LARGER area
    if (viewUIWidth > width) {
        width = viewUIWidth;
    }
    if (viewUIHeight > height) {
        height = viewUIHeight;
    }
    Dimension prefSize = new Dimension(width, height);
    contents.setPreferredSize(prefSize);
    contents.setSize(width, height);
    interactionLayer.setPreferredSize(prefSize);
    interactionLayer.setSize(width, height);
    backgroundColorFigure.setPreferredSize(prefSize);
    backgroundColorFigure.setSize(width, height);
    if (resizeMin) {
        setMinVisibleArea(width, height, false);
        // Check to see if the area was enlarged if so grow to match
        int editorWidth = editorComposite.getSize().x;
        int editorHeight = editorComposite.getSize().y;
        if (editorWidth > width) {
            width = editorWidth;
        }
        if (editorHeight > height) {
            height = editorHeight;
        }
        contents.setSize(width, height);
        interactionLayer.setSize(width, height);
        backgroundColorFigure.setSize(width, height);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 17 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.

the class InteractionDrawingEditor method computeZoomToFit.

public double computeZoomToFit() {
    // Put the origin of the scrollable region back to 0,0
    scrollComposite.setOrigin(0, 0);
    // Ensures that both width and height will fit in available space
    org.eclipse.swt.graphics.Rectangle visibleBounds = getVisibleBounds();
    // Need to get the UNSCALEd version of currentFrame
    Rectangle neededBounds = contents.getChildrenUtilizedAreaUnscaled();
    double scalingToFit = 1.0;
    // Need a fudge factor for some reason.
    double neededWidth = neededBounds.width + 5.0;
    double neededHeight = neededBounds.height + 5.0;
    if (neededBounds.x > 0) {
        neededWidth += neededBounds.x;
    }
    if (neededBounds.y > 0) {
        neededHeight += neededBounds.y;
    }
    // If it doesn't fit then resize by height.
    if ((neededWidth != 0.0) && (neededHeight != 0.0)) {
        if (((visibleBounds.width) / neededWidth) * neededHeight < visibleBounds.height) {
            scalingToFit = (visibleBounds.width) / neededWidth;
        } else {
            scalingToFit = (visibleBounds.height) / neededHeight;
        }
    }
    return scalingToFit;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 18 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.

the class InteractionDrawingEditor method getContentSize.

@Override
public org.eclipse.swt.graphics.Rectangle getContentSize() {
    Rectangle viewSize = contents.getChildrenUtilizedAreaScaled();
    // We need the TOTAL size starting from 0,0. Not just the actual size.
    viewSize.width += viewSize.x;
    viewSize.height += viewSize.y;
    // use 0,0 as origin
    return new org.eclipse.swt.graphics.Rectangle(0, 0, viewSize.width, viewSize.height);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 19 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.

the class ScalableGraphicalFigure method getChildrenUtilizedAreaUnscaled.

/**
     * Returns the area occupied by the children in UNSCALED coordinates
     */
public Rectangle getChildrenUtilizedAreaUnscaled() {
    Rectangle r = null;
    Iterator<?> iter = getChildren().iterator();
    while (iter.hasNext()) {
        IFigure fi = (IFigure) iter.next();
        if (r == null) {
            r = new Rectangle(fi.getBounds());
        } else {
            r.union(fi.getBounds());
        }
    }
    return (r == null) ? new Rectangle(0, 0, 0, 0) : r;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 20 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.

the class MoveHalo method setScale.

@Override
public void setScale(double newScale) {
    scale = newScale;
    Rectangle scaled = PrecisionUtilities.getDraw2DRectangle(bds.x * scale, bds.y * scale, bds.width * scale, bds.height * scale);
    scaled.x -= (ResizeThumb.WIDTH_HEIGHT / 2) + 2;
    scaled.y -= (ResizeThumb.WIDTH_HEIGHT / 2) + 2;
    scaled.width += ResizeThumb.WIDTH_HEIGHT + 4;
    scaled.height += ResizeThumb.WIDTH_HEIGHT + 4;
    setBounds(scaled);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)197 Point (org.eclipse.draw2d.geometry.Point)59 Dimension (org.eclipse.draw2d.geometry.Dimension)43 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)21 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)17 Iterator (java.util.Iterator)11 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)11 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)9 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)8 ArrayList (java.util.ArrayList)8 Node (org.talend.designer.core.ui.editor.nodes.Node)8 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)7 Figure (org.eclipse.draw2d.Figure)6 Color (org.eclipse.swt.graphics.Color)6 ERTable (com.cubrid.common.ui.er.model.ERTable)5 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)5 Label (org.eclipse.draw2d.Label)5 Image (org.eclipse.swt.graphics.Image)5