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();
}
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();
}
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();
}
}
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;
}
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();
}
Aggregations