Split the person panel into two sub panels : one for the current person, one for...
[Persons_Comparator.git] / src / RightPersonPanel.java
diff --git a/src/RightPersonPanel.java b/src/RightPersonPanel.java
new file mode 100644 (file)
index 0000000..2e3460b
--- /dev/null
@@ -0,0 +1,45 @@
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.io.File;
+import java.io.IOException;
+
+public class RightPersonPanel extends JPanel {
+    private JLabel rightLabel = new JLabel();
+    private String contentText = new String();
+    private Image personImage;
+
+    RightPersonPanel() {
+        rightLabel.setText("Closest person found");
+        add(rightLabel);
+        try {
+            this.personImage = ImageIO.read(new File("data/personImage.png"));
+        } catch (IOException e) {
+            System.out.println(e.getStackTrace());
+        }
+    }
+
+    public void setContentText(String contentText) {
+        this.contentText = contentText;
+    }
+
+    public String getContentText() {
+        return contentText;
+    }
+
+    public Image getPersonImage() {
+        return personImage;
+    }
+
+    public void paintComponent(Graphics g) {
+        super.paintComponent(g);
+
+        // Draw
+        g.setColor(Color.black);
+        g.drawString(getContentText(), 5, 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);
+    }
+}