ppgraphics2d.java
来自「EXCEL read and write」· Java 代码 · 共 1,499 行 · 第 1/5 页
JAVA
1,499 行
* Fills the interior of a <code>Shape</code> using the settings of the * <code>Graphics2D</code> context. The rendering attributes applied * include the <code>Clip</code>, <code>Transform</code>, * <code>Paint</code>, and <code>Composite</code>. * @param shape the <code>Shape</code> to be filled * @see #setPaint * @see java.awt.Graphics#setColor * @see #transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip */ public void fill(Shape shape){ GeneralPath path = new GeneralPath(transform.createTransformedShape(shape)); Freeform p = new Freeform(group); p.setPath(path); applyPaint(p); p.setLineColor(null); //Fills must be "No Line" group.addShape(p); } /** * Translates the origin of the graphics context to the point * (<i>x</i>, <i>y</i>) in the current coordinate system. * Modifies this graphics context so that its new origin corresponds * to the point (<i>x</i>, <i>y</i>) in this graphics context's * original coordinate system. All coordinates used in subsequent * rendering operations on this graphics context will be relative * to this new origin. * @param x the <i>x</i> coordinate. * @param y the <i>y</i> coordinate. */ public void translate(int x, int y){ transform.translate(x, y); } /** * Intersects the current <code>Clip</code> with the interior of the * specified <code>Shape</code> and sets the <code>Clip</code> to the * resulting intersection. The specified <code>Shape</code> is * transformed with the current <code>Graphics2D</code> * <code>Transform</code> before being intersected with the current * <code>Clip</code>. This method is used to make the current * <code>Clip</code> smaller. * To make the <code>Clip</code> larger, use <code>setClip</code>. * The <i>user clip</i> modified by this method is independent of the * clipping associated with device bounds and visibility. If no clip has * previously been set, or if the clip has been cleared using * {@link java.awt.Graphics#setClip(Shape) setClip} with a * <code>null</code> argument, the specified <code>Shape</code> becomes * the new user clip. * @param s the <code>Shape</code> to be intersected with the current * <code>Clip</code>. If <code>s</code> is <code>null</code>, * this method clears the current <code>Clip</code>. */ public void clip(Shape s){ log.log(POILogger.WARN, "Not implemented"); } /** * Gets the current clipping area. * This method returns the user clip, which is independent of the * clipping associated with device bounds and window visibility. * If no clip has previously been set, or if the clip has been * cleared using <code>setClip(null)</code>, this method returns * <code>null</code>. * @return a <code>Shape</code> object representing the * current clipping area, or <code>null</code> if * no clip is set. * @see java.awt.Graphics#getClipBounds() * @see java.awt.Graphics#clipRect * @see java.awt.Graphics#setClip(int, int, int, int) * @see java.awt.Graphics#setClip(Shape) * @since JDK1.1 */ public Shape getClip(){ log.log(POILogger.WARN, "Not implemented"); return null; } /** * Concatenates the current <code>Graphics2D</code> * <code>Transform</code> with a scaling transformation * Subsequent rendering is resized according to the specified scaling * factors relative to the previous scaling. * This is equivalent to calling <code>transform(S)</code>, where S is an * <code>AffineTransform</code> represented by the following matrix: * <pre> * [ sx 0 0 ] * [ 0 sy 0 ] * [ 0 0 1 ] * </pre> * @param sx the amount by which X coordinates in subsequent * rendering operations are multiplied relative to previous * rendering operations. * @param sy the amount by which Y coordinates in subsequent * rendering operations are multiplied relative to previous * rendering operations. */ public void scale(double sx, double sy){ transform.scale(sx, sy); } /** * 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 */ public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight){ RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight); draw(rect); } /** * 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 */ public void drawString(String str, int x, int y){ drawString(str, (float)x, (float)y); } /** * 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 */ public void fillOval(int x, int y, int width, int height){ Ellipse2D oval = new Ellipse2D.Float(x, y, width, height); fill(oval); } /** * 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 */ public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight){ RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight); fill(rect); } /** * 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 */ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle){ Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.PIE); fill(arc); } /** * 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 */ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN); draw(arc); } /** * 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 */ public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints){ if(nPoints > 0){ GeneralPath path = new GeneralPath(); path.moveTo(xPoints[0], yPoints[0]); for(int i=1; i<nPoints; i++) path.lineTo(xPoints[i], yPoints[i]); draw(path); } } /** * 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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?