-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArticleLonely.java
44 lines (39 loc) · 1.36 KB
/
ArticleLonely.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.awt.*;
import java.util.Vector;
class ArticleLonely extends Article{
public ArticleLonely(Vector<String> article) {
super(article);
bordered = false;
style = ElementFactory.STYLE_LONELY_LUCKILY;
}
@Override
int show(Graphics2D graphics2D, int hPos) {
this.hPos = hPos;
graphics2D.setColor(backgroundColor);
graphics2D.setStroke(new BasicStroke(2));
int fontHeight = 22;
graphics2D.fillRect(10, hPos - 20, DPGenGUI.width - 20, article.size() * fontHeight + 5);
if (bordered) {
graphics2D.setColor(Color.BLACK);
graphics2D.drawRect(10, hPos - 20, DPGenGUI.width - 20, article.size() * fontHeight + 5);
}
graphics2D.setFont(DPGenGUI.textFont);
graphics2D.setColor(textColor);
for (String line : article) {
graphics2D.drawString(line, getAlignedTextPosition(line, 10, DPGenGUI.width - 10, DPGenGUI.textFont), hPos);
hPos += fontHeight;
}
hPos += fontHeight + 1;
height = hPos - this.hPos - fontHeight - 1;
if (height < 20) height += fontHeight;
return hPos;
}
@Override
Rectangle getSelectionRegion() {
return new Rectangle(5, hPos - 25, DPGenGUI.width - 20, height + 10);
}
@Override
int getHeight() {
return height + 20;
}
}