Search in sources :

Example 1 with AShape

use of edu.cmu.cs.hcii.cogtool.model.AShape in project cogtool by cogtool.

the class GraphicalWidgetBase method updateShape.

public synchronized void updateShape() {
    // Mark the caches as dirty so that no one will use them
    synchronized (this.flagLock) {
        this.cachedMidgroundDirty = true;
        this.cachedBackgroundDirty = true;
    }
    // Keep track of some properties that we need later
    Dimension oldSize = getSize();
    GraphicalWidgetClipper oldClipper = this.clipper;
    AShape s = model.getShape();
    DoubleRectangle shapeBds = s.getBounds();
    Rectangle figBds = PrecisionUtilities.getDraw2DRectangle(shapeBds);
    // Inherit properties from our model's shape
    setBounds(figBds);
    if ((figBds.width == 0) || (figBds.height == 0)) {
        if (figBds.width == 0) {
            figBds.width = 1;
        }
        if (figBds.height == 0) {
            figBds.height = 1;
        }
        super.setSize(figBds.width, figBds.height);
    }
    this.renderer.setSize(figBds.width, figBds.height);
    setPreferredSize(figBds.width, figBds.height);
    this.clipper = getClipperForShape(s);
    // Decide whether the caches are really dirty
    if (this.clipper.equals(oldClipper) && getSize().equals(oldSize)) {
        synchronized (this.flagLock) {
            this.cachedMidgroundDirty = false;
            this.cachedBackgroundDirty = false;
        }
    }
    regenerateCaches(figBds.width, figBds.height);
}
Also used : ShapeRoundedRectangle(edu.cmu.cs.hcii.cogtool.model.ShapeRoundedRectangle) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) AShape(edu.cmu.cs.hcii.cogtool.model.AShape)

Example 2 with AShape

use of edu.cmu.cs.hcii.cogtool.model.AShape in project cogtool by cogtool.

the class DesignEditorCmd method getFirstChildPosition.

private static DoublePoint getFirstChildPosition(AParentWidget parent) {
    AShape parentShape = parent.getShape();
    DoublePoint pos = parentShape.getOrigin();
    DoubleSize extent = parentShape.getSize();
    switch(parent.getChildrenLocation()) {
        case AParentWidget.CHILDREN_BELOW:
            {
                pos.y += extent.height;
                break;
            }
        case AParentWidget.CHILDREN_RIGHT:
            {
                pos.x += extent.width;
                break;
            }
        case AParentWidget.CHILDREN_CENTER:
            {
                pos.x += extent.width / 2.0;
                pos.y += extent.height / 2.0;
                break;
            }
    }
    return pos;
}
Also used : DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) AShape(edu.cmu.cs.hcii.cogtool.model.AShape) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Aggregations

AShape (edu.cmu.cs.hcii.cogtool.model.AShape)2 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)1 DoubleSize (edu.cmu.cs.hcii.cogtool.model.DoubleSize)1 ShapeRoundedRectangle (edu.cmu.cs.hcii.cogtool.model.ShapeRoundedRectangle)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1