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


Java GlyphVector.getOutline方法代码示例

本文整理汇总了Java中java.awt.font.GlyphVector.getOutline方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphVector.getOutline方法的具体用法?Java GlyphVector.getOutline怎么用?Java GlyphVector.getOutline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.font.GlyphVector的用法示例。


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

示例1: renderChar

import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public void renderChar(FontMetrics fontMetrics, BufferedImage image, char c, int safetyMargin) {
	Graphics2D g = (Graphics2D) image.getGraphics();
	GlyphVector v = fontMetrics.getFont().createGlyphVector(g.getFontRenderContext(), new char[] {c});
	Shape shape = v.getOutline(safetyMargin/2, fontMetrics.getHeight()-safetyMargin/2);
	g.setColor(color);
	g.draw(shape);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:8,代码来源:DrawCharacterOutline.java

示例2: runTest

import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        s = gv.getOutline();
    } while (--numReps >= 0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:TextMeasureTests.java

示例3: drawGlyphVector

import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public void drawGlyphVector(SunGraphics2D g2d, GlyphVector gv,
                            float x, float y) {


    Shape s = gv.getOutline(x, y);
    int prevaaHint = - 1;
    FontRenderContext frc = gv.getFontRenderContext();
    boolean aa = frc.isAntiAliased();

    /* aa will be true if any AA mode has been specified.
     * ie for LCD and 'gasp' modes too.
     * We will check if 'gasp' has resolved AA to be "OFF", and
     * in all other cases (ie AA ON and all LCD modes) use AA outlines.
     */
    if (aa) {
        if (g2d.getGVFontInfo(gv.getFont(), frc).aaHint ==
            SunHints.INTVAL_TEXT_ANTIALIAS_OFF) {
            aa = false;
        }
    }

    if (aa && g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
        prevaaHint = g2d.antialiasHint;
        g2d.antialiasHint =  SunHints.INTVAL_ANTIALIAS_ON;
        g2d.validatePipe();
    } else if (!aa && 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,代码行数:39,代码来源:OutlineTextRenderer.java

示例4: main

import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public static void main(String[] args) {
    Locale.setDefault(Locale.US);

    // initialize j.u.l Looger:
    final Logger log = Logger.getLogger("sun.java2d.marlin");
    log.addHandler(new Handler() {
        @Override
        public void publish(LogRecord record) {
            Throwable th = record.getThrown();
            // detect any Throwable:
            if (th != null) {
                System.out.println("Test failed:\n" + record.getMessage());
                th.printStackTrace(System.out);

                throw new RuntimeException("Test failed: ", th);
            }
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
        }
    });

    log.info("TextClipErrorTest: start");

    // enable Marlin logging & internal checks:
    System.setProperty("sun.java2d.renderer.log", "true");
    System.setProperty("sun.java2d.renderer.useLogger", "true");
    System.setProperty("sun.java2d.renderer.doChecks", "true");

    BufferedImage image = new BufferedImage(256, 256,
                                            BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2d = image.createGraphics();
    g2d.setColor(Color.red);
    try {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);

        Font font = g2d.getFont();
        FontRenderContext frc = new FontRenderContext(
            new AffineTransform(), true, true);

        g2d.setStroke(new BasicStroke(4.0f,
                                      BasicStroke.CAP_ROUND,
                                      BasicStroke.JOIN_ROUND));

        final Shape badShape;
        if (SERIALIZE) {
            final GlyphVector gv1 = font.createGlyphVector(frc, "\u00d6");
            final Shape textShape = gv1.getOutline();

            final AffineTransform at1 = AffineTransform.getTranslateInstance(
                -2091202.554154681, 5548.601436981691);
            badShape = at1.createTransformedShape(textShape);
            serializeShape(badShape);
        } else {
            badShape = deserializeShape();
        }

        g2d.draw(badShape);

        // Draw anything within bounds and it fails:
        g2d.draw(new Line2D.Double(10, 20, 30, 40));

        if (SAVE_IMAGE) {
            final File file = new File("TextClipErrorTest.png");
            System.out.println("Writing file: " + file.getAbsolutePath());
            ImageIO.write(image, "PNG", file);
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {
        g2d.dispose();
        log.info("TextClipErrorTest: end");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:82,代码来源:TextClipErrorTest.java

示例5: drawPointsTrail

import java.awt.font.GlyphVector; //导入方法依赖的package包/类
private void drawPointsTrail(Graphics2D g2d, double downsampleFactor, Rectangle clippingRectangle, Fixations fixations) {
    g2d.setStroke(new BasicStroke((downsampleFactor > 1) ? (float) downsampleFactor : 1));

    double[] zoomLevel;
    Point2D[] points = fixations.getCentroids();
    zoomLevel = new double[fixations.getFixations().size()];
    for (int j = 0; j < fixations.getFixations().size(); j++) {
        zoomLevel[j] = fixations.getFixations().get(j).calculateAverageZoom(
                viewer.getServer().getAveragedPixelSizeMicrons());
    }

    Point2D previousPoint = null;
    for (int i = 0; i < points.length; i++) {
        Point2D point = points[i];

        if (point != null) {
            if (clippingRectangle.contains(point)) {

                Color lowColor = fixations.getLowColor();
                Color medColor = fixations.getMedColor();
                Color highColor = fixations.getHighColor();

                g2d.setColor(lowColor);
                if (zoomLevel[i] < lowZoomThreshold.get()) {
                    g2d.setColor(medColor);
                }
                if (zoomLevel[i] < medZoomThreshold.get()) {
                    g2d.setColor(highColor);
                }
                g2d.setStroke(new BasicStroke((float) (downsampleFactor * fixations.getThicknessScalar())));

                if (previousPoint != null) {
                    g2d.drawLine(
                            (int) point.getX(), (int) point.getY(),
                            (int) previousPoint.getX(), (int) previousPoint.getY());
                }

                if (fixations.getFixations() != null) {
                    g2d.setStroke(new BasicStroke((float) downsampleFactor));
                    double circleSizeCoef = (downsampleFactor * fixations.getDurations()[i] / 30) *
                            fixations.getDurationSizeScalarScalar();

                    g2d.fillOval(
                            (int) point.getX() - (int) (circleSizeCoef / 2),
                            (int) point.getY() - (int) (circleSizeCoef / 2),
                            (int) circleSizeCoef,
                            (int) circleSizeCoef);

                    if (doPaintNumbers) {
                        Font font = new Font("Impact", Font.BOLD, (int) (30 * downsampleFactor));
                        g2d.setFont(font);
                        String str = Integer.toString(i + 1);
                        g2d.setColor(Color.WHITE);
                        g2d.drawString(str, (int) point.getX(), (int) point.getY());

                        GlyphVector gv = font.createGlyphVector(g2d.getFontRenderContext(), str);
                        Shape s = gv.getOutline((int) point.getX(), (int) point.getY());
                        g2d.setColor(Color.BLACK);
                        g2d.draw(s);
                    }
                }
            }
            previousPoint = point;
        }
    }
}
 
开发者ID:Alanocallaghan,项目名称:qupath-tracking-extension,代码行数:67,代码来源:TrackerFeatureOverlay.java


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