Search in sources :

Example 21 with Rectangle

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

the class PERTInteractivePanel method resizeVisualization.

@Override
public void resizeVisualization(Event e) {
    int regionWidth = getClientArea().width - (marginLeft + marginRight);
    if (regionWidth > 0) {
        double displayedTime = displayEndTime - displayStartTime;
        // find appropriate resolution for timeline
        dispTimeInterval = 1;
        int x = 1;
        while ((regionWidth * ((dispTimeInterval) / displayedTime)) < 4.0) {
            dispTimeInterval = Math.pow(10, x);
            x++;
        }
        dispTimeIntervalWidth = (regionWidth) * (dispTimeInterval / displayedTime);
        int timeLineX = marginLeft - (int) ((displayStartTime / displayedTime) * regionWidth);
        int hiddenWidth = (int) (regionWidth * (totalTime / displayedTime));
        timeLine.setBounds(new Rectangle(timeLineX, 0, hiddenWidth, marginTop));
    }
    super.resizeVisualization(e);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 22 with Rectangle

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

the class PERTPanel method resizeVisualization.

/**
     * Resets the position and size of the PERTChartOperatorBar objects
     * when the panel is resized.
     *
     * @param e resize Event to respond to.
     */
public void resizeVisualization(Event e) {
    int totalWidth = getVisualizationWidth();
    int totalHeight = getVisualizationHeight();
    int regionHeight = PrecisionUtilities.round((totalHeight - 10) / Math.max(numRows, 1));
    Iterator<PERTChartOperatorBar> barIterator = bars.iterator();
    PERTChartOperatorBar bar;
    int barW;
    int barH;
    int barX;
    int barY;
    // rescale the width of each bar based on the ratio of it's duration to
    // the total time, and set its new position
    double displayedDuration = displayEndTime - displayStartTime;
    if ((totalTime > 0) && (displayedDuration > 0)) {
        while (barIterator.hasNext()) {
            bar = barIterator.next();
            // Calculate position based on the position of the right of the
            // bar to avoid oscillating widths
            int barRightPos = marginLeft + PrecisionUtilities.round(((bar.getStartTime() + bar.getDuration() - displayStartTime) / displayedDuration) * (totalWidth - 10));
            //
            //                barW = PrecisionUtilities.round((bar.getDuration() * (totalWidth - 10))
            //                                                / displayedDuration) + 1;
            barX = marginLeft + PrecisionUtilities.round(((bar.getStartTime() - displayStartTime) / displayedDuration) * (totalWidth - 10));
            barW = barRightPos - barX + 1;
            if (bar.isCascade()) {
                int y1 = Math.min(bar.getRow(), bar.getEndRow());
                int y2 = Math.max(bar.getRow(), bar.getEndRow());
                barY = marginTop + (y1 * regionHeight) + PrecisionUtilities.round(0.5 * barHeight);
                barH = (y2 - y1) * regionHeight;
                if (barW < 1) {
                    barW = 1;
                }
            } else {
                barY = marginTop + (bar.getRow() * regionHeight);
                barH = barHeight;
                if (barW < 3) {
                    barX -= 1;
                    barW = 3;
                }
            }
            bar.setBounds(new Rectangle(barX, barY, barW, barH));
        }
    }
    lws.getUpdateManager().performUpdate();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) PERTChartOperatorBar(edu.cmu.cs.hcii.cogtool.uimodel.PERTChartOperatorBar)

Example 23 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.

the class DiagramPart method setTableModelBounds.

/**
     * Updates the table bounds in the model so that the same bounds can be
     * restored after saving
     *
     * @return whether the procedure execute successfully without any omissions.
     *         The latter occurs if any EntityFigure has no bounds set for any of
     *         the Table model objects
     */
public boolean setTableModelBounds() {
    List<?> entityParts = getChildren();
    for (Iterator<?> iter = entityParts.iterator(); iter.hasNext(); ) {
        NodePart entityPart = (NodePart) iter.next();
        IFigure entityFigure = entityPart.getFigure();
        // continue
        if (entityFigure == null) {
            continue;
        }
        Rectangle bounds = entityFigure.getBounds().getCopy();
        entityPart.setBounds(bounds);
    }
    return true;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 24 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.

the class DiagramXYLayoutPolicy method getCurrentConstraintFor.

/**
	 * Returns the current bounds as the constraint if none can be found in the
	 * figures Constraint object
	 */
@Override
public Rectangle getCurrentConstraintFor(GraphicalEditPart child) {
    IFigure fig = child.getFigure();
    Rectangle rectangle = (Rectangle) fig.getParent().getLayoutManager().getConstraint(fig);
    if (rectangle == null) {
        rectangle = fig.getBounds();
    }
    return rectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 25 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.

the class EntityPart method createFigure.

//******************* Layout related methods *********************/
/**
	 * Creates a figure which represents the table
	 */
@Override
protected EntityFigure createFigure() {
    final EntityFigure figure = new EntityFigure(getTable());
    final EntityDiagram diagram = ((DiagramPart) getParent()).getDiagram();
    Rectangle bounds = diagram.getInitBounds(getTable());
    if (bounds != null) {
        figure.setLocation(bounds.getLocation());
    }
    return figure;
}
Also used : EntityDiagram(org.jkiss.dbeaver.ext.erd.model.EntityDiagram) EntityFigure(org.jkiss.dbeaver.ext.erd.figures.EntityFigure) 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