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

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

GUI updated (using Jpanel). DemandPlanDrawing updated. PutImaged renamed to DrawImage. DemandPlan is updating for the Utility, Bid, and Preference classes. Protocol and Agents packages (and some classes) added.

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