private int width = 400;
private int height = 600;
private Person personObj;
+ private ArrayList<Person> personArrayList;
private FirstnameView firstnameView;
private OriginView originView;
private SizeView sizeView;
/*private ImageIcon originImage;
private ImageIcon personImage;*/
- PersonView(Person personObj) {
+ PersonView(Person personObj, ArrayList<Person> personArrayList) {
setPersonObj(personObj);
setFirstnameView(new FirstnameView(15, this.personObj.getFirstname()));
setOriginView(new OriginView(this.personObj.getOrigin()));
setSizeView(new SizeView(this.personObj.getPersonSize()));
setWeightView(new WeightView(this.personObj.getWeight()));
setEyeView(new EyeView(this.personObj.getEye()));
+ setPersonArrayList(personArrayList);
this.compareButton.addActionListener(this);
JLabel personLabel = new JLabel("Closest person found");
this.weightView = weightView;
}
+ /**
+ * @return
+ */
+ public EyeView getEyeView() {
+ return eyeView;
+ }
+
/**
* @param eyeView
*/
this.eyeView = eyeView;
}
- /**
- * @return
- */
- public EyeView getEyeView() {
- return eyeView;
+ public ArrayList<Person> getPersonArrayList() {
+ return personArrayList;
+ }
+
+ public void setPersonArrayList(ArrayList<Person> personArrayList) {
+ this.personArrayList = personArrayList;
}
@Override
this.getPersonObj().setPersonSize(new Size(size));
this.getPersonObj().setWeight(new Weight(weight));
this.getPersonObj().setEye(new Eye(eye_color));
- //this.getPersonObj().displayPersonArrayList();
- ArrayList<Person> personArrayList = this.getPersonObj().getPersonArrayList();
- personArrayList.add(this.getPersonObj());
- this.getPersonObj().displayArrayList(personArrayList);
+ ArrayList<Person> personArrayList = this.getPersonArrayList();
+ //Utils.displayArrayList(personArrayList);
+ Utils.computeDistanceFrom(getPersonObj(), personArrayList);
personArrayList.sort(getPersonObj());
- this.getPersonObj().displayArrayList(personArrayList);
- Integer previousPersonIndex = personArrayList.indexOf(this.getPersonObj()) - 1;
- Integer nextPersonIndex = personArrayList.indexOf(this.getPersonObj()) + 1;
- //Person previousPerson = personArrayList.get(personArrayList.indexOf(this.getPersonObj()) - 1);
- //Person nextPerson = personArrayList.get(personArrayList.indexOf(this.getPersonObj()) + 1);
- System.out.println(previousPersonIndex);
- System.out.println(nextPersonIndex);
+ //Utils.displayArrayList(personArrayList);
+ Person closestPerson = personArrayList.get(personArrayList.indexOf(this.getPersonObj()) + 1);
+ JLabel closestPersonLabel = new JLabel();
+ closestPersonLabel.setText(closestPerson.toString());
+ this.personPanel.add(closestPersonLabel);
}
}
}