当前位置: 首页>>代码示例>>Java>>正文


Java CompositeFont类代码示例

本文整理汇总了Java中org.apache.harmony.awt.gl.font.CompositeFont的典型用法代码示例。如果您正苦于以下问题:Java CompositeFont类的具体用法?Java CompositeFont怎么用?Java CompositeFont使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompositeFont类属于org.apache.harmony.awt.gl.font包,在下文中一共展示了CompositeFont类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
@Override
public void run() {            
    try{
        /* Disposing native font peer's resources */
        Enumeration<String> kEnum = fontsTable.keys();

        while(kEnum.hasMoreElements()){
            Object key = kEnum.nextElement();
            HashMapReference hmr = fontsTable.get(key);
            FontPeerImpl delPeer = (FontPeerImpl)hmr.get();
            
            if ((delPeer != null) && (delPeer.getClass() != CompositeFont.class)){
                // there's nothing to dispose in CompositeFont objects
                
                delPeer.dispose();
            }
        }
        
        dispose();
        
    } catch (Throwable t){
        throw new RuntimeException(t);
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:FLFontManager.java

示例2: drawString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
public void drawString(Graphics2D ga, String str, float x, float y) {
    CommonGraphics2D g = (CommonGraphics2D)ga;
    AffineTransform trans = g.getTransform();
    double xOffset = x + trans.getTranslateX();
    double yOffset = y + trans.getTranslateY();

    FontPeerImpl fnt = (FontPeerImpl)g.getFont().getPeer();

    if (fnt.getClass() == CompositeFont.class){
        drawCompositeString(g, str, xOffset, yOffset);
    } else {
        drawNormalString(g, str, xOffset, yOffset);
    }

}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:DrawableTextRenderer.java

示例3: drawGlyphVector

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
public void drawGlyphVector(Graphics2D ga, GlyphVector gv, float x, 
        float y) {
    CommonGraphics2D g = (CommonGraphics2D)ga;
    AffineTransform trans = g.getTransform();
    float xOffset = x + (float)trans.getTranslateX();
    float yOffset = y + (float)trans.getTranslateY();

    FontPeerImpl fnt = (FontPeerImpl)gv.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        drawCompositeGlyphVector(g, gv, xOffset, yOffset);
    } else {
        drawNormalGlyphVector(g, gv, xOffset, yOffset);
    }

}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:DrawableTextRenderer.java

示例4: drawGlyphVector

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void drawGlyphVector(Graphics2D g, GlyphVector gv, float x, 
        float y) {
    FontPeerImpl fnt = (FontPeerImpl)gv.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        gdipDrawCompositeGlyphVector(g, gv, x, y);
    } else {
        gdipDrawNormalGlyphVector(g, gv, x, y);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:GDIPTextRenderer.java

示例5: drawString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void drawString(Graphics2D g, String str, float x, float y) {
    int len = str.length();
    if (len == 0){
        return;
    }

    FontPeerImpl fnt = (FontPeerImpl)g.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        gdipDrawCompositeString(g, str, x, y);
    } else {
        gdipDrawNormalChars(g, g.getFont(), str.toCharArray(), len, x, y);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:GDIPTextRenderer.java

示例6: drawGlyphVector

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void drawGlyphVector(Graphics2D g, GlyphVector gv, float x, 
        float y) {
    FontPeerImpl fnt = (FontPeerImpl)gv.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        drawCompositeGlyphVector(g, gv, x, y);
    } else {
        drawNormalGlyphVector(g, gv, x, y);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:GDITextRenderer.java

示例7: drawCompositeGlyphVector

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
/**
 * Method to draw GlyphVector created from composite font onto a 
 * specified graphics at desired coordinates.
 * 
 * @param g Graphics to draw onto
 * @param gv GlyphVector to draw
 * @param x starting X coordinate to draw at
 * @param y starting Y coordinate to draw at
 */
@SuppressWarnings("deprecation")
public void drawCompositeGlyphVector(Graphics2D g, GlyphVector gv, float x, 
        float y) {
    AffineTransform trans = ((WinGDIGraphics2D)g).getTransform();
    long hdc = ((WinGDIGraphics2D)g).getDC();

    x += (int)Math.round(trans.getTranslateX());
    y += (int)Math.round(trans.getTranslateY());

    win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
    win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);

    CompositeFont cf = (CompositeFont)gv.getFont().getPeer();

    int ascent = cf.getAscent();

    long font = 0;

    for (int i=0; i < gv.getNumGlyphs(); i++){
        Glyph gl = ((CommonGlyphVector)gv).vector[i];
        char chr = gl.getChar();

        if (gl.getPointWidth()==0) {
            continue;
        }

        String sChar = String.valueOf(chr);

        long glPFont = gl.getPFont();
        if (font != glPFont){
            font = glPFont;
            win32.SelectObject(hdc, font);
        }

        Point2D pos = gv.getGlyphPosition(i);
        win32.TextOutW(hdc, (int)Math.round(x+pos.getX()), 
                (int)Math.round(y + pos.getY() - ascent), sChar, 1);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:GDITextRenderer.java

示例8: drawString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void drawString(Graphics2D g, String str, float x, float y) {
    FontPeerImpl fnt = (FontPeerImpl)g.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        drawCompositeString(g, str, Math.round(x), Math.round(y));
    } else {
        drawNormalString(g, str, Math.round(x), Math.round(y));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:GDITextRenderer.java

示例9: drawString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
public void drawString(Graphics2D ga, String str, float x, float y) {
    CommonGraphics2D g = (CommonGraphics2D)ga;
    AffineTransform trans = g.getTransform();
    double xOffset = x + trans.getTranslateX();
    double yOffset = y + trans.getTranslateY();

    FontPeerImpl fnt = (FontPeerImpl)g.getFont().getPeer();
    if (fnt.getClass() == CompositeFont.class){
        drawCompositeString(g, str, xOffset, yOffset);
    } else {
        drawNormalString(g, str, xOffset, yOffset);
    }

}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:15,代码来源:DrawableTextRenderer.java

示例10: drawCompositeGlyphVector

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
/**
 * Method to draw GlyphVector created from composite font onto a 
 * specified graphics at desired coordinates.
 * 
 * @param g Graphics to draw onto
 * @param gv GlyphVector to draw
 * @param x starting X coordinate to draw at
 * @param y starting Y coordinate to draw at
 */
@SuppressWarnings("deprecation")
public void drawCompositeGlyphVector(Graphics2D g, GlyphVector gv, float x, 
        float y) {
    AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform();
    long hdc = ((WinGDIPGraphics2D)g).getDC();

    x += (int)Math.round(trans.getTranslateX());
    y += (int)Math.round(trans.getTranslateY());

    win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
    win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);

    CompositeFont cf = (CompositeFont)gv.getFont().getPeer();

    int ascent = cf.getAscent();

    long font = 0;

    for (int i=0; i < gv.getNumGlyphs(); i++){
        Glyph gl = ((CommonGlyphVector)gv).vector[i];
        char chr = gl.getChar();

        if (gl.getPointWidth()==0) {
            continue;
        }

        String sChar = String.valueOf(chr);

        long glPFont = gl.getPFont();
        if (font != glPFont){
            font = glPFont;
            win32.SelectObject(hdc, font);
        }

        Point2D pos = gv.getGlyphPosition(i);
        win32.TextOutW(hdc, (int)Math.round(x+pos.getX()), 
                (int)Math.round(y + pos.getY() - ascent), sChar, 1);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:49,代码来源:GDITextRenderer.java

示例11: drawCompositeString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
/**
 * Method to draw string with graphics that has composite font
 *  at desired coordinates.
 * 
 * @param g CommonGraphics2D to draw onto
 * @param str String to draw
 * @param x starting X coordinate to draw at
 * @param y starting Y coordinate to draw at
 */
public void drawCompositeString(CommonGraphics2D g, String str, double x, 
        double y) {
    XGraphics2D xg2d =  (XGraphics2D)g;

    long display = xg2d.display;
    int screen = xg2d.xConfig.dev.screen;
    long colormap = x11.XDefaultColormap(display, screen);

    X11.XColor xcolor = getXColor(g.getColor());
    long xcolorPtr = xcolor.lock();
    
    CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
    long font = 0;
    int xOffset = (int)Math.round(x);    // X offset to draw
    int yOffset = (int)Math.round(y);    // Y offset to draw
    int offs = 0;       // width of substring with the same font header
    String sChars = new String();
    char chars[];
    for (int i=0; i < str.length(); i++){
        char c = str.charAt(i);
        Glyph gl = wcf.getGlyph(c);
        if (font == 0){
            font = gl.getPFont();
        }
        int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
        if (glWidth ==0){
            continue;
        }
        long glPFont = gl.getPFont();
        if (font != glPFont){
            chars = sChars.toCharArray();
            LinuxNativeFont.drawStringNative(xg2d.xftDraw, display, 
                    colormap, font, xOffset, yOffset, chars, 
                    sChars.length(), xcolorPtr);

            xOffset += offs;
            offs = 0;
            sChars = String.valueOf(gl.getChar());
            font = glPFont;
        } else {
            sChars += String.valueOf(gl.getChar());
        }
        offs += glWidth;
    }
    chars = sChars.toCharArray();
    if (chars.length != 0){
        LinuxNativeFont.drawStringNative(xg2d.xftDraw, display, colormap, 
                font, xOffset, yOffset, chars, sChars.length(), 
                xcolorPtr);
    }
    xcolor.unlock();

}
 
开发者ID:shannah,项目名称:cn1,代码行数:63,代码来源:DrawableTextRenderer.java

示例12: drawCompositeString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
/**
 * Method to draw string with graphics that has composite font
 *  at desired coordinates.
 * 
 * @param g Graphics to draw onto
 * @param str String to draw
 * @param x starting X coordinate to draw at
 * @param y starting Y coordinate to draw at
 */
@SuppressWarnings("deprecation")
public void drawCompositeString(Graphics2D g, String str, int x, int y) {

    int len = str.length();

    if (len == 0){
        return;
    }

    AffineTransform trans = ((WinGDIGraphics2D)g).getTransform();

    long gi = ((WinGDIGraphics2D)g).getGraphicsInfo();
    long hdc = ((WinGDIGraphics2D)g).getDC();
    
    x += (int)Math.round(trans.getTranslateX());
    y += (int)Math.round(trans.getTranslateY());
    
    win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
    win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);

    CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
    int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
    int fontIndex = charFontIndex;

    WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
    long font = physFont.getFontHandle();

    win32.SelectObject(hdc, font);

    int ascent = physFont.getAscent(); // Font ascent
    int offs = 0;       // width of substring with the same font header
    int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
    int xOffset = x;    // X offset to draw
    int start = 0;
    int count = 0;
    
    for (int i=0; i < len; i++){
        char c = str.charAt(i);
        Glyph gl = wcf.getGlyph(c);

        int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
        if (glWidth ==0){
            continue;
        }

        fontIndex = wcf.getCharFontIndex(c, 0);
        
        if (fontIndex != charFontIndex){
            charFontIndex = fontIndex;
            win32.TextOutW(hdc, xOffset, yOffset, 
                    str.substring(start, start + count), count);

            xOffset += offs;
            offs = 0;
            count = 1;
            start = i;

            physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
            font = physFont.getFontHandle();
            win32.SelectObject(hdc, font);
            yOffset = y - physFont.getAscent();
        } else {
            count++;
        }

        offs += glWidth;
    }

    win32.TextOutW(hdc, xOffset, yOffset, 
            str.substring(start, start + count), count);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:81,代码来源:GDITextRenderer.java

示例13: drawCompositeString

import org.apache.harmony.awt.gl.font.CompositeFont; //导入依赖的package包/类
/**
 * Method to draw string with graphics that has composite font
 *  at desired coordinates.
 * 
 * @param g Graphics to draw onto
 * @param str String to draw
 * @param x starting X coordinate to draw at
 * @param y starting Y coordinate to draw at
 */
@SuppressWarnings("deprecation")
public void drawCompositeString(Graphics2D g, String str, int x, int y) {

    int len = str.length();

    if (len == 0){
        return;
    }

    AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform();

    long gi = ((WinGDIPGraphics2D)g).getGraphicsInfo();
    long hdc = NativeFont.gdiPlusGetHDC(gi);
    
    x += (int)Math.round(trans.getTranslateX());
    y += (int)Math.round(trans.getTranslateY());
    
    win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
    win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);

    CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
    int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
    int fontIndex = charFontIndex;

    WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
    long font = physFont.getFontHandle();

    win32.SelectObject(hdc, font);

    int ascent = physFont.getAscent(); // Font ascent
    int offs = 0;       // width of substring with the same font header
    int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
    int xOffset = x;    // X offset to draw
    int start = 0;
    int count = 0;
    
    for (int i=0; i < len; i++){
        char c = str.charAt(i);
        Glyph gl = wcf.getGlyph(c);

        int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
        if (glWidth ==0){
            continue;
        }

        fontIndex = wcf.getCharFontIndex(c, 0);
        
        if (fontIndex != charFontIndex){
            charFontIndex = fontIndex;
            win32.TextOutW(hdc, xOffset, yOffset, 
                    str.substring(start, start + count), count);

            xOffset += offs;
            offs = 0;
            count = 1;
            start = i;

            physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
            font = physFont.getFontHandle();
            win32.SelectObject(hdc, font);
            yOffset = y - physFont.getAscent();
        } else {
            count++;
        }

        offs += glWidth;
    }

    win32.TextOutW(hdc, xOffset, yOffset, 
            str.substring(start, start + count), count);
    NativeFont.gdiPlusReleaseHDC(gi, hdc);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:82,代码来源:GDITextRenderer.java


注:本文中的org.apache.harmony.awt.gl.font.CompositeFont类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。