Java Code Examples for java.awt.geom.Point2D#Float
The following examples show how to use
java.awt.geom.Point2D#Float .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardGlyphVector.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Ensure that the positions array exists and holds position data. * If the array is null, this allocates it and sets default positions. */ private void initPositions() { if (positions == null) { setFRCTX(); positions = new float[glyphs.length * 2 + 2]; Point2D.Float trackPt = null; float track = getTracking(font); if (track != 0) { track *= font.getSize2D(); trackPt = new Point2D.Float(track, 0); // advance delta } Point2D.Float pt = new Point2D.Float(0, 0); if (font.isTransformed()) { AffineTransform at = font.getTransform(); at.transform(pt, pt); positions[0] = pt.x; positions[1] = pt.y; if (trackPt != null) { at.deltaTransform(trackPt, trackPt); } } for (int i = 0, n = 2; i < glyphs.length; ++i, n += 2) { getGlyphStrike(i).addDefaultGlyphAdvance(glyphs[i], pt); if (trackPt != null) { pt.x += trackPt.x; pt.y += trackPt.y; } positions[n] = pt.x; positions[n+1] = pt.y; } } }
Example 2
Source File: WPathGraphics.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected void deviceFillRect(int x, int y, int width, int height, Color color) { /* * Transform to device coordinates */ AffineTransform deviceTransform = getTransform(); /* check if rotated or sheared */ int transformType = deviceTransform.getType(); boolean usePath = ((transformType & (AffineTransform.TYPE_GENERAL_ROTATION | AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0); if (usePath) { fill(new Rectangle2D.Float(x, y, width, height)); return; } Point2D.Float tlc_pos = new Point2D.Float(x, y); deviceTransform.transform(tlc_pos, tlc_pos); Point2D.Float brc_pos = new Point2D.Float(x+width, y+height); deviceTransform.transform(brc_pos, brc_pos); float deviceWidth = (float) (brc_pos.getX() - tlc_pos.getX()); float deviceHeight = (float)(brc_pos.getY() - tlc_pos.getY()); WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob(); wPrinterJob.fillRect((float)tlc_pos.getX(), (float)tlc_pos.getY(), deviceWidth, deviceHeight, color); }
Example 3
Source File: FileFont.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void getGlyphMetrics(long pScalerContext, int glyphCode, Point2D.Float metrics) { try { getScaler().getGlyphMetrics(pScalerContext, glyphCode, metrics); } catch (FontScalerException fe) { scaler = FontScaler.getNullScaler(); getGlyphMetrics(pScalerContext, glyphCode, metrics); } }
Example 4
Source File: ConcurrentReadingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void createTestFile() { int w = 1280; int h = 1024; BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = img.createGraphics(); Color[] colors = { Color.red, Color.green, Color.blue }; float[] dist = {0.0f, 0.5f, 1.0f }; Point2D center = new Point2D.Float(0.5f * w, 0.5f * h); RadialGradientPaint p = new RadialGradientPaint(center, 0.5f * w, dist, colors); g.setPaint(p); g.fillRect(0, 0, w, h); g.dispose(); try { System.out.println("Create test image " + file.getAbsolutePath()); boolean b = ImageIO.write(img, "JPEG", file); if (!b) { throw new RuntimeException("Failed to create test image."); } } catch (IOException e) { throw new RuntimeException("Test failed", e); } }
Example 5
Source File: DelegateStrike.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
Point2D.Float getGlyphMetrics(int glyphCode) { return delegateStrike.getGlyphMetrics(glyphCode); }
Example 6
Source File: AlertReportExportPDF.java From zap-extensions with Apache License 2.0 | 4 votes |
/** * add a title page to the PDF document * * @param extensionExport * @throws IOException */ private void addTitlePage(ExtensionAlertReportExport extensionExport) throws IOException { page = new PDPage(pageSize); document.addPage(page); // calculate initial positioning on the page (origin = bottom left) textInsertionPoint = new Point2D.Float( page.findMediaBox().getLowerLeftX() + marginPoints, page.findMediaBox().getUpperRightY() - marginPoints); // draw the logo at 40% size. textInsertionPoint = addImage(extensionExport.getParams().getLogoFileName(), 40f, textInsertionPoint); for (int i = 0; i < 4; i++) { textInsertionPoint = addText(textFormatting, " ", textInsertionPoint); } textInsertionPoint = addText( titlePageHeader1Formatting, extensionExport.getParams().getTitleReport(), textInsertionPoint); for (int i = 0; i < 3; i++) { textInsertionPoint = addText(textFormatting, " ", textInsertionPoint); } textInsertionPoint = addText( titlePageHeader2Formatting, extensionExport.getParams().getCustomerName(), textInsertionPoint); for (int i = 0; i < 15; i++) { textInsertionPoint = addText(textFormatting, " ", textInsertionPoint); } textInsertionPoint = addText( smallLabelFormatting, extensionExport .getMessages() .getString("alertreport.export.message.export.pdf.confidential"), textInsertionPoint); textInsertionPoint = addText( smallPrintFormatting, extensionExport.getParams().getConfidentialText(), textInsertionPoint); }
Example 7
Source File: DelegateStrike.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void getGlyphImageBounds(int glyphCode, Point2D.Float pt, Rectangle result) { delegateStrike.getGlyphImageBounds(glyphCode, pt, result); }
Example 8
Source File: FileFontStrike.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private Point2D.Float getGlyphMetrics(int glyphCode, boolean getImage) { Point2D.Float metrics = new Point2D.Float(); // !!! or do we force sgv user glyphs? if (glyphCode >= INVISIBLE_GLYPHS) { return metrics; } long glyphPtr; if (getImageWithAdvance && getImage) { /* A heuristic optimisation says that for most cases its * worthwhile retrieving the image at the same time as the * metrics. So here we get the image data even if its not * already cached. */ glyphPtr = getGlyphImagePtr(glyphCode); } else { glyphPtr = getCachedGlyphPtr(glyphCode); } if (glyphPtr != 0L) { metrics = new Point2D.Float(); metrics.x = StrikeCache.unsafe.getFloat (glyphPtr + StrikeCache.xAdvanceOffset); metrics.y = StrikeCache.unsafe.getFloat (glyphPtr + StrikeCache.yAdvanceOffset); /* advance is currently in device space, need to convert back * into user space. * This must not include the translation component. */ if (invertDevTx != null) { invertDevTx.deltaTransform(metrics, metrics); } } else { /* We sometimes cache these metrics as they are expensive to * generate for large glyphs. * We never reach this path if we obtain images with advances. * But if we do not obtain images with advances its possible that * we first obtain this information, then the image, and never * will access this value again. */ Integer key = Integer.valueOf(glyphCode); Point2D.Float value = null; ConcurrentHashMap<Integer, Point2D.Float> glyphMetricsMap = null; if (glyphMetricsMapRef != null) { glyphMetricsMap = glyphMetricsMapRef.get(); } if (glyphMetricsMap != null) { value = glyphMetricsMap.get(key); if (value != null) { metrics.x = value.x; metrics.y = value.y; /* already in user space */ return metrics; } } if (value == null) { fileFont.getGlyphMetrics(pScalerContext, glyphCode, metrics); /* advance is currently in device space, need to convert back * into user space. */ if (invertDevTx != null) { invertDevTx.deltaTransform(metrics, metrics); } value = new Point2D.Float(metrics.x, metrics.y); /* We aren't synchronizing here so it is possible to * overwrite the map with another one but this is harmless. */ if (glyphMetricsMap == null) { glyphMetricsMap = new ConcurrentHashMap<Integer, Point2D.Float>(); glyphMetricsMapRef = new SoftReference<ConcurrentHashMap<Integer, Point2D.Float>>(glyphMetricsMap); } glyphMetricsMap.put(key, value); } } return metrics; }
Example 9
Source File: PhysicalStrike.java From Bytecoder with Apache License 2.0 | 4 votes |
Point2D.Float getCharMetrics(char ch) { return getGlyphMetrics(physicalFont.getMapper().charToGlyph(ch)); }
Example 10
Source File: FontScaler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
abstract Point2D.Float getGlyphPoint(long pScalerContext, int glyphCode, int ptNumber) throws FontScalerException;
Example 11
Source File: LinearGradientPaint.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a {@code LinearGradientPaint} with a default {@code SRGB} * color space. * * @param startX the X coordinate of the gradient axis start point * in user space * @param startY the Y coordinate of the gradient axis start point * in user space * @param endX the X coordinate of the gradient axis end point * in user space * @param endY the Y coordinate of the gradient axis end point * in user space * @param fractions numbers ranging from 0.0 to 1.0 specifying the * distribution of colors along the gradient * @param colors array of colors corresponding to each fractional value * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT}, * or {@code REPEAT} * * @throws NullPointerException * if {@code fractions} array is null, * or {@code colors} array is null, * or {@code cycleMethod} is null * @throws IllegalArgumentException * if start and end points are the same points, * or {@code fractions.length != colors.length}, * or {@code colors} is less than 2 in size, * or a {@code fractions} value is less than 0.0 or greater than 1.0, * or the {@code fractions} are not provided in strictly increasing order */ public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, CycleMethod cycleMethod) { this(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, cycleMethod); }
Example 12
Source File: LinearGradientPaint.java From jdk-1.7-annotated with Apache License 2.0 | 3 votes |
/** * Constructs a {@code LinearGradientPaint} with a default {@code SRGB} * color space. * * @param startX the X coordinate of the gradient axis start point * in user space * @param startY the Y coordinate of the gradient axis start point * in user space * @param endX the X coordinate of the gradient axis end point * in user space * @param endY the Y coordinate of the gradient axis end point * in user space * @param fractions numbers ranging from 0.0 to 1.0 specifying the * distribution of colors along the gradient * @param colors array of colors corresponding to each fractional value * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT}, * or {@code REPEAT} * * @throws NullPointerException * if {@code fractions} array is null, * or {@code colors} array is null, * or {@code cycleMethod} is null * @throws IllegalArgumentException * if start and end points are the same points, * or {@code fractions.length != colors.length}, * or {@code colors} is less than 2 in size, * or a {@code fractions} value is less than 0.0 or greater than 1.0, * or the {@code fractions} are not provided in strictly increasing order */ public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, CycleMethod cycleMethod) { this(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, cycleMethod); }
Example 13
Source File: LinearGradientPaint.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Constructs a {@code LinearGradientPaint} with a default {@code SRGB} * color space. * * @param startX the X coordinate of the gradient axis start point * in user space * @param startY the Y coordinate of the gradient axis start point * in user space * @param endX the X coordinate of the gradient axis end point * in user space * @param endY the Y coordinate of the gradient axis end point * in user space * @param fractions numbers ranging from 0.0 to 1.0 specifying the * distribution of colors along the gradient * @param colors array of colors corresponding to each fractional value * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT}, * or {@code REPEAT} * * @throws NullPointerException * if {@code fractions} array is null, * or {@code colors} array is null, * or {@code cycleMethod} is null * @throws IllegalArgumentException * if start and end points are the same points, * or {@code fractions.length != colors.length}, * or {@code colors} is less than 2 in size, * or a {@code fractions} value is less than 0.0 or greater than 1.0, * or the {@code fractions} are not provided in strictly increasing order */ public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, CycleMethod cycleMethod) { this(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, cycleMethod); }
Example 14
Source File: RescaleOp.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns the location of the destination point given a * point in the source. If dstPt is non-null, it will * be used to hold the return value. Since this is not a geometric * operation, the srcPt will equal the dstPt. * @param srcPt a point in the source image * @param dstPt the destination point or <code>null</code> * @return the location of the destination point. */ public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
Example 15
Source File: LookupOp.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Returns the location of the destination point given a * point in the source. If {@code dstPt} is not * {@code null}, it will be used to hold the return value. * Since this is not a geometric operation, the {@code srcPt} * will equal the {@code dstPt}. * @param srcPt a {@code Point2D} that represents a point * in the source image * @param dstPt a {@code Point2D} that represents the location * in the destination * @return the {@code Point2D} in the destination that * corresponds to the specified point in the source. */ public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
Example 16
Source File: RescaleOp.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns the location of the destination point given a * point in the source. If dstPt is non-null, it will * be used to hold the return value. Since this is not a geometric * operation, the srcPt will equal the dstPt. * @param srcPt a point in the source image * @param dstPt the destination point or <code>null</code> * @return the location of the destination point. */ public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
Example 17
Source File: RescaleOp.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Returns the location of the destination point given a * point in the source. If dstPt is non-null, it will * be used to hold the return value. Since this is not a geometric * operation, the srcPt will equal the dstPt. * @param srcPt a point in the source image * @param dstPt the destination point or <code>null</code> * @return the location of the destination point. */ public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
Example 18
Source File: IUser.java From scelight with Apache License 2.0 | 2 votes |
/** * Returns the start location on the map, matched by the first camera update event (which has a target point). * * @return the start location on the map, matched by the first camera update event (which has a target point) */ Point2D.Float getStartLocation();
Example 19
Source File: GlyphLayout.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Given a strike descriptor, text, rtl flag, and starting point, append information about * glyphs, positions, and character indices to the glyphvector data, and advance the point. * * If the GVData does not have room for the glyphs, throws an IndexOutOfBoundsException and * leave pt and the gvdata unchanged. */ public void layout(FontStrikeDesc sd, float[] mat, int gmask, int baseIndex, TextRecord text, int typo_flags, Point2D.Float pt, GVData data);
Example 20
Source File: FontStrike.java From jdk8u-dev-jdk with GNU General Public License v2.0 | votes |
abstract Point2D.Float getCharMetrics(char ch);