X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FPersonRightPanel.java;h=f56b32db4dd1cbeff9cf50dbd365cdcad9b7ce11;hb=e16e3b1587a729dd1e2d39bd4426831136376aa7;hp=28099b249fcfb0e1d61f99458a2fb94ed000183e;hpb=7add5cb9b2213df01b559a59f39b033e27f50e72;p=Persons_Comparator.git diff --git a/src/PersonRightPanel.java b/src/PersonRightPanel.java index 28099b2..f56b32d 100644 --- a/src/PersonRightPanel.java +++ b/src/PersonRightPanel.java @@ -15,7 +15,7 @@ public class PersonRightPanel extends JPanel { try { this.personImage = ImageIO.read(new File("data/personImage.png")); } catch (IOException e) { - System.out.println(e.getStackTrace()); + e.printStackTrace(); } } @@ -27,19 +27,29 @@ public class PersonRightPanel extends JPanel { return contentText; } - public Image getPersonImage() { - return personImage; - } + //FIXME: redraw on resizing + /*@Override + public void paint(Graphics g) { + super.paint(g); + drawPerson(); + }*/ - public void paintComponent(Graphics g) { - super.paintComponent(g); + public void drawPerson(Person personObj) { + Graphics g = this.getGraphics(); + g.clearRect(0, 25, getWidth(), getHeight()); // 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); + // Eyes + g2d.setColor(personObj.getEye().getColor()); + g2d.fillOval(50, 50, 6, 3); + g2d.fillOval(62, 50, 6, 3); + // Weigth + g2d.setColor(Color.black); + g2d.fillOval(44, 76, 30, (personObj.getWeight().getWeight() * 20) / 600); } }