Import java. AWT. dimension;
Import javax. Swing. jpanel;
Import org. jfree. Chart .*;
Import org. jfree. Chart. Plot. pieplot3d;
Import org. jfree. Data. General. defaultpiedataset;
Import org. jfree. Data. General. piedataset;
Import org. jfree. UI. applicationframe;
Import org. jfree. UI. refineryutilities;
Import org. jfree. util. rotation;
Import org. jfree. Chart. Labels. pietooltipgenerator;
Import org. jfree. Chart. Labels. standardpieitemlabelgenerator;
Import org. jfree. Chart. Labels. piesectionlabelgenerator;
Import java. AWT. insets;
Import rewin. Tools. reportstat. pieplot3dcustom;
Import rewin. Tools. reportstat. customlegend;
Public class piecharttest extends applicationframe {
Public piecharttest (string s ){
Super (s );
Piedataset = createdataset ();
Jfreechart freechart = createchart (piedataset );
Chartpanel = new chartpanel (freechart );
Chartpanel. setpreferredsize (new dimension (180,120 ));
Setcontentpane (chartpanel );
}
Private Static piedataset createdataset (){
Defaultpiedataset dataset = new defaultpiedataset ();
System. Out. println ("dataset. getitemcount () =" + dataset. getitemcount ());
// Dataset. setvalue ("Nokia", new double (40 ));
// System. Out. println ("dataset. getitemcount () =" + dataset. getitemcount ());
Dataset. setvalue ("Moto", new double (30 ));
Dataset. setvalue ("Samsung", new double (20 ));
Dataset. setvalue ("Siemens", new double (10 ));
Dataset. setvalue ("waveguide", new double (5 ));
Dataset. setvalue ("Lenovo", new double (5 ));
Dataset. setvalue ("other", new double (5 ));
// Dataset. setvalue ("no complaint", new double (1 ));
System. Out. println ("dataset. getitemcount () =" + dataset. getitemcount ());
Return dataset;
}
Private Static jfreechart createchart (piedataset ){
// Jfreechart freechart = chartfactory. createpiechart3d ("cell phone blacklist", piedataset, true, false, false );
// Jfreechart freechart = chartfactory. createpiechart3d ("", piedataset, true, false, false );
Pieplot3dcustom pieplot3d = new pieplot3dcustom (piedataset );
Int Index = piedataset. getindex ("no complaints ");
System. Out. println ("Index =" + index );
System. Out. println (piedataset. getkey (0 ));
Pieplot3d. setinsets (New insets (0, 0, 0, 0 ));
// Pieplot3d. setsectionpaint (0, new java. AWT. color (0x88eefa ));
Pieplot3d. setsectionpaint (0, new java. AWT. color (0x56d0f5 ));
// Pieplot3d. setsectionpaint (1, new java. AWT. color (0xbeec56 ));
Pieplot3d. setsectionpaint (1, new java. AWT. color (0x51e050 ));
// Pieplot3d. setsectionpaint (2, new java. AWT. color (0 xfacbdb ));
Pieplot3d. setsectionpaint (2, new java. AWT. color (0xe6315c ));
// Pieplot3d. setsectionpaint (3, new java. AWT. color (0xfef29e ));
Pieplot3d. setsectionpaint (3, new java. AWT. color (0xfcc938 ));
// Pieplot3d. setsectionpaint (4, new java. AWT. color (0xfd9bf0 ));
Pieplot3d. setsectionpaint (4, new java. AWT. color (0xed36c2 ));
// Pieplot3d. setsectionpaint (5, java. AWT. color. Orange );
// Pieplot3d. setsectionpaint (6, java. AWT. color. Magenta );
// Pieplot3d. setsectionpaint (7, java. AWT. color. Black );
// Pieplot3d. setsectionpaint (8, java. AWT. color. lightgray );
// Pieplot3d. setsectionpaint (9, java. AWT. color. Red );
// Pieplot3d. setoutlinepaint (Java. AWT. color. White );
If (piedataset. getitemcount () = 1 & piedataset. getindex ("no complaints")> = 0 ){
Pieplot3d. setsectionpaint (0, java. AWT. color. Red );
}
Pieplot3d. setstartangle (60d );
Pieplot3d. setdirection (rotation. Clockwise );
Pieplot3d. setforegroundalpha (0.8f );
Pieplot3d. setnodatamessage ("no data to display ");
Pieplot3d. setlabelgenerator (New customlabelgenerator ());
Pieplot3d. setbackgroundalpha (0f); // sets the background transparency.
Pieplot3d. setoutlinepaint (Java. AWT. color. White); // set the border to white.
Jfreechart freechart = new jfreechart ("", jfreechart. default_title_font, pieplot3d, true );
Freechart. setbackgroundpaint (Java. AWT. color. White );
Freechart. setbordervisible (false); // whether to display the border
Customlegend legend = new customlegend ();
Legend. setanchor (legend. East );
Legend. setoutlinepaint (Java. AWT. color. White); // set the border to white.
Freechart. setlegend (LEGEND );
// Legend = freechart. getlegend ();
// Standardlegend legend = (standardlegend) freechart. getlegend ();
// Legend. setanchor (legend. East );
// Legend. setoutlinepaint (Java. AWT. color. White );
Return freechart;
}
Public static void main (string [] ARGs ){
String STR = "# e6315c ";
String S = Str. substring (1 );
System. Out. println (s );
Int color = integer. parseint (S, 16 );
System. Out. println (color );
Piecharttest = new piecharttest ("piecharttest ");
Piecharttest. Pack ();
Refineryutilities. centerframeonscreen (piecharttest );
Piecharttest. setvisible (true );
}
Static class customlabelgenerator implements piesectionlabelgenerator {
Public String generatesectionlabel (piedataset, comparable ){
Return NULL;
}
Customlabelgenerator (){
}
}
}