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


Java TextLayout.getOutline方法代码示例

本文整理汇总了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);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:17,代码来源:LayerViewer.java

示例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);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:19,代码来源:Custo.java

示例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());
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:21,代码来源:TextoComBorda.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:TextMeasureTests.java

示例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();
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:OutlineTextRenderer.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:PathGraphics.java

示例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);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:16,代码来源:JLabelAtributos.java

示例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);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:16,代码来源:JLabelAtributos.java


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