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

Last change on this file since 224 was 224, checked in by Faria Nassiri Mofakham, 6 years ago

PortfolioDrawing, DemandPlanDrawing, GUI, and Main updated. DemandPlanDrwaing lists products in multiple rows. Drwaing1, Drawing2, Circle are deleted. Bob name changed to PutImage.

File size: 980 bytes
Line 
1package negotiator.onetomany.etc;
2import java.awt.Canvas;
3import java.awt.Graphics;
4import java.io.FileNotFoundException;
5
6import negotiator.onetomany.Portfolio;
7import negotiator.onetomany.Product;
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 public void paint(Graphics g)
27 {
28 int z= p.size();
29 int r=30/z;
30 int yOffset=50;
31 int d=(g.getClipBounds().width-z*2*r)/(z+5);
32 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
33
34 for (Product product : p.getPortfolio())
35 {
36 g.setColor(product.getColor());
37 g.fillOval(x, g.getClipBounds().y+yOffset, 2*r, 2*r); // it also needs to became dynamic
38 x += d;
39 }
40
41
42
43 }
44}
45
Note: See TracBrowser for help on using the repository browser.