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


Java PrintColorUIResource类代码示例

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


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

示例1: drawString

import sun.swing.PrintColorUIResource; //导入依赖的package包/类
public static float drawString(JComponent c, Graphics g,
                               AttributedCharacterIterator iterator,
                               int x,
                               int y) {

    float retVal;
    boolean isPrinting = isPrinting(g);
    Color col = g.getColor();

    if (isPrinting) {
        /* Use alternate print color if specified */
        if (col instanceof PrintColorUIResource) {
            g.setColor(((PrintColorUIResource)col).getPrintColor());
        }
    }

    Graphics2D g2d = getGraphics2D(g);
    if (g2d == null) {
        g.drawString(iterator,x,y); //for the cases where advance
                                    //matters it should not happen
        retVal = x;

    } else {
        FontRenderContext frc;
        if (isPrinting) {
            frc = getFontRenderContext(c);
            if (frc.isAntiAliased() || frc.usesFractionalMetrics()) {
                frc = new FontRenderContext(frc.getTransform(), false, false);
            }
        } else if ((frc = getFRCProperty(c)) != null) {
            /* frc = frc; ! */
        } else {
            frc = g2d.getFontRenderContext();
        }
        TextLayout layout;
        if (isPrinting) {
            FontRenderContext deviceFRC = g2d.getFontRenderContext();
            if (!isFontRenderContextPrintCompatible(frc, deviceFRC)) {
                layout = new TextLayout(iterator, deviceFRC);
                AttributedCharacterIterator trimmedIt =
                        getTrimmedTrailingSpacesIterator(iterator);
                if (trimmedIt != null) {
                    float screenWidth = new TextLayout(trimmedIt, frc).
                            getAdvance();
                    layout = layout.getJustifiedLayout(screenWidth);
                }
            } else {
                layout = new TextLayout(iterator, frc);
            }
        } else {
            layout = new TextLayout(iterator, frc);
        }
        layout.draw(g2d, x, y);
        retVal = layout.getAdvance();
    }

    if (isPrinting) {
        g.setColor(col);
    }

    return retVal;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:SwingUtilities2.java

示例2: getAnotherObject

import sun.swing.PrintColorUIResource; //导入依赖的package包/类
protected Color getAnotherObject() {
    return new PrintColorUIResource(0, Color.WHITE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:sun_swing_PrintColorUIResource.java

示例3: drawStringImpl

import sun.swing.PrintColorUIResource; //导入依赖的package包/类
private static float drawStringImpl(JComponent c, Graphics g,
                               AttributedCharacterIterator iterator,
                               float x, float y)
{

    float retVal;
    boolean isPrinting = isPrinting(g);
    Color col = g.getColor();

    if (isPrinting) {
        /* Use alternate print color if specified */
        if (col instanceof PrintColorUIResource) {
            g.setColor(((PrintColorUIResource)col).getPrintColor());
        }
    }

    Graphics2D g2d = getGraphics2D(g);
    if (g2d == null) {
        g.drawString(iterator, (int)x, (int)y); //for the cases where advance
                                                //matters it should not happen
        retVal = x;

    } else {
        FontRenderContext frc;
        if (isPrinting) {
            frc = getFontRenderContext(c);
            if (frc.isAntiAliased() || frc.usesFractionalMetrics()) {
                frc = new FontRenderContext(frc.getTransform(), false, false);
            }
        } else if ((frc = getFRCProperty(c)) != null) {
            /* frc = frc; ! */
        } else {
            frc = g2d.getFontRenderContext();
        }
        TextLayout layout;
        if (isPrinting) {
            FontRenderContext deviceFRC = g2d.getFontRenderContext();
            if (!isFontRenderContextPrintCompatible(frc, deviceFRC)) {
                layout = new TextLayout(iterator, deviceFRC);
                AttributedCharacterIterator trimmedIt =
                        getTrimmedTrailingSpacesIterator(iterator);
                if (trimmedIt != null) {
                    float screenWidth = new TextLayout(trimmedIt, frc).
                            getAdvance();
                    layout = layout.getJustifiedLayout(screenWidth);
                }
            } else {
                layout = new TextLayout(iterator, frc);
            }
        } else {
            layout = new TextLayout(iterator, frc);
        }
        layout.draw(g2d, x, y);
        retVal = layout.getAdvance();
    }

    if (isPrinting) {
        g.setColor(col);
    }

    return retVal;
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:63,代码来源:SwingUtilities2.java

示例4: drawString

import sun.swing.PrintColorUIResource; //导入依赖的package包/类
public static float drawString(JComponent c, Graphics g,
                               AttributedCharacterIterator iterator,
                               int x,
                               int y) {

    float retVal;
    boolean isPrinting = isPrinting(g);
    Color col = g.getColor();

    if (isPrinting) {
        /* Use alternate print color if specified */
        if (col instanceof PrintColorUIResource) {
            g.setColor(((PrintColorUIResource)col).getPrintColor());
        }
    }

    Graphics2D g2d = getGraphics2D(g);
    if (g2d == null) {
        g.drawString(iterator,x,y); //for the cases where advance
                                    //matters it should not happen
        retVal = x;

    } else {
        FontRenderContext frc;
        if (isPrinting) {
            frc = getFontRenderContext(c);
            if (frc.isAntiAliased() || frc.usesFractionalMetrics()) {
                frc = new FontRenderContext(frc.getTransform(), false, false);
            }
        } else if ((frc = getFRCProperty(c)) != null) {
            /* frc = frc; ! */
        } else {
            frc = g2d.getFontRenderContext();
        }
        TextLayout layout = new TextLayout(iterator, frc);
        if (isPrinting) {
            FontRenderContext deviceFRC = g2d.getFontRenderContext();
            if (!isFontRenderContextPrintCompatible(frc, deviceFRC)) {
                float screenWidth = layout.getAdvance();
                layout = new TextLayout(iterator, deviceFRC);
                layout = layout.getJustifiedLayout(screenWidth);
            }
        }
        layout.draw(g2d, x, y);
        retVal = layout.getAdvance();
    }

    if (isPrinting) {
        g.setColor(col);
    }

    return retVal;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:54,代码来源:SwingUtilities2.java


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