本文整理汇总了Java中java.awt.font.TextLayout.getOutline方法的典型用法代码示例。如果您正苦于以下问题:Java TextLayout.getOutline方法的具体用法?Java TextLayout.getOutline怎么用?Java TextLayout.getOutline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.font.TextLayout
的用法示例。
在下文中一共展示了TextLayout.getOutline方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import java.awt.font.TextLayout; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
Dimension d = vv.getSize();
FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();
Font f = new Font("Times", Font.BOLD, 30);
TextLayout tl = new TextLayout(str, f, frc);
AffineTransform transform = new AffineTransform();
transform.setToTranslation(d.width / 2, d.height / 2);
transform.rotate(Math.toRadians(315));
Shape shape = tl.getOutline(transform);
g.translate(-shape.getBounds().width / 2,
shape.getBounds().height / 2);
g.setColor(Color.lightGray);
((Graphics2D) g).draw(shape);
}
示例2: paintComponent
import java.awt.font.TextLayout; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
atualizar();
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(FONT);
FontRenderContext frc = g2.getFontRenderContext();
TextLayout textLayout = new TextLayout(Integer.toString(value), FONT, frc);
g2.setPaint(textColor);
AffineTransform at = AffineTransform.getTranslateInstance(20, 30);
Shape outline = textLayout.getOutline(at);
g2.fill(outline);
g2.setPaint(BLACK);
g2.draw(outline);
}
示例3: paintComponent
import java.awt.font.TextLayout; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
//super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(font);
FontRenderContext frc = g2.getFontRenderContext();
TextLayout textLayout = new TextLayout(text, font, frc);
g2.setPaint(color);
g2.setStroke(new BasicStroke(((float) font.getSize()) * (font.getStyle() == Font.BOLD ? 0.05f : 0.025f), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
AffineTransform at = AffineTransform.getTranslateInstance(5, font.getSize());
Shape outline = textLayout.getOutline(at);
g2.fill(outline);
g2.setPaint(border);
g2.draw(outline);
g2.dispose();
setSize(getFontMetrics(font).stringWidth(text) + 10, font.getSize() + 5);
setPreferredSize(getSize());
}
示例4: runTest
import java.awt.font.TextLayout; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
TLContext tlctx = (TLContext)ctx;
TextLayout tl = tlctx.tl;
Shape s;
do {
s = tl.getOutline(null);
} while (--numReps >= 0);
}
示例5: drawString
import java.awt.font.TextLayout; //导入方法依赖的package包/类
public void drawString(SunGraphics2D g2d, String str, double x, double y) {
if ("".equals(str)) {
return; // TextLayout constructor throws IAE on "".
}
TextLayout tl = new TextLayout(str, g2d.getFont(),
g2d.getFontRenderContext());
Shape s = tl.getOutline(AffineTransform.getTranslateInstance(x, y));
int textAAHint = g2d.getFontInfo().aaHint;
int prevaaHint = - 1;
if (textAAHint != SunHints.INTVAL_TEXT_ANTIALIAS_OFF &&
g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
prevaaHint = g2d.antialiasHint;
g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_ON;
g2d.validatePipe();
} else if (textAAHint == SunHints.INTVAL_TEXT_ANTIALIAS_OFF
&& g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_OFF) {
prevaaHint = g2d.antialiasHint;
g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
g2d.validatePipe();
}
g2d.fill(s);
if (prevaaHint != -1) {
g2d.antialiasHint = prevaaHint;
g2d.validatePipe();
}
}
示例6: drawString
import java.awt.font.TextLayout; //导入方法依赖的package包/类
protected void drawString(String str, float x, float y,
Font font, FontRenderContext frc, float w) {
TextLayout layout =
new TextLayout(str, font, frc);
Shape textShape =
layout.getOutline(AffineTransform.getTranslateInstance(x, y));
fill(textShape);
}
示例7: paintComponent
import java.awt.font.TextLayout; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
atualizar();
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(FONT);
FontRenderContext frc = g2.getFontRenderContext();
TextLayout textLayout = new TextLayout(Integer.toString(value), FONT, frc);
g2.setPaint(textColor);
Shape outline = textLayout.getOutline(AffineTransform.getTranslateInstance(value < 10 ? 20 : 10, 30));
g2.fill(outline);
g2.setPaint(BLACK);
g2.draw(outline);
}
示例8: paintComponent
import java.awt.font.TextLayout; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
atualizar();
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(FONT);
FontRenderContext frc = g2.getFontRenderContext();
TextLayout textLayout = new TextLayout(Integer.toString(value), FONT, frc);
g2.setPaint(textColor);
Shape outline = textLayout.getOutline(AffineTransform.getTranslateInstance(value < 10 ? 20 : type == SHIELD ? 10 : 14, 30));
g2.fill(outline);
g2.setPaint(BLACK);
g2.draw(outline);
}