source: src/main/java/bargainingchips/etc/PortfolioDrawing.java@ 343

Last change on this file since 343 was 316, checked in by Tim Baarslag, 5 years ago

new packages complete

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