2022-01-20 13:49:07 +01:00
|
|
|
package main;
|
|
|
|
|
|
|
|
import javafx.geometry.Bounds;
|
|
|
|
import javafx.scene.Group;
|
|
|
|
import customUI.Button;
|
|
|
|
import javafx.scene.control.ContentDisplay;
|
|
|
|
import javafx.scene.shape.SVGPath;
|
|
|
|
|
|
|
|
public class SvgBtnCreator {
|
|
|
|
|
2022-01-20 13:52:35 +01:00
|
|
|
public static Button cretaeBtn(Group group, int svgSize) {
|
2022-01-20 13:49:07 +01:00
|
|
|
Button btn = new Button();
|
|
|
|
|
|
|
|
Bounds boundsDel = group.getBoundsInParent();
|
|
|
|
double scaleDel = Math.min(20 / boundsDel.getWidth(), 20 / boundsDel.getHeight());
|
|
|
|
group.setScaleX(scaleDel);
|
|
|
|
group.setScaleY(scaleDel);
|
|
|
|
btn.setGraphic(group);
|
2022-01-20 13:52:35 +01:00
|
|
|
btn.setMaxSize(svgSize, svgSize);
|
|
|
|
btn.setMinSize(svgSize, svgSize);
|
2022-01-20 13:49:07 +01:00
|
|
|
btn.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
|
|
|
|
|
|
|
|
return btn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SVGPath createPath(String d, String fill, String hoverFill) {
|
|
|
|
SVGPath path = new SVGPath();
|
|
|
|
path.getStyleClass().add("svg");
|
|
|
|
path.setContent(d);
|
|
|
|
path.setStyle("-fill:" + fill + ";-hover-fill:"+hoverFill+';');
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|