Only draw eyes on selection and the full closest person on validation.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 17 Jan 2019 10:43:00 +0000 (11:43 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 17 Jan 2019 10:43:00 +0000 (11:43 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/EyeView.java
src/PersonLeftPanel.java
src/PersonRightPanel.java
src/PersonView.java

index bc1b89b85665413e51de38360592ba3ede4637f8..48ad0b5636d36d28b8f1cbaa9565d19e7b0d905d 100644 (file)
@@ -48,6 +48,7 @@ public class EyeView extends JPanel implements ListSelectionListener {
     public void valueChanged(ListSelectionEvent listSelectionEvent) {
         Eye currentEye = new Eye((String) getColorsList().getSelectedValue());
         PersonLeftPanel personLeftPanel = MainWindowsView.getInstance().getCurrentPersonView().getPersonPanel().getLeftPanel();
+        personLeftPanel.drawEyes(currentEye.getColor());
     }
 
     private static class EyeCellRenderer extends DefaultListCellRenderer {
index a7022fb9460de77364a9016d7797982768ec164d..e5892a63a32642e94dcf01cd5e3b6b121c22dcae 100644 (file)
@@ -22,10 +22,16 @@ public class PersonLeftPanel extends JPanel {
         super.paintComponent(g);
 
         // Draw
-        g.setColor(Color.black);
         Graphics2D g2d = (Graphics2D) g;
         int imageWidth = 120;
         int imageHeight = 180;
         g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
     }
+
+    public void drawEyes(Color color) {
+        Graphics g = this.getGraphics();
+        g.setColor(color);
+        g.fillOval(50, 50, 6, 3);
+        g.fillOval(62, 50, 6, 3);
+    }
 }
index 28099b249fcfb0e1d61f99458a2fb94ed000183e..0cf73436b5c8090f9ec1d84f1697a703ed6e356b 100644 (file)
@@ -31,15 +31,17 @@ public class PersonRightPanel extends JPanel {
         return personImage;
     }
 
-    public void paintComponent(Graphics g) {
-        super.paintComponent(g);
+    public void drawPerson(Person personObj) {
+        Graphics g = this.getGraphics();
 
         // Draw
-        g.setColor(Color.black);
-        g.drawString(getContentText(), 5, 35);
+        g.drawString(getContentText(), 12, 35);
         Graphics2D g2d = (Graphics2D) g;
         int imageWidth = 120;
         int imageHeight = 180;
         g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
+        g.setColor(personObj.getEye().getColor());
+        g.fillOval(50, 50, 6, 3);
+        g.fillOval(62, 50, 6, 3);
     }
 }
index b583cd5a9a499cbfcf1d51c25de9243652dce28d..1998cece9e3afdbc071b6de389bba316eb06e397 100644 (file)
@@ -183,6 +183,7 @@ public class PersonView extends JComponent implements ActionListener {
             //Utils.displayArrayList(personArrayList);
             Person closestPerson = personArrayList.get(personArrayList.indexOf(this.getPersonObj()) + 1);
             personPanel.setRightContentText(closestPerson.getFirstname().getFirstname() + " at distance " + closestPerson.getDistanceFromReference());
+            personPanel.getRightPanel().drawPerson(closestPerson);
         }
     }
 }