Esempio n. 1
0
 @Override
 public void paintComponent(Graphics g) {
   if (slices != null && !slices.isEmpty()) {
     Arc2D arc2D = null;
     double start = 0;
     int size = Math.min(getWidth(), getHeight()) - 10;
     int x = getWidth() / 2 - size / 2;
     int y = getHeight() / 2 - size / 2;
     if (g instanceof Graphics2D) {
       arc2D = new Arc2D.Double(Arc2D.PIE);
       arc2D.setFrame(x, y, size, size);
       ((Graphics2D) g)
           .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     }
     for (PieSlice slice : slices) {
       double arc = (slice.cost / total) * 360.0;
       if (g instanceof Graphics2D) {
         arc2D.setAngleStart(start);
         arc2D.setAngleExtent(arc);
         Color c = ScenarioColorPalette.getColor(slice.toString());
         g.setColor(slice.equals(highlighted) ? c.brighter() : c);
         ((Graphics2D) g).fill(arc2D);
         g.setColor(Color.BLACK);
         ((Graphics2D) g).draw(arc2D);
       } else {
         g.setColor(ScenarioColorPalette.getColor(slice.toString()));
         g.fillArc(x, y, size, size, (int) start, (int) arc);
         g.setColor(Color.BLACK);
         g.drawArc(x, y, size, size, (int) start, (int) arc);
       }
       start += arc;
     }
     g.setColor(ScenarioColorPalette.getColor("Untagged"));
     g.fillArc(x, y, size, size, (int) start, (int) (360.0 - start));
   }
 }
Esempio n. 2
0
 public LegendIcon(TagSet tagSet) {
   this.tagSet = tagSet;
   this.color = ScenarioColorPalette.getColor(tagSet.toString());
 }