source: lost-haven/gamegui/ScrollBar.java@ 8edd04e

Last change on this file since 8edd04e was 8edd04e, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Make the decompiled game code compile successfully

  • Property mode set to 100644
File size: 2.6 KB
Line 
1package gamegui;
2
3import java.awt.*;
4import java.awt.event.MouseEvent;
5
6public class ScrollBar extends Member {
7
8 int size;
9 int position;
10 int scrollSpeed;
11
12 public ScrollBar(String newName, int newX, int newY, int newWidth, int newHeight, int newScrollSpeed) {
13 super(newName, newX, newY, newWidth, newHeight);
14 this.size = 0;
15 this.position = 0;
16 this.scrollSpeed = newScrollSpeed;
17 }
18
19 public void clear() {
20 this.size = 0;
21 this.position = 0;
22 }
23
24 public boolean handleEvent(MouseEvent e) {
25 if (getX() >= e.getX() || e.getX() >= getX() + getWidth() || getY() >= e.getY() || e.getY() >= getY() + getHeight()) {
26 return false;
27 }
28 return true;
29 }
30
31 public void draw(Graphics g) {
32 g.setColor(Color.black);
33 g.fillRect(getX(), getY(), getWidth(), getHeight());
34 g.setColor(Color.red);
35 g.drawRect(getX(), getY(), getWidth(), getHeight());
36 g.drawLine(getX(), getY() + getWidth(), getX() + getWidth(), getY() + getWidth());
37 g.drawLine(getX(), getY() + getHeight() - getWidth(), getX() + getWidth(), getY() + getHeight() - getWidth());
38 g.drawLine(getX(), getY() + getWidth() + this.position, getX() + getWidth(), getY() + getWidth() + this.position);
39 g.drawLine(getX(), getY() + getWidth() + this.position + this.size, getX() + getWidth(), getY() + getWidth() + this.position + this.size);
40 g.drawLine(getX() + getWidth() * 3 / 20, getY() + getWidth() * 17 / 20, getX() + getWidth() * 17 / 20, getY() + getWidth() * 17 / 20);
41 g.drawLine(getX() + getWidth() * 17 / 20, getY() + getWidth() * 17 / 20, getX() + getWidth() / 2, getY() + getWidth() * 3 / 20);
42 g.drawLine(getX() + getWidth() / 2, getY() + getWidth() * 3 / 20, getX() + getWidth() * 3 / 20, getY() + getWidth() * 17 / 20);
43 g.drawLine(getX() + getWidth() * 3 / 20, getY() + getHeight() - getWidth() * 17 / 20, getX() + getWidth() * 17 / 20, getY() + getHeight() - getWidth() * 17 / 20);
44 g.drawLine(getX() + getWidth() * 17 / 20, getY() + getHeight() - getWidth() * 17 / 20, getX() + getWidth() / 2, getY() + getHeight() - getWidth() * 3 / 20);
45 g.drawLine(getX() + getWidth() / 2, getY() + getHeight() - getWidth() * 3 / 20, getX() + getWidth() * 3 / 20, getY() + getHeight() - getWidth() * 17 / 20);
46 }
47
48 public int getPosition() {
49 return this.position;
50 }
51
52 public int getScrollSpeed() {
53 return this.scrollSpeed;
54 }
55
56 public int getSize() {
57 return this.size;
58 }
59
60 public int getMaxSize() {
61 return getHeight() - 2 * getWidth();
62 }
63
64 public void setPosition(int position) {
65 this.position = position;
66 }
67
68 public void setSize(int size) {
69 this.size = size;
70 }
71}
Note: See TracBrowser for help on using the repository browser.