1 | package negotiator.onetomany;
|
---|
2 |
|
---|
3 | import java.awt.Canvas;
|
---|
4 | import java.awt.Color;
|
---|
5 | import java.awt.Font;
|
---|
6 |
|
---|
7 |
|
---|
8 | import javax.swing.JButton;
|
---|
9 | import javax.swing.JFrame;
|
---|
10 | import javax.swing.JLabel;
|
---|
11 |
|
---|
12 | import negotiator.onetomany.etc.PortfolioDrawing;
|
---|
13 | import negotiator.onetomany.etc.DemandPlanDrawing;
|
---|
14 | import negotiator.onetomany.etc.Line;
|
---|
15 | import negotiator.onetomany.etc.PutImage;
|
---|
16 | import net.miginfocom.swing.MigLayout;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @author Faria Nassiri-Mofakham
|
---|
20 | *
|
---|
21 | */
|
---|
22 | public class GUI extends JFrame
|
---|
23 | {
|
---|
24 | Main main;
|
---|
25 | private static final long serialVersionUID = -5602032021645365870L;
|
---|
26 |
|
---|
27 |
|
---|
28 | public GUI(Main m) //throws MalformedURLException, IOException
|
---|
29 | {
|
---|
30 | super("Bob gets ready for negotiation ...");
|
---|
31 | main = m;
|
---|
32 |
|
---|
33 |
|
---|
34 | // Show the GUI
|
---|
35 | setLayout(new MigLayout("", "", ""));
|
---|
36 |
|
---|
37 | // Could not `resize' and show small CWI-ACUMEX QR-code
|
---|
38 | // Canvas canvas00 = new PutImage("C:\\Users\\fnm\\Pictures\\qr_code.png");
|
---|
39 | // canvas00.setBounds(0,0,50,50);
|
---|
40 | // canvas00.setSize(50, 50);
|
---|
41 | // add(canvas00);
|
---|
42 |
|
---|
43 |
|
---|
44 | // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
|
---|
45 | Canvas canvas0 = new PutImage("C:\\Users\\fnm\\eclipse-workspace\\NegotiatorGUI\\src\\main\\java\\negotiator\\onetomany\\etc\\Bob.png");
|
---|
46 | // Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
|
---|
47 | canvas0.setSize(400, 200);
|
---|
48 | add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
|
---|
49 |
|
---|
50 | //defining a font
|
---|
51 | Font f1 = new Font("TimesRoman",Font.BOLD,20);
|
---|
52 | Font f2 = new Font("TimesRoman",Font.ITALIC,20);
|
---|
53 | Font f3 = new Font("TimesRoman",Font.PLAIN,16);
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | JLabel l1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" differnt products as follows:");
|
---|
58 | l1.setFont(f2);
|
---|
59 | add(l1, "cell 1 1, center, width 100:650:1000, wrap"); // no notice to min and max constraints for column width, just the preferred (the middle number)
|
---|
60 |
|
---|
61 | Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
|
---|
62 | canvas1.setBackground(Color.decode("#5C8585"));
|
---|
63 | canvas1.setSize(200, 200);
|
---|
64 | add(canvas1, "cell 1 2, growx, center, wrap");
|
---|
65 |
|
---|
66 | add(new JLabel(" "), "center, wrap");
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 | //a line
|
---|
72 | int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 | Canvas canvas2 = new Line(Color.BLACK,w);
|
---|
79 | canvas2.setSize(1, 1);
|
---|
80 | add(canvas2, "span 2 0, growx, center, wrap");
|
---|
81 |
|
---|
82 | add(new JLabel(" "), "center, wrap");
|
---|
83 |
|
---|
84 |
|
---|
85 | JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
|
---|
86 | l2.setFont(f1);
|
---|
87 | add(l2, "span 2 0, center, wrap");
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | add(new JLabel(" "), "center, wrap");
|
---|
93 |
|
---|
94 | JLabel n = new JLabel(m.getDemandPlan().toString());
|
---|
95 | n.setFont(f3);
|
---|
96 | add(n, "span 2 0, center, wrap");
|
---|
97 |
|
---|
98 |
|
---|
99 | Canvas canvas3 = new DemandPlanDrawing(m.getDemandPlan());
|
---|
100 | canvas3.setBackground(Color.WHITE);
|
---|
101 | canvas3.setSize(200, 400);
|
---|
102 | add(canvas3, "span 2 0, growx, growy, center, wrap");
|
---|
103 |
|
---|
104 |
|
---|
105 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
106 |
|
---|
107 | //a line
|
---|
108 | Canvas canvas4 = new Line(Color.BLACK,w);
|
---|
109 | canvas4.setSize(1, 1);
|
---|
110 | add(canvas4, "span 2 0, growx, center, wrap");
|
---|
111 |
|
---|
112 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
113 |
|
---|
114 | //buttons
|
---|
115 |
|
---|
116 | add(new JButton("Edit..."), "cell 0 12, span 2 0, center, w 90"); // at dynamic position ? for the height ?! by canvases heights, or counting the rows and columns?
|
---|
117 | add(new JButton("Delete..."), "cell 0 12, span 2 0, center, w 90");
|
---|
118 | add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
|
---|
119 | add(new JButton("Close"), "cell 0 12, span 2 0, center, wrap, w 90");
|
---|
120 |
|
---|
121 | //setting the background as the Bob's image
|
---|
122 | getContentPane().setBackground(Color.decode("#AFD6D6"));
|
---|
123 |
|
---|
124 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
125 | pack();
|
---|
126 |
|
---|
127 | setLocationRelativeTo(null);
|
---|
128 | // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
129 | // setBounds(0,0,screenSize.width, screenSize.height);
|
---|
130 | setVisible(true);
|
---|
131 | }
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * @param args
|
---|
135 | */
|
---|
136 | public static void main(String[] args)
|
---|
137 | {
|
---|
138 | Main main = new Main();
|
---|
139 | GUI gui = new GUI(main);
|
---|
140 |
|
---|
141 | }
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|