/** * 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. */ public void drawLine(int x1, int y1, int x2, int y2){ Line2D line = new Line2D.Double(x1, y1, x2, y2); draw(line); }
/** * 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 */ public void drawRect(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); draw(rect); }
/** * 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 */ public void drawOval(int x, int y, int width, int height){ Ellipse2D oval = new Ellipse2D.Double(x, y, width, height); draw(oval); }
/** * 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(int[],int[],int) * @see java.awt.Graphics#drawPolyline */ public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints){ java.awt.Polygon polygon = new java.awt.Polygon(xPoints, yPoints, nPoints); draw(polygon); }
/** * 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 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.Double(x, y, width, height, arcWidth, arcHeight); draw(rect); }
/** * 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. */ public void drawLine(int x1, int y1, int x2, int y2){ Line2D line = new Line2D.Double(x1, y1, x2, y2); draw(line); }
/** * 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 */ public void drawRect(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); draw(rect); }
/** * 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 */ public void drawOval(int x, int y, int width, int height){ Ellipse2D oval = new Ellipse2D.Double(x, y, width, height); draw(oval); }
/** * 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(int[],int[],int) * @see java.awt.Graphics#drawPolyline */ public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints){ java.awt.Polygon polygon = new java.awt.Polygon(xPoints, yPoints, nPoints); draw(polygon); }
/** * 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 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.Double(x, y, width, height, arcWidth, arcHeight); draw(rect); }