1 | package com.jsql.view.swing.util; | |
2 | ||
3 | import com.formdev.flatlaf.extras.FlatSVGIcon; | |
4 | ||
5 | import javax.swing.*; | |
6 | import java.awt.*; | |
7 | import java.util.Objects; | |
8 | ||
9 | public class ModelSvgIcon { | |
10 | private final Color from; | |
11 | private final String toDarkUi; | |
12 | private final Color toDark; | |
13 | private final FlatSVGIcon icon; | |
14 | private String keyLabel; | |
15 | private String keyTooltip; | |
16 | ||
17 | ModelSvgIcon(String name, float scale) { | |
18 | this(name, Color.BLACK, "ComboBox.foreground", scale); | |
19 | } | |
20 | ||
21 | ModelSvgIcon(String name, int from) { | |
22 | this(name, new Color(from), "ComboBox.foreground", 0.02f); | |
23 | } | |
24 | ||
25 | ModelSvgIcon(String name, Color from, String toDark, float scale) { | |
26 | this(name, from, toDark, UIManager.getColor(toDark), scale); | |
27 | } | |
28 | ||
29 | ModelSvgIcon(String name, Color from, String toDarkUi, Color toDark, float scale) { | |
30 | this.from = from; | |
31 | this.toDarkUi = toDarkUi; | |
32 | this.toDark = toDark; | |
33 | this.icon = this.createSvgIcon( | |
34 | name, | |
35 | from, | |
36 |
1
1. <init> : negated conditional → NO_COVERAGE |
toDarkUi != null |
37 | ? UIManager.getColor(toDarkUi) | |
38 | : toDark, | |
39 | scale | |
40 | ); | |
41 | } | |
42 | ||
43 | public FlatSVGIcon createSvgIcon(String name, Color from, Color toDark, float scale) { | |
44 |
1
1. createSvgIcon : replaced return value with null for com/jsql/view/swing/util/ModelSvgIcon::createSvgIcon → NO_COVERAGE |
return new FlatSVGIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource(String.format( |
45 |
1
1. createSvgIcon : negated conditional → NO_COVERAGE |
name.endsWith(".svg") ? "%s" : "swing/images/icons/%s.svg", |
46 | name | |
47 | )))) | |
48 | .setColorFilter(new FlatSVGIcon.ColorFilter().add(from, null, toDark)) | |
49 | .derive(scale); | |
50 | } | |
51 | ||
52 | public void setColorFilter() { | |
53 | this.icon.setColorFilter(new FlatSVGIcon.ColorFilter().add( | |
54 | this.from, | |
55 | null, | |
56 |
1
1. setColorFilter : negated conditional → NO_COVERAGE |
this.toDarkUi != null |
57 | ? UIManager.getColor(this.toDarkUi) | |
58 | : this.toDark | |
59 | )); | |
60 | } | |
61 | ||
62 | public ModelSvgIcon withTab(String keyLabel, String keyTooltip) { | |
63 | this.keyLabel = keyLabel; | |
64 | this.keyTooltip = keyTooltip; | |
65 |
1
1. withTab : replaced return value with null for com/jsql/view/swing/util/ModelSvgIcon::withTab → NO_COVERAGE |
return this; |
66 | } | |
67 | ||
68 | public FlatSVGIcon getIcon() { | |
69 |
1
1. getIcon : replaced return value with null for com/jsql/view/swing/util/ModelSvgIcon::getIcon → NO_COVERAGE |
return icon; |
70 | } | |
71 | ||
72 | public String getKeyLabel() { | |
73 |
1
1. getKeyLabel : replaced return value with "" for com/jsql/view/swing/util/ModelSvgIcon::getKeyLabel → NO_COVERAGE |
return keyLabel; |
74 | } | |
75 | ||
76 | public String getKeyTooltip() { | |
77 |
1
1. getKeyTooltip : replaced return value with "" for com/jsql/view/swing/util/ModelSvgIcon::getKeyTooltip → NO_COVERAGE |
return keyTooltip; |
78 | } | |
79 | } | |
Mutations | ||
36 |
1.1 |
|
44 |
1.1 |
|
45 |
1.1 |
|
56 |
1.1 |
|
65 |
1.1 |
|
69 |
1.1 |
|
73 |
1.1 |
|
77 |
1.1 |