-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageViewButton.java
More file actions
55 lines (52 loc) · 1.37 KB
/
ImageViewButton.java
File metadata and controls
55 lines (52 loc) · 1.37 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import javafx.scene.effect.Bloom;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
/**
*
* @author BehzaD
*/
public class ImageViewButton extends ImageView
{
ColorAdjust colorAdjust = new ColorAdjust();
DropShadow shadow = new DropShadow();
Bloom blm = new Bloom(0);
public ImageViewButton()
{
initButton();
}
public ImageViewButton(String path)
{
super(path);
initButton();
}
public void setImage(String path)
{
setImage(new Image(path));
}
private void initButton()
{
colorAdjust.setContrast(0.1);
colorAdjust.setHue(-0.05);
colorAdjust.setBrightness(0.1);
colorAdjust.setSaturation(0.2);
shadow.setOffsetY(0f);
shadow.setOffsetX(0f);
shadow.setColor(Color.rgb(0x41,0x98,0xff));
shadow.setInput(colorAdjust);
setOnMouseEntered((event) -> {
setEffect(shadow);
});
setOnMouseExited((event) -> {
setEffect(null);
});
setOnMousePressed((event) -> {
setEffect(blm);
});
setOnMouseReleased((event) -> {
setEffect(shadow);
});
}
}