source: src/main/java/negotiator/onetomany/etc/PortfolioDrawing.java@ 244

Last change on this file since 244 was 236, checked in by Faria Nassiri Mofakham, 5 years ago

Bug in classes Chip, Stack and operations, Bundle and operations fixed; they work well. Old versions of aggregation operators and tests copied into an old file.

File size: 1.2 KB
Line 
1package negotiator.onetomany.etc;
2import java.awt.Canvas;
3import java.awt.Graphics;
4
5import negotiator.onetomany.Portfolio;
6import negotiator.onetomany.Product;
7
8
9/** Draws n circles, where n is the number of products in the portfolio.
10 * The circles are spaced apart by....
11 *
12 *
13 *
14 * @author Faria Nassiri-Mofakham
15 *
16 */
17public class PortfolioDrawing extends Canvas
18{
19
20 private static final long serialVersionUID = 1L;
21 Portfolio p;
22
23 public PortfolioDrawing(Portfolio p2)
24 {
25 p = p2;
26 }
27
28 /**
29 * Draws n circles, where n is the number of products in the portfolio.
30 * The circles are spaced apart by....
31 */
32 public void paint(Graphics g)
33 {
34 int z= p.size();
35 int r=30/z;
36 int yOffset=50;
37 int d=(g.getClipBounds().width-z*2*r)/(z+5);
38 int x = g.getClipBounds().x+ d; // it is now aligned, so the result seem be shown at the center!! but replace it with a mathematical formula which aligns it dynamically at the center
39
40 for (Product product : p.getPortfolio())
41 {
42 g.setColor(product.getColor());
43 g.fillOval(x, g.getClipBounds().y+yOffset, 2*r, 2*r); // it also needs to became more dynamic
44 x += d;
45 }
46
47 }
48}
49
Note: See TracBrowser for help on using the repository browser.