public void paintComponent(Graphics A00) { super.paintComponent(A00); Graphics2D L00 = (Graphics2D) A00; L00.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); L00.setColor(I00); L00.fillOval(C02 + C03, C02 + C03, C04, C04); int L01 = 90; // 円グラフの描画開始角度 int L02 = 0; // 扇形の中心角 setRates(); for (Color L03 : I01.keySet()) { L02 = Math.round(360f * I01.get(L03) / I02); L01 -= L02; L00.setColor(L03); L00.fillArc(C02, C02, C04, C04, L01, L02); } // 四捨五入の都合で塗り残しが出た場合の対処 L00.fillArc(C02, C02, C04, C04, -270, L02); L00.setColor(I00); L00.drawOval(C02, C02, C04, C04); }
/** Creates new form CircleGraphPanel */ public PieChart(ControlPanel controlPanel) { this.controlPanel = controlPanel; initComponents(); setBackground(Color.white); setPreferredSize(new Dimension(C00, C01)); I01 = new LinkedHashMap<Color, Integer>(); setRates(); }