Is it possible to increase/decrease the diameter of circle

Assignment Help JAVA Programming
Reference no: EM13945020

// Fig. 12.31: Shapes2JPanel.java
// Demonstrating a general path.
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import java.util.Random;
import javax.swing.JPanel;

public class Shapes2JPanel extends JPanel
{
// draw general paths
public void paintComponent( Graphics g )
{
super.paintComponent( g ); // call superclass's paintComponent
Random random = new Random(); // get random number generator

int[] xPoints = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43,56,78,90 };
int[] yPoints = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36,78,68,35 };

Graphics2D g2d = ( Graphics2D ) g;
GeneralPath star = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); // create GeneralPath object

// set the initial coordinate of the General Path
star.moveTo( xPoints[ 9 ], yPoints[ 9 ] );

// create the star--this does not draw the star
for ( int count = 1; count < xPoints.length; count++ )
star.lineTo( xPoints[ count ], yPoints[ count ] );

star.closePath(); // close the shape

g2d.translate( 500, 500 ); // translate the origin to (150, 150)

// rotate around origin and draw stars in random colors
for ( int count = 1; count <= 20; ++count )
{
g2d.rotate( Math.PI / 10.0 ); // rotate coordinate system

// set random drawing color
g2d.setColor( new Color( random.nextInt( 256 ),
random.nextInt( 256 ), random.nextInt( 256 ) ) );

g2d.fill( star ); // draw filled star
} // end for
} // end method paintComponent
} // end class Shapes2JPanel

/**************************************************************************
* (C) Copyright 1992-2012 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/

--------------------------------------------------------------------
---DRIVER---
// Fig. 12.32: Shapes2.java
// Demonstrating a general path.
import java.awt.Color;
import javax.swing.JFrame;

public class Shapes2
{
// execute application
public static void main( String[] args )
{
// create frame for Shapes2JPanel
JFrame frame = new JFrame( "Drawing 2D Shapes" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

Shapes2JPanel shapes2JPanel = new Shapes2JPanel();
frame.add( shapes2JPanel ); // add shapes2JPanel to frame
frame.setBackground( Color.WHITE ); // set frame background color
frame.setSize( 1200, 1000 ); // set frame size
frame.setVisible( true ); // display frame
} // end main
} // end class Shapes2

/**************************************************************************
* (C) Copyright 1992-2012 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *

Reference no: EM13945020

Questions Cloud

Quality specification highlighted by customers : Quality specification highlighted by customers: Firstly we would be resolving delivery time that is 1.5 days than benchmarked date by checking up with delivery driver and managing team also may use express delivery method.
Program that help an elementary school learn multiplication : Computers are playing an increasing role in education. Write a program that will help an elementary school learn multiplication
Identify and describe and segment the market : You are to identify, describe and segment the market and can use whatever information you can gather from sources available from the internet, associations, vendors, customers and regulatory bodies.
Sources of national statistics on crime rates : In the U.S., there are two sources of national statistics on crime rates: (i) the FBI's Uniform Crime Reporting Program, which publishes summaries on all crimes reported to police agencies in jurisdictions covering virtually 100% or the population..
Is it possible to increase/decrease the diameter of circle : GeneralPath star = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); // create GeneralPath object
Problems in investigating system requirements : One of the toughest problems in investigating system requirements is to make sure they are complete and comprehensive.
Confidence interval estimate on the fare : Develop a 94% confidence interval estimate on the fare between the two airports for XYZ. Develop a 98% confidence interval estimate on the fare between the two airports for XYZ.
Presentation about nclex-rn test taking strategies : Make a Powerpoint Presentation about NCLEX-RN TEST TAKING STRATEGIES- Kindly use Kaplan NCLEX_RN Premier 2015-2016 as reference. Add a diagram/figure about the Kaplan Decision tree
What are reasons for defining the importance of the problem : In the problem history phase of policy research, defining the importance of the problem is a critical step. What are the reasons for defining the importance of the problem? What difficulties might arise in the policy project if the importance of t..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Splash page designed for an app called super foods

Splash page designed for an app called Super Foods. Attached is the skeleton app

  Implement the link list using java programming concepts

Modify the class LinkedList by adding to it the following methods. The appropriate error message should be generated if an invalid condition occurs.

  Write a simple application which implements the stockwatcher

Write a simple application which implements the StockWatcher interface (attached file)

  Design and implement a small and simple email server using

design and implement a small and simple email server using the concept of web based information system. your system

  Calculate the area and circumference of a circle

Write a program to move and calculate the area and circumference of a circle. - Calculate function, which passes the radius by value, and get back the area (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference

  Java program asks the user to input the number of gallons

Write a java program asks the user to input the number of gallons of gas in the tank and the price of gas per gallon

  Java socket hello i need to this assignment done in net

hello i need to this assignment done in net beans . and i want comment in code .also screen shots of running program

  Program to find maximum-minimum of sequence of values

Common task which should be done in loop is to find maximum and minimum of sequence of values. File Temps.java contains program which reads in sequence of hourly temperature readings over 24- hour period.

  Eax contains the given contents before the instruction

For each add instruction in this problem, assume that EAX contains the given contents before the instruction is executed, and give the contents of EAX as well as the values of the CF, OF, SF, and ZF flags after the instruction is executed:

  Why do i not create a constructor for an applet

When should one use applets and when should one use servlets? Why do I not create a constructor for an applet? Why doesn't appletviewer appletclass.class work?

  Need a console program

Need a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd