本文整理汇总了Java中org.eclipse.swt.graphics.Font.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Font.dispose方法的具体用法?Java Font.dispose怎么用?Java Font.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.Font
的用法示例。
在下文中一共展示了Font.dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispose
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
@Override
public void dispose() {
super.dispose();
if (null != boldFontSupplier) {
final Font font = boldFontSupplier.get();
if (null != font && !font.isDisposed()) {
font.dispose();
}
}
}
示例2: dispose
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
@Override
public void dispose ()
{
for ( final Font font : this.fontCache.values () )
{
font.dispose ();
}
this.fontCache.clear ();
super.dispose ();
}
示例3: swapFont
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
private Font swapFont(Font old, Font newFont) {
if (old == newFont)
logger.error("font swap error.");
if (isset(old))
old.dispose();
return newFont;
}
示例4: toAwtFont
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
/**
* Create an awt font by converting as much information
* as possible from the provided swt <code>FontData</code>.
* <p>Generally speaking, given a font size, an swt font will
* display differently on the screen than the corresponding awt
* one. Because the SWT toolkit use native graphical ressources whenever
* it is possible, this fact is plateform dependent. To address
* this issue, it is possible to enforce the method to return
* an awt font with the same height as the swt one.
*
* @param device The swt device being drawn on (display or gc device).
* @param fontData The swt font to convert.
* @param ensureSameSize A boolean used to enforce the same size
* (in pixels) between the swt font and the newly created awt font.
* @return An awt font converted from the provided swt font.
*/
public static java.awt.Font toAwtFont(Device device, FontData fontData,
boolean ensureSameSize) {
int style;
switch (fontData.getStyle()) {
case SWT.NORMAL:
style = java.awt.Font.PLAIN;
break;
case SWT.ITALIC:
style = java.awt.Font.ITALIC;
break;
case SWT.BOLD:
style = java.awt.Font.BOLD;
break;
default:
style = java.awt.Font.PLAIN;
break;
}
int height = (int) Math.round(fontData.getHeight() * device.getDPI().y
/ 72.0);
// hack to ensure the newly created awt fonts will be rendered with the
// same height as the swt one
if (ensureSameSize) {
GC tmpGC = new GC(device);
Font tmpFont = new Font(device, fontData);
tmpGC.setFont(tmpFont);
JPanel DUMMY_PANEL = new JPanel();
java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
style, height);
if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
> tmpGC.textExtent(Az).x) {
while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
> tmpGC.textExtent(Az).x) {
height--;
tmpAwtFont = new java.awt.Font(fontData.getName(), style,
height);
}
}
else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
< tmpGC.textExtent(Az).x) {
while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
< tmpGC.textExtent(Az).x) {
height++;
tmpAwtFont = new java.awt.Font(fontData.getName(), style,
height);
}
}
tmpFont.dispose();
tmpGC.dispose();
}
return new java.awt.Font(fontData.getName(), style, height);
}
示例5: getFont
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
/**
*
*/
public static Font getFont(Class<?> clazz, String key, Supplier<Font> font) {
Font r = FONTS.get(clazz, key); if(r != null) return r;
Font existing = FONTS.putIfAbsent(clazz, key, r = font.get());
if (existing != null) { r.dispose(); r = existing; } return r; // Dispose
}
示例6: dispose
import org.eclipse.swt.graphics.Font; //导入方法依赖的package包/类
public static void dispose() {
for(Font f : instances.values())
f.dispose();
}