Here you can find the source of raiseOval(Graphics2D g2, Rectangle r, Color foreColor)
Parameter | Description |
---|---|
gr | non-null graphic context |
img | non-null image |
r | non-null rectangle |
obs | non-null observer |
public static void raiseOval(Graphics2D g2, Rectangle r, Color foreColor)
//package com.java2s; //License from project: Apache License import java.awt.*; import java.awt.geom.Ellipse2D; public class Main { /**/*from w w w .j av a2 s .c o m*/ * draw an image in a rectangle * * @param gr non-null graphic context * @param img non-null image * @param r non-null rectangle * @param obs non-null observer */ public static void raiseOval(Graphics2D g2, Rectangle r, Color foreColor) { Color background = g2.getBackground(); Color oldColor = g2.getColor(); Ellipse2D e = new Ellipse2D.Double(r.getX(), r.getY(), r.getWidth(), r.getHeight()); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Paint oldPaint = g2.getPaint(); GradientPaint gp = new GradientPaint(r.x, r.y, foreColor, r.width, r.height, background, true); g2.setPaint(gp); g2.fill(e); g2.setPaint(oldPaint); g2.setColor(oldColor); } }