Split the person panel into two sub panels : one for the current person, one for...
[Persons_Comparator.git] / src / PersonView.java
index 6823579d2bc162a43ea1fc6d1b377a1e43c73fe0..b583cd5a9a499cbfcf1d51c25de9243652dce28d 100644 (file)
@@ -5,8 +5,8 @@ import java.awt.event.ActionListener;
 import java.util.ArrayList;
 
 public class PersonView extends JComponent implements ActionListener {
-    private int width = 800;
-    private int height = 500;
+    private int width = 600;
+    private int height = 600;
     private Person personObj;
     private ArrayList<Person> personArrayList;
     private FirstnameView firstnameView;
@@ -18,12 +18,12 @@ public class PersonView extends JComponent implements ActionListener {
     private JPanel southPanel = new JPanel();
     private JPanel eastPanel = new JPanel();
     private JPanel westPanel = new JPanel();
-    private PersonPanel personPanel = new PersonPanel("Person comparison");
+    private PersonPanel personPanel = new PersonPanel();
     private JButton compareButton = new JButton("Compare");
 
     PersonView(Person personObj, ArrayList<Person> personArrayList) {
         setPersonObj(personObj);
-        setFirstnameView(new FirstnameView(15, this.personObj.getFirstname()));
+        setFirstnameView(new FirstnameView(14, this.personObj.getFirstname()));
         setOriginView(new OriginView(this.personObj.getOrigin()));
         setSizeView(new SizeView(this.personObj.getPersonSize()));
         setWeightView(new WeightView(this.personObj.getWeight()));
@@ -35,12 +35,12 @@ public class PersonView extends JComponent implements ActionListener {
         northPanel.add(firstnameView);
         southPanel.setBorder(BorderFactory.createRaisedSoftBevelBorder());
         southPanel.add(compareButton);
-        eastPanel.setLayout(new BoxLayout(this.eastPanel, BoxLayout.Y_AXIS));
+        eastPanel.setLayout(new BoxLayout(this.eastPanel, BoxLayout.PAGE_AXIS));
         eastPanel.setBorder(BorderFactory.createRaisedSoftBevelBorder());
         eastPanel.add(sizeView);
         eastPanel.add(weightView);
         eastPanel.add(eyeView);
-        westPanel.setLayout(new BoxLayout(this.westPanel, BoxLayout.Y_AXIS));
+        westPanel.setLayout(new BoxLayout(this.westPanel, BoxLayout.PAGE_AXIS));
         westPanel.setBorder(BorderFactory.createRaisedSoftBevelBorder());
         westPanel.add(originView);
     }
@@ -182,7 +182,7 @@ public class PersonView extends JComponent implements ActionListener {
             personArrayList.sort(getPersonObj());
             //Utils.displayArrayList(personArrayList);
             Person closestPerson = personArrayList.get(personArrayList.indexOf(this.getPersonObj()) + 1);
-            personPanel.setContentText(closestPerson.toString());
+            personPanel.setRightContentText(closestPerson.getFirstname().getFirstname() + " at distance " + closestPerson.getDistanceFromReference());
         }
     }
 }