1 import javax
.imageio
.ImageIO
;
4 import java
.awt
.geom
.Ellipse2D
;
5 import java
.awt
.geom
.Point2D
;
7 import java
.io
.IOException
;
9 public class PersonPanel
extends JPanel
{
10 private boolean debug
= true;
11 private String titleText
= new String();
12 private JLabel personLabel
= new JLabel();
13 private String contentText
= new String();
14 private Image personImage
;
16 public PersonPanel(String title
) {
18 personLabel
.setText(this.getTitleText());
21 this.personImage
= ImageIO
.read(new File("data/personImage.png"));
22 } catch (IOException e
) {
23 System
.out
.println(e
.getStackTrace());
27 public void setTitleText(String titleText
) {
28 this.titleText
= titleText
;
31 public String
getTitleText() {
35 public void setContentText(String contentText
) {
36 this.contentText
= contentText
;
39 public String
getContentText() {
43 public void paintComponent(Graphics g
) {
44 super.paintComponent(g
);
47 g
.setColor(Color
.black
);
50 g
.drawString(this.getContentText(), 5, 35);
51 Graphics2D g2d
= (Graphics2D
) g
;
52 g2d
.drawImage(this.personImage
.getScaledInstance(getWidth() / 2, getHeight() / 2, Image
.SCALE_SMOOTH
), getWidth() / 4, getHeight() / 4, this);
55 private static Ellipse2D
getCircleByCenter(Point2D center
, double radius
) {
56 Ellipse2D
.Double myCircle
= new Ellipse2D
.Double(center
.getX() - radius
, center
.getY() - radius
, 2 * radius
, 2 * radius
);