-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTitleLines.java
More file actions
36 lines (31 loc) · 1.2 KB
/
TitleLines.java
File metadata and controls
36 lines (31 loc) · 1.2 KB
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
import java.awt.*;
public class TitleLines extends Title{
public TitleLines(String header) {
super(header);
style = ElementFactory.STYLE_LINES;
}
@Override
int show(Graphics2D graphics2D, int hPos) {
this.hPos = hPos;
graphics2D.setFont(DPGenGUI.headerFont);
graphics2D.setColor(textColor);
int alignedPos = getAlignedTextPosition(header, 25, DPGenGUI.width - 50, DPGenGUI.headerFont);
graphics2D.drawString(header, alignedPos, hPos - 7);
graphics2D.setColor(DPGenGUI.thematicColor);
graphics2D.setStroke(new BasicStroke(2));
FontMetrics metrics = graphics2D.getFontMetrics();
int lineHeight = metrics.getHeight() / 3;
graphics2D.drawLine(12, hPos - 7 + 3 - lineHeight, alignedPos - 5, hPos - 7 + 3 - lineHeight);
graphics2D.drawLine(alignedPos + metrics.stringWidth(header) + 10, hPos - 7 + 3 - lineHeight, DPGenGUI.width - 12, hPos - 7 + 3 - lineHeight);
height = 45;
return hPos + height;
}
@Override
Rectangle getSelectionRegion() {
return new Rectangle(10, hPos - 40, DPGenGUI.width - 55, 50);
}
@Override
int getHeight() {
return height;
}
}