diff --git a/src/main/java/com/zhangmeng/tools/controller/HomeController.java b/src/main/java/com/zhangmeng/tools/controller/HomeController.java index ba1655e..ff224ed 100644 --- a/src/main/java/com/zhangmeng/tools/controller/HomeController.java +++ b/src/main/java/com/zhangmeng/tools/controller/HomeController.java @@ -40,6 +40,8 @@ public class HomeController implements Serializable { private SimpleDoubleProperty width = new SimpleDoubleProperty(0.0); private SimpleDoubleProperty height = new SimpleDoubleProperty(0.0); private AnchorPane root; + private AnchorPane md5; + private AnchorPane spring_security; public static final String color_cell = "#f4f4f4"; @@ -51,12 +53,20 @@ public class HomeController implements Serializable { @FXML public void md5_menu_item() { - md5(); + boolean flag = false; + if (md5 != null){ + flag = true; + } + md5(flag); } @FXML public void spring_security_menu_item() { - spring(); + boolean flag = false; + if (spring_security != null){ + flag = true; + } + spring(flag); } @FXML @@ -95,11 +105,19 @@ public class HomeController implements Serializable { init(); listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { + boolean flag = false; + if (newValue.getIndex() == 0) { - md5(); + if (md5 != null){ + flag = true; + } + md5(flag); } if (newValue.getIndex() == 1) { - spring(); + if (spring_security != null){ + flag = true; + } + spring(flag); } } }); @@ -163,15 +181,38 @@ public class HomeController implements Serializable { } }); - md5(); + md5(false); } - private void spring() { + private void spring(boolean flag) { listView.getSelectionModel().select(1); - try { - root = FXMLLoader.load(ResourcesUtils.getResource("spring-security")); - } catch (IOException e) { - e.printStackTrace(); + if (!flag){ + try { + root = FXMLLoader.load(ResourcesUtils.getResource("spring-security")); + } catch (IOException e) { + e.printStackTrace(); + } + spring_security = root; + }else { + root = spring_security; + } + common_method(); + } + + + private void md5(boolean flag) { + //默认选择第一个 + listView.getSelectionModel().select(0); + + if (!flag){ + try { + root = FXMLLoader.load(ResourcesUtils.getResource("md5")); + } catch (IOException e) { + e.printStackTrace(); + } + md5 = root; + }else { + root = md5; } common_method(); } @@ -203,14 +244,4 @@ public class HomeController implements Serializable { }); } - private void md5() { - //默认选择第一个 - listView.getSelectionModel().select(0); - try { - root = FXMLLoader.load(ResourcesUtils.getResource("md5")); - } catch (IOException e) { - e.printStackTrace(); - } - common_method(); - } } \ No newline at end of file diff --git a/src/main/java/com/zhangmeng/tools/controller/VideoController.java b/src/main/java/com/zhangmeng/tools/controller/VideoController.java index ed0c760..dd7c0d7 100644 --- a/src/main/java/com/zhangmeng/tools/controller/VideoController.java +++ b/src/main/java/com/zhangmeng/tools/controller/VideoController.java @@ -19,6 +19,7 @@ import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.geometry.Rectangle2D; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.*; @@ -62,7 +63,6 @@ public class VideoController { private static ObservableList files = FXCollections.observableArrayList(); private static String abpath = System.getProperty("user.dir") + "/"; private static BufferedWriter bw = null; - public ScrollPane scrollPane; private MediaPlayer mp; private final SimpleBooleanProperty isplaying = new SimpleBooleanProperty(false); private final SimpleIntegerProperty playindex = new SimpleIntegerProperty(1); @@ -71,6 +71,7 @@ public class VideoController { private final Random ran = new Random(); private HBox hbox; + private static final double gap = 5.0D; private final int number = SpectrumUtils.CELL_NUMBER; private ObservableList height; @@ -159,6 +160,12 @@ public class VideoController { @FXML private MediaView mv; + @FXML + private AnchorPane video_root; + + @FXML + private AnchorPane mv_an; + public void full_screen() { AnchorPane root = null; @@ -190,6 +197,7 @@ public class VideoController { @FXML public void initialize() { + files = getMusicFiles(); initListView(); medias = getMusicMedias(); @@ -218,9 +226,12 @@ public class VideoController { this.sb = new StringBuffer(files.get(this.playindex.get()).getName()); this.sb = new StringBuffer(this.sb.substring(0, this.sb.length() - 4)); this.mp.setVolume(sl_vol_num); + this.mv.setMediaPlayer(mp); } this.playindex.addListener((observable, oldValue, newValue) -> VideoController.this.myPlay()); + this.mv.setPreserveRatio(false); + this.mv.fitWidthProperty().bind(video_root.prefWidthProperty().subtract(300)); //设置按钮 set_button(); @@ -508,7 +519,7 @@ public class VideoController { public void myPlay() { this.mp.dispose(); - this.mp = new MediaPlayer(this.medias.get(this.playindex.get())); + this.mp = new MediaPlayer(medias.get(this.playindex.get())); initProgressBar(mp); this.mp.setOnReady(() -> { VideoController.this.mp.play(); @@ -572,7 +583,7 @@ public class VideoController { if (!empty && item != null) { sb = new StringBuffer(item.getName()); Text text = new Text(sb.substring(0, sb.length() - 4)); - text.setWrappingWidth(300.0D); + text.setStrokeWidth(300); text.setTextAlignment(TextAlignment.CENTER); if (this.getIndex() == VideoController.this.playindex.get()) { text.setFont(Font.font(16.0D)); @@ -582,7 +593,7 @@ public class VideoController { //text.setFill(Color.WHITE); } - this.setAlignment(Pos.CENTER); + this.setAlignment(Pos.CENTER_LEFT); this.setGraphic(text); this.setOpacity(1.0D); this.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, (CornerRadii)null, (Insets)null))); diff --git a/src/main/resources/fxml/video.fxml b/src/main/resources/fxml/video.fxml index 2aaf262..5776a6e 100644 --- a/src/main/resources/fxml/video.fxml +++ b/src/main/resources/fxml/video.fxml @@ -11,9 +11,9 @@ - + - + @@ -54,12 +54,11 @@ - - - - - + + +