Search in sources :

Example 11 with Rectangle

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

the class DesignEditorUI method getSelectedRegion.

/**
     * Support for centering selection when zooming
     */
@Override
protected Rectangle getSelectedRegion() {
    Iterator<DesignEditorFrame> selectedFigs = selection.getSelectedFrameFigures();
    Rectangle r = computeUnion(selectedFigs);
    if (r != null) {
        return r;
    }
    if (selection.getSelectedTransitionCount() > 0) {
        Iterator<DesignEditorTransition> transitionFigs = selection.getSelectedTransitionFigures();
        return computeUnion(transitionFigs);
    }
    return super.getSelectedRegion();
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)

Example 12 with Rectangle

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

the class StructureViewUIModel method computeFrameArea.

protected Rectangle computeFrameArea() {
    Rectangle r = null;
    Iterator<DesignEditorFrame> frames = installedFrames.values().iterator();
    while (frames.hasNext()) {
        DesignEditorFrame frameFigure = frames.next();
        if (r == null) {
            r = new Rectangle(frameFigure.getBounds());
        } else {
            r.union(frameFigure.getBounds());
        }
    }
    return (r != null) ? r : new Rectangle(0, 0, 0, 0);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 13 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle 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 14 with Rectangle

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

the class NinePartRenderer method paintBackground.

// getNinePartImages
public void paintBackground(Graphics g) {
    if ((imageParts == null) || (imageParts.length == 0) || (imageParts[0] == null)) {
        return;
    }
    g.pushState();
    try {
        // This is the clip to the figure. We must clip to this the whole time!
        Rectangle mainClip = getBounds();
        g.setClip(mainClip);
        // This will represent temporary clips while drawing the 9part.
        // All subClips must be a union of mainClip and something else.
        Rectangle subClip = mainClip;
        // This is the top and left of the 9-part tiled image.
        // widgetBounds.x and .y should both always be 0 since we want to fill
        // the space we have been given.
        int topOfImg = widgetBounds.x;
        int leftOfImg = widgetBounds.y;
        // These variables represent the distances between the actual edges
        // of the 9-part tiling and the edge of the center area of the 9-part.
        // we will assume we have all images so no error checking is needed.
        int leftSize = imageParts[0].getBounds().width;
        int rightSize = imageParts[2].getBounds().width;
        int topSize = imageParts[0].getBounds().height;
        int bottomSize = imageParts[6].getBounds().height;
        // These variables represent the absolute coordinates
        // of the edges of the center area.
        int rightOfCenter = leftOfImg + widgetBounds.width - rightSize;
        int leftOfCenter = leftOfImg + leftSize;
        int topOfCenter = topOfImg + topSize;
        int bottomOfCenter = topOfImg + widgetBounds.height - bottomSize;
        // These are  variables for when I am drawing a row of images.
        int drawX;
        int drawY;
        // When I am drawing a row of images, these variables store the
        // dimension of the image I'm drawing.
        int imgWidth;
        int imgHeight;
        // Setting the subclip for drawing the center area.
        subClip = mainClip;
        subClip = subClip.getIntersection(new Rectangle(leftOfCenter, topOfCenter, rightOfCenter - leftOfCenter + 2, bottomOfCenter - topOfCenter + 2));
        g.setClip(subClip);
        if (imageParts[4] != null) {
            imgWidth = imageParts[4].getBounds().width;
            imgHeight = imageParts[4].getBounds().height;
            for (drawX = leftOfCenter; drawX < rightOfCenter; drawX += imgWidth) {
                for (drawY = topOfCenter; drawY < bottomOfCenter; drawY += imgHeight) {
                    g.drawImage(imageParts[4], drawX, drawY);
                }
            }
        }
        // Setting the subclip for drawing horizontal rows.
        subClip = mainClip;
        subClip = subClip.getIntersection(new Rectangle(leftOfCenter, topOfImg, rightOfCenter - leftOfCenter + 2, widgetBounds.height));
        g.setClip(subClip);
        // Drawing the top row.
        if (imageParts[1] != null) {
            imgWidth = imageParts[1].getBounds().width;
            for (drawX = leftOfCenter; drawX < rightOfCenter; drawX += imgWidth) {
                g.drawImage(imageParts[1], drawX, topOfImg);
            }
        }
        // Drawing the bottom row.
        if (imageParts[7] != null) {
            imgWidth = imageParts[7].getBounds().width;
            for (drawX = leftOfCenter; drawX < rightOfCenter; drawX += imgWidth) {
                g.drawImage(imageParts[7], drawX, bottomOfCenter);
            }
        }
        // Setting the subclip for drawing vertical rows.
        subClip = mainClip;
        subClip = subClip.getIntersection(new Rectangle(leftOfImg, topOfCenter, widgetBounds.width, bottomOfCenter - topOfCenter + 2));
        g.setClip(subClip);
        // Drawing the left side row.
        if (imageParts[3] != null) {
            imgHeight = imageParts[3].getBounds().height;
            for (drawY = topOfCenter; drawY < bottomOfCenter; drawY += imgHeight) {
                g.drawImage(imageParts[3], leftOfImg, drawY);
            }
        }
        // Drawing the right side row.
        if (imageParts[5] != null) {
            imgHeight = imageParts[5].getBounds().height;
            for (drawY = topOfCenter; drawY < bottomOfCenter; drawY += imgHeight) {
                g.drawImage(imageParts[5], rightOfCenter, drawY);
            }
        }
        // Reset the clip to the main clip, the entire size of the frame.
        g.setClip(mainClip);
        // Drawing the top left corner.
        if (imageParts[0] != null) {
            g.drawImage(imageParts[0], leftOfImg, topOfImg);
        }
        // Drawing the top right corner.
        if (imageParts[2] != null) {
            g.drawImage(imageParts[2], rightOfCenter, topOfImg);
        }
        // Drawing the bottom left corner.
        if (imageParts[6] != null) {
            g.drawImage(imageParts[6], leftOfImg, bottomOfCenter);
        }
        // Drawing the bottom right corner.
        if (imageParts[8] != null) {
            g.drawImage(imageParts[8], rightOfCenter, bottomOfCenter);
        }
    } finally {
        g.popState();
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 15 with Rectangle

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

the class PERTChartOperatorBar method paint.

//  ----------- UI METHODS _------------------------------------------------
@Override
public void paint(Graphics g) {
    g.pushState();
    try {
        Color drawColor = (selected) ? selectedColor : color;
        Rectangle bds = getBounds();
        g.setBackgroundColor(drawColor);
        g.setForegroundColor(ColorConstants.black);
        g.fillRectangle(bds);
        if (!selected) {
            g.setForegroundColor(ColorConstants.white);
        }
        // don't display it.  This avoids unnecessary (& illegible) visual clutter
        if (name != null) {
            String minVisibleName = name;
            if (name.length() > 3) {
                minVisibleName = name.substring(0, 3);
            }
            Dimension textDim = FigureUtilities.getTextExtents(minVisibleName, g.getFont());
            if (textDim.width < (bds.width - 5)) {
                if (textDim.height < (bds.height - 5)) {
                    g.drawText(name, bds.x + 2, bds.y + 2);
                }
            }
        }
        g.setForegroundColor(ColorConstants.black);
        if (!isCascade()) {
            g.drawRectangle(new Rectangle(bds.x, bds.y, bds.width - 1, bds.height - 1));
        }
    } finally {
        g.popState();
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

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