Search in sources :

Example 51 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class WorkflowOutPortEditPart method refreshVisuals.

/**
 * {@inheritDoc}
 */
@Override
protected void refreshVisuals() {
    IFigure fig = getFigure();
    fig.setBounds(new Rectangle(new Point(0, 50), new Dimension(30, 30)));
    super.refreshVisuals();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Example 52 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class NodeContainerFigure method setLabelText.

/**
 * Sets the text of the heading label.
 *
 * @param text The text to set.
 */
@SuppressWarnings("unchecked")
public void setLabelText(final String text) {
    m_label = text;
    m_headingContainer.removeAll();
    // needed, otherwise labels disappear after font size has changed
    m_headingContainer.setBounds(new Rectangle(0, 0, 0, 0));
    Font boldFont = FontStore.INSTANCE.getDefaultFontBold(FontStore.getFontSizeFromKNIMEPrefPage());
    m_headingContainer.setFont(boldFont);
    int width = 0;
    for (String s : wrapText(text).split("\n")) {
        Label l = new Label(s) {

            /**
             * {@inheritDoc}
             */
            @Override
            public Dimension getPreferredSize(final int wHint, final int hHint) {
                Dimension d = super.getPreferredSize(wHint, hHint).getCopy();
                // headings labels are too small when the editor is zoomed.
                d.width = (int) (d.width * 1.1);
                return d;
            }
        };
        l.setForegroundColor(ColorConstants.black);
        l.setFont(boldFont);
        m_headingContainer.add(l);
        Dimension size = l.getPreferredSize();
        width = Math.max(width, size.width);
    }
    int height = 0;
    for (IFigure child : (List<IFigure>) m_headingContainer.getChildren()) {
        Dimension size = child.getPreferredSize();
        int offset = (width - size.width) / 2;
        child.setBounds(new Rectangle(offset, height, size.width, size.height));
        height += size.height;
    }
    m_headingContainer.setBounds(new Rectangle(0, 0, width, height));
    repaint();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Label(org.eclipse.draw2d.Label) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) Font(org.eclipse.swt.graphics.Font) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 53 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class ProgressToolTipHelper method displayToolTipNear.

/**
 * Sets the LightWeightSystem's contents to the passed tooltip, and displays
 * the tip. The tip will be displayed only if the tip source is different
 * than the previously viewed tip source. (i.e. The cursor has moved off of
 * the previous tooltip source figure.)
 * <p>
 * The tooltip will be painted directly below the cursor if possible,
 * otherwise it will be painted directly above cursor.
 *
 * No timer is set for this kind of dynamic tool tip.
 *
 * @param hoverSource the figure over which the hover event was fired
 * @param tip the tooltip to be displayed
 * @param eventX the x coordinate of the hover event
 * @param eventY the y coordinate of the hover event
 * @since 2.0
 */
public void displayToolTipNear(final IFigure hoverSource, final IFigure tip, final int eventX, final int eventY) {
    /*
         * If the cursor is not on any Figures, it has been moved off of the
         * control. Hide the tool tip.
         */
    if (hoverSource == null) {
        if (isShowing()) {
            hide();
        }
        return;
    }
    if (tip != null) {
        getLightweightSystem().setContents(tip);
        org.eclipse.draw2d.geometry.Point position = new org.eclipse.draw2d.geometry.Point(eventX, eventY);
        WorkflowEditor.transposeZoom(m_zoomManager, position, true);
        Point absolute;
        absolute = control.toDisplay(new Point(position.x, position.y));
        Point displayPoint = computeWindowLocation(absolute.x, absolute.y);
        Dimension shellSize = getLightweightSystem().getRootFigure().getPreferredSize().getExpanded(getShellTrimSize());
        setShellBounds(displayPoint.x, displayPoint.y, shellSize.width, shellSize.height);
        show();
    }
}
Also used : Point(org.eclipse.swt.graphics.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 54 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class ProgressToolTipHelper method computeWindowLocation.

/*
     * Calculates the location where the tooltip will be painted. Returns this
     * as a Point. Tooltip will be painted directly below the cursor if
     * possible, otherwise it will be painted directly above cursor.
     */
private Point computeWindowLocation(final int eventX, final int eventY) {
    org.eclipse.swt.graphics.Rectangle clientArea = control.getDisplay().getClientArea();
    Point preferredLocation = new Point(eventX, eventY + 26);
    Dimension tipSize = getLightweightSystem().getRootFigure().getPreferredSize().getExpanded(getShellTrimSize());
    // Adjust location if tip is going to fall outside display
    if (preferredLocation.y + tipSize.height > clientArea.height) {
        preferredLocation.y = eventY - tipSize.height;
    }
    if (preferredLocation.x + tipSize.width > clientArea.width) {
        preferredLocation.x -= (preferredLocation.x + tipSize.width) - clientArea.width;
    }
    return preferredLocation;
}
Also used : Point(org.eclipse.swt.graphics.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 55 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class WorkflowEditor method getEditorGridX.

/*
     * ---------- end of auto-placing and auto-connecting --------------
     */
/**
 * Returns the grid horizontal spacing or the x value from the preference page, if the editor's property is not
 * set.
 *
 * @return the editors grid, or the value from the pref page (if not set in the editor)
 */
public int getEditorGridX() {
    GraphicalViewer viewer = getViewer();
    if (viewer == null) {
        return getPrefGridXSize();
    }
    Dimension grid = (Dimension) viewer.getProperty(SnapToGrid.PROPERTY_GRID_SPACING);
    if (grid != null) {
        return grid.width;
    }
    return getPrefGridXSize();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Dimension(org.eclipse.draw2d.geometry.Dimension)

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