Search in sources :

Example 86 with Dimension

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

the class GraphicalWidgetBase method updateType.

public synchronized void updateType() {
    // Mark the caches as dirty so that no one will use them
    synchronized (this.flagLock) {
        this.cachedMidgroundDirty = true;
    }
    IWidget w = getModel();
    try {
        // Change the renderer to one that is appropriate for the type
        this.renderer = getRendererForType(w.getWidgetType(), w.getFrame().getDesign().getSkin(), w.isRendered());
    } catch (Exception e) {
        System.err.println("Error creating widget renderer: " + e);
        try {
            this.renderer = getRendererForType(w.getWidgetType(), SkinType.None, w.isRendered());
        } catch (Exception ex) {
            System.err.println("Error creating unskinned widget renderer: " + e);
            this.renderer = new LabelRenderer(this.attrOverride);
        }
    }
    Dimension widgetExtent = getSize();
    this.renderer.setSize(widgetExtent.width, widgetExtent.height);
    this.renderer.setText(w.getTitle());
    this.renderer.updateData();
    setCursor(determineProperCursor(w, this.desiredRolloverCursor));
    regenerateCaches();
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 87 with Dimension

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

the class GraphicalDevice method paintFigure.

/**
     * Override to perform drawing tasks common to all graphical sources
     */
@Override
protected void paintFigure(Graphics g) {
    Dimension size = getSize();
    // Workaround Draw2D's inability to draw 0-size images.
    int width = size.width;
    if (width == 0) {
        width = 1;
    }
    int height = size.height;
    if (height == 0) {
        height = 1;
    }
    Image scaled = null;
    try {
        // Draw foreground sheen (not selected)
        foreground.setAlpha(0, 0, displayAlpha.determineAlpha(false));
        // TODO: Can this be cached more efficiently?
        scaled = new Image(null, foreground.scaledTo(width, height));
        Point location = getLocation();
        g.drawImage(scaled, location.x, location.y);
    } catch (SWTException ex) {
        throw new RcvrImageException("Drawing device foreground image failed", ex);
    } finally {
        if (scaled != null) {
            scaled.dispose();
        }
    }
    super.paintFigure(g);
    button.paintFigure(g);
}
Also used : SWTException(org.eclipse.swt.SWTException) RcvrImageException(edu.cmu.cs.hcii.cogtool.util.RcvrImageException) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.draw2d.geometry.Point)

Example 88 with Dimension

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

the class ScalableGraphicalFigure method getPreferredSize.

/**
     * @see Figure#getPreferredSize(int, int)
     */
@Override
public Dimension getPreferredSize(int wHint, int hHint) {
    Dimension d = super.getPreferredSize(wHint, hHint);
    int w = getInsets().getWidth();
    int h = getInsets().getHeight();
    return d.getExpanded(-w, -h).scale(scale).expand(w, h);
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 89 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class GraphPlanStyleProvider method wrapText.

/**
	 * wrap the too long text
	 *
	 * @param width
	 * @param str
	 * @return
	 */
private String wrapText(int width, String str) {
    Dimension dim1 = TextUtilities.INSTANCE.getStringExtents(str, GraphPlanTooltipFigure.normalFont);
    // the width is big enough to display the String
    if (dim1.width < width) {
        return str;
    }
    // Calculate how many character to display per line
    int pixPerChar = dim1.width / str.length();
    int charPerLine = (MIN_CHAR_PER_LINE > width / pixPerChar) ? MIN_CHAR_PER_LINE : width / pixPerChar;
    StringBuilder sb = new StringBuilder();
    int startpos = 0;
    int endpos = charPerLine;
    while (startpos < str.length()) {
        if (endpos >= str.length()) {
            endpos = str.length();
        }
        sb.append(str.substring(startpos, endpos)).append("\n");
        startpos += charPerLine;
        endpos += charPerLine;
    }
    return sb.toString();
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 90 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERTableNode method getMaxSizeNode.

public static ERTableNode getMaxSizeNode(Collection<ERTableNode> allNodes, boolean horizon) {
    int max = 0;
    ERTableNode result = null;
    for (ERTableNode node : allNodes) {
        Dimension d = node.getDefaultPreferredSize();
        if (horizon && d.width > max) {
            result = node;
            max = d.width;
        } else if (!horizon && d.height > max) {
            result = node;
            max = d.height;
        }
    }
    return result;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)180 Rectangle (org.eclipse.draw2d.geometry.Rectangle)80 Point (org.eclipse.draw2d.geometry.Point)70 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)16 Insets (org.eclipse.draw2d.geometry.Insets)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)8 PointList (org.eclipse.draw2d.geometry.PointList)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)5 ArrayList (java.util.ArrayList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 Font (org.eclipse.swt.graphics.Font)4 Point (org.eclipse.swt.graphics.Point)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 Label (org.eclipse.draw2d.Label)3 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3