blob: 0a6b25bba88e66d665d28c00a91a4604cd2d3c39 (
plain) (
blame)
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
|
package space.m0e.quga.oop.lab56maven.entities.common;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.Image;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Rectangle;
public class MiniMap extends Rectangle
{
private final Group mainGroup;
public Rectangle rect = new Rectangle();
public MiniMap(double width, double height,double selectionWidth,double selectionHeight, Group mainGroup)
{
setHeight(height);
setWidth(width);
this.mainGroup = mainGroup;
setFill(Color.GREY);
setStroke(Color.YELLOW);
setStrokeWidth(2);
rect.setWidth(selectionWidth);
rect.setHeight(selectionHeight);
rect.setFill(Color.TRANSPARENT);
rect.setStroke(Color.BLACK);
rect.setStrokeWidth(1);
rect.setMouseTransparent(true);
updateMap();
}
public void updateMap()
{
Image image = createSnapshot(mainGroup);
ImagePattern imagePatternmagePattern = new ImagePattern(image);
this.setFill(imagePatternmagePattern);
}
private Image createSnapshot(Group group) {
SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
return group.snapshot(params, null);
}
}
|