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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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