JAVA Radar Scan Map __java

Source: Internet
Author: User
Tags radar

Above, on the code



Package demo;
Import Java.awt.AlphaComposite;
Import Java.awt.Color;
Import Java.awt.Composite;
Import java.awt.Dimension;
Import Java.awt.Graphics;
Import Java.awt.Graphics2D;
Import java.awt.RenderingHints;
Import Java.awt.geom.Arc2D;

Import Java.awt.geom.Ellipse2D;
Import javax.swing.JComponent;

Import Javax.swing.JFrame;

Import Blade.paint.FanShapedGradientPaint; /** * * @author Administrator */public class Radardemo extends JComponent {public static void main (String argv
		[]) {JFrame frame = new JFrame ();
		Frame.setcontentpane (New Radardemo ());
		Frame.setsize (800, 600);
		Frame.setdefaultcloseoperation (Jframe.exit_on_close);
	Frame.setvisible (TRUE);
		@Override public void Paintcomponent (Graphics g) {graphics2d g2d = (graphics2d) g;
		G2d.setrenderinghint (renderinghints.key_antialiasing, renderinghints.value_antialias_on);
		Paintbackground (g);
		Paintradarring (g);
	Paintfanshapedgradient (g); } protected void Paintbackground (Graphics g) {G.setcoloR (Color.Black);
	G.fillrect (0, 0, this.getwidth (), This.getheight ());
		} protected void Paintradarring (Graphics g) {graphics2d g2d = (graphics2d) g;
		G.setcolor (Color.green);
		Dimension d = this.getsize ();

		Double radius = math.min (d.width, d.height)/2;
			for (int r = 1; r <= 5; r++) {Double R = R * RADIUS/5;
			Double x = D.WIDTH/2-R;
			Double y = d.height/2-R;
			ellipse2d ellipse = new Ellipse2d.double (x, Y, R * 2, R * 2);
		G2d.draw (ellipse);
		} protected void Paintfanshapedgradient (Graphics g) {graphics2d g2d = (graphics2d) g;
		Composite Oldcomp = G2d.getcomposite ();
		Alphacomposite comp = alphacomposite.getinstance (3, 0.5f);

		G2d.setcomposite (comp);
		Dimension d = this.getsize ();
		Double radius = math.min (d.width, d.height)/2;
		Double x = (D.width-radius * 2)/2;

		Double y = (D.height-radius * 2)/2; Fanshapedgradientpaint paint = new Fanshapedgradientpaint (x, Y, MATH.PI/2, MATH.PI/2, radius, Color.green, color.black);

		G2d.setpaint (paint);
		arc2d arc = new arc2d.double (x, y, Radius * 2, RADIUS * 2, N, Arc2d.pie);

		G2d.fill (ARC);
	G2d.setcomposite (Oldcomp);
 }
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.