Split the person panel into two sub panels : one for the current person, one for...
[Persons_Comparator.git] / src / PersonPanel.java
index 7c8e2410c386211e68e3495c8995ead56ae3fc11..5b2e190531d076f7176feb09e213f546bc21b3bf 100644 (file)
@@ -1,59 +1,16 @@
-import javax.imageio.ImageIO;
 import javax.swing.*;
-import java.awt.*;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Point2D;
-import java.io.File;
-import java.io.IOException;
 
 public class PersonPanel extends JPanel {
-    private boolean debug = true;
-    private String titleText = new String();
-    private JLabel personLabel = new JLabel();
-    private String contentText = new String();
-    private Image personImage;
+    private LeftPersonPanel leftPanel = new LeftPersonPanel();
+    private RightPersonPanel rightPanel = new RightPersonPanel();
 
-    public PersonPanel(String title) {
-        setTitleText(title);
-        personLabel.setText(this.getTitleText());
-        add(personLabel);
-        try {
-            this.personImage = ImageIO.read(new File("data/personImage.png"));
-        } catch (IOException e) {
-            System.out.println(e.getStackTrace());
-        }
+    public PersonPanel() {
+        setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
+        add(leftPanel);
+        add(rightPanel);
     }
 
-    public void setTitleText(String titleText) {
-        this.titleText = titleText;
-    }
-
-    public String getTitleText() {
-        return titleText;
-    }
-
-    public void setContentText(String contentText) {
-        this.contentText = contentText;
-    }
-
-    public String getContentText() {
-        return contentText;
-    }
-
-    public void paintComponent(Graphics g) {
-        super.paintComponent(g);
-
-        // Draw
-        g.setColor(Color.black);
-        if (debug)
-            // Below the JLabel
-            g.drawString(this.getContentText(), 5, 35);
-        Graphics2D g2d = (Graphics2D) g;
-        g2d.drawImage(this.personImage.getScaledInstance(getWidth() / 2, getHeight() / 2, Image.SCALE_SMOOTH), getWidth() / 4, getHeight() / 4, this);
-    }
-
-    private static Ellipse2D getCircleByCenter(Point2D center, double radius) {
-        Ellipse2D.Double myCircle = new Ellipse2D.Double(center.getX() - radius, center.getY() - radius, 2 * radius, 2 * radius);
-        return myCircle;
+    public void setRightContentText(String rightContentText) {
+        this.rightPanel.setContentText(rightContentText);
     }
 }