Remove unused library.
[Persons_Comparator.git] / src / PersonLeftPanel.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 PersonLeftPanel extends JPanel {
255d3354
JB
8 private JLabel leftLabel = new JLabel();
9 private Image personImage;
10
7add5cb9 11 PersonLeftPanel() {
255d3354
JB
12 leftLabel.setText("Current person");
13 add(leftLabel);
14 try {
15 this.personImage = ImageIO.read(new File("data/personImage.png"));
16 } catch (IOException e) {
e16e3b15 17 e.printStackTrace();
255d3354
JB
18 }
19 }
20
fcc86ba9 21 private void draw(Graphics g) {
255d3354 22 // Draw
255d3354
JB
23 Graphics2D g2d = (Graphics2D) g;
24 int imageWidth = 120;
25 int imageHeight = 180;
26 g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
27 }
d418dae1 28
fcc86ba9
JB
29 @Override
30 public void paintComponent(Graphics g) {
31 super.paintComponent(g);
32 draw(g);
33 }
34
35 //FIXME: redraw on resizing
36 /*@Override
37 public void paint(Graphics g) {
38 super.paint(g);
39 draw(g);
40 }*/
41
d418dae1
JB
42 public void drawEyes(Color color) {
43 Graphics g = this.getGraphics();
44 g.setColor(color);
45 g.fillOval(50, 50, 6, 3);
46 g.fillOval(62, 50, 6, 3);
47 }
e16e3b15
JB
48
49 public void drawWeight(int weight) {
50 Graphics g = this.getGraphics();
51 g.setColor(Color.black);
dcde664f 52 g.fillOval(44, 80, 30, (weight * 30) / 250);
e16e3b15 53 }
255d3354 54}