source: src/main/java/onetomany/etc/GUI.java@ 267

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

Packages cleanup

File size: 5.5 KB
Line 
1package onetomany.etc;
2
3import java.awt.Canvas;
4import java.awt.Color;
5import java.awt.Dimension;
6import java.awt.Font;
7import java.awt.Toolkit;
8import java.awt.image.BufferedImage;
9
10import javax.swing.BorderFactory;
11import javax.swing.JButton;
12import javax.swing.JFrame;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15
16import onetomany.etc.CloseButtonListener;
17import net.miginfocom.swing.MigLayout;
18
19/**
20 * @author Faria Nassiri-Mofakham
21 *
22 */
23public class GUI extends JFrame
24{
25 Main main;
26 private static final long serialVersionUID = -5602032021645365870L;
27
28
29 public GUI(Main m) //throws MalformedURLException, IOException
30 {
31 super("Bob gets ready for negotiation ...");
32 main = m;
33
34
35 // Show the GUI
36 setLayout(new MigLayout("", "", ""));
37
38 // Could not `resize' and show small CWI-ACUMEX QR-code
39// Canvas canvas00 = new PutImage("C:\\Users\\fnm\\Pictures\\qr_code.png");
40// canvas00.setBounds(0,0,50,50);
41// canvas00.setSize(50, 50);
42// add(canvas00);
43
44
45
46
47 // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
48 Canvas canvas0 = new DrawImage("C:\\Users\\fnm\\Pictures\\Bob.png");
49// Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
50 canvas0.setSize(400, 200);
51 add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
52
53 //defining a font
54 Font f1 = new Font("TimesRoman",Font.BOLD,20);
55 Font f2 = new Font("TimesRoman",Font.ITALIC,20);
56 Font f3 = new Font("TimesRoman",Font.PLAIN,16);
57
58
59// JLabel l1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" different products as follows:");
60 JLabel l1 = new JLabel("Bob's PORTFOLIO contains "+m.getPortfolio().size()+" different products as follows:");
61 l1.setFont(f1);
62
63 add(l1, "cell 1 1, center, width 100:550:1000, wrap"); // no notice to min and max constraints for column width, just the preferred (the middle number)
64
65
66 JPanel panel1 = new JPanel();
67 panel1.setForeground(Color.WHITE);
68 panel1.setFont(f3);
69
70 panel1.setBorder(BorderFactory.createTitledBorder("Portfolio"));
71 panel1.setBackground(Color.decode("#5C8585"));
72 Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
73 canvas1.setBackground(Color.decode("#5C8585"));
74 canvas1.setSize(550, 200);
75 panel1.add(canvas1);
76 add(panel1, "cell 1 2, growx, center, wrap");
77
78
79
80// Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
81// canvas1.setBackground(Color.decode("#5C8585"));
82// canvas1.setSize(200, 200);
83// add(canvas1, "cell 1 2, growx, center, wrap");
84
85 add(new JLabel(" "), "center, wrap");
86
87
88
89
90 //a line
91 int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
92
93
94
95 Canvas canvas2 = new Line(Color.BLACK,w);
96 canvas2.setSize(1, 1);
97 add(canvas2, "span 2 0, growx, center, wrap");
98
99 add(new JLabel(" "), "center, wrap");
100
101
102// JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
103 JLabel l2 = new JLabel("And his DEMAND has been planed as the following quantities:");
104 l2.setFont(f1);
105
106 add(l2, "span 2 0, center, wrap");
107
108
109
110
111 add(new JLabel(" "), "center, wrap");
112
113 JLabel n = new JLabel(m.getDemandPlan().toString());
114 n.setFont(f2);
115 add(n, "span 2 0, center, wrap");
116
117
118 JPanel panel2 = new JPanel();
119 //panel2.setFont(f1);
120 panel2.setBackground(Color.WHITE);
121 panel2.setBorder(BorderFactory.createTitledBorder("Demand Plan"));
122
123
124 //Canvas canvas3 = new DemandPlan(m.getDemandPlan());
125 //canvas3.setBackground(Color.WHITE);
126 //canvas3.setSize(800, 300);
127
128
129 //panel2.add(canvas3);
130 //add(panel2, "span 2 0, growx, growy, center, wrap");
131
132
133
134// Canvas canvas3 = new DemandPlanDrawing(m.getDemandPlan());
135// canvas3.setBackground(Color.WHITE);
136// canvas3.setSize(200, 400);
137// add(canvas3, "span 2 0, growx, growy, center, wrap");
138
139
140
141
142
143 add(new JLabel(" "), "span 2 0, center, wrap");
144
145 //a line
146// Canvas canvas4 = new Line(Color.BLACK,w);
147// canvas4.setSize(1, 1);
148// add(canvas4, "span 2 0, growx, center, wrap");
149
150 add(new JLabel(" "), "span 2 0, center, wrap");
151
152
153
154
155
156 Canvas canvas222 = new Paraboloid(Color.BLACK,w, 0.4, 0.4, 0.4);
157 canvas222.setSize(800, 800);
158 add(canvas222, "span 2 0, growx, center, wrap");
159
160
161
162 //buttons
163
164 JButton a = new JButton("Edit...");
165 add(a, "cell 0 12, span 2 0, center, w 90");
166 // at dynamic position ? for the height ?! by canvases heights, or counting the rows and columns?
167 JButton b = new JButton("Delete...");
168 add(b, "cell 0 12, span 2 0, center, w 90");
169
170 add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
171
172 JButton d = new JButton("Close");
173 d.addActionListener(new CloseButtonListener(this)); // <-- only this was added to this from examples closeButtonListenner and ClosableWindow
174 add(d, "cell 0 12, span 2 0, center, wrap, w 90");
175
176
177 //setting the background as the Bob's image
178 getContentPane().setBackground(Color.decode("#AFD6D6"));
179
180 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
181 pack();
182
183 setLocationRelativeTo(null);
184// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
185// setBounds(0,0,screenSize.width, screenSize.height);
186
187 setVisible(true);
188 }
189
190 /**
191 * @param args
192 */
193 public static void main(String[] args)
194 {
195 Main main = new Main();
196 GUI gui = new GUI(main);
197
198 }
199
200}
201
202
Note: See TracBrowser for help on using the repository browser.