1 | package negotiator.onetomany.etc;
|
---|
2 | import java.awt.Canvas;
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.Graphics;
|
---|
5 | import javax.swing.JFrame;
|
---|
6 |
|
---|
7 | import negotiator.onetomany.DemandPlan;
|
---|
8 | import negotiator.onetomany.Portfolio;
|
---|
9 | import negotiator.onetomany.Product;
|
---|
10 |
|
---|
11 | public class Drawing extends Canvas
|
---|
12 | {
|
---|
13 | Portfolio p;
|
---|
14 |
|
---|
15 | public Drawing(Portfolio p2)
|
---|
16 | {
|
---|
17 | p = p2;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public void paint(Graphics g)
|
---|
21 | {
|
---|
22 | int x = g.getClipBounds().x+ g.getClipBounds().width/3; // 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
|
---|
23 | for (Product product : p.getPortfolio())
|
---|
24 | {
|
---|
25 | g.setColor(product.getColor());
|
---|
26 | g.fillOval(x, 100, 20, 20); // it also need to became dynamic
|
---|
27 | x += 50;
|
---|
28 | }
|
---|
29 | //simpleFill(g, p);
|
---|
30 | //ComplexFill(g);
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | // public Drawing(DemandPlan p2)
|
---|
35 | // {
|
---|
36 | // p = p2.get;
|
---|
37 | // }
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 | // private void simpleFill(Graphics g, Portfolio port)
|
---|
42 | // {
|
---|
43 | // for (Product product : port.getPortfolio())
|
---|
44 | // {
|
---|
45 | // g.setColor(product.getColor());
|
---|
46 | // int x = g.getClipBounds().x+ g.getClipBounds().width/3; // 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
|
---|
47 | // g.fillOval(x, 100, 20, 20); // it also need to became dynamic
|
---|
48 | // x += 50;
|
---|
49 | // }
|
---|
50 | // }
|
---|
51 | //
|
---|
52 | // private void ComplexFill(Graphics g) {
|
---|
53 | // // TODO Auto-generated method stub
|
---|
54 | //
|
---|
55 | // }
|
---|
56 | } |
---|