private Font createFont ( final ResourceManager resourceManager )
{
final Font defaultFont = resourceManager.getDevice ().getSystemFont ();
if ( defaultFont == null )
{
return null;
}
final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
if ( fd == null )
{
return null;
}
for ( final FontData f : fd )
{
if ( this.fontSize > 0 )
{
f.setHeight ( this.fontSize );
}
}
return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
java类org.eclipse.swt.graphics.FontData的实例源码
TitleRenderer.java 文件源码
项目:neoscada
阅读 27
收藏 0
点赞 0
评论 0
ViewLabelProvider.java 文件源码
项目:convertigo-eclipse
阅读 25
收藏 0
点赞 0
评论 0
public ViewLabelProvider() {
Device device = Display.getCurrent();
fontSystem = device.getSystemFont();
FontData fontData = fontSystem.getFontData()[0];
fontDetectedDatabaseObject = new Font(device, fontData);
FontData fontDataModified = fontSystem.getFontData()[0];
fontDataModified.setStyle(SWT.BOLD);
fontModifiedDatabaseObject = new Font(device, fontDataModified);
colorUnloadedProject = new Color(device, 12, 116, 176);
colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
StatisticsDialog.java 文件源码
项目:convertigo-eclipse
阅读 36
收藏 0
点赞 0
评论 0
private void addStats() {
for (String key : statsProject.keySet()) {
if (key != project.getName()) {
CLabel title = new CLabel(descriptifRight, SWT.BOLD);
title.setText(key);
title.setImage(new Image(display, getClass()
.getResourceAsStream(
"images/stats_"
+ key.replaceAll(" ", "_")
.toLowerCase() + "_16x16.png")));
title.setBackground(new Color(display, 255, 255, 255));
title.setMargins(10, 10, 0, 0);
FontData[] fd = title.getFont().getFontData();
fd[0].setStyle(SWT.BOLD);
title.setFont(new Font(title.getFont().getDevice(), fd));
CLabel subText = new CLabel(descriptifRight, SWT.NONE);
subText.setText(statsProject.get(key)
.replaceAll("<br/>", "\r\n").replaceAll(" ", " "));
subText.setBackground(new Color(display, 255, 255, 255));
subText.setMargins(30, 0, 0, 0);
}
}
}
MELabel.java 文件源码
项目:avoCADo
阅读 30
收藏 0
点赞 0
评论 0
@Override
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
// draw text
g.setForeground(this.meColorForeground);
FontData fd = new FontData();
fd.setHeight(8);
if(textIsBold){
fd.setStyle(SWT.BOLD);
}else{
fd.setStyle(SWT.NORMAL);
}
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
TipDayEx.java 文件源码
项目:SWET
阅读 26
收藏 0
点赞 0
评论 0
private void fillTipArea() {
if (TipDayEx.fontName == null) {
final FontData[] fontData = Display.getDefault().getSystemFont()
.getFontData();
if (fontData != null && fontData.length > 0) {
TipDayEx.fontName = String.format("\"%s\"", fontData[0].getName());
} else {
TipDayEx.fontName = "Arial,​\"Helvetica Neue\",​Helvetica,​sans-serif";
}
}
String text = String.format(
"<html><body bgcolor=\"#EFEFEF\" text=\"#000000\" style='font-family:%s;font-size=14px\'>%s</body></html>",
TipDayEx.fontName, this.tips.get(TipDayEx.index));
// System.err.println(text);
this.tipArea.setText(text);
}
TipDayEx.java 文件源码
项目:SWET
阅读 29
收藏 0
点赞 0
评论 0
private void fillTipArea() {
if (TipDayEx.fontName == null) {
final FontData[] fontData = Display.getDefault().getSystemFont()
.getFontData();
if (fontData != null && fontData.length > 0) {
TipDayEx.fontName = String.format("\"%s\"", fontData[0].getName());
} else {
TipDayEx.fontName = "Arial,​\"Helvetica Neue\",​Helvetica,​sans-serif";
}
}
String text = String.format(
"<html><body bgcolor=\"#EFEFEF\" text=\"#000000\" style='font-family:%s;font-size=14px\'>%s</body></html>",
TipDayEx.fontName, this.tips.get(TipDayEx.index));
System.err.println(text);
this.tipArea.setText(text);
}
HeaderAndDataFormattingDialog.java 文件源码
项目:Hydrograph
阅读 30
收藏 0
点赞 0
评论 0
private void addSelectionListeneronToFontButton(Button fontButton, TableEditor fontEditor) {
fontButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String fontdata = "";
dialog = new FontDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
dialog.setText("Select Font");
String string = formatMap.get(excelFormats[4]);
fontdata = checkDefaultValue(fontEditor, fontdata, string);
RGB checkDefaultColor = checkDefaultColor(fontdata, string);
dialog.setRGB(checkDefaultColor);
FontData defaultFont = new FontData(fontdata);
dialog.setFontData(defaultFont);
FontData newFont = dialog.open();
RGB rgb = dialog.getRGB();
String convertRGBToHEX = convertRGBToHEX(rgb);
if (newFont != null) {
fontEditor.getItem().setText(1, newFont.toString() + "|" + convertRGBToHEX);
}
}
});
}
CommentBoxLabelEditManager.java 文件源码
项目:Hydrograph
阅读 31
收藏 0
点赞 0
评论 0
/**
* update scaledFonts
* @param zoom
* at zoom
*/
private void updateScaledFont(double zoom) {
if (cachedZoom == zoom)
return;
Text text = (Text)getCellEditor().getControl();
Font font = getEditPart().getFigure().getFont();
disposeScaledFont();
cachedZoom = zoom;
if (zoom == 1.0)
text.setFont(font);
else {
FontData fd = font.getFontData()[0];
fd.setHeight((int)(fd.getHeight() * zoom));
text.setFont(scaledFont = new Font(null, fd));
}
}
CustomCSSHelpHoverProvider.java 文件源码
项目:solidity-ide
阅读 26
收藏 0
点赞 0
评论 0
protected String getStyleSheet() {
if (fgStyleSheet == null)
fgStyleSheet = loadStyleSheet();
String css = fgStyleSheet;
if (css != null) {
FontData fontData = JFaceResources.getFontRegistry().getFontData(
fontSymbolicName)[0];
css = HTMLPrinter.convertTopLevelFont(css, fontData);
}
return css;
}
SWTGraphics2D.java 文件源码
项目:PhET
阅读 30
收藏 0
点赞 0
评论 0
/** {@inheritDoc} */
public Font getFont() {
if (curFont != null) {
int style = Font.PLAIN;
final FontData[] fd = curFont.getFontData();
if (fd.length > 0) {
if ((fd[0].getStyle() & SWT.BOLD) != 0) {
style = style | Font.BOLD;
}
if ((fd[0].getStyle() & SWT.ITALIC) != 0) {
style = style | SWT.ITALIC;
}
return new Font(fd[0].getName(), style, fd[0].getHeight());
}
return null;
}
else {
return null;
}
}
VirtualKeyboard.java 文件源码
项目:TranskribusSwtGui
阅读 23
收藏 0
点赞 0
评论 0
private Button initButton(Pair<Integer, String> c) {
Button b = new Button(this, SWT.PUSH);
FontData[] fD = b.getFont().getFontData();
fD[0].setHeight(16);
// b.setFont( new Font(getDisplay(), fD[0]));
b.setFont(Fonts.createFont(fD[0]));
String text = c.getRight();
Integer code = c.getLeft();
// b.setText(Character.toString(c));
// b.setToolTipText(Character.getName(c));
//Character tmp = c.toCharArray()[0];
b.setText(text);
b.setToolTipText(Character.getName(code));
b.addSelectionListener(btnSelectionListener);
return b;
}
CompositeFactory.java 文件源码
项目:ermaster-k
阅读 34
收藏 0
点赞 0
评论 0
public static Label createExampleLabel(Composite composite, String title,
int span) {
Label label = new Label(composite, SWT.NONE);
label.setText(ResourceString.getResourceString(title));
if (span > 0) {
GridData gridData = new GridData();
gridData.horizontalSpan = span;
label.setLayoutData(gridData);
}
FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
Font font = Resources.getFont(fontData.getName(), 8);
label.setFont(font);
return label;
}
WorkItemHistoryControl.java 文件源码
项目:team-explorer-everywhere
阅读 29
收藏 0
点赞 0
评论 0
private void setTextControlFont(final Text text) {
final FontData[] tahomaFontData = getShell().getDisplay().getFontList("Tahoma", true); //$NON-NLS-1$
if (tahomaFontData != null && tahomaFontData.length > 0) {
historyFont = new Font(getShell().getDisplay(), "Tahoma", 10, SWT.NORMAL); //$NON-NLS-1$
}
if (historyFont != null) {
text.setFont(historyFont);
}
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(final DisposeEvent e) {
if (historyFont != null) {
historyFont.dispose();
}
}
});
}
Datepicker.java 文件源码
项目:team-explorer-everywhere
阅读 36
收藏 0
点赞 0
评论 0
private void configureMacOSX() {
final FontData fontData = font.getFontData()[0];
fontData.setHeight(11);
font.dispose();
font = new Font(getDisplay(), fontData);
final FontData fontBoldData = fontBold.getFontData()[0];
fontBoldData.setHeight(11);
fontBold.dispose();
fontBold = new Font(getDisplay(), fontBoldData);
setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
spacing = new Point(0, 2);
weekdayStringLength = 1;
dayAlignment = SWT.RIGHT;
drawOtherDays = false;
}
FontUtil.java 文件源码
项目:google-cloud-eclipse
阅读 27
收藏 0
点赞 0
评论 0
/**
* Converts the font of the control by adding a single style bit, unless the font already have
* that style.
* <p>
* If the font is converted, it will attach a {@link DisposeListener}
* to the <code>control</code> to dispose the font when it's not needed anymore.
* <p>
* <em>If converting fonts is a frequent operation, this method will create
* several {@link DisposeListener}s that can lead to high resource allocation</em>
*
* @param control whose font will be changed
* @param style e.g. SWT.BOLD or SWT.ITALIC
*/
public static void convertFont(Control control, int style) {
for (FontData fontData : control.getFont().getFontData()) {
if (hasStyle(fontData, style)) {
return;
}
}
FontDescriptor fontDescriptor = FontDescriptor.createFrom(control.getFont()).setStyle(style);
final Font newFont = fontDescriptor.createFont(control.getDisplay());
control.setFont(newFont);
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
newFont.dispose();
}
});
}
NodeElementEditPart.java 文件源码
项目:ermasterr
阅读 35
收藏 0
点赞 0
评论 0
protected Font changeFont(final IFigure figure) {
final NodeElement nodeElement = (NodeElement) getModel();
String fontName = nodeElement.getFontName();
int fontSize = nodeElement.getFontSize();
if (Check.isEmpty(fontName)) {
final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
fontName = fontData.getName();
nodeElement.setFontName(fontName);
}
if (fontSize <= 0) {
fontSize = ViewableModel.DEFAULT_FONT_SIZE;
nodeElement.setFontSize(fontSize);
}
font = Resources.getFont(fontName, fontSize);
figure.setFont(font);
return font;
}
TGMatrixConfig.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 31
收藏 0
点赞 0
评论 0
public void save(FontData fontData,
RGB rgbForeground,
RGB rgbBorder,
RGB rgbPosition,
RGB rgbNote,
RGB rgbPlay,
RGB rgbLines[]){
TGConfigManager config = TuxGuitar.getInstance().getConfig();
config.setValue(TGConfigKeys.MATRIX_FONT,fontData);
config.setValue(TGConfigKeys.MATRIX_COLOR_FOREGROUND,rgbForeground);
config.setValue(TGConfigKeys.MATRIX_COLOR_BORDER,rgbBorder);
config.setValue(TGConfigKeys.MATRIX_COLOR_POSITION,rgbPosition);
config.setValue(TGConfigKeys.MATRIX_COLOR_NOTE,rgbNote);
config.setValue(TGConfigKeys.MATRIX_COLOR_PLAY_NOTE,rgbPlay);
config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_1,rgbLines[0]);
config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_2,rgbLines[1]);
config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_3,rgbLines[2]);
}
Option.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 28
收藏 0
点赞 0
评论 0
protected Label showLabel(Composite parent,int hAlign,int vAlign,boolean grabExcessHSpace,boolean grabExcessVSpace,int labelStyle,int fontStyle,int fontScale,String text){
Label label = new Label(parent,labelStyle);
label.setText(text);
label.setLayoutData(new GridData(hAlign,vAlign,grabExcessHSpace,grabExcessVSpace));
FontData[] fontDatas = label.getFont().getFontData();
if(fontDatas.length > 0){
final Font font = new Font(label.getDisplay(),fontDatas[0].getName(),(fontDatas[0].getHeight() + fontScale),fontStyle);
label.setFont(font);
label.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
font.dispose();
}
});
}
return label;
}
StylesOption.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 33
收藏 0
点赞 0
评论 0
private void addFontButtonListeners(final Button button, final FontData fontData){
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if(StylesOption.this.initialized){
Font font = new Font(getDisplay(),fontData);
FontData[] fontDataList = font.getFontData();
font.dispose();
FontDialog fontDialog = new FontDialog(getShell());
fontDialog.setFontList(fontDataList);
FontData result = fontDialog.open();
if(result != null){
loadFontData(result, fontData,button);
}
}
}
});
}
TGFretBoardConfig.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 28
收藏 0
点赞 0
评论 0
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());
Label label = new Label(parent, SWT.NULL);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
label.setText(title);
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
button.setText(TuxGuitar.getProperty("choose"));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
Font font = new Font(parent.getDisplay(),selection);
FontDialog fontDialog = new FontDialog(parent.getShell());
fontDialog.setFontList(font.getFontData());
FontData fd = fontDialog.open();
if(fd != null){
selection.setName( fd.getName() );
selection.setHeight( fd.getHeight() );
selection.setStyle( fd.getStyle() );
}
font.dispose();
}
});
return selection;
}
TGConfigManager.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 30
收藏 0
点赞 0
评论 0
public FontData getFontDataConfigValue(String key){
try{
String value = getProperties().getValue(key);
if(value != null){
String[] values = value.trim().split(",");
if(values != null && values.length == 3){
try{
String name = values[0].trim();
int size = Integer.parseInt(values[1].trim());
int style = Integer.parseInt(values[2].trim());
return new FontData( (name == null ? "" : name),size,style);
}catch(NumberFormatException e){
e.printStackTrace();
}
}
}
}catch(Throwable throwable){
throwable.printStackTrace();
}
return new FontData();
}
TGCommunityStartupScreen.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 25
收藏 0
点赞 0
评论 0
private void addTitle( Composite parent , String text ){
Label label = new Label( parent , SWT.LEFT );
label.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,true,2,1));
label.setText(text);
FontData[] fontDatas = label.getFont().getFontData();
if(fontDatas.length > 0){
int fHeight = (fontDatas[0].getHeight() + 2);
int fStyle = (fontDatas[0].getStyle() | SWT.BOLD);
final Font font = new Font(label.getDisplay(),fontDatas[0].getName(),fHeight, fStyle);
label.setFont(font);
label.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
font.dispose();
}
});
}
}
CompositeFactory.java 文件源码
项目:ermasterr
阅读 32
收藏 0
点赞 0
评论 0
public static Label createExampleLabel(final Composite composite, final String title, final int span) {
final Label label = new Label(composite, SWT.NONE);
label.setText(ResourceString.getResourceString(title));
if (span > 0) {
final GridData gridData = new GridData();
gridData.horizontalSpan = span;
label.setLayoutData(gridData);
}
final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
final Font font = Resources.getFont(fontData.getName(), 8);
label.setFont(font);
return label;
}
OpenTypeSelectionDialog.java 文件源码
项目:n4js
阅读 32
收藏 0
点赞 0
评论 0
@Override
public Font get() {
final Font font = getDialogArea().getFont();
final FontData[] data = font.getFontData();
for (int i = 0; i < data.length; i++) {
data[i].setStyle(BOLD);
}
return new Font(font.getDevice(), data);
}
JmxDocFormText.java 文件源码
项目:eZooKeeper
阅读 26
收藏 0
点赞 0
评论 0
public static void initFormText(FormText formText) {
formText.setWhitespaceNormalized(false);
Font formTextFont = formText.getFont();
FontData formTextFontData = formTextFont.getFontData()[0];
FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD);
final Font h1Font = new Font(formTextFont.getDevice(), h1FontData);
formText.setFont(FONT_H1_KEY, h1Font);
FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD);
final Font h3Font = new Font(formTextFont.getDevice(), h3FontData);
formText.setFont(FONT_H3_KEY, h3Font);
Font codeFont = JFaceResources.getTextFont();
formText.setFont(FONT_CODE_KEY, codeFont);
formText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
h1Font.dispose();
h3Font.dispose();
}
});
// Set fontKeySet = JFaceResources.getFontRegistry().getKeySet();
// if (fontKeySet != null) {
// for (Object fontKey : fontKeySet) {
// System.out.println(fontKey);
// }
// }
}
TreeNodeLabelProvider.java 文件源码
项目:neoscada
阅读 28
收藏 0
点赞 0
评论 0
public TreeNodeLabelProvider ( final TreeViewer viewer, final IObservableMap... attributeMaps )
{
super ( attributeMaps );
this.viewer = viewer;
this.defaultFont = viewer.getControl ().getFont ();
final FontData[] fds = this.viewer.getControl ().getFont ().getFontData ();
for ( final FontData fd : fds )
{
fd.setStyle ( SWT.ITALIC );
}
this.font = new Font ( this.viewer.getControl ().getDisplay (), fds );
}
GeneratorSelectionComposite.java 文件源码
项目:tap17-muggl-javaee
阅读 21
收藏 0
点赞 0
评论 0
/**
* Set the supplied text for the provider description text widget and make its font style
* bold.
* @param text The text for the provider description text widget.
*/
private void setProviderLoadingFailureText(String text) {
this.providerDescriptionText.setText(text);
Font font = this.providerDescriptionText.getFont();
FontData[] fontData = font.getFontData();
fontData[0].setStyle(SWT.BOLD);
this.providerDescriptionText.setFont(new Font(this.display, fontData));
}
GeneratorSelectionComposite.java 文件源码
项目:tap17-muggl-javaee
阅读 24
收藏 0
点赞 0
评论 0
/**
* Set the supplied text for the generator description text widget and make its font style
* bold.
* @param text The text for the generator description text widget.
*/
private void setGeneratorLoadingFailureText(String text) {
this.generatorDescriptionText.setText(text);
Font font = this.generatorDescriptionText.getFont();
FontData[] fontData = font.getFontData();
fontData[0].setStyle(SWT.BOLD);
this.generatorDescriptionText.setFont(new Font(this.display, fontData));
}
ParameterGridDialog.java 文件源码
项目:Hydrograph
阅读 26
收藏 0
点赞 0
评论 0
private void attachNote(final Composite container) {
Label lblParameterGridNote=new Label(container, SWT.NONE);
FontData fontData = lblParameterGridNote.getFont().getFontData()[0];
Font font = new Font(lblParameterGridNote.getDisplay(), new FontData(fontData.getName(), fontData
.getHeight(), SWT.ITALIC));
lblParameterGridNote.setText("Note - New parameters will be visible only after you save the job.");
lblParameterGridNote.setFont(font);
if(!visibleParameterGirdNote)
lblParameterGridNote.setVisible(false);
}
JobRunPreferenceComposite.java 文件源码
项目:Hydrograph
阅读 26
收藏 0
点赞 0
评论 0
/**
* Create console buffer widget
* @param bufferSize
*/
private void createConsoleBufferWidget(String bufferSize){
HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);
hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
hydroGroup.setLayout(new GridLayout(1, false));
hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));
Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);
textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
textWidget.setText(bufferSize);
textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
textWidget.setTextLimit(6);
attachConsoleBufferValidator();
Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
purgeComposite.setLayout(new GridLayout(2, false));
purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
FontData fontData = lblNote.getFont().getFontData()[0];
Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
lblNote.setFont(font);
Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);
}