[209] | 1 | package negotiator.onetomany;
|
---|
| 2 |
|
---|
[222] | 3 | import java.awt.BorderLayout;
|
---|
[212] | 4 | import java.awt.Canvas;
|
---|
[218] | 5 | import java.awt.Color;
|
---|
[219] | 6 | import java.awt.Dimension;
|
---|
[221] | 7 | import java.awt.Font;
|
---|
[220] | 8 | import java.awt.Image;
|
---|
[219] | 9 | import java.awt.Toolkit;
|
---|
[218] | 10 |
|
---|
[209] | 11 | import javax.swing.JButton;
|
---|
[219] | 12 | import javax.swing.JComponent;
|
---|
[209] | 13 | import javax.swing.JFrame;
|
---|
| 14 | import javax.swing.JLabel;
|
---|
[219] | 15 | import javax.swing.JPanel;
|
---|
[209] | 16 |
|
---|
[216] | 17 | import negotiator.onetomany.etc.Bob;
|
---|
[222] | 18 | import negotiator.onetomany.etc.Drawing1;
|
---|
[219] | 19 | import negotiator.onetomany.etc.Line;
|
---|
[216] | 20 | //import negotiator.onetomany.etc.Line;
|
---|
[209] | 21 | import net.miginfocom.swing.MigLayout;
|
---|
| 22 |
|
---|
[210] | 23 | /**
|
---|
| 24 | * @author Faria Nassiri-Mofakham
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
[209] | 27 | public class GUI extends JFrame
|
---|
| 28 | {
|
---|
| 29 | Main main;
|
---|
[216] | 30 | private static final long serialVersionUID = -5602032021645365870L;
|
---|
| 31 |
|
---|
[211] | 32 |
|
---|
[216] | 33 | public GUI(Main m) //throws MalformedURLException, IOException
|
---|
[209] | 34 | {
|
---|
[215] | 35 | super("Bob gets ready for negotiation ...");
|
---|
[209] | 36 | main = m;
|
---|
| 37 |
|
---|
[211] | 38 |
|
---|
[209] | 39 | // Show the GUI
|
---|
[215] | 40 | setLayout(new MigLayout("", "", ""));
|
---|
[211] | 41 |
|
---|
[221] | 42 | // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
|
---|
| 43 | Canvas canvas0 = new Bob("C:\\Users\\fnm\\eclipse-workspace\\NegotiatorGUI\\src\\main\\java\\negotiator\\onetomany\\etc\\Bob.png");
|
---|
| 44 | // Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
|
---|
[222] | 45 | canvas0.setSize(400, 200);
|
---|
| 46 | add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
|
---|
| 47 |
|
---|
[221] | 48 | //defining a font
|
---|
| 49 | Font f1 = new Font("TimesRoman",Font.BOLD,20);
|
---|
| 50 | Font f2 = new Font("TimesRoman",Font.ITALIC,20);
|
---|
[215] | 51 |
|
---|
[221] | 52 |
|
---|
[222] | 53 | JLabel l1_1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" differnt products as follows:");
|
---|
[221] | 54 | l1_1.setFont(f2);
|
---|
| 55 | //l1_1.setForeground(Color.GRAY);
|
---|
[222] | 56 | add(l1_1, "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)
|
---|
[216] | 57 |
|
---|
[222] | 58 | Canvas canvas1 = new Drawing1(m.getPortfolio());
|
---|
| 59 | canvas1.setBackground(Color.decode("#5C8585"));
|
---|
[215] | 60 | canvas1.setSize(200, 200);
|
---|
[222] | 61 | add(canvas1, "cell 1 2, growx, center, wrap");
|
---|
[215] | 62 |
|
---|
[222] | 63 | add(new JLabel(" "), "center, wrap");
|
---|
[215] | 64 |
|
---|
[221] | 65 | //a line
|
---|
[222] | 66 | int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
|
---|
| 67 | System.out.println(w);
|
---|
| 68 | Canvas canvas2 = new Line(Color.BLACK,w);
|
---|
[219] | 69 | canvas2.setSize(1, 1);
|
---|
[222] | 70 | add(canvas2, "span 2 0, growx, center, wrap");
|
---|
| 71 |
|
---|
| 72 | add(new JLabel(" "), "center, wrap");
|
---|
| 73 |
|
---|
[219] | 74 |
|
---|
[221] | 75 | JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
|
---|
| 76 | l2.setFont(f1);
|
---|
[222] | 77 | add(l2, "span 2 0, center, wrap");
|
---|
[215] | 78 |
|
---|
[222] | 79 | // Canvas canvas3 = new Drawing(m.getDemandPlan());
|
---|
| 80 | // canvas3.setSize(200, 200);
|
---|
| 81 | // add(canvas3, "center");
|
---|
[215] | 82 |
|
---|
[222] | 83 | add(new JLabel(" "), "center, wrap");
|
---|
[216] | 84 |
|
---|
[222] | 85 | Canvas canvas3 = new Drawing1(m.getPortfolio());
|
---|
| 86 | canvas3.setBackground(Color.WHITE);
|
---|
| 87 | canvas3.setSize(200, 200);
|
---|
| 88 | add(canvas3, "span 2 0, growx, growy, center, wrap");
|
---|
[219] | 89 | //
|
---|
[222] | 90 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
[218] | 91 |
|
---|
[222] | 92 | //a line
|
---|
| 93 | Canvas canvas4 = new Line(Color.BLACK,w);
|
---|
| 94 | canvas4.setSize(1, 1);
|
---|
| 95 | add(canvas4, "span 2 0, growx, center, wrap");
|
---|
| 96 |
|
---|
| 97 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
| 98 |
|
---|
| 99 | //buttons
|
---|
[218] | 100 |
|
---|
[222] | 101 | 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?
|
---|
| 102 | add(new JButton("Delete..."), "cell 0 12, span 2 0, center, w 90");
|
---|
| 103 | add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
|
---|
| 104 | add(new JButton("Close"), "cell 0 12, span 2 0, center, wrap, w 90");
|
---|
[221] | 105 |
|
---|
| 106 | //setting the background as the Bob's image
|
---|
[219] | 107 | getContentPane().setBackground(Color.decode("#AFD6D6"));
|
---|
[221] | 108 |
|
---|
[209] | 109 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
| 110 | pack();
|
---|
[221] | 111 |
|
---|
[209] | 112 | setLocationRelativeTo(null);
|
---|
[219] | 113 | // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
[222] | 114 | // setBounds(0,0,screenSize.width, screenSize.height);
|
---|
[209] | 115 | setVisible(true);
|
---|
| 116 | }
|
---|
[211] | 117 |
|
---|
[210] | 118 | /**
|
---|
| 119 | * @param args
|
---|
| 120 | */
|
---|
[209] | 121 | public static void main(String[] args)
|
---|
| 122 | {
|
---|
| 123 | Main main = new Main();
|
---|
| 124 | GUI gui = new GUI(main);
|
---|
[211] | 125 |
|
---|
[209] | 126 | }
|
---|
| 127 |
|
---|
[216] | 128 | }
|
---|
[211] | 129 |
|
---|
| 130 |
|
---|