[209] | 1 | package negotiator.onetomany;
|
---|
| 2 |
|
---|
[212] | 3 | import java.awt.Canvas;
|
---|
[218] | 4 | import java.awt.Color;
|
---|
[221] | 5 | import java.awt.Font;
|
---|
[218] | 6 |
|
---|
[226] | 7 | import javax.swing.BorderFactory;
|
---|
[209] | 8 | import javax.swing.JButton;
|
---|
| 9 | import javax.swing.JFrame;
|
---|
| 10 | import javax.swing.JLabel;
|
---|
[226] | 11 | import javax.swing.JPanel;
|
---|
[209] | 12 |
|
---|
[224] | 13 | import negotiator.onetomany.etc.PortfolioDrawing;
|
---|
| 14 | import negotiator.onetomany.etc.DemandPlanDrawing;
|
---|
[219] | 15 | import negotiator.onetomany.etc.Line;
|
---|
[226] | 16 | import negotiator.onetomany.etc.DrawImage;
|
---|
[209] | 17 | import net.miginfocom.swing.MigLayout;
|
---|
| 18 |
|
---|
[210] | 19 | /**
|
---|
| 20 | * @author Faria Nassiri-Mofakham
|
---|
| 21 | *
|
---|
| 22 | */
|
---|
[209] | 23 | public class GUI extends JFrame
|
---|
| 24 | {
|
---|
| 25 | Main main;
|
---|
[216] | 26 | private static final long serialVersionUID = -5602032021645365870L;
|
---|
| 27 |
|
---|
[211] | 28 |
|
---|
[216] | 29 | public GUI(Main m) //throws MalformedURLException, IOException
|
---|
[209] | 30 | {
|
---|
[215] | 31 | super("Bob gets ready for negotiation ...");
|
---|
[209] | 32 | main = m;
|
---|
| 33 |
|
---|
[211] | 34 |
|
---|
[209] | 35 | // Show the GUI
|
---|
[215] | 36 | setLayout(new MigLayout("", "", ""));
|
---|
[211] | 37 |
|
---|
[224] | 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 |
|
---|
[221] | 45 | // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
|
---|
[226] | 46 | Canvas canvas0 = new DrawImage("C:\\Users\\fnm\\eclipse-workspace\\NegotiatorGUI\\src\\main\\java\\negotiator\\onetomany\\etc\\Bob.png");
|
---|
[221] | 47 | // Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
|
---|
[225] | 48 | canvas0.setSize(400, 200);
|
---|
[222] | 49 | add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
|
---|
| 50 |
|
---|
[221] | 51 | //defining a font
|
---|
| 52 | Font f1 = new Font("TimesRoman",Font.BOLD,20);
|
---|
| 53 | Font f2 = new Font("TimesRoman",Font.ITALIC,20);
|
---|
[224] | 54 | Font f3 = new Font("TimesRoman",Font.PLAIN,16);
|
---|
[215] | 55 |
|
---|
[226] | 56 |
|
---|
| 57 | // JLabel l1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" different products as follows:");
|
---|
| 58 | JLabel l1 = new JLabel("Bob's PORTFOLIO contains "+m.getPortfolio().size()+" different products as follows:");
|
---|
| 59 | l1.setFont(f1);
|
---|
[224] | 60 |
|
---|
[226] | 61 | 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)
|
---|
| 62 |
|
---|
[221] | 63 |
|
---|
[226] | 64 | JPanel panel1 = new JPanel();
|
---|
| 65 | panel1.setForeground(Color.WHITE);
|
---|
| 66 | panel1.setFont(f3);
|
---|
| 67 |
|
---|
| 68 | panel1.setBorder(BorderFactory.createTitledBorder("Portfolio"));
|
---|
| 69 | panel1.setBackground(Color.decode("#5C8585"));
|
---|
[224] | 70 | Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
|
---|
[222] | 71 | canvas1.setBackground(Color.decode("#5C8585"));
|
---|
[226] | 72 | canvas1.setSize(550, 200);
|
---|
| 73 | panel1.add(canvas1);
|
---|
| 74 | add(panel1, "cell 1 2, growx, center, wrap");
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | // Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
|
---|
| 79 | // canvas1.setBackground(Color.decode("#5C8585"));
|
---|
| 80 | // canvas1.setSize(200, 200);
|
---|
| 81 | // add(canvas1, "cell 1 2, growx, center, wrap");
|
---|
| 82 |
|
---|
[222] | 83 | add(new JLabel(" "), "center, wrap");
|
---|
[215] | 84 |
|
---|
[224] | 85 |
|
---|
[226] | 86 |
|
---|
[224] | 87 |
|
---|
[221] | 88 | //a line
|
---|
[224] | 89 | int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 |
|
---|
[222] | 95 | Canvas canvas2 = new Line(Color.BLACK,w);
|
---|
[219] | 96 | canvas2.setSize(1, 1);
|
---|
[222] | 97 | add(canvas2, "span 2 0, growx, center, wrap");
|
---|
| 98 |
|
---|
| 99 | add(new JLabel(" "), "center, wrap");
|
---|
| 100 |
|
---|
[219] | 101 |
|
---|
[226] | 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:");
|
---|
[221] | 104 | l2.setFont(f1);
|
---|
[226] | 105 |
|
---|
[222] | 106 | add(l2, "span 2 0, center, wrap");
|
---|
[215] | 107 |
|
---|
| 108 |
|
---|
[224] | 109 |
|
---|
| 110 |
|
---|
[222] | 111 | add(new JLabel(" "), "center, wrap");
|
---|
[224] | 112 |
|
---|
| 113 | JLabel n = new JLabel(m.getDemandPlan().toString());
|
---|
[226] | 114 | n.setFont(f2);
|
---|
[224] | 115 | add(n, "span 2 0, center, wrap");
|
---|
[216] | 116 |
|
---|
[226] | 117 |
|
---|
| 118 | JPanel panel2 = new JPanel();
|
---|
| 119 | //panel2.setFont(f1);
|
---|
| 120 | panel2.setBackground(Color.WHITE);
|
---|
| 121 | panel2.setBorder(BorderFactory.createTitledBorder("Demand Plan"));
|
---|
| 122 | Canvas canvas3 = new DemandPlanDrawing(m.getDemandPlan());
|
---|
[222] | 123 | canvas3.setBackground(Color.WHITE);
|
---|
[226] | 124 | canvas3.setSize(800, 300);
|
---|
| 125 | panel2.add(canvas3);
|
---|
| 126 | add(panel2, "span 2 0, growx, growy, center, wrap");
|
---|
[224] | 127 |
|
---|
| 128 |
|
---|
[226] | 129 |
|
---|
| 130 | // Canvas canvas3 = new DemandPlanDrawing(m.getDemandPlan());
|
---|
| 131 | // canvas3.setBackground(Color.WHITE);
|
---|
| 132 | // canvas3.setSize(200, 400);
|
---|
| 133 | // add(canvas3, "span 2 0, growx, growy, center, wrap");
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 |
|
---|
[222] | 139 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
[218] | 140 |
|
---|
[222] | 141 | //a line
|
---|
[226] | 142 | // Canvas canvas4 = new Line(Color.BLACK,w);
|
---|
| 143 | // canvas4.setSize(1, 1);
|
---|
| 144 | // add(canvas4, "span 2 0, growx, center, wrap");
|
---|
[222] | 145 |
|
---|
| 146 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
| 147 |
|
---|
| 148 | //buttons
|
---|
[218] | 149 |
|
---|
[222] | 150 | 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?
|
---|
| 151 | add(new JButton("Delete..."), "cell 0 12, span 2 0, center, w 90");
|
---|
| 152 | add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
|
---|
| 153 | add(new JButton("Close"), "cell 0 12, span 2 0, center, wrap, w 90");
|
---|
[221] | 154 |
|
---|
| 155 | //setting the background as the Bob's image
|
---|
[219] | 156 | getContentPane().setBackground(Color.decode("#AFD6D6"));
|
---|
[221] | 157 |
|
---|
[209] | 158 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
| 159 | pack();
|
---|
[221] | 160 |
|
---|
[209] | 161 | setLocationRelativeTo(null);
|
---|
[219] | 162 | // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
[222] | 163 | // setBounds(0,0,screenSize.width, screenSize.height);
|
---|
[225] | 164 |
|
---|
[209] | 165 | setVisible(true);
|
---|
| 166 | }
|
---|
[211] | 167 |
|
---|
[210] | 168 | /**
|
---|
| 169 | * @param args
|
---|
| 170 | */
|
---|
[209] | 171 | public static void main(String[] args)
|
---|
| 172 | {
|
---|
| 173 | Main main = new Main();
|
---|
| 174 | GUI gui = new GUI(main);
|
---|
[211] | 175 |
|
---|
[209] | 176 | }
|
---|
| 177 |
|
---|
[216] | 178 | }
|
---|
[211] | 179 |
|
---|
| 180 |
|
---|