From: Jérôme Benoit Date: Thu, 10 Jan 2019 10:47:16 +0000 (+0100) Subject: A lib directory to the project with gson library. X-Git-Url: https://git.piment-noir.org/?p=Persons_Comparator.git;a=commitdiff_plain;h=f1e9d6d2fcc7253b117278c4439b656a1e532e68 A lib directory to the project with gson library. Signed-off-by: Jérôme Benoit --- diff --git a/Persons_Comparator.iml b/Persons_Comparator.iml index 9e63df5..fb8e866 100644 --- a/Persons_Comparator.iml +++ b/Persons_Comparator.iml @@ -7,5 +7,6 @@ + - + \ No newline at end of file diff --git a/lib/gson-2.8.5.jar b/lib/gson-2.8.5.jar new file mode 100644 index 0000000..0d5baf3 Binary files /dev/null and b/lib/gson-2.8.5.jar differ diff --git a/src/Eye.java b/src/Eye.java index a165830..ed2231b 100644 --- a/src/Eye.java +++ b/src/Eye.java @@ -62,7 +62,7 @@ public class Eye implements Comparable { double r_diff = this.getColor().getRed() - eye.getColor().getRed(); double g_diff = this.getColor().getGreen() - eye.getColor().getGreen(); double b_diff = this.getColor().getBlue() - eye.getColor().getBlue(); - // See https://en.wikipedia.org/wiki/Color_difference + //See https://en.wikipedia.org/wiki/Color_difference Double distance = Math.sqrt(2 * Math.pow(r_diff, 2) + 4 * Math.pow(g_diff, 2) + 3 * Math.pow(b_diff, 2)); return distance.intValue(); } diff --git a/src/EyeView.java b/src/EyeView.java index f88e52e..aa54c8b 100644 --- a/src/EyeView.java +++ b/src/EyeView.java @@ -11,6 +11,7 @@ public class EyeView extends JComponent { this.label.setText("Eyes color"); this.colorsList = new JList(getEyeObj().getColorsList()); this.colorsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + this.colorsList.setLayoutOrientation(JList.VERTICAL); add(label); add(colorsList); } diff --git a/src/Main.java b/src/Main.java index 6937e91..77979da 100644 --- a/src/Main.java +++ b/src/Main.java @@ -5,6 +5,12 @@ public class Main { //creating and showing this application's GUI. String programName = "Person Comparator"; + Eye blackEye = new Eye("black"); + Eye greenEye = new Eye("green"); + Eye blueEye = new Eye("blue"); + Eye brownEye = new Eye("brown"); + + //Person person = new Person(); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index bc79511..729a9ad 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -5,6 +5,7 @@ import java.awt.event.ActionListener; import java.util.ArrayList; public class MainWindowsView extends JFrame { + MainWindowsView(String title) { //Create and set up the window. setTitle(title); @@ -56,5 +57,4 @@ public class MainWindowsView extends JFrame { //this.pack(); this.setVisible(true); } - } \ No newline at end of file diff --git a/src/Person.java b/src/Person.java index d1ceb35..3e6788f 100644 --- a/src/Person.java +++ b/src/Person.java @@ -1,3 +1,4 @@ +import java.util.ArrayList; import java.util.Comparator; public class Person implements Comparable, Comparator { @@ -6,6 +7,8 @@ public class Person implements Comparable, Comparator { private Size size; private Weight weight; private Eye eye; + //List of persons in the database to compare to. + private ArrayList personArrayList; Person(Firstname firstname, Origin origin, Size size, Weight weight, Eye eye) { setFirstname(firstname); @@ -55,6 +58,14 @@ public class Person implements Comparable, Comparator { return eye; } + public void setPersonArrayList(ArrayList personArrayList) { + this.personArrayList = personArrayList; + } + + public ArrayList getPersonArrayList() { + return personArrayList; + } + @Override public int compareTo(Person person) { return this.firstname.compareTo(person.getFirstname()) + this.origin.compareTo(person.getOrigin())