use of org.eclipse.swt.graphics.Font 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.swt.graphics.Font in project knime-core by knime.
the class NodeContainerFigure method setFontSize.
/**
* Set a new font size which is applied to the node name and label.
*
* @param fontSize the new font size to ba applied.
*/
public void setFontSize(final int fontSize) {
setLabelText(m_label);
// apply new font for node label
Font font2 = super.getFont();
FontData fontData2 = font2.getFontData()[0];
Font newFont2 = FontStore.INSTANCE.getFont(fontData2.getName(), fontSize, fontData2.getStyle());
// apply the standard node label font also to its parent figure to allow
// editing the node label with the same font (size)
super.setFont(newFont2);
FontStore.INSTANCE.releaseFont(font2);
}
use of org.eclipse.swt.graphics.Font in project knime-core by knime.
the class NodeUsageComposite method createNodeGrid.
private void createNodeGrid(final SubNodeContainer subNodeContainer, @SuppressWarnings("rawtypes") final Map<NodeIDSuffix, WizardNode> viewNodes) {
ScrolledComposite scrollPane = new ScrolledComposite(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
scrollPane.setExpandHorizontal(true);
scrollPane.setExpandVertical(true);
Composite composite = new Composite(scrollPane, SWT.NONE);
scrollPane.setContent(composite);
scrollPane.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
// titles
new Composite(composite, SWT.NONE);
/* Placeholder */
Label wizardLabel = new Label(composite, SWT.CENTER);
FontData fontData = wizardLabel.getFont().getFontData()[0];
Font boldFont = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
wizardLabel.setText("WebPortal /\nWrapped Metanode View");
wizardLabel.setFont(boldFont);
Label dialogLabel = new Label(composite, SWT.CENTER);
dialogLabel.setText("\nWrapped Metanode Dialog");
dialogLabel.setFont(boldFont);
// select all checkboxes
Label selectAllLabel = new Label(composite, SWT.LEFT);
selectAllLabel.setText("Enable/Disable");
Button selectAllWizard = createCheckbox(composite);
Button selectAllDialog = createCheckbox(composite);
// individual nodes
for (@SuppressWarnings("rawtypes") Entry<NodeIDSuffix, WizardNode> entry : viewNodes.entrySet()) {
NodeIDSuffix suffix = entry.getKey();
NodeID id = suffix.prependParent(subNodeContainer.getWorkflowManager().getID());
NodeContainer nodeContainer = viewNodes.containsKey(suffix) ? subNodeContainer.getWorkflowManager().getNodeContainer(id) : null;
createNodeLabelComposite(composite, id, nodeContainer);
@SuppressWarnings("rawtypes") WizardNode model = entry.getValue();
Button wizardButton = createCheckbox(composite);
wizardButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
checkAllSelected(m_wizardUsageMap, selectAllWizard);
}
});
wizardButton.setToolTipText("Enable/disable for usage in WebPortal and wizard execution.");
wizardButton.setSelection(!((WizardNode<?, ?>) model).isHideInWizard());
m_wizardUsageMap.put(id, wizardButton);
if (model instanceof DialogNode) {
Button dialogButton = createCheckbox(composite);
dialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
checkAllSelected(m_dialogUsageMap, selectAllDialog);
}
});
dialogButton.setToolTipText("Enable/disable for usage in wrapped metanode configure dialog.");
dialogButton.setSelection(!((DialogNode<?, ?>) model).isHideInDialog());
m_dialogUsageMap.put(id, dialogButton);
} else {
new Composite(composite, SWT.NONE);
/* Placeholder */
}
}
checkAllSelected(m_wizardUsageMap, selectAllWizard);
checkAllSelected(m_dialogUsageMap, selectAllDialog);
selectAllWizard.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
selectAllWizard.setGrayed(false);
for (Button b : m_wizardUsageMap.values()) {
b.setSelection(selectAllWizard.getSelection());
}
}
});
if (m_wizardUsageMap.size() < 1) {
selectAllWizard.setEnabled(false);
}
selectAllDialog.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
selectAllDialog.setGrayed(false);
for (Button b : m_dialogUsageMap.values()) {
b.setSelection(selectAllDialog.getSelection());
}
}
});
if (m_dialogUsageMap.size() < 1) {
selectAllDialog.setEnabled(false);
}
}
use of org.eclipse.swt.graphics.Font in project knime-core by knime.
the class EditorUISettingsDialog method createHeader.
private void createHeader(final Composite parent) {
Composite header = new Composite(parent, SWT.FILL);
Color white = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
header.setBackground(white);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
header.setLayoutData(gridData);
header.setLayout(new GridLayout(2, false));
// 1st row
Label exec = new Label(header, SWT.NONE);
exec.setBackground(white);
exec.setText("Workflow Editor Settings");
FontData[] fd = parent.getFont().getFontData();
for (FontData f : fd) {
f.setStyle(SWT.BOLD);
f.setHeight(f.getHeight() + 2);
}
exec.setFont(new Font(parent.getDisplay(), fd));
exec.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Label execIcon = new Label(header, SWT.NONE);
execIcon.setBackground(white);
execIcon.setImage(IMG_PERMS.createImage());
execIcon.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, true, true));
// 2nd row
Label txt = new Label(header, SWT.NONE);
txt.setBackground(white);
txt.setText("Modify the settings for the active workflow editor. \n" + "All settings will be store with the workflow.\n" + "To change default settings for new workflow editors go to the preference page.\n" + "Snap to grid behavior can be toggled by pressing 'Ctrl-Shift-X'.");
txt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
new Label(header, SWT.NONE);
// 3rd row
m_error = new Label(header, SWT.NONE);
m_error.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false));
m_error.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
m_error.setBackground(white);
new Label(header, SWT.NONE);
}
use of org.eclipse.swt.graphics.Font in project knime-core by knime.
the class AnnotationEditPart method toSWTStyleRanges.
public static StyleRange[] toSWTStyleRanges(final AnnotationData t, final Font defaultFont) {
AnnotationData.StyleRange[] knimeStyleRanges = t.getStyleRanges();
ArrayList<StyleRange> swtStyleRange = new ArrayList<StyleRange>(knimeStyleRanges.length);
for (AnnotationData.StyleRange knimeSR : knimeStyleRanges) {
StyleRange swtStyle = new StyleRange();
Font f = FontStore.INSTANCE.getAnnotationFont(knimeSR, defaultFont);
swtStyle.font = f;
if (knimeSR.getFgColor() >= 0) {
int rgb = knimeSR.getFgColor();
RGB rgbObj = RGBintToRGBObj(rgb);
swtStyle.foreground = new Color(null, rgbObj);
}
swtStyle.start = knimeSR.getStart();
swtStyle.length = knimeSR.getLength();
swtStyleRange.add(swtStyle);
}
return swtStyleRange.toArray(new StyleRange[swtStyleRange.size()]);
}
Aggregations