Only draw eyes on selection and the full closest person on validation.
[Persons_Comparator.git] / src / PersonRightPanel.java
CommitLineData
255d3354
JB
1import javax.imageio.ImageIO;
2import javax.swing.*;
3import java.awt.*;
4import java.io.File;
5import java.io.IOException;
6
7add5cb9 7public class PersonRightPanel extends JPanel {
255d3354
JB
8 private JLabel rightLabel = new JLabel();
9 private String contentText = new String();
10 private Image personImage;
11
7add5cb9 12 PersonRightPanel() {
255d3354
JB
13 rightLabel.setText("Closest person found");
14 add(rightLabel);
15 try {
16 this.personImage = ImageIO.read(new File("data/personImage.png"));
17 } catch (IOException e) {
18 System.out.println(e.getStackTrace());
19 }
20 }
21
22 public void setContentText(String contentText) {
23 this.contentText = contentText;
24 }
25
26 public String getContentText() {
27 return contentText;
28 }
29
30 public Image getPersonImage() {
31 return personImage;
32 }
33
d418dae1
JB
34 public void drawPerson(Person personObj) {
35 Graphics g = this.getGraphics();
255d3354
JB
36
37 // Draw
d418dae1 38 g.drawString(getContentText(), 12, 35);
255d3354
JB
39 Graphics2D g2d = (Graphics2D) g;
40 int imageWidth = 120;
41 int imageHeight = 180;
42 g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
d418dae1
JB
43 g.setColor(personObj.getEye().getColor());
44 g.fillOval(50, 50, 6, 3);
45 g.fillOval(62, 50, 6, 3);
255d3354
JB
46 }
47}