-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 PersonLeftPanel leftPanel = new PersonLeftPanel();
+ private PersonRightPanel rightPanel = new PersonRightPanel();
- 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 void setRightContentText(String rightContentText) {
+ this.rightPanel.setContentText(rightContentText);
}
- public String getTitleText() {
- return titleText;
+ public PersonLeftPanel getLeftPanel() {
+ return leftPanel;
}
- 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 PersonRightPanel getRightPanel() {
+ return rightPanel;
}
}