-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPictureBlockBasic.java
More file actions
36 lines (30 loc) · 1.25 KB
/
PictureBlockBasic.java
File metadata and controls
36 lines (30 loc) · 1.25 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.*;
class PictureBlockBasic extends PictureBlock{
public PictureBlockBasic(Image picture, String description) {
super(picture, description);
int resizedImageWidth = DPGenGUI.width - 40;
this.picture = DPGenGUI.getResizedImageByWidth(picture, resizedImageWidth);
this.description = description;
pictureHeight = picture.getHeight(null);
style = ElementFactory.STYLE_BASIC;
}
@Override
int show(Graphics2D graphics2D, int hPos) {
this.hPos = hPos;
blockWidth = this.picture.getWidth(null);
hPos += 5;
graphics2D.drawImage(picture, DPGenGUI.width / 2 - blockWidth / 2, hPos - 30, null);
graphics2D.setColor(DPGenGUI.textColor);
graphics2D.setFont(DPGenGUI.commentFont);
graphics2D.drawString(description, DPGenGUI.width / 2 - blockWidth / 2 + 5, hPos - 30 + 18 + picture.getHeight(null));
return hPos + picture.getHeight(null) + 40;
}
@Override
Rectangle getSelectionRegion() {
return new Rectangle(DPGenGUI.width / 2 - blockWidth / 2 - 10, hPos - 30 - 10, picture.getWidth(null) + 20, picture.getHeight(null) + 40);
}
@Override
int getHeight() {
return picture.getHeight(null) + 40;
}
}