/******************************************************************************
* Name: Donna Gabai
* NetID: dgabai
* Precept: P99
*
* Description: A client program for Ngon that reads in Ngons
* from StdIn and draws them in order from biggest area to smallest.
*
* Dependencies: StdDraw, Ngon, StdIn, ST
*
* Remarks: There are many ways to implement the sorting part of this program!
*****************************************************************************/
import java.awt.Color;
public class NgonArt {
// read from standard input values to define Ngons
// store Ngons to draw in order of their areas
public static void main(String[] args) {
// same scale as Ngon
StdDraw.setXscale(-1, 1);
StdDraw.setYscale(-1, 1);
// how many?
int COUNT = StdIn.readInt();
// store Ngons in ST using inverse area as key
ST<Double, Ngon> ngons = new ST<Double, Ngon>();
// read in Ngon info, construct Ngon, put in symbol table
for (int i = 0; i < COUNT; i++) {
int n = StdIn.readInt();
double rad = StdIn.readDouble();
double x = StdIn.readDouble();
double y = StdIn.readDouble();
int r = StdIn.readInt();
int g = StdIn.readInt();
int b = StdIn.readInt();
Color c = new Color(r, g, b);
Ngon ngon = new Ngon(n, rad, x, y, c);
ngons.put(0 - ngon.area(), ngon);
}
// sorting by inverse area means largest will come out first
for (double inverseArea : ngons) {
Ngon ngon = ngons.get(inverseArea);
ngon.drawFilled();
}
// NOTE:
// There were many acceptable solutions for sorting
// the Ngons. For instance, some students read in the
// Ngons into an array and implemented insertion sort.
}
}