⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glyphvector.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * Returns a <code>Shape</code> whose interior corresponds to the     * visual representation of the specified glyph     * within this <code>GlyphVector</code>, offset to x,&nbsp;y.     * The outline returned by this method is positioned around the     * origin of each individual glyph.     * @param glyphIndex the index into this <code>GlyphVector</code>     * @param x,&nbsp;y the coordinates of the location of this      *   <code>GlyphVector</code>.     * @return a <code>Shape</code> that is the outline of the glyph     *   at the specified <code>glyphIndex</code> of this     *	 <code>GlyphVector</code> when rendered at the specified     *   coordinates.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number     *   of glyphs in this <code>GlyphVector</code>     * @since 1.4     */    public Shape getGlyphOutline(int glyphIndex, float x, float y) {	Shape s = getGlyphOutline(glyphIndex);	AffineTransform at = AffineTransform.getTranslateInstance(x,y);	return at.createTransformedShape(s);	}    /**     * Returns the position of the specified glyph relative to the     * origin of this <code>GlyphVector</code>.     * If <code>glyphIndex</code> equals the number of of glyphs in      * this <code>GlyphVector</code>, this method returns the position after     * the last glyph. This position is used to define the advance of      * the entire <code>GlyphVector</code>.     * @param glyphIndex the index into this <code>GlyphVector</code>     * @return a {@link Point2D} object that is the position of the glyph     *	 at the specified <code>glyphIndex</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than the number of glyphs     *   in this <code>GlyphVector</code>     * @see #setGlyphPosition      */    public abstract Point2D getGlyphPosition(int glyphIndex);    /**     * Sets the position of the specified glyph within this     * <code>GlyphVector</code>.     * If <code>glyphIndex</code> equals the number of of glyphs in      * this <code>GlyphVector</code>, this method sets the position after     * the last glyph. This position is used to define the advance of      * the entire <code>GlyphVector</code>.     * @param glyphIndex the index into this <code>GlyphVector</code>     * @param newPos the <code>Point2D</code> at which to position the     *	 glyph at the specified <code>glyphIndex</code>     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than the number of glyphs     *   in this <code>GlyphVector</code>     * @see #getGlyphPosition     */    public abstract void setGlyphPosition(int glyphIndex, Point2D newPos);    /**     * Returns the transform of the specified glyph within this     * <code>GlyphVector</code>.  The transform is relative to the     * glyph position.  If no special transform has been applied,      * <code>null</code> can be returned.  A null return indicates     * an identity transform.     * @param glyphIndex the index into this <code>GlyphVector</code>     * @return an {@link AffineTransform} that is the transform of     *	 the glyph at the specified <code>glyphIndex</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     * @see #setGlyphTransform     */    public abstract AffineTransform getGlyphTransform(int glyphIndex);    /**     * Sets the transform of the specified glyph within this     * <code>GlyphVector</code>.  The transform is relative to the glyph     * position.  A <code>null</code> argument for <code>newTX</code>     * indicates that no special transform is applied for the specified     * glyph.     * This method can be used to rotate, mirror, translate and scale the     * glyph.  Adding a transform can result in signifant performance changes.     * @param glyphIndex the index into this <code>GlyphVector</code>     * @param newTX the new transform of the glyph at <code>glyphIndex</code>     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     * @see #getGlyphTransform     */    public abstract void setGlyphTransform(int glyphIndex, AffineTransform newTX);    /**     * Returns flags describing the global state of the GlyphVector.     * Flags not described below are reserved.  The default      * implementation returns 0 (meaning false) for the position adjustments,     * transforms, rtl, and complex flags.     * Subclassers should override this method, and make sure     * it correctly describes the GlyphVector and corresponds     * to the results of related calls.     * @return an int containing the flags describing the state     * @see #FLAG_HAS_POSITION_ADJUSTMENTS     * @see #FLAG_HAS_TRANSFORMS     * @see #FLAG_RUN_RTL     * @see #FLAG_COMPLEX_GLYPHS     * @see #FLAG_MASK     * @since 1.4     */    public int getLayoutFlags() {		return 0;	}    /**     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has     * per-glyph transforms.     * @since 1.4     */    public static final int FLAG_HAS_TRANSFORMS = 1;        /**     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has     * position adjustments.  When this is true, the glyph positions don't match the     * accumulated default advances of the glyphs (for example, if kerning has been done).     * @since 1.4     */    public static final int FLAG_HAS_POSITION_ADJUSTMENTS = 2;        /**     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has     * a right-to-left run direction.  This refers to the glyph-to-char mapping and does     * not imply that the visual locations of the glyphs are necessarily in this order,     * although generally they will be.     * @since 1.4     */    public static final int FLAG_RUN_RTL = 4;    /**     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has     * a complex glyph-to-char mapping (one that does not map glyphs to chars one-to-one in     * strictly ascending or descending order matching the run direction).     * @since 1.4     */    public static final int FLAG_COMPLEX_GLYPHS = 8;    /**     * A mask for supported flags from getLayoutFlags.  Only bits covered by the mask     * should be tested.     * @since 1.4     */    public static final int FLAG_MASK = 	FLAG_HAS_TRANSFORMS |	FLAG_HAS_POSITION_ADJUSTMENTS |	FLAG_RUN_RTL |	FLAG_COMPLEX_GLYPHS;    /**     * Returns an array of glyph positions for the specified glyphs.     * This method is used for convenience and performance when     * processing glyph positions.     * If no array is passed in, a new array is created.     * Even numbered array entries beginning with position zero are the X     * coordinates of the glyph numbered <code>beginGlyphIndex + position/2</code>.       * Odd numbered array entries beginning with position one are the Y     * coordinates of the glyph numbered <code>beginGlyphIndex + (position-1)/2</code>.     * If <code>beginGlyphIndex</code> equals the number of of glyphs in      * this <code>GlyphVector</code>, this method gets the position after     * the last glyph and this position is used to define the advance of      * the entire <code>GlyphVector</code>.     * @param beginGlyphIndex the index at which to begin retrieving     *   glyph positions     * @param numEntries the number of glyphs to retrieve     * @param positionReturn the array that receives the glyph positions     *   and is then returned.     * @return an array of glyph positions specified by     *	<code>beginGlyphIndex</code> and <code>numEntries</code>.     * @throws IllegalArgumentException if <code>numEntries</code> is     *   less than 0     * @throws IndexOutOfBoundsException if <code>beginGlyphIndex</code>     *   is less than 0     * @throws IndexOutOfBoundsException if the sum of      *   <code>beginGlyphIndex</code> and <code>numEntries</code>      *   is greater than the number of glyphs in this      *   <code>GlyphVector</code> plus one     */    public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries,                                              float[] positionReturn);    /**     * Returns the logical bounds of the specified glyph within this     * <code>GlyphVector</code>.     * These logical bounds have a total of four edges, with two edges     * parallel to the baseline under the glyph's transform and the other two     * edges are shared with adjacent glyphs if they are present.  This     * method is useful for hit-testing of the specified glyph,     * positioning of a caret at the leading or trailing edge of a glyph,     * and for drawing a highlight region around the specified glyph.     * @param glyphIndex the index into this <code>GlyphVector</code>     *   that corresponds to the glyph from which to retrieve its logical     *   bounds     * @return  a <code>Shape</code> that is the logical bounds of the     *	 glyph at the specified <code>glyphIndex</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     * @see #getGlyphVisualBounds     */    public abstract Shape getGlyphLogicalBounds(int glyphIndex);    /**     * Returns the visual bounds of the specified glyph within the     * <code>GlyphVector</code>.     * The bounds returned by this method is positioned around the     * origin of each individual glyph.     * @param glyphIndex the index into this <code>GlyphVector</code>     *   that corresponds to the glyph from which to retrieve its visual     *   bounds     * @return a <code>Shape</code> that is the visual bounds of the     *   glyph at the specified <code>glyphIndex</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     * @see #getGlyphLogicalBounds     */    public abstract Shape getGlyphVisualBounds(int glyphIndex);    /**     * Returns the pixel bounds of the glyph at index when this     * <code>GlyphVector</code> is rendered in a <code>Graphics</code> with the     * given <code>FontRenderContext</code> at the given location. The     * renderFRC need not be the same as the     * <code>FontRenderContext</code> of this     * <code>GlyphVector</code>, and can be null.  If it is null, the     * <code>FontRenderContext</code> of this <code>GlyphVector</code>     * is used.  The default implementation returns the visual bounds of the glyph,      * offset to x, y and rounded out to the next integer value, and     * ignores the FRC.  Subclassers should override this method.     * @param index the index of the glyph.     * @param renderFRC the <code>FontRenderContext</code> of the <code>Graphics</code>.     * @param x,&nbsp;y the position at which to render this <code>GlyphVector</code>.     * @return a <code>Rectangle</code> bounding the pixels that would be affected.     * @since 1.4     */    public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) {		Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D();		int l = (int)Math.floor(rect.getX() + x);		int t = (int)Math.floor(rect.getY() + y);		int r = (int)Math.ceil(rect.getMaxX() + x);		int b = (int)Math.ceil(rect.getMaxY() + y);		return new Rectangle(l, t, r - l, b - t);	}    /**     * Returns the metrics of the glyph at the specified index into     * this <code>GlyphVector</code>.     * @param glyphIndex the index into this <code>GlyphVector</code>     *   that corresponds to the glyph from which to retrieve its metrics     * @return a {@link GlyphMetrics} object that represents the     *	 metrics of the glyph at the specified <code>glyphIndex</code>      *	 into this <code>GlyphVector</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     */    public abstract GlyphMetrics getGlyphMetrics(int glyphIndex);    /**     * Returns the justification information for the glyph at     * the specified index into this <code>GlyphVector</code>.     * @param glyphIndex the index into this <code>GlyphVector</code>     *	 that corresponds to the glyph from which to retrieve its      *	 justification properties     * @return a {@link GlyphJustificationInfo} object that     *	 represents the justification properties of the glyph at the     *	 specified <code>glyphIndex</code> into this     *	 <code>GlyphVector</code>.     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>     *   is less than 0 or greater than or equal to the number      *   of glyphs in this <code>GlyphVector</code>     */    public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex);    //    // general utility methods    //    /**     * Tests if the specified <code>GlyphVector</code> exactly     * equals this <code>GlyphVector</code>.     * @param set the specified <code>GlyphVector</code> to test     * @return <code>true</code> if the specified     *	 <code>GlyphVector</code> equals this <code>GlyphVector</code>;     *	 <code>false</code> otherwise.     */    public abstract boolean equals(GlyphVector set);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -