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