本文整理匯總了Java中org.eclipse.swt.graphics.FontData.setHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java FontData.setHeight方法的具體用法?Java FontData.setHeight怎麽用?Java FontData.setHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.graphics.FontData
的用法示例。
在下文中一共展示了FontData.setHeight方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
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 ) );
}
示例2: paintElement
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
@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);
}
示例3: updateScaledFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* 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));
}
}
示例4: configureMacOSX
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
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;
}
示例5: setFontFromSettings
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private void setFontFromSettings() {
if (false)
return;
FontData fd = new FontData();
logger.debug("settings font name: '"+settings.getTranscriptionFontName()
+"', size: "+settings.getTranscriptionFontSize()+", style: "+settings.getTranscriptionFontStyle());
// fd.setName(Fonts.getSystemFontName(false, false, false));
// if (settings.getTranscriptionFontName()==null || settings.getTranscriptionFontName().isEmpty()) {
// fd.setName(Fonts.getSystemFontName(false, false, false));
// } else
// fd.setName(settings.getTranscriptionFontName());
fd.setName(settings.getTranscriptionFontName());
fd.setHeight(settings.getTranscriptionFontSize());
fd.setStyle(settings.getTranscriptionFontStyle());
logger.debug("font name = "+fd.getName());
Font globalTextFont = Fonts.createFont(fd);
text.setFont(globalTextFont);
}
示例6: createFontWithHeight
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public static Font createFontWithHeight(Font f, int height) {
if (f.getFontData().length > 0) {
FontData fd = f.getFontData()[0];
fd.setHeight(height);
return createFont(fd);
}
return null;
}
示例7: paintElement
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
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 button background
int selShift = 0;
if(mouseIsOver && !isSelected){
g.setBackground(this.meColorMouseOver);
}else{
g.setBackground(this.meColorUnselected);
}
if(isSelected){
selShift = MEB_SIDE_SPACE-1;
g.setBackground(this.meColorSelected);
}
g.fillRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
// draw button outline
g.setLineWidth(1);
if(mouseIsOver){ // || isFocused, but not currently used
g.setForeground(this.meColorFocused);
}else{
g.setForeground(this.meColorOutline2);
}
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1), height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-1, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-2, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.setForeground(this.meColorOutline);
g.setLineWidth(1);
g.drawRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
//
// handle position of Text/Icon within MEButton
//
int usableHeight = height-4;
// draw button text
g.setForeground(this.meColorForeground);
FontData fd = new FontData();
fd.setHeight(8);
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
switch(this.meDispOptions){
case(MenuetElement.ME_ICON_ONLY): {
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
break;
}
case(MenuetElement.ME_TEXT_ONLY): {
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
case(MenuetElement.ME_TRY_ICON): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
}
break;
}
case(MenuetElement.ME_TRY_TEXT): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
}
break;
}
default:{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
}
}
示例8: XYZDisplayComp
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public XYZDisplayComp(Composite parent, int style){
super(parent, style);
this.setLayout(new RowLayout(SWT.HORIZONTAL));
this.setBackground(AvoColors.COLOR_QSET_BG);
FontData fd = new FontData();
fd.setHeight(10);
fd.setStyle(SWT.BOLD);
fd.setName("Verdana");
Font f = new Font(this.getDisplay(), fd);
Label llx = new Label(this, SWT.NO_BACKGROUND);
llx.setFont(f);
llx.setText("X:");
llx.setBackground(AvoColors.COLOR_QSET_BG);
lX = new Label(this, SWT.NONE);
lX.setAlignment(SWT.RIGHT);
lX.setFont(f);
lX.setBackground(AvoColors.COLOR_QSET_BG);
Label lly = new Label(this, SWT.NONE);
lly.setFont(f);
lly.setText(" Y:");
lly.setBackground(AvoColors.COLOR_QSET_BG);
lY = new Label(this, SWT.NONE);
lY.setAlignment(SWT.RIGHT);
lY.setFont(f);
lY.setBackground(AvoColors.COLOR_QSET_BG);
Label llz = new Label(this, SWT.NONE);
llz.setFont(f);
llz.setText(" Z:");
llz.setBackground(AvoColors.COLOR_QSET_BG);
lZ = new Label(this, SWT.NONE);
lZ.setAlignment(SWT.RIGHT);
lZ.setFont(f);
lZ.setBackground(AvoColors.COLOR_QSET_BG);
updateXYZ();
AvoGlobal.glViewEventHandler.addGLViewListener(new GLViewListener(){
@Override
public void cursorMoved() {
updateXYZ();
}
});
}
示例9: toSwtFontData
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* Create a <code>FontData</code> object which encapsulate
* the essential data to create a swt font. The data is taken
* from the provided awt Font.
* <p>Generally speaking, given a font size, the returned swt font
* will display differently on the screen than the awt one.
* Because the SWT toolkit use native graphical resources whenever
* it is possible, this fact is platform dependent. To address
* this issue, it is possible to enforce the method to return
* a font with the same size (or at least as close as possible)
* as the awt one.
* <p>When the object is no more used, the user must explicitly
* call the dispose method on the returned font to free the
* operating system resources (the garbage collector won't do it).
*
* @param device The swt device to draw on (display or gc device).
* @param font The awt font from which to get the data.
* @param ensureSameSize A boolean used to enforce the same size
* (in pixels) between the awt font and the newly created swt font.
* @return a <code>FontData</code> object.
*/
public static FontData toSwtFontData(Device device, java.awt.Font font,
boolean ensureSameSize) {
FontData fontData = new FontData();
fontData.setName(font.getFamily());
// SWT and AWT share the same style constants.
fontData.setStyle(font.getStyle());
// convert the font size (in pt for awt) to height in pixels for swt
int height = (int) Math.round(font.getSize() * 72.0
/ device.getDPI().y);
fontData.setHeight(height);
// hack to ensure the newly created swt fonts will be rendered with the
// same height as the awt one
if (ensureSameSize) {
GC tmpGC = new GC(device);
Font tmpFont = new Font(device, fontData);
tmpGC.setFont(tmpFont);
if (tmpGC.textExtent(Az).x
> DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
while (tmpGC.textExtent(Az).x
> DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
tmpFont.dispose();
height--;
fontData.setHeight(height);
tmpFont = new Font(device, fontData);
tmpGC.setFont(tmpFont);
}
}
else if (tmpGC.textExtent(Az).x
< DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
while (tmpGC.textExtent(Az).x
< DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
tmpFont.dispose();
height++;
fontData.setHeight(height);
tmpFont = new Font(device, fontData);
tmpGC.setFont(tmpFont);
}
}
tmpFont.dispose();
tmpGC.dispose();
}
return fontData;
}
示例10: copyFontData
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected void copyFontData(FontData src, FontData dst){
dst.setName( src.getName() );
dst.setStyle( src.getStyle() );
dst.setHeight( src.getHeight() );
}