本文整理匯總了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);
}
示例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);
}
示例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();
}
}
示例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");
}
}
示例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;
}
}
}