PathGraphics.java revision 4798
2362N/A * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Return the Printable instance responsible for drawing 0N/A * into this Graphics. 0N/A * Return the PageFormat associated with this page of 0N/A * Return the page index associated with this Graphics. 0N/A * Return true if we are allowed to ask the application 0N/A * to redraw portions of the page. In general, with the 0N/A * PrinterJob API, the application can be asked to do a 0N/A * redraw. When PrinterJob is emulating PrintJob then we 0N/A * Redraw a rectanglular area using a proxy graphics 0N/A * Draws a line, using the current color, between the points 0N/A * <code>(x1, y1)</code> and <code>(x2, y2)</code> 0N/A * in this graphics context's coordinate system. 0N/A * @param x1 the first point's <i>x</i> coordinate. 0N/A * @param y1 the first point's <i>y</i> coordinate. 0N/A * @param x2 the second point's <i>x</i> coordinate. 0N/A * @param y2 the second point's <i>y</i> coordinate. 0N/A * Draws the outline of the specified rectangle. 0N/A * The left and right edges of the rectangle are at 0N/A * <code>x</code> and <code>x + width</code>. 0N/A * The top and bottom edges are at 0N/A * <code>y</code> and <code>y + height</code>. 0N/A * The rectangle is drawn using the graphics context's current color. 0N/A * @param x the <i>x</i> coordinate 0N/A * of the rectangle to be drawn. 0N/A * @param y the <i>y</i> coordinate 0N/A * of the rectangle to be drawn. 0N/A * @param width the width of the rectangle to be drawn. 0N/A * @param height the height of the rectangle to be drawn. 0N/A * @see java.awt.Graphics#fillRect 0N/A * @see java.awt.Graphics#clearRect 0N/A * Fills the specified rectangle. 0N/A * The left and right edges of the rectangle are at 0N/A * <code>x</code> and <code>x + width - 1</code>. 0N/A * The top and bottom edges are at 0N/A * <code>y</code> and <code>y + height - 1</code>. 0N/A * The resulting rectangle covers an area 0N/A * <code>width</code> pixels wide by 0N/A * <code>height</code> pixels tall. 0N/A * The rectangle is filled using the graphics context's current color. 0N/A * @param x the <i>x</i> coordinate 0N/A * of the rectangle to be filled. 0N/A * @param y the <i>y</i> coordinate 0N/A * of the rectangle to be filled. 0N/A * @param width the width of the rectangle to be filled. 0N/A * @param height the height of the rectangle to be filled. 0N/A * @see java.awt.Graphics#clearRect 0N/A * @see java.awt.Graphics#drawRect 0N/A * Clears the specified rectangle by filling it with the background 0N/A * color of the current drawing surface. This operation does not 0N/A * use the current paint mode. 0N/A * Beginning with Java 1.1, the background color 0N/A * of offscreen images may be system dependent. Applications should 0N/A * use <code>setColor</code> followed by <code>fillRect</code> to 0N/A * ensure that an offscreen image is cleared to a specific color. 0N/A * @param x the <i>x</i> coordinate of the rectangle to clear. 0N/A * @param y the <i>y</i> coordinate of the rectangle to clear. 0N/A * @param width the width of the rectangle to clear. 0N/A * @param height the height of the rectangle to clear. 0N/A * @see java.awt.Graphics#fillRect(int, int, int, int) 0N/A * @see java.awt.Graphics#drawRect 0N/A * @see java.awt.Graphics#setColor(java.awt.Color) 0N/A * @see java.awt.Graphics#setPaintMode 0N/A * @see java.awt.Graphics#setXORMode(java.awt.Color) 0N/A * Draws an outlined round-cornered rectangle using this graphics 0N/A * context's current color. The left and right edges of the rectangle 0N/A * are at <code>x</code> and <code>x + width</code>, 0N/A * respectively. The top and bottom edges of the rectangle are at 0N/A * <code>y</code> and <code>y + height</code>. 0N/A * @param x the <i>x</i> coordinate of the rectangle to be drawn. 0N/A * @param y the <i>y</i> coordinate of the rectangle to be drawn. 0N/A * @param width the width of the rectangle to be drawn. 0N/A * @param height the height of the rectangle to be drawn. 0N/A * @param arcWidth the horizontal diameter of the arc 0N/A * at the four corners. 0N/A * @param arcHeight the vertical diameter of the arc 0N/A * at the four corners. 0N/A * @see java.awt.Graphics#fillRoundRect 0N/A * Fills the specified rounded corner rectangle with the current color. 0N/A * The left and right edges of the rectangle 0N/A * are at <code>x</code> and <code>x + width - 1</code>, 0N/A * respectively. The top and bottom edges of the rectangle are at 0N/A * <code>y</code> and <code>y + height - 1</code>. 0N/A * @param x the <i>x</i> coordinate of the rectangle to be filled. 0N/A * @param y the <i>y</i> coordinate of the rectangle to be filled. 0N/A * @param width the width of the rectangle to be filled. 0N/A * @param height the height of the rectangle to be filled. 0N/A * @param arcWidth the horizontal diameter 0N/A * of the arc at the four corners. 0N/A * @param arcHeight the vertical diameter 0N/A * of the arc at the four corners. 0N/A * @see java.awt.Graphics#drawRoundRect 0N/A * Draws the outline of an oval. 0N/A * The result is a circle or ellipse that fits within the 0N/A * rectangle specified by the <code>x</code>, <code>y</code>, 0N/A * <code>width</code>, and <code>height</code> arguments. 0N/A * The oval covers an area that is 0N/A * <code>width + 1</code> pixels wide 0N/A * and <code>height + 1</code> pixels tall. 0N/A * @param x the <i>x</i> coordinate of the upper left 0N/A * corner of the oval to be drawn. 0N/A * @param y the <i>y</i> coordinate of the upper left 0N/A * corner of the oval to be drawn. 0N/A * @param width the width of the oval to be drawn. 0N/A * @param height the height of the oval to be drawn. 0N/A * @see java.awt.Graphics#fillOval 0N/A * Fills an oval bounded by the specified rectangle with the 0N/A * @param x the <i>x</i> coordinate of the upper left corner 0N/A * of the oval to be filled. 0N/A * @param y the <i>y</i> coordinate of the upper left corner 0N/A * of the oval to be filled. 0N/A * @param width the width of the oval to be filled. 0N/A * @param height the height of the oval to be filled. 0N/A * @see java.awt.Graphics#drawOval 0N/A * Draws the outline of a circular or elliptical arc 0N/A * covering the specified rectangle. 0N/A * The resulting arc begins at <code>startAngle</code> and extends 0N/A * for <code>arcAngle</code> degrees, using the current color. 0N/A * Angles are interpreted such that 0 degrees 0N/A * is at the 3 o'clock position. 0N/A * A positive value indicates a counter-clockwise rotation 0N/A * while a negative value indicates a clockwise rotation. 0N/A * The center of the arc is the center of the rectangle whose origin 0N/A * is (<i>x</i>, <i>y</i>) and whose size is specified by the 0N/A * <code>width</code> and <code>height</code> arguments. 0N/A * The resulting arc covers an area 0N/A * <code>width + 1</code> pixels wide 0N/A * by <code>height + 1</code> pixels tall. 0N/A * The angles are specified relative to the non-square extents of 0N/A * the bounding rectangle such that 45 degrees always falls on the 0N/A * line from the center of the ellipse to the upper right corner of 0N/A * the bounding rectangle. As a result, if the bounding rectangle is 0N/A * noticeably longer in one axis than the other, the angles to the 0N/A * start and end of the arc segment will be skewed farther along the 0N/A * longer axis of the bounds. 0N/A * @param x the <i>x</i> coordinate of the 0N/A * upper-left corner of the arc to be drawn. 0N/A * @param y the <i>y</i> coordinate of the 0N/A * upper-left corner of the arc to be drawn. 0N/A * @param width the width of the arc to be drawn. 0N/A * @param height the height of the arc to be drawn. 0N/A * @param startAngle the beginning angle. 0N/A * @param arcAngle the angular extent of the arc, 0N/A * relative to the start angle. 0N/A * @see java.awt.Graphics#fillArc 0N/A * Fills a circular or elliptical arc covering the specified rectangle. 0N/A * The resulting arc begins at <code>startAngle</code> and extends 0N/A * for <code>arcAngle</code> degrees. 0N/A * Angles are interpreted such that 0 degrees 0N/A * is at the 3 o'clock position. 0N/A * A positive value indicates a counter-clockwise rotation 0N/A * while a negative value indicates a clockwise rotation. 0N/A * The center of the arc is the center of the rectangle whose origin 0N/A * is (<i>x</i>, <i>y</i>) and whose size is specified by the 0N/A * <code>width</code> and <code>height</code> arguments. 0N/A * The resulting arc covers an area 0N/A * <code>width + 1</code> pixels wide 0N/A * by <code>height + 1</code> pixels tall. 0N/A * The angles are specified relative to the non-square extents of 0N/A * the bounding rectangle such that 45 degrees always falls on the 0N/A * line from the center of the ellipse to the upper right corner of 0N/A * the bounding rectangle. As a result, if the bounding rectangle is 0N/A * noticeably longer in one axis than the other, the angles to the 0N/A * start and end of the arc segment will be skewed farther along the 0N/A * longer axis of the bounds. 0N/A * @param x the <i>x</i> coordinate of the 0N/A * upper-left corner of the arc to be filled. 0N/A * @param y the <i>y</i> coordinate of the 0N/A * upper-left corner of the arc to be filled. 0N/A * @param width the width of the arc to be filled. 0N/A * @param height the height of the arc to be filled. 0N/A * @param startAngle the beginning angle. 0N/A * @param arcAngle the angular extent of the arc, 0N/A * relative to the start angle. 0N/A * @see java.awt.Graphics#drawArc 0N/A * Draws a sequence of connected lines defined by 0N/A * arrays of <i>x</i> and <i>y</i> coordinates. 0N/A * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point. 0N/A * The figure is not closed if the first point 0N/A * differs from the last point. 0N/A * @param xPoints an array of <i>x</i> points 0N/A * @param yPoints an array of <i>y</i> points 0N/A * @param nPoints the total number of points 0N/A * @see java.awt.Graphics#drawPolygon(int[], int[], int) 0N/A * Draws a closed polygon defined by 0N/A * arrays of <i>x</i> and <i>y</i> coordinates. 0N/A * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point. 0N/A * This method draws the polygon defined by <code>nPoint</code> line 0N/A * segments, where the first <code>nPoint - 1</code> 0N/A * line segments are line segments from 0N/A * <code>(xPoints[i - 1], yPoints[i - 1])</code> 0N/A * to <code>(xPoints[i], yPoints[i])</code>, for 0N/A * 1 ≤ <i>i</i> ≤ <code>nPoints</code>. 0N/A * The figure is automatically closed by drawing a line connecting 0N/A * the final point to the first point, if those points are different. 0N/A * @param xPoints a an array of <code>x</code> coordinates. 0N/A * @param yPoints a an array of <code>y</code> coordinates. 0N/A * @param nPoints a the total number of points. 0N/A * @see java.awt.Graphics#fillPolygon 0N/A * @see java.awt.Graphics#drawPolyline 0N/A * Draws the outline of a polygon defined by the specified 0N/A * <code>Polygon</code> object. 0N/A * @param p the polygon to draw. 0N/A * @see java.awt.Graphics#fillPolygon 0N/A * @see java.awt.Graphics#drawPolyline 0N/A * Fills a closed polygon defined by 0N/A * arrays of <i>x</i> and <i>y</i> coordinates. 0N/A * This method draws the polygon defined by <code>nPoint</code> line 0N/A * segments, where the first <code>nPoint - 1</code> 0N/A * line segments are line segments from 0N/A * <code>(xPoints[i - 1], yPoints[i - 1])</code> 0N/A * to <code>(xPoints[i], yPoints[i])</code>, for 0N/A * 1 ≤ <i>i</i> ≤ <code>nPoints</code>. 0N/A * The figure is automatically closed by drawing a line connecting 0N/A * the final point to the first point, if those points are different. 0N/A * The area inside the polygon is defined using an 0N/A * even-odd fill rule, also known as the alternating rule. 0N/A * @param xPoints a an array of <code>x</code> coordinates. 0N/A * @param yPoints a an array of <code>y</code> coordinates. 0N/A * @param nPoints a the total number of points. 0N/A * @see java.awt.Graphics#drawPolygon(int[], int[], int) 0N/A * Fills the polygon defined by the specified Polygon object with 0N/A * the graphics context's current color. 0N/A * The area inside the polygon is defined using an 0N/A * even-odd fill rule, also known as the alternating rule. 0N/A * @param p the polygon to fill. 0N/A * @see java.awt.Graphics#drawPolygon(int[], int[], int) 0N/A * Draws the text given by the specified string, using this 0N/A * graphics context's current font and color. The baseline of the 0N/A * first character is at position (<i>x</i>, <i>y</i>) in this 0N/A * graphics context's coordinate system. 0N/A * @param str the string to be drawn. 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @see java.awt.Graphics#drawBytes 0N/A * @see java.awt.Graphics#drawChars 0N/A * Draws the text given by the specified iterator, using this 0N/A * graphics context's current color. The iterator has to specify a font 0N/A * for each character. The baseline of the 0N/A * first character is at position (<i>x</i>, <i>y</i>) in this 0N/A * graphics context's coordinate system. 0N/A * @param iterator the iterator whose text is to be drawn 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @see java.awt.Graphics#drawBytes 0N/A * @see java.awt.Graphics#drawChars 0N/A * Draws a GlyphVector. 0N/A * The rendering attributes applied include the clip, transform, 0N/A * paint or color, and composite attributes. The GlyphVector specifies 0N/A * individual glyphs from a Font. 0N/A * @param g The GlyphVector to be drawn. 0N/A * @param x,y The coordinates where the glyphs should be drawn. 0N/A * @see java.awt.Graphics#setColor 0N/A * @see #setTransform 0N/A * @see #setComposite 0N/A /* We should not reach here if printingGlyphVector is already true. 0N/A * Add an assert so this can be tested if need be. 0N/A * But also ensure that we do at least render properly by filling 0N/A * Default implementation returns false. 0N/A * Callers of this method must always be prepared for this, 0N/A * and delegate to outlines or some other solution. 0N/A /* GlyphVectors are usually encountered because TextLayout is in use. 0N/A * Some times TextLayout is needed to handle complex text or some 0N/A * rendering attributes trigger it. 0N/A * We try to print GlyphVectors by reconstituting into a String, 0N/A * as that is most recoverable for applications that export to formats 0N/A * such as Postscript or PDF. In some cases (eg where its not complex 0N/A * text and its just that positions aren't what we'd expect) we print 0N/A * one character at a time. positioning individually. 0N/A * Failing that, if we can directly send glyph codes to the printer 0N/A * then we do that (printGlyphVector). 0N/A * As a last resort we return false and let the caller print as filled 0N/A /* We can't handle RTL, re-ordering, complex glyphs etc by 0N/A * reconstituting glyphs into a String. So if any flags besides 0N/A * position adjustments are set, see if we can directly 0N/A * print the GlyphVector as glyph codes, using the positions 0N/A * layout has assigned. If that fails return false; 0N/A /* suspicious, may be a bad font. lets bail */ 0N/A /* Build the needed maps for this font in a synchronized block */ 0N/A /* X11 symbol & dingbats fonts used only for global metrics, 0N/A * so the glyph codes we have really refer to Lucida Sans 0N/A * So its possible the glyph code may appear out of range. 0N/A * Note that later on we double-check the glyph codes that 0N/A * we get from re-creating the GV from the string are the 0N/A * same as those we started with. 0N/A * If the glyphcode is INVISIBLE_GLYPH_ID then this may 0N/A * be \t, \n or \r which are mapped to that by layout. 0N/A * This is a case we can handle. It doesn't matter what 0N/A * character we use (we use \n) so long as layout maps it 0N/A * back to this in the verification, since the invisible 0N/A * glyph isn't visible :) 0N/A * Needed to double-check remapping of X11 symbol & dingbats. 0N/A /* If differ only in specifying A-A or a translation, these are 0N/A * also compatible FRC's, and we can do one drawString call. 0N/A for (
int i=
0;i<
4;i++) {
0N/A /* We have to consider that the application may be directly 0N/A * creating a GlyphVector, rather than one being created by 0N/A * TextLayout or indirectly from drawString. In such a case, if the 0N/A * font has layout attributes, the text may measure differently 0N/A * when we reconstitute it into a String and ask for the length that 0N/A * drawString would use. For example, KERNING will be applied in such 0N/A * a case but that Font attribute is not applied when the application 0N/A * directly created a GlyphVector. So in this case we need to verify 0N/A * that the text measures the same in both cases - ie that the 0N/A * layout attribute has no effect. If it does we can't always 0N/A * use the drawString call unless we can coerce the drawString call 0N/A * into measuring and displaying the string to the same length. 0N/A * That is the case where there is only one font used and we can 0N/A * specify the overall advance of the string. (See below). 0N/A /* If TRACKING is in use then the glyph vector will report 0N/A * position adjustments, then that ought to be sufficient to 0N/A * tell us we can't just ask native to do "drawString". But layout 0N/A * always sets the position adjustment flag, so we don't believe 0N/A * it and verify the positions are really different than 0N/A * createGlyphVector() (with no layout) would create. However 0N/A * inconsistently, TRACKING is applied when creating a GlyphVector, 0N/A * since it doesn't actually require "layout" (even though its 0N/A * considered a layout attribute), it just requires a fractional 0N/A * tweak to the[default]advances. So we need to specifically 0N/A * check for tracking until such time as as we can trust 0N/A * the GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS bit. 0N/A /* If positions have not been explicitly assigned, we can 0N/A * ask the string to be drawn adjusted to this width. 0N/A * This call is supported only in the PS generator. 0N/A * GDI has API to specify the advance for each glyph in a 0N/A * string which could be used here too, but that is not yet 0N/A * implemented, and we'd need to update the signature of the 0N/A * drawString method to take the advances (ie relative positions) 0N/A * and use that instead of the width. 0N/A /* In some scripts chars drawn individually do not have the 0N/A * same representation (glyphs) as when combined with other chars. 0N/A * The logic here is erring on the side of caution, in particular 0N/A * in including supplementary characters. 0N/A /* If we reach here we have mapped all the glyphs back 0N/A * one-to-one to simple unicode chars that we know are in the font. 0N/A * We can call "drawChars" on each one of them in turn, setting 0N/A * the position based on the glyph positions. 0N/A * There's typically overhead in this. If numGlyphs is 'large', 0N/A * it may even be better to try printGlyphVector() in this case. 0N/A * This may be less recoverable for apps, but sophisticated apps 0N/A * should be able to recover the text from simple glyph vectors 0N/A * and we can avoid penalising the more common case - although 0N/A * this is already a minority case. 0N/A /* The same codes must be in the same positions for this to return true. 0N/A * This would look cleaner if it took the original GV as a parameter but 0N/A * we already have the codes and will need to get the positions array 0N/A * too in most cases anyway. So its cheaper to pass them in. 0N/A * This call wouldn't be necessary if layout didn't always set the 0N/A * FLAG_HAS_POSITION_ADJUSTMENTS even if the default advances are used 0N/A * and there was no re-ordering (this should be fixed some day). 0N/A /* this shouldn't happen here, but just in case */ 0N/A /* return an array which can map glyphs back to char codes. 0N/A * Glyphs which aren't mapped from a simple unicode code point 0N/A * will have no mapping in this array, and will be assumed to be 0N/A * because of some substitution that we can't handle. 0N/A /* NB Composites report the number of glyphs in slot 0. 0N/A * So if a string uses a char from a later slot, or a fallback slot, 0N/A * it will not be able to use this faster path. 0N/A /* Consider refining the ranges to try to map by asking the font 0N/A * what ranges it supports. 0N/A * Since a glyph may be mapped by multiple code points, and this 0N/A * code can't handle that, we always prefer the earlier code point. 0N/A for (
char c=
0; c<
0xFFFF; c++) {
0N/A * Strokes the outline of a Shape using the settings of the current 0N/A * graphics state. The rendering attributes applied include the 0N/A * clip, transform, paint or color, composite and stroke attributes. 0N/A * @param s The shape to be drawn. 0N/A * @see java.awt.Graphics#setColor 0N/A * @see #setTransform 0N/A * @see #setComposite 0N/A * Fills the interior of a Shape using the settings of the current 0N/A * graphics state. The rendering attributes applied include the 0N/A * clip, transform, paint or color, and composite. 0N/A * @see java.awt.Graphics#setColor 0N/A * @see #setTransform 0N/A * @see #setComposite 0N/A /* The PathGraphics class only supports filling with 0N/A * solid colors and so we do not expect the cast of Paint 0N/A * to Color to fail. If it does fail then something went 0N/A * wrong, like the app draw a page with a solid color but 0N/A * then redrew it with a Gradient. 0N/A * Fill the path defined by <code>pathIter</code> 0N/A * with the specified color. 0N/A * The path is provided in device coordinates. 0N/A * Set the clipping path to that defined by 0N/A * the passed in <code>PathIterator</code>. 0N/A * Draw the outline of the rectangle without using path 0N/A * if supported by platform. 0N/A * Draw a line without using path if supported by platform. 0N/A * Fill a rectangle using specified color. 0N/A /* Obtain a BI from known implementations of java.awt.Image 0N/A // Otherwise we expect a BufferedImage to behave as a standard BI 0N/A // This can be null if the image isn't loaded yet. 0N/A // This is fine as in that case our caller will return 0N/A // as it will only draw a fully loaded image 0N/A // VI needs to make a new BI: this is unavoidable but 0N/A // I don't expect VI's to be "huge" in any case. 0N/A // may be null or may be some non-standard Image which 0N/A // shouldn't happen as Image is implemented by the platform 0N/A // not by applications 0N/A // If you add a new Image implementation to the platform you 0N/A // will need to support it here similarly to VI. 0N/A * Return true if the BufferedImage argument has non-opaque 0N/A * bits in it and therefore can not be directly rendered by 0N/A * GDI. Return false if the image is opaque. If this function 0N/A * can not tell for sure whether the image has transparent 0N/A * pixels then it assumes that it does. 0N/A * For the default INT ARGB check the image to see if any pixels are 0N/A * really transparent. If there are no transparent pixels then the 0N/A * transparency of the color model can be ignored. 0N/A * We assume that IndexColorModel images have already been 0N/A * checked for transparency and will be OPAQUE unless they actually 0N/A * have transparent pixels present. 0N/A // Stealing the data array for reading only... 0N/A for (
int j = y; j < y+h; j++) {
0N/A for (
int i = x; i < x+w; i++) {
0N/A /* An optimisation for the special case of ICM images which have 0N/A * bitmask transparency. 0N/A // to be compatible with 1.1 printing which treated b/g colors 0N/A // with alpha 128 as opaque 0N/A /* don't just use srcWidth & srcHeight from application - they 0N/A * may exceed the extent of the image - may need to clip. 0N/A * The image xform will ensure that points are still mapped properly. 0N/A * The various <code>drawImage()</code> methods for 0N/A * <code>PathGraphics</code> are all decomposed 0N/A * into an invocation of <code>drawImageToPlatform</code>. 0N/A * The portion of the passed in image defined by 0N/A * <code>srcX, srcY, srcWidth, and srcHeight</code> 0N/A * is transformed by the supplied AffineTransform and 0N/A * drawn using PS to the printer context. 0N/A * @param img The image to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param xform Used to tranform the image before drawing. 0N/A * @param bgcolor This color is drawn where the image has transparent 0N/A * pixels. If this parameter is null then the 0N/A * pixels already in the destination should show 0N/A * @param srcX With srcY this defines the upper-left corner 0N/A * of the portion of the image to be drawn. 0N/A * @param srcY With srcX this defines the upper-left corner 0N/A * of the portion of the image to be drawn. 0N/A * @param srcWidth The width of the portion of the image to 0N/A * @param srcHeight The height of the portion of the image to 0N/A * @param handlingTransparency if being recursively called to 0N/A * print opaque region of transparent image 0N/A protected abstract boolean 0N/A * Draws as much of the specified image as is currently available. 0N/A * The image is drawn with its top-left corner at 0N/A * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 0N/A * space. Transparent pixels in the image do not affect whatever 0N/A * pixels are already there. 0N/A * This method returns immediately in all cases, even if the 0N/A * complete image has not yet been loaded, and it has not been dithered 0N/A * and converted for the current output device. 0N/A * If the image has not yet been completely loaded, then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the specified image observer. 0N/A * @param img the specified image to be drawn. 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @param observer object to be notified as more of 0N/A * the image is converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A * Draws as much of the specified image as has already been scaled 0N/A * to fit inside the specified rectangle. 0N/A * The image is drawn inside the specified rectangle of this 0N/A * graphics context's coordinate space, and is scaled if 0N/A * necessary. Transparent pixels do not affect whatever pixels 0N/A * are already there. 0N/A * This method returns immediately in all cases, even if the 0N/A * entire image has not yet been scaled, dithered, and converted 0N/A * for the current output device. 0N/A * If the current output representation is not yet complete, then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the image observer by calling its <code>imageUpdate</code> method. 0N/A * A scaled version of an image will not necessarily be 0N/A * available immediately just because an unscaled version of the 0N/A * image has been constructed for this output device. Each size of 0N/A * the image may be cached separately and generated from the original 0N/A * data in a separate image production sequence. 0N/A * @param img the specified image to be drawn. 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @param width the width of the rectangle. 0N/A * @param height the height of the rectangle. 0N/A * @param observer object to be notified as more of 0N/A * the image is converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A * Draws as much of the specified image as is currently available. 0N/A * The image is drawn with its top-left corner at 0N/A * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 0N/A * space. Transparent pixels are drawn in the specified 0N/A * This operation is equivalent to filling a rectangle of the 0N/A * width and height of the specified image with the given color and then 0N/A * drawing the image on top of it, but possibly more efficient. 0N/A * This method returns immediately in all cases, even if the 0N/A * complete image has not yet been loaded, and it has not been dithered 0N/A * and converted for the current output device. 0N/A * If the image has not yet been completely loaded, then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the specified image observer. 0N/A * @param img the specified image to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @param bgcolor the background color to paint under the 0N/A * non-opaque portions of the image. 0N/A * In this WPathGraphics implementation, 0N/A * this parameter can be null in which 0N/A * case that background is made a transparent 0N/A * @param observer object to be notified as more of 0N/A * the image is converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A * Draws as much of the specified image as has already been scaled 0N/A * to fit inside the specified rectangle. 0N/A * The image is drawn inside the specified rectangle of this 0N/A * graphics context's coordinate space, and is scaled if 0N/A * necessary. Transparent pixels are drawn in the specified 0N/A * This operation is equivalent to filling a rectangle of the 0N/A * width and height of the specified image with the given color and then 0N/A * drawing the image on top of it, but possibly more efficient. 0N/A * This method returns immediately in all cases, even if the 0N/A * entire image has not yet been scaled, dithered, and converted 0N/A * for the current output device. 0N/A * If the current output representation is not yet complete then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the specified image observer. 0N/A * A scaled version of an image will not necessarily be 0N/A * available immediately just because an unscaled version of the 0N/A * image has been constructed for this output device. Each size of 0N/A * the image may be cached separately and generated from the original 0N/A * data in a separate image production sequence. 0N/A * @param img the specified image to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param x the <i>x</i> coordinate. 0N/A * @param y the <i>y</i> coordinate. 0N/A * @param width the width of the rectangle. 0N/A * @param height the height of the rectangle. 0N/A * @param bgcolor the background color to paint under the 0N/A * non-opaque portions of the image. 0N/A * @param observer object to be notified as more of 0N/A * the image is converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A * Draws as much of the specified area of the specified image as is 0N/A * currently available, scaling it on the fly to fit inside the 0N/A * specified area of the destination drawable surface. Transparent pixels 0N/A * do not affect whatever pixels are already there. 0N/A * This method returns immediately in all cases, even if the 0N/A * image area to be drawn has not yet been scaled, dithered, and converted 0N/A * for the current output device. 0N/A * If the current output representation is not yet complete then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the specified image observer. 0N/A * This method always uses the unscaled version of the image 0N/A * to render the scaled rectangle and performs the required 0N/A * scaling on the fly. It does not use a cached, scaled version 0N/A * of the image for this operation. Scaling of the image from source 0N/A * to destination is performed such that the first coordinate 0N/A * of the source rectangle is mapped to the first coordinate of 0N/A * the destination rectangle, and the second source coordinate is 0N/A * mapped to the second destination coordinate. The subimage is 0N/A * scaled and flipped as needed to preserve those mappings. 0N/A * @param img the specified image to be drawn 0N/A * @param dx1 the <i>x</i> coordinate of the first corner of the 0N/A * destination rectangle. 0N/A * @param dy1 the <i>y</i> coordinate of the first corner of the 0N/A * destination rectangle. 0N/A * @param dx2 the <i>x</i> coordinate of the second corner of the 0N/A * destination rectangle. 0N/A * @param dy2 the <i>y</i> coordinate of the second corner of the 0N/A * destination rectangle. 0N/A * @param sx1 the <i>x</i> coordinate of the first corner of the 0N/A * @param sy1 the <i>y</i> coordinate of the first corner of the 0N/A * @param sx2 the <i>x</i> coordinate of the second corner of the 0N/A * @param sy2 the <i>y</i> coordinate of the second corner of the 0N/A * @param observer object to be notified as more of the image is 0N/A * scaled and converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A * Draws as much of the specified area of the specified image as is 0N/A * currently available, scaling it on the fly to fit inside the 0N/A * specified area of the destination drawable surface. 0N/A * Transparent pixels are drawn in the specified background color. 0N/A * This operation is equivalent to filling a rectangle of the 0N/A * width and height of the specified image with the given color and then 0N/A * drawing the image on top of it, but possibly more efficient. 0N/A * This method returns immediately in all cases, even if the 0N/A * image area to be drawn has not yet been scaled, dithered, and converted 0N/A * for the current output device. 0N/A * If the current output representation is not yet complete then 0N/A * <code>drawImage</code> returns <code>false</code>. As more of 0N/A * the image becomes available, the process that draws the image notifies 0N/A * the specified image observer. 0N/A * This method always uses the unscaled version of the image 0N/A * to render the scaled rectangle and performs the required 0N/A * scaling on the fly. It does not use a cached, scaled version 0N/A * of the image for this operation. Scaling of the image from source 0N/A * to destination is performed such that the first coordinate 0N/A * of the source rectangle is mapped to the first coordinate of 0N/A * the destination rectangle, and the second source coordinate is 0N/A * mapped to the second destination coordinate. The subimage is 0N/A * scaled and flipped as needed to preserve those mappings. 0N/A * @param img the specified image to be drawn 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param dx1 the <i>x</i> coordinate of the first corner of the 0N/A * destination rectangle. 0N/A * @param dy1 the <i>y</i> coordinate of the first corner of the 0N/A * destination rectangle. 0N/A * @param dx2 the <i>x</i> coordinate of the second corner of the 0N/A * destination rectangle. 0N/A * @param dy2 the <i>y</i> coordinate of the second corner of the 0N/A * destination rectangle. 0N/A * @param sx1 the <i>x</i> coordinate of the first corner of the 0N/A * @param sy1 the <i>y</i> coordinate of the first corner of the 0N/A * @param sx2 the <i>x</i> coordinate of the second corner of the 0N/A * @param sy2 the <i>y</i> coordinate of the second corner of the 0N/A * @param bgcolor the background color to paint under the 0N/A * non-opaque portions of the image. 0N/A * @param observer object to be notified as more of the image is 0N/A * scaled and converted. 0N/A * @see java.awt.Image 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A /* Create a transform which describes the changes 0N/A * from the source coordinates to the destination 0N/A * coordinates. The scaling is determined by the 0N/A * ratio of the two rectangles, while the translation 0N/A * comes from the difference of their origins. 0N/A /* drawImageToPlatform needs the top-left of the source area and 0N/A * a positive width and height. The xform describes how to map 0N/A * src->dest, so that information is not lost. 0N/A /* if src area is beyond the bounds of the image, we must clip it. 0N/A * The transform is based on the specified area, not the clipped one. 0N/A if (
sx2 <
0) {
// empty srcArea, nothing to draw 0N/A if (
sy2 <
0) {
// empty srcArea 0N/A * Draws an image, applying a transform from image space into user space 0N/A * The transformation from user space into device space is done with 0N/A * the current transform in the Graphics2D. 0N/A * The given transformation is applied to the image before the 0N/A * transform attribute in the Graphics2D state is applied. 0N/A * The rendering attributes applied include the clip, transform, 0N/A * and composite attributes. Note that the result is 0N/A * undefined, if the given transform is noninvertible. 0N/A * @param img The image to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param xform The transformation from image space into user space. 0N/A * @param obs The image observer to be notified as more of the image 0N/A * @see #setTransform 0N/A * @see #setComposite 0N/A * Draws a BufferedImage that is filtered with a BufferedImageOp. 0N/A * The rendering attributes applied include the clip, transform 0N/A * and composite attributes. This is equivalent to: 0N/A * img1 = op.filter(img, null); 0N/A * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null); 0N/A * @param op The filter to be applied to the image before drawing. 0N/A * @param img The BufferedImage to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param x,y The location in user space where the image should be drawn. 0N/A * @see #setTransform 0N/A * @see #setComposite 0N/A * Draws an image, applying a transform from image space into user space 0N/A * The transformation from user space into device space is done with 0N/A * the current transform in the Graphics2D. 0N/A * The given transformation is applied to the image before the 0N/A * transform attribute in the Graphics2D state is applied. 0N/A * The rendering attributes applied include the clip, transform, 0N/A * and composite attributes. Note that the result is 0N/A * undefined, if the given transform is noninvertible. 0N/A * @param img The image to be drawn. 0N/A * This method does nothing if <code>img</code> is null. 0N/A * @param xform The transformation from image space into user space. 0N/A * @see #setTransform 0N/A * @see #setComposite