完善 2023年2月17日16:14:28

master
zhangmeng 2023-02-17 16:14:39 +08:00
parent 014e3eeaa2
commit ae0f4779e3
9 changed files with 195 additions and 31 deletions

View File

@ -1,5 +1,6 @@
package com.zhangmeng.tools.controller; package com.zhangmeng.tools.controller;
import com.zhangmeng.tools.utils.ImagePath;
import com.zhangmeng.tools.utils.ResourcesUtils; import com.zhangmeng.tools.utils.ResourcesUtils;
import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
@ -9,12 +10,19 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane; 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.stage.Stage;
import javafx.util.Callback;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.IOException; import java.io.IOException;
@ -33,6 +41,8 @@ public class HomeController implements Serializable {
private SimpleDoubleProperty height = new SimpleDoubleProperty(0.0); private SimpleDoubleProperty height = new SimpleDoubleProperty(0.0);
private AnchorPane root; private AnchorPane root;
public static final String color_cell = "#f4f4f4";
@FXML @FXML
private ListView<ResourcesUtils.Menu> listView; private ListView<ResourcesUtils.Menu> listView;
@ -40,31 +50,31 @@ public class HomeController implements Serializable {
private SplitPane splitPane; private SplitPane splitPane;
@FXML @FXML
public void md5_menu_item(){ public void md5_menu_item() {
md5(); md5();
} }
@FXML @FXML
public void spring_security_menu_item(){ public void spring_security_menu_item() {
spring(); spring();
} }
@FXML @FXML
public void video_menu_item(){ public void video_menu_item() {
load_player(0); load_player(0);
} }
@FXML @FXML
public void music_menu_item(){ public void music_menu_item() {
load_player(1); load_player(1);
} }
@FXML @FXML
public void vip_parser_menu_item(){ public void vip_parser_menu_item() {
load_player(2); load_player(2);
} }
public void load_player(int index){ public void load_player(int index) {
AnchorPane fx = null; AnchorPane fx = null;
try { try {
fx = FXMLLoader.load(ResourcesUtils.getResource("player")); fx = FXMLLoader.load(ResourcesUtils.getResource("player"));
@ -85,25 +95,78 @@ public class HomeController implements Serializable {
init(); init();
listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
if (newValue.getIndex() == 0 ){ if (newValue.getIndex() == 0) {
md5(); md5();
} }
if (newValue.getIndex() == 1 ){ if (newValue.getIndex() == 1) {
spring(); 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() { public void init() {
ResourcesUtils.Menu[] values = ResourcesUtils.Menu.values(); ResourcesUtils.Menu[] values = ResourcesUtils.Menu.values();
ObservableList<ResourcesUtils.Menu> list = FXCollections.observableArrayList(); ObservableList<ResourcesUtils.Menu> list = FXCollections.observableArrayList();
list.addAll(Arrays.asList(values)); list.addAll(Arrays.asList(values));
listView.setItems(list); 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(); md5();
} }
private void spring(){ private void spring() {
listView.getSelectionModel().select(1); listView.getSelectionModel().select(1);
try { try {
root = FXMLLoader.load(ResourcesUtils.getResource("spring-security")); root = FXMLLoader.load(ResourcesUtils.getResource("spring-security"));
@ -113,21 +176,21 @@ public class HomeController implements Serializable {
common_method(); common_method();
} }
private void common_method(){ private void common_method() {
splitPane.getItems().remove(1); splitPane.getItems().remove(1);
splitPane.getItems().add(1, root); splitPane.getItems().add(1, root);
root.widthProperty().addListener((observable, oldValue, newValue) -> { root.widthProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
double width = splitPane.getWidth(); double width = splitPane.getWidth();
HomeController.this.width.set(width); HomeController.this.width.set(width);
log.info("home:--->width:{}",width); log.info("home:--->width:{}", width);
} }
}); });
root.heightProperty().addListener((observable, oldValue, newValue) -> { root.heightProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
double height = splitPane.getHeight(); double height = splitPane.getHeight();
HomeController.this.height.set(height); 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); listView.getSelectionModel().select(0);
try { try {

View File

@ -592,13 +592,13 @@ public class MusicController {
if (newValue.intValue() == cell.getIndex()) { if (newValue.intValue() == cell.getIndex()) {
if (cell.getGraphic() != null) { if (cell.getGraphic() != null) {
text = (Text)cell.getGraphic(); text = (Text)cell.getGraphic();
text.setFont(Font.font(19.0D)); text.setFont(Font.font(16.0D));
text.setFill(Color.DEEPSKYBLUE); text.setFill(Color.DEEPSKYBLUE);
} }
} else if (cell.getGraphic() != null) { } else if (cell.getGraphic() != null) {
text = (Text)cell.getGraphic(); text = (Text)cell.getGraphic();
text.setFont(Font.font(16.0D)); text.setFont(Font.font(13.0D));
text.setFill(Color.WHITE); text.setFill(Color.BLACK);
} }
} }

View File

@ -1,17 +1,32 @@
package com.zhangmeng.tools.controller; package com.zhangmeng.tools.controller;
import com.zhangmeng.tools.utils.ImagePath;
import com.zhangmeng.tools.utils.ResourcesUtils; import com.zhangmeng.tools.utils.ResourcesUtils;
import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.SplitPane; 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.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.stage.Stage;
import javafx.util.Callback;
import javafx.util.StringConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.IOException; import java.io.IOException;
@ -35,32 +50,34 @@ public class PlayerController {
@FXML @FXML
private SplitPane splitPane; private SplitPane splitPane;
public static final String color_cell = "#f4f4f4";
@FXML @FXML
public void md5_menu_item(){ public void md5_menu_item() {
load_encrypt(); load_encrypt();
} }
@FXML @FXML
public void spring_security_menu_item(){ public void spring_security_menu_item() {
load_encrypt(); load_encrypt();
} }
@FXML @FXML
public void video_menu_item(){ public void video_menu_item() {
video(); video();
} }
@FXML @FXML
public void music_menu_item(){ public void music_menu_item() {
music(); music();
} }
@FXML @FXML
public void vip_parser_menu_item(){ public void vip_parser_menu_item() {
vip_parser(); vip_parser();
} }
public void load_encrypt(){ public void load_encrypt() {
Stage stage = (Stage) splitPane.getScene().getWindow(); Stage stage = (Stage) splitPane.getScene().getWindow();
@ -79,29 +96,86 @@ public class PlayerController {
init(); init();
listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
if (newValue.getIndex() == 0 ){ if (newValue.getIndex() == 0) {
video(); video();
} }
if (newValue.getIndex() == 1 ){ if (newValue.getIndex() == 1) {
music(); music();
} }
if (newValue.getIndex() == 2){ if (newValue.getIndex() == 2) {
vip_parser(); 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() { public void init() {
ResourcesUtils.Player[] values = ResourcesUtils.Player.values(); ResourcesUtils.Player[] values = ResourcesUtils.Player.values();
ObservableList<ResourcesUtils.Player> list = FXCollections.observableArrayList(); ObservableList<ResourcesUtils.Player> list = FXCollections.observableArrayList();
list.addAll(Arrays.asList(values)); list.addAll(Arrays.asList(values));
listView.setItems(list); 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(); video();
} }
private void music(){ private void music() {
listView.getSelectionModel().select(1); listView.getSelectionModel().select(1);
try { try {
root = FXMLLoader.load(ResourcesUtils.getResource("music")); root = FXMLLoader.load(ResourcesUtils.getResource("music"));
@ -111,7 +185,7 @@ public class PlayerController {
common_method(); common_method();
} }
private void vip_parser(){ private void vip_parser() {
listView.getSelectionModel().select(2); listView.getSelectionModel().select(2);
try { try {
root = FXMLLoader.load(ResourcesUtils.getResource("vip-parser")); root = FXMLLoader.load(ResourcesUtils.getResource("vip-parser"));
@ -121,21 +195,21 @@ public class PlayerController {
common_method(); common_method();
} }
private void common_method(){ private void common_method() {
splitPane.getItems().remove(1); splitPane.getItems().remove(1);
splitPane.getItems().add(1, root); splitPane.getItems().add(1, root);
root.widthProperty().addListener((observable, oldValue, newValue) -> { root.widthProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
double width = splitPane.getWidth(); double width = splitPane.getWidth();
PlayerController.this.width.set(width); PlayerController.this.width.set(width);
log.info("player:--->width:{}",width); log.info("player:--->width:{}", width);
} }
}); });
root.heightProperty().addListener((observable, oldValue, newValue) -> { root.heightProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
double height = splitPane.getHeight(); double height = splitPane.getHeight();
PlayerController.this.height.set(height); 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); listView.getSelectionModel().select(0);
try { try {

View File

@ -49,6 +49,12 @@ public class ImagePath {
IMAGE_FILE("文件图标"), IMAGE_FILE("文件图标"),
VIDEO_PLAYER("视频播放"),
MUSIC_PLAYER("音乐播放"),
VIP_PLAYER("VIP解析播放"),
MD5("md5 加密"),
SPRING_SECURITY("SPRING_SECURITY 加密"),
ICON_NULL_COVER(""); ICON_NULL_COVER("");
private String desc; private String desc;
@ -222,6 +228,12 @@ public class ImagePath {
public static String SVG_FILE = "svg/file.png"; 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) { public static String path(ImagePathType type) {
String path = null; String path = null;
@ -348,6 +360,21 @@ public class ImagePath {
case IMAGE_FILE: case IMAGE_FILE:
path = ImagePath.SVG_FILE; path = ImagePath.SVG_FILE;
break; 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; 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