本文整理汇总了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;
}
示例2: getAnotherObject
import sun.swing.PrintColorUIResource; //导入依赖的package包/类
protected Color getAnotherObject() {
return new PrintColorUIResource(0, Color.WHITE);
}
示例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;
}
示例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;
}