Refine the weight max and its drawing.
[Persons_Comparator.git] / src / PersonLeftPanel.java
index e5892a63a32642e94dcf01cd5e3b6b121c22dcae..4c4d9a40203dafb50e32aa9e3eb300baacbb4fa6 100644 (file)
@@ -14,13 +14,11 @@ public class PersonLeftPanel extends JPanel {
         try {
             this.personImage = ImageIO.read(new File("data/personImage.png"));
         } catch (IOException e) {
-            System.out.println(e.getStackTrace());
+            e.printStackTrace();
         }
     }
 
-    public void paintComponent(Graphics g) {
-        super.paintComponent(g);
-
+    private void draw(Graphics g) {
         // Draw
         Graphics2D g2d = (Graphics2D) g;
         int imageWidth = 120;
@@ -28,10 +26,29 @@ public class PersonLeftPanel extends JPanel {
         g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
     }
 
+    @Override
+    public void paintComponent(Graphics g) {
+        super.paintComponent(g);
+        draw(g);
+    }
+
+    //FIXME: redraw on resizing
+    /*@Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        draw(g);
+    }*/
+
     public void drawEyes(Color color) {
         Graphics g = this.getGraphics();
         g.setColor(color);
         g.fillOval(50, 50, 6, 3);
         g.fillOval(62, 50, 6, 3);
     }
+
+    public void drawWeight(int weight) {
+        Graphics g = this.getGraphics();
+        g.setColor(Color.black);
+        g.fillOval(44, 80, 30, (weight * 30) / 250);
+    }
 }