完善 2023年2月17日16:14:28
parent
014e3eeaa2
commit
ae0f4779e3
|
|
@ -1,5 +1,6 @@
|
|||
package com.zhangmeng.tools.controller;
|
||||
|
||||
import com.zhangmeng.tools.utils.ImagePath;
|
||||
import com.zhangmeng.tools.utils.ResourcesUtils;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
|
@ -9,12 +10,19 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -33,6 +41,8 @@ public class HomeController implements Serializable {
|
|||
private SimpleDoubleProperty height = new SimpleDoubleProperty(0.0);
|
||||
private AnchorPane root;
|
||||
|
||||
public static final String color_cell = "#f4f4f4";
|
||||
|
||||
@FXML
|
||||
private ListView<ResourcesUtils.Menu> listView;
|
||||
|
||||
|
|
@ -40,31 +50,31 @@ public class HomeController implements Serializable {
|
|||
private SplitPane splitPane;
|
||||
|
||||
@FXML
|
||||
public void md5_menu_item(){
|
||||
public void md5_menu_item() {
|
||||
md5();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void spring_security_menu_item(){
|
||||
public void spring_security_menu_item() {
|
||||
spring();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void video_menu_item(){
|
||||
public void video_menu_item() {
|
||||
load_player(0);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void music_menu_item(){
|
||||
public void music_menu_item() {
|
||||
load_player(1);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void vip_parser_menu_item(){
|
||||
public void vip_parser_menu_item() {
|
||||
load_player(2);
|
||||
}
|
||||
|
||||
public void load_player(int index){
|
||||
public void load_player(int index) {
|
||||
AnchorPane fx = null;
|
||||
try {
|
||||
fx = FXMLLoader.load(ResourcesUtils.getResource("player"));
|
||||
|
|
@ -85,25 +95,78 @@ public class HomeController implements Serializable {
|
|||
init();
|
||||
listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
if (newValue.getIndex() == 0 ){
|
||||
if (newValue.getIndex() == 0) {
|
||||
md5();
|
||||
}
|
||||
if (newValue.getIndex() == 1 ){
|
||||
if (newValue.getIndex() == 1) {
|
||||
spring();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Image getImage(ResourcesUtils.Menu player){
|
||||
return switch (player){
|
||||
case Md5 -> new Image(ImagePath.path(ImagePath.ImagePathType.MD5));
|
||||
case SpringSecurity -> new Image(ImagePath.path(ImagePath.ImagePathType.SPRING_SECURITY));
|
||||
};
|
||||
}
|
||||
|
||||
public void init() {
|
||||
ResourcesUtils.Menu[] values = ResourcesUtils.Menu.values();
|
||||
ObservableList<ResourcesUtils.Menu> list = FXCollections.observableArrayList();
|
||||
list.addAll(Arrays.asList(values));
|
||||
listView.setItems(list);
|
||||
listView.setFixedCellSize(40);
|
||||
listView.setCellFactory(new Callback<>() {
|
||||
private int position;
|
||||
@Override
|
||||
public ListCell<ResourcesUtils.Menu> call(ListView<ResourcesUtils.Menu> playerListView) {
|
||||
Label label = new Label();
|
||||
label.setPrefWidth(100);
|
||||
ListCell<ResourcesUtils.Menu> listCell = new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(ResourcesUtils.Menu player, boolean b) {
|
||||
super.updateItem(player, b);
|
||||
if (!b) {
|
||||
HBox hBox = new HBox(25);
|
||||
hBox.setAlignment(Pos.CENTER);
|
||||
label.setText(player.getTitle());
|
||||
label.setTextFill(Paint.valueOf("#000000"));
|
||||
Image im = getImage(player);
|
||||
ImageView iv = new ImageView(im);
|
||||
iv.setPreserveRatio(true);
|
||||
iv.setFitWidth(15);
|
||||
hBox.getChildren().add(iv);
|
||||
|
||||
hBox.getChildren().add(label);
|
||||
this.setGraphic(hBox);
|
||||
}
|
||||
this.setStyle("-fx-background-color: " + color_cell);
|
||||
}
|
||||
};
|
||||
|
||||
listCell.hoverProperty().addListener((observableValue, aBoolean, t1) -> {
|
||||
if (t1 && !label.getText().equals("")) {
|
||||
position = playerListView.getItems().indexOf(label.getText());
|
||||
label.setFont(new Font(16));
|
||||
playerListView.getFocusModel().focus(position);
|
||||
listCell.setStyle("-fx-background-color: #f6edc3");
|
||||
} else {
|
||||
label.setPrefHeight(20);
|
||||
label.setFont(new Font(13));
|
||||
listCell.setStyle("-fx-background-color: " + color_cell);
|
||||
}
|
||||
});
|
||||
|
||||
return listCell;
|
||||
}
|
||||
});
|
||||
|
||||
md5();
|
||||
}
|
||||
|
||||
private void spring(){
|
||||
private void spring() {
|
||||
listView.getSelectionModel().select(1);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("spring-security"));
|
||||
|
|
@ -113,21 +176,21 @@ public class HomeController implements Serializable {
|
|||
common_method();
|
||||
}
|
||||
|
||||
private void common_method(){
|
||||
private void common_method() {
|
||||
splitPane.getItems().remove(1);
|
||||
splitPane.getItems().add(1, root);
|
||||
root.widthProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
double width = splitPane.getWidth();
|
||||
HomeController.this.width.set(width);
|
||||
log.info("home:--->width:{}",width);
|
||||
log.info("home:--->width:{}", width);
|
||||
}
|
||||
});
|
||||
root.heightProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
double height = splitPane.getHeight();
|
||||
HomeController.this.height.set(height);
|
||||
log.info("home:--->height:{}",height);
|
||||
log.info("home:--->height:{}", height);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -140,7 +203,7 @@ public class HomeController implements Serializable {
|
|||
});
|
||||
}
|
||||
|
||||
private void md5(){
|
||||
private void md5() {
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(0);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -592,13 +592,13 @@ public class MusicController {
|
|||
if (newValue.intValue() == cell.getIndex()) {
|
||||
if (cell.getGraphic() != null) {
|
||||
text = (Text)cell.getGraphic();
|
||||
text.setFont(Font.font(19.0D));
|
||||
text.setFont(Font.font(16.0D));
|
||||
text.setFill(Color.DEEPSKYBLUE);
|
||||
}
|
||||
} else if (cell.getGraphic() != null) {
|
||||
text = (Text)cell.getGraphic();
|
||||
text.setFont(Font.font(16.0D));
|
||||
text.setFill(Color.WHITE);
|
||||
text.setFont(Font.font(13.0D));
|
||||
text.setFill(Color.BLACK);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,32 @@
|
|||
package com.zhangmeng.tools.controller;
|
||||
|
||||
import com.zhangmeng.tools.utils.ImagePath;
|
||||
import com.zhangmeng.tools.utils.ResourcesUtils;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.cell.TextFieldListCell;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -35,32 +50,34 @@ public class PlayerController {
|
|||
@FXML
|
||||
private SplitPane splitPane;
|
||||
|
||||
public static final String color_cell = "#f4f4f4";
|
||||
|
||||
@FXML
|
||||
public void md5_menu_item(){
|
||||
public void md5_menu_item() {
|
||||
load_encrypt();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void spring_security_menu_item(){
|
||||
public void spring_security_menu_item() {
|
||||
load_encrypt();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void video_menu_item(){
|
||||
public void video_menu_item() {
|
||||
video();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void music_menu_item(){
|
||||
public void music_menu_item() {
|
||||
music();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void vip_parser_menu_item(){
|
||||
public void vip_parser_menu_item() {
|
||||
vip_parser();
|
||||
}
|
||||
|
||||
public void load_encrypt(){
|
||||
public void load_encrypt() {
|
||||
|
||||
Stage stage = (Stage) splitPane.getScene().getWindow();
|
||||
|
||||
|
|
@ -79,29 +96,86 @@ public class PlayerController {
|
|||
init();
|
||||
listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
if (newValue.getIndex() == 0 ){
|
||||
if (newValue.getIndex() == 0) {
|
||||
video();
|
||||
}
|
||||
if (newValue.getIndex() == 1 ){
|
||||
if (newValue.getIndex() == 1) {
|
||||
music();
|
||||
}
|
||||
if (newValue.getIndex() == 2){
|
||||
if (newValue.getIndex() == 2) {
|
||||
vip_parser();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Image getImage(ResourcesUtils.Player player){
|
||||
return switch (player){
|
||||
case Video -> new Image(ImagePath.path(ImagePath.ImagePathType.VIDEO_PLAYER));
|
||||
case Music -> new Image(ImagePath.path(ImagePath.ImagePathType.MUSIC_PLAYER));
|
||||
case VipParser -> new Image(ImagePath.path(ImagePath.ImagePathType.VIP_PLAYER));
|
||||
};
|
||||
}
|
||||
|
||||
public void init() {
|
||||
ResourcesUtils.Player[] values = ResourcesUtils.Player.values();
|
||||
ObservableList<ResourcesUtils.Player> list = FXCollections.observableArrayList();
|
||||
list.addAll(Arrays.asList(values));
|
||||
listView.setItems(list);
|
||||
listView.setFixedCellSize(40);
|
||||
listView.setCellFactory(new Callback<>() {
|
||||
|
||||
private int position;
|
||||
|
||||
@Override
|
||||
public ListCell<ResourcesUtils.Player> call(ListView<ResourcesUtils.Player> playerListView) {
|
||||
|
||||
Label label = new Label();
|
||||
label.setPrefWidth(100);
|
||||
ListCell<ResourcesUtils.Player> listCell = new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(ResourcesUtils.Player player, boolean b) {
|
||||
super.updateItem(player, b);
|
||||
if (!b) {
|
||||
HBox hBox = new HBox(30);
|
||||
hBox.setAlignment(Pos.CENTER);
|
||||
label.setText(player.getTitle());
|
||||
label.setTextFill(Paint.valueOf("#000000"));
|
||||
Image im = getImage(player);
|
||||
ImageView iv = new ImageView(im);
|
||||
iv.setPreserveRatio(true);
|
||||
iv.setFitWidth(15);
|
||||
hBox.getChildren().add(iv);
|
||||
hBox.getChildren().add(label);
|
||||
this.setGraphic(hBox);
|
||||
}
|
||||
this.setStyle("-fx-background-color: " + color_cell);
|
||||
}
|
||||
};
|
||||
|
||||
listCell.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean t1) {
|
||||
if (t1 && !label.getText().equals("")) {
|
||||
position = playerListView.getItems().indexOf(label.getText());
|
||||
label.setFont(new Font(16));
|
||||
playerListView.getFocusModel().focus(position);
|
||||
listCell.setStyle("-fx-background-color: #f6edc3");
|
||||
}else {
|
||||
label.setPrefHeight(20);
|
||||
label.setFont(new Font(13));
|
||||
listCell.setStyle("-fx-background-color: " + color_cell);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return listCell;
|
||||
}
|
||||
});
|
||||
video();
|
||||
}
|
||||
|
||||
private void music(){
|
||||
private void music() {
|
||||
listView.getSelectionModel().select(1);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("music"));
|
||||
|
|
@ -111,7 +185,7 @@ public class PlayerController {
|
|||
common_method();
|
||||
}
|
||||
|
||||
private void vip_parser(){
|
||||
private void vip_parser() {
|
||||
listView.getSelectionModel().select(2);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("vip-parser"));
|
||||
|
|
@ -121,21 +195,21 @@ public class PlayerController {
|
|||
common_method();
|
||||
}
|
||||
|
||||
private void common_method(){
|
||||
private void common_method() {
|
||||
splitPane.getItems().remove(1);
|
||||
splitPane.getItems().add(1, root);
|
||||
root.widthProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
double width = splitPane.getWidth();
|
||||
PlayerController.this.width.set(width);
|
||||
log.info("player:--->width:{}",width);
|
||||
log.info("player:--->width:{}", width);
|
||||
}
|
||||
});
|
||||
root.heightProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
double height = splitPane.getHeight();
|
||||
PlayerController.this.height.set(height);
|
||||
log.info("player:--->height:{}",height);
|
||||
log.info("player:--->height:{}", height);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -150,7 +224,7 @@ public class PlayerController {
|
|||
});
|
||||
}
|
||||
|
||||
private void video(){
|
||||
private void video() {
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(0);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ public class ImagePath {
|
|||
|
||||
IMAGE_FILE("文件图标"),
|
||||
|
||||
VIDEO_PLAYER("视频播放"),
|
||||
MUSIC_PLAYER("音乐播放"),
|
||||
VIP_PLAYER("VIP解析播放"),
|
||||
MD5("md5 加密"),
|
||||
SPRING_SECURITY("SPRING_SECURITY 加密"),
|
||||
|
||||
ICON_NULL_COVER("");
|
||||
|
||||
private String desc;
|
||||
|
|
@ -222,6 +228,12 @@ public class ImagePath {
|
|||
|
||||
public static String SVG_FILE = "svg/file.png";
|
||||
|
||||
public static String VIP_PLAYER = "svg/vip-player.png";
|
||||
public static String VIDEO_PLAYER = "svg/video-player.png";
|
||||
public static String MUSIC_PLAYER = "svg/music-player.png";
|
||||
public static String MD5 = "svg/md5.png";
|
||||
public static String SPRING_SECURITY = "svg/spring-security.png";
|
||||
|
||||
public static String path(ImagePathType type) {
|
||||
|
||||
String path = null;
|
||||
|
|
@ -348,6 +360,21 @@ public class ImagePath {
|
|||
case IMAGE_FILE:
|
||||
path = ImagePath.SVG_FILE;
|
||||
break;
|
||||
case VIDEO_PLAYER:
|
||||
path = ImagePath.VIDEO_PLAYER;
|
||||
break;
|
||||
case MUSIC_PLAYER:
|
||||
path = ImagePath.MUSIC_PLAYER;
|
||||
break;
|
||||
case VIP_PLAYER:
|
||||
path = ImagePath.VIP_PLAYER;
|
||||
break;
|
||||
case MD5:
|
||||
path = ImagePath.MD5;
|
||||
break;
|
||||
case SPRING_SECURITY:
|
||||
path = ImagePath.SPRING_SECURITY;
|
||||
break;
|
||||
}
|
||||
return "static/" + path;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
Loading…
Reference in New Issue