diff --git a/XR3Player Manual.odt b/XR3Player Manual.odt index de94bc0d..6b26d4e7 100644 Binary files a/XR3Player Manual.odt and b/XR3Player Manual.odt differ diff --git a/XR3Player Manual.pdf b/XR3Player Manual.pdf index 47dca488..0cf1ce19 100644 Binary files a/XR3Player Manual.pdf and b/XR3Player Manual.pdf differ diff --git a/XR3PlayerUpdatePage.html b/XR3PlayerUpdatePage.html index 5b277c4e..5669fdc8 100644 --- a/XR3PlayerUpdatePage.html +++ b/XR3PlayerUpdatePage.html @@ -403,5 +403,32 @@

1.8.0_111

+ +
+ +
+

+ --Update 55 Importing new layouts!--
+

+

+ ChangeLog : +

+

+
*General Layout and Code Bug Fixes +
*New Spectrum Analyser mode [ Circle with Lines] +
*Changes Rozette Visualizer [ You need to check it :) ] +
*Added SnapShot tool to the application +
*Preparing for saving all application settings into JSON database +
*Preparing for implementing a new Layout for the application +

+

+ Release Date : +

+

12/03/2017

+

+ Minimum Java[JRE] Version : +

+

1.8.0_111

+
\ No newline at end of file diff --git a/resources/fxml/Library.fxml b/resources/fxml/Library.fxml index 5e3e3a91..c4b835fa 100644 --- a/resources/fxml/Library.fxml +++ b/resources/fxml/Library.fxml @@ -1,8 +1,6 @@ - - @@ -16,7 +14,7 @@ - + @@ -24,12 +22,12 @@ - - + diff --git a/resources/fxml/RenameWindow.fxml b/resources/fxml/RenameWindow.fxml index 6f38014c..42bace3a 100644 --- a/resources/fxml/RenameWindow.fxml +++ b/resources/fxml/RenameWindow.fxml @@ -32,7 +32,7 @@ - + diff --git a/resources/fxml/SideBar.fxml b/resources/fxml/SideBar.fxml index 17345b52..cf3c6944 100644 --- a/resources/fxml/SideBar.fxml +++ b/resources/fxml/SideBar.fxml @@ -4,7 +4,7 @@ - + @@ -22,71 +22,21 @@ - - - -
- - - - - - - - - - - - - - - -
- - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -147,32 +97,156 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + - - - + - - - + + + + + + +
diff --git a/resources/fxml/StarWindow.fxml b/resources/fxml/StarWindow.fxml index 1d78f635..ebbd2a99 100644 --- a/resources/fxml/StarWindow.fxml +++ b/resources/fxml/StarWindow.fxml @@ -26,7 +26,7 @@ - - - +
@@ -79,17 +54,6 @@ - diff --git a/resources/fxml/VisualizerWindowController.fxml b/resources/fxml/VisualizerWindowController.fxml index b133af76..e595512a 100644 --- a/resources/fxml/VisualizerWindowController.fxml +++ b/resources/fxml/VisualizerWindowController.fxml @@ -81,7 +81,7 @@ - + @@ -104,7 +104,7 @@ - + diff --git a/resources/image/Console-32.png b/resources/image/Console-32.png new file mode 100644 index 00000000..7c764b34 Binary files /dev/null and b/resources/image/Console-32.png differ diff --git a/resources/image/Database-32.png b/resources/image/Database-32.png new file mode 100644 index 00000000..71614b7f Binary files /dev/null and b/resources/image/Database-32.png differ diff --git a/resources/image/Gears-32.png b/resources/image/Gears-32.png new file mode 100644 index 00000000..03f00ae4 Binary files /dev/null and b/resources/image/Gears-32.png differ diff --git a/resources/image/Home-32.png b/resources/image/Home-32.png new file mode 100644 index 00000000..5afb4925 Binary files /dev/null and b/resources/image/Home-32.png differ diff --git a/resources/image/Screenshot-32.png b/resources/image/Screenshot-32.png new file mode 100644 index 00000000..daef8013 Binary files /dev/null and b/resources/image/Screenshot-32.png differ diff --git a/resources/image/User-32.png b/resources/image/User-32.png new file mode 100644 index 00000000..385cdcd7 Binary files /dev/null and b/resources/image/User-32.png differ diff --git a/resources/image/gear.png b/resources/image/gear.png index c7366459..93cac252 100644 Binary files a/resources/image/gear.png and b/resources/image/gear.png differ diff --git a/resources/libs/fontawesomefx-8.0.10.jar b/resources/libs/fontawesomefx-8.0.10.jar deleted file mode 100644 index 9ef33992..00000000 Binary files a/resources/libs/fontawesomefx-8.0.10.jar and /dev/null differ diff --git a/resources/libs/fontawesomefx-8.9.jar b/resources/libs/fontawesomefx-8.9.jar deleted file mode 100644 index 7af093dc..00000000 Binary files a/resources/libs/fontawesomefx-8.9.jar and /dev/null differ diff --git a/resources/style/application.css b/resources/style/application.css index 9bfed364..fecf85a0 100644 --- a/resources/style/application.css +++ b/resources/style/application.css @@ -7,7 +7,7 @@ -.icon{ +/* .icon{ -fx-text-fill: #FE774D; -fx-padding: 10.0; -fx-cursor: hand; @@ -26,6 +26,7 @@ -fx-font-size: 13.0px !important; -fx-text-fill: WHITE; } +*/ /******************************************************************************* @@ -326,18 +327,19 @@ -fx-font-size: 12.0px; -fx-font-weight: bold; -fx-wrap-text: true; + -fx-cursor:hand; } .tab:selected .tab-label { -fx-alignment: CENTER; - -fx-text-fill:brown ; + -fx-text-fill:black ; /* before it was BROWN */ -fx-font-size:130.0%; } .tab:hover .tab-label{ -fx-text-fill:white; -fx-background-color:firebrick; - -fx-background-radius:8.0px; + -fx-background-radius:8.0 0.0 8.0 0.0; } @@ -446,7 +448,7 @@ } .arrowButton2{ - -fx-background-color:rgb(0,0,0,0.9); + -fx-background-color:rgb(0.0,0.0,0.0,0.9); -fx-background-radius:45.0; -fx-cursor:hand; } @@ -874,8 +876,8 @@ } #sideBar{ - -fx-background-color:rgb(0.0,0.0,0.0,0.95); - -fx-border-color:white; + -fx-background-color:rgb(0.0,0.0,0.0,0.9); + /*-fx-border-color:white;*/ } .sideBarSectionLabel{ diff --git a/src/aa_test_code_for_future_updates/FlipPaneDemo.java b/src/aa_test_code_for_future_updates/FlipPaneDemo.java new file mode 100644 index 00000000..bc37f93c --- /dev/null +++ b/src/aa_test_code_for_future_updates/FlipPaneDemo.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2015 by Gerrit Grunwald + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package aa_test_code_for_future_updates; + +import eu.hansolo.enzo.flippanel.FlipEvent; +import eu.hansolo.enzo.flippanel.FlipPanel; +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.scene.PerspectiveCamera; +import javafx.scene.control.RadioButton; +import javafx.scene.control.ToggleGroup; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; +import javafx.scene.layout.StackPane; +import javafx.scene.Scene; + + +/** + * User: hansolo + * Date: 30.04.14 + * Time: 07:55 + */ +public class FlipPaneDemo extends Application { + private FlipPanel flipPanel; + private StackPane frontPanel; + + + @Override public void init() { + frontPanel = new StackPane(); + frontPanel.setBackground(new Background(new BackgroundFill(Color.AQUAMARINE, CornerRadii.EMPTY, Insets.EMPTY))); + + flipPanel = new FlipPanel(Orientation.VERTICAL); + flipPanel.getFront().getChildren().add(initFront(flipPanel, frontPanel)); + flipPanel.getBack().getChildren().add(initBack(flipPanel, frontPanel)); + + flipPanel.addEventHandler(FlipEvent.FLIP_TO_FRONT_FINISHED, event -> System.out.println("Flip to front finished")); + flipPanel.addEventHandler(FlipEvent.FLIP_TO_BACK_FINISHED, event -> System.out.println("Flip to back finished")); + } + + private Pane initFront(final FlipPanel FLIP_PANEL, final StackPane FRONT_PANEL) { + Region settingsButton = new Region(); + settingsButton.getStyleClass().add("settings-button"); + settingsButton.addEventHandler(MouseEvent.MOUSE_CLICKED, EVENT -> FLIP_PANEL.flipToBack()); + + VBox componentsFront = new VBox(settingsButton, FRONT_PANEL); + componentsFront.setSpacing(10); + VBox.setVgrow(FRONT_PANEL, Priority.ALWAYS); + + StackPane front = new StackPane(); + front.setPadding(new Insets(20, 20, 20, 20)); + front.getStyleClass().add("panel"); + front.getChildren().addAll(componentsFront); + return front; + } + private Pane initBack(final FlipPanel flipPanel, final StackPane FRONT_PANEL) { + Region backButton = new Region(); + backButton.getStyleClass().add("back-button"); + backButton.addEventHandler(MouseEvent.MOUSE_CLICKED, EVENT -> flipPanel.flipToFront()); + + ToggleGroup group = new ToggleGroup(); + + final RadioButton standardGreen = new RadioButton("Green"); + standardGreen.setToggleGroup(group); + standardGreen.setSelected(true); + standardGreen.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, Insets.EMPTY)))); + + final RadioButton amber = new RadioButton("Red"); + amber.setToggleGroup(group); + amber.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)))); + + final RadioButton blueDarkBlue = new RadioButton("Blue"); + blueDarkBlue.setToggleGroup(group); + blueDarkBlue.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.BLUE, CornerRadii.EMPTY, Insets.EMPTY)))); + + VBox componentsBack = new VBox(backButton, standardGreen, amber, blueDarkBlue); + componentsBack.setSpacing(10); + + StackPane back = new StackPane(); + back.setPadding(new Insets(20, 20, 20, 20)); + back.getStyleClass().add("panel"); + back.getChildren().addAll(componentsBack); + return back; + } + + @Override public void start(Stage stage) { + BorderPane pane = new BorderPane(flipPanel); + pane.setPrefSize(400, 250); + pane.setPadding(new Insets(50, 50, 50, 50)); + pane.setBackground(new Background(new BackgroundFill(Color.rgb(68, 68, 68), CornerRadii.EMPTY, Insets.EMPTY))); + + PerspectiveCamera camera = new PerspectiveCamera(false); + camera.setFieldOfView(20); + + Scene scene = new Scene(pane); + scene.setCamera(camera); + //scene.getStylesheets().add(Demo.class.getResource("styles.css").toExternalForm()); + + stage.setTitle("FlipPanel Demo"); + stage.setScene(scene); + stage.show(); + } + + @Override public void stop() {} + + public static void main(String[] args) { + launch(args); + } +} diff --git a/src/aa_test_code_for_future_updates/RotCanvas.java b/src/aa_test_code_for_future_updates/RotCanvas.java new file mode 100644 index 00000000..40045442 --- /dev/null +++ b/src/aa_test_code_for_future_updates/RotCanvas.java @@ -0,0 +1,75 @@ +/** + * + */ +package aa_test_code_for_future_updates; + +import java.util.Random; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.stage.Stage; + +/** + * @author GOXR3PLUS + * + */ +public class RotCanvas extends Application { + + Random random = new Random(); + + /* (non-Javadoc) + * @see javafx.application.Application#start(javafx.stage.Stage) + */ + @Override + public void start(Stage primaryStage) throws Exception { + + Canvas canvas = new Canvas(1000, 1000); + StackPane stackPane = new StackPane(canvas); + + //Draw + GraphicsContext gc = canvas.getGraphicsContext2D(); + int points = 300; //number of points + //float pointAngle = 360 / points; //angle between points + int half = 1000 / 2; + int r = 1000/3; + gc.setLineWidth(2); + + for (float angle = 0; angle < 360; angle++){ + System.out.println("Calculating"); + gc.setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))); + + int px1 = (int) (half+Math.sin(Math.toRadians(angle))*r); + int py1 = (int) (half+Math.cos(Math.toRadians(angle))*r); + int px2 = (int) (half+Math.sin(Math.toRadians(angle))*(r+50)); + int py2 = (int) (half+Math.cos(Math.toRadians(angle))*(r+50)); + + gc.strokeLine(px1,py1, px2, py2); //draw a line from each point back to the centre + //draw line between (px1,py1) and (px2,py2) + } + +// for (float angle = 0; angle < 360; angle = angle + pointAngle) { //move round the circle to each point +// gc.setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))); +// +// double x = Math.cos(Math.toRadians(angle)) * radius; //convert angle to radians for x and y coordinates +// double y = Math.sin(Math.toRadians(angle)) * radius; +// +// // gc.strokeLine(x + half, y + half, half, half); //draw a line from each point back to the centre +// +// } + + primaryStage.setWidth(1000); + primaryStage.setHeight(1000); + primaryStage.setScene(new Scene(stackPane)); + primaryStage.show(); + + } + + public static void main(String[] args) { + launch(args); + } + +} diff --git a/src/application/ConsoleWindowController.java b/src/application/ConsoleWindowController.java index 7e2c9913..c4f3a317 100644 --- a/src/application/ConsoleWindowController.java +++ b/src/application/ConsoleWindowController.java @@ -241,7 +241,8 @@ else if ("h".equals(array[4])) //make it hours } else if ("help".equals(command)) { //help ActionTool.openFile(InfoTool.getBasePathForClass(ActionTool.class) + "XR3Player Manual.pdf"); success = true; - } + } else if ("exit".equals(command) || "close".equals(command)) //close console + window.close(); System.out.println(command); diff --git a/src/application/Main.java b/src/application/Main.java index 4c0a45ec..7a1cb067 100644 --- a/src/application/Main.java +++ b/src/application/Main.java @@ -31,7 +31,6 @@ import javafx.application.Application; import javafx.application.Platform; import javafx.beans.binding.Bindings; -import javafx.geometry.Pos; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.ButtonBar.ButtonData; @@ -50,6 +49,7 @@ import smartcontroller.MediaContextMenu; import smartcontroller.PlayedMediaList; import smartcontroller.SmartSearcher.AdvancedSearch; +import snapshot.SnapshotWindowController; import tools.ActionTool; import tools.InfoTool; import tools.NotificationType; @@ -85,6 +85,11 @@ public class Main extends Application { // + /** + * The SnapShot Window + */ + public static final SnapshotWindowController snapShotWindow = new SnapshotWindowController(); + /** The star window. */ public static final StarWindow starWindow = new StarWindow(); @@ -159,11 +164,11 @@ public class Main extends Application { /** * The current update of XR3Player */ - public final static int currentVersion = 54; + public final static int currentVersion = 55; /** * This application version release date */ - public final static String releaseDate = "10/03/2017"; + public final static String releaseDate = "12/03/2017"; /** * The Thread which is responsible for the update check @@ -204,13 +209,21 @@ public void start(Stage primaryStage) throws Exception { loginMode = new LoginMode(); // rootStack - stackPaneRoot.getChildren().addAll(root, sideBar, updateScreen, loginMode); - StackPane.setAlignment(sideBar, Pos.CENTER_LEFT); + BorderPane rootParent = new BorderPane(); + rootParent.setStyle("-fx-background-color:black;"); + rootParent.setCenter(root); + rootParent.setLeft(sideBar); + root.setStyle("-fx-background-color:red"); + stackPaneRoot.getChildren().addAll(rootParent, updateScreen, loginMode); + // StackPane.setAlignment(sideBar, Pos.CENTER_LEFT) // root + //rootParent.setVisible(false) updateScreen.setVisible(false); + sideBar.setVisible(false); topBar.setVisible(false); root.setTop(topBar); + //root.setLeft(sideBar) // Window window = primaryStage; @@ -355,6 +368,7 @@ public static void startAppWithUser(User user) { //When Top Bar to be visible? topBar.visibleProperty() .bind(libraryMode.sceneProperty().isNotNull().or(djMode.sceneProperty().isNotNull())); + sideBar.visibleProperty().bind(topBar.visibleProperty()); //Important binding libraryMode.multipleLibs.emptyLabel.textProperty() diff --git a/src/application/MultipleTabs.java b/src/application/MultipleTabs.java index b8b5261a..c47f9ca6 100644 --- a/src/application/MultipleTabs.java +++ b/src/application/MultipleTabs.java @@ -31,7 +31,7 @@ public MultipleTabs() { tabPane.setSide(Side.LEFT); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); - addTab(new Tab("Libraries", Main.libraryMode.multipleLibs)); + addTab(new Tab("Opened Libraries", Main.libraryMode.multipleLibs)); // addTab(new Tab("Radio Stations", radioStations)) tabPane.getSelectionModel().select(0); @@ -45,7 +45,7 @@ public MultipleTabs() { * the tab */ public void addTab(Tab tab) { - tab.getStyleClass().add("STab"); + //tab.getStyleClass().add("STab"); tabPane.getTabs().add(tab); } diff --git a/src/application/SideBar.java b/src/application/SideBar.java index 16fa21ac..03143baa 100644 --- a/src/application/SideBar.java +++ b/src/application/SideBar.java @@ -36,55 +36,59 @@ */ public class SideBar extends BorderPane { - /** The speech label. */ + @FXML + private JFXButton hideSideBar; + @FXML private Label speechLabel; - /** The internet label. */ @FXML private Label internetLabel; - /** The speech toggle. */ @FXML private JFXToggleButton speechToggle; - /** The speech progress indicator. */ @FXML private ProgressIndicator speechProgressIndicator; - /** The internet toggle. */ @FXML private JFXToggleButton internetToggle; - /** The internet progress indicator. */ @FXML private ProgressIndicator internetProgressIndicator; + @FXML + private ImageView userImageView; + @FXML Label userNameLabel; - /** The xr 3 settings. */ @FXML private MenuButton xr3Settings; - /** The import data base. */ @FXML private MenuItem importDataBase; - /** The export data base. */ @FXML private MenuItem exportDataBase; - /** The delete data base. */ @FXML private MenuItem deleteDataBase; - /** The hide side bar. */ @FXML - private JFXButton hideSideBar; + private JFXButton homeScreen; @FXML - private ImageView userImageView; + private JFXButton userSettings; + + @FXML + private JFXButton applicationSettings; + + @FXML + private JFXButton applicationConsole; + + @FXML + private JFXButton snapshot; // ------------------------------------------------------------- @@ -153,6 +157,16 @@ public void hideBar() { } } + /** + * Shows/Hides Side Bar + */ + public void toogleBar() { + if (this.getTranslateX() == -this.getPrefWidth()) + showBar(); + else + hideBar(); + } + /** * Called as soon as .fxml is initialized */ @@ -164,10 +178,24 @@ private void initialize() { tTrans.setFromX(-this.getPrefWidth()); tTrans.setToX(0); - this.setTranslateX(-this.getPrefWidth()); + //this.setTranslateX(-this.getPrefWidth()) + //showBar() // closeSideBar - hideSideBar.setOnAction(a -> hideBar()); + hideSideBar.setOnAction(a -> toogleBar()); + + //applicationSettings + applicationSettings.setOnAction(a -> Main.settingsWindow.showWindow()); + + //applicationConsole + applicationConsole.setOnAction(a -> Main.consoleWindow.show()); + + //snapShot + snapshot.setOnAction(a -> { + ActionTool.showAlert("Snapshot Window", "Read the below.", + "This is a prototype , and it will be improved on the next updates. \n\n----------------------------Helpful Info----------------------------\nA window will appear , you have to drag your mouse to select an area of the screen, \n Press : [ ESCAPE OR BACKSPACE ] to exit \n Press : [ ENTER OR SPACE ] to capture the selected area."); + Main.snapShotWindow.prepareForCapture(); + }); // Clip Rectangle rect = new Rectangle(); diff --git a/src/application/TopBar.java b/src/application/TopBar.java index dd047784..7f90d27d 100644 --- a/src/application/TopBar.java +++ b/src/application/TopBar.java @@ -36,14 +36,14 @@ public class TopBar extends BorderPane { @FXML private ToggleButton goLibrariesMode; - @FXML - private Button openSettings; + // @FXML + // private Button openSettings @FXML private ToggleButton goDJMode; - @FXML - private Button openConsole; + // @FXML + //private Button openConsole @FXML private MenuItem checkForUpdates; @@ -69,8 +69,8 @@ public class TopBar extends BorderPane { @FXML private Button close; - @FXML - private Button showSideBar; + // @FXML + //private Button showSideBar; @FXML private StackPane cpuStackPane; @@ -126,7 +126,7 @@ public TopBar() { private void initialize() { //openConsole - openConsole.setOnAction(a -> Main.consoleWindow.show()); + //openConsole.setOnAction(a -> Main.consoleWindow.show()) //help help.setOnAction( @@ -149,7 +149,7 @@ private void initialize() { //cpUsage.restartUpdater() // showSideBar - showSideBar.setOnAction(a -> Main.sideBar.showBar()); + //showSideBar.setOnAction(a -> Main.sideBar.toogleBar()); // checkForUpdates checkForUpdates.setOnAction(a -> Main.checkForUpdates(true)); @@ -178,7 +178,7 @@ private void initialize() { }); //openSettings - openSettings.setOnAction(a -> Main.settingsWindow.showWindow()); + //openSettings.setOnAction(a -> Main.settingsWindow.showWindow()); // minimize minimize.setOnAction(ac -> Main.window.setIconified(true)); diff --git a/src/application/users/LoginMode.java b/src/application/users/LoginMode.java index 17babed0..4d4996d6 100644 --- a/src/application/users/LoginMode.java +++ b/src/application/users/LoginMode.java @@ -98,7 +98,7 @@ public void invalidated(Observable observable) { Main.renameWindow.showingProperty().removeListener(this); // !Showing && !XPressed - if (!Main.renameWindow.isShowing() && !Main.renameWindow.isXPressed()) { + if (!Main.renameWindow.isShowing() && Main.renameWindow.wasAccepted()) { Main.window.requestFocus(); @@ -167,13 +167,18 @@ private void initialize() { //deleteUser deleteUser.disableProperty().bind(newUser.visibleProperty()); deleteUser.setOnAction(a -> { - //Try to delete it - if (ActionTool.deleteFile(new File( - InfoTool.ABSOLUTE_DATABASE_PATH_WITH_SEPARATOR + userViewer.getSelectedItem().getUserName()))) - userViewer.deleteUser(userViewer.getSelectedItem()); - else - ActionTool.showNotification("Error", "An error occured trying to delete the user", Duration.seconds(2), - NotificationType.ERROR); + //Ask + if (ActionTool.doQuestion("Confirm that you want to 'delete' this user ,\n Name: [ " + + userViewer.getSelectedItem().getUserName() + " ]")) { + + //Try to delete it + if (ActionTool.deleteFile(new File( + InfoTool.ABSOLUTE_DATABASE_PATH_WITH_SEPARATOR + userViewer.getSelectedItem().getUserName()))) + userViewer.deleteUser(userViewer.getSelectedItem()); + else + ActionTool.showNotification("Error", "An error occured trying to delete the user", + Duration.seconds(2), NotificationType.ERROR); + } }); //exitButton diff --git a/src/database/LocalDBManager.java b/src/database/LocalDBManager.java index d975dc1d..7ae18153 100644 --- a/src/database/LocalDBManager.java +++ b/src/database/LocalDBManager.java @@ -281,11 +281,11 @@ private void createXPlayListTable(Statement statement, int key) throws SQLExcept public void loadApplicationDataBase() { Main.updateScreen.setVisible(true); Main.updateScreen.progressBar.progressProperty().bind(dataLoader.progressProperty()); - // System.out.println(Main.updateScreen.progressBar.getProgress()); - // System.out.println(Main.updateScreen.progressBar.getProgress()); - // System.out.println(Main.updateScreen.progressBar.getProgress()); - // System.out.println(Main.updateScreen.progressBar.getProgress()); - // System.out.println(Main.updateScreen.progressBar.getProgress()); + // System.out.println(Main.updateScreen.progressBar.getProgress()) + // System.out.println(Main.updateScreen.progressBar.getProgress()) + // System.out.println(Main.updateScreen.progressBar.getProgress()) + // System.out.println(Main.updateScreen.progressBar.getProgress()) + // System.out.println(Main.updateScreen.progressBar.getProgress()) dataLoader.restart(); } diff --git a/src/disc/DJDisc.java b/src/disc/DJDisc.java index b98cf4d1..a2d748f5 100644 --- a/src/disc/DJDisc.java +++ b/src/disc/DJDisc.java @@ -26,6 +26,7 @@ import javafx.scene.paint.Color; import javafx.scene.shape.ArcType; import javafx.scene.shape.Circle; +import javafx.scene.text.TextAlignment; import javafx.scene.transform.Rotate; import javafx.util.Duration; import tools.InfoTool; @@ -124,6 +125,8 @@ public DJDisc(int width, int height, Color arcColor, int volume, int maximumVolu // StackPane canvas.setPickOnBounds(false); canvas.setCursor(Cursor.OPEN_HAND); + canvas.setPickOnBounds(false); + super.setPickOnBounds(false); //setStyle("-fx-background-color:green;") this.arcColor = arcColor; @@ -133,6 +136,7 @@ public DJDisc(int width, int height, Color arcColor, int volume, int maximumVolu replaceImage(null); // timeField + timeField.setTextAlignment(TextAlignment.CENTER); timeField.setStyle( "-fx-background-color:white; -fx-padding:-2 8 -2 8; -fx-background-radius: 15; -fx-font-weight:bold; -fx-font-size:15; -fx-text-fill:black; -fx-cursor:hand;"); timeField.setOnMouseClicked(c -> { @@ -441,6 +445,9 @@ public void updateTimeDirectly(int current, int total, String milliseconds) { this.time = time + "." + (9 - Integer.parseInt(milliseconds.replace(".", ""))); else this.time = time + milliseconds; + + //Final + //this.time = time + "\n," + InfoTool.getTimeEdited(total); } /** @@ -542,7 +549,7 @@ public void calculateAngleByMouse(MouseEvent m, int current, int total) { else { angle = (int) Math.toDegrees(Math.atan2(getWidth() / 2 - mouseX, getHeight() / 2 - mouseY)); angle = -(360 - angle); // make it minus cause i turn it - // on the right + // on the right } // System.out.println(-angle) diff --git a/src/librarysystema/Library.java b/src/librarysystema/Library.java index e79115c5..195a165e 100644 --- a/src/librarysystema/Library.java +++ b/src/librarysystema/Library.java @@ -12,7 +12,6 @@ import org.controlsfx.control.Notifications; -import com.jfoenix.controls.JFXBadge; import com.jfoenix.controls.JFXCheckBox; import application.Main; @@ -30,15 +29,12 @@ import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import javafx.scene.control.Tab; -import javafx.scene.effect.DropShadow; -import javafx.scene.effect.Reflection; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.TransferMode; import javafx.scene.layout.StackPane; -import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.util.Duration; import smartcontroller.Genre; @@ -54,14 +50,12 @@ */ public class Library extends StackPane { - /** The logger for this class */ - private static final Logger logger = Logger.getLogger(Library.class.getName()); + @FXML + ImageView imageView; - /** The image view. */ @FXML - public ImageView imageView; + private Label nameField; - /** The go settings. */ @FXML private Label goSettings; @@ -71,13 +65,8 @@ public class Library extends StackPane { @FXML private Label warningLabel; - /** The rating label. */ @FXML - private JFXBadge ratingLabel; - - /** The name field. */ - @FXML - private Label nameField; + private Label ratingLabel; @FXML private StackPane progressBarStackPane; @@ -100,6 +89,9 @@ public class Library extends StackPane { // ------------------------------------------- + /** The logger for this class */ + private static final Logger logger = Logger.getLogger(Library.class.getName()); + /** The controller. */ private final SmartController controller; @@ -219,7 +211,7 @@ public void invalidated(Observable observable) { nameField.textProperty().unbind(); // !XPressed && Old name !=newName - if (!Main.renameWindow.isXPressed() && !libraryName.equals(newName)) { + if (Main.renameWindow.wasAccepted() && !libraryName.equals(newName)) { // duplicate? if (!(duplicate = Main.libraryMode.libraryViewer.items.stream().anyMatch( @@ -266,7 +258,7 @@ public void invalidated(Observable observable) { // Rename Tab + Unbind Tab textProperty if (isLibraryOpened()) { - if (!Main.renameWindow.isXPressed() && !newName.equals(oldName) && !duplicate) + if (!Main.renameWindow.wasAccepted() && !newName.equals(oldName) && !duplicate) Main.libraryMode.multipleLibs.renameTab(oldName, getLibraryName()); Main.libraryMode.multipleLibs.getTab(getLibraryName()).getTooltip().textProperty().unbind(); @@ -276,7 +268,7 @@ public void invalidated(Observable observable) { controller.renameWorking = false; // commit - if (!Main.renameWindow.isXPressed() && !newName.equals(oldName) && !duplicate) + if (!Main.renameWindow.wasAccepted() && !newName.equals(oldName) && !duplicate) Main.dbManager.commit(); } @@ -495,7 +487,7 @@ private void initialize() { // Rating Label ratingLabel.textProperty().bind(starsProperty().asString()); - ratingLabel.visibleProperty().bind(starsProperty().greaterThan(0)); + //ratingLabel.visibleProperty().bind(starsProperty().greaterThan(0)); this.setOnScroll(scroll -> { if (scroll.getDeltaY() > 0) updateStars(starsProperty().get() + 0.5); @@ -820,6 +812,11 @@ protected void updateLibraryStars() { .bind(Main.starWindow.starsProperty().asString()); Main.starWindow.show(starsProperty().get(), Main.libraryMode.libraryViewer.settings.getStarsLabel()); + + //Keep a reference to the previous stars + double previousStars = stars.get(); + + //Bind stars.bind(Main.starWindow.starsProperty()); Main.starWindow.window.showingProperty().addListener(new InvalidationListener() { @@ -834,9 +831,15 @@ public void invalidated(Observable observable) { // if !showing if (!Main.starWindow.window.isShowing()) { + + //Unbind + Main.libraryMode.libraryViewer.settings.getStarsLabel().textProperty().unbind(); + + //Was accepted if (Main.starWindow.wasAccepted()) updateStars(Main.starWindow.getStars()); - Main.libraryMode.libraryViewer.settings.getStarsLabel().textProperty().unbind(); + else + setStars(previousStars); } } @@ -850,7 +853,7 @@ public void invalidated(Observable observable) { */ public void deleteLibrary() { if (controller.isFree(true) && ActionTool - .doQuestion("Confirm that you want to 'delete' this library,\n Name: " + getLibraryName())) { + .doQuestion("Confirm that you want to 'delete' this library,\n Name: [" + getLibraryName()+" ]")) { try { diff --git a/src/librarysystema/LibraryMode.java b/src/librarysystema/LibraryMode.java index c4747385..c33081ba 100644 --- a/src/librarysystema/LibraryMode.java +++ b/src/librarysystema/LibraryMode.java @@ -29,7 +29,6 @@ import javafx.fxml.FXMLLoader; import javafx.geometry.Bounds; import javafx.geometry.Side; -import javafx.scene.CacheHint; import javafx.scene.Cursor; import javafx.scene.Group; import javafx.scene.Node; @@ -120,7 +119,7 @@ public void invalidated(Observable observable) { Main.renameWindow.showingProperty().removeListener(this); // !Showing && !XPressed - if (!Main.renameWindow.isShowing() && !Main.renameWindow.isXPressed()) { + if (!Main.renameWindow.isShowing() && Main.renameWindow.wasAccepted()) { Main.window.requestFocus(); @@ -271,7 +270,7 @@ public void initialize() { Main.xPlayersList.addXPlayerController(new XPlayerController(0)); Main.xPlayersList.getXPlayerController(0).makeTheDisc(136, 136, Color.ORANGE, 45, Side.LEFT); Main.xPlayersList.getXPlayerController(0).makeTheVisualizer(Side.RIGHT); - add(Main.xPlayersList.getXPlayerController(0), 1, 1); + add(Main.xPlayersList.getXPlayerController(0).getFlipPanel(), 1, 1); } diff --git a/src/media/Media.java b/src/media/Media.java index 25409e9a..2ed6f2ea 100644 --- a/src/media/Media.java +++ b/src/media/Media.java @@ -470,7 +470,7 @@ public void invalidated(Observable observable) { String newName = new File(getFilePath()).getParent() + File.separator + fileName.get(); // !XPressed && // Old name != New name - if (!Main.renameWindow.isXPressed() && !getFilePath().equals(newName)) { + if (Main.renameWindow.wasAccepted() && !getFilePath().equals(newName)) { try { diff --git a/src/snapshot/SnapshotWindowController.java b/src/snapshot/SnapshotWindowController.java index cab1a40d..7040df84 100644 --- a/src/snapshot/SnapshotWindowController.java +++ b/src/snapshot/SnapshotWindowController.java @@ -80,7 +80,7 @@ public class SnapshotWindowController extends StackPane { public SnapshotWindowController() { // FXMLLOADER - FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.fxmls+"SnapshotWindowController.fxml")); + FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.fxmls + "SnapshotWindowController.fxml")); loader.setController(this); loader.setRoot(this); @@ -286,7 +286,7 @@ private void deActivateAllKeys() { /** * Creates and saves the image. */ - public void prepareImage() { + private void prepareImage() { Platform.runLater(() -> { // Clear the canvas gc.clearRect(0, 0, window.getWidth(), window.getHeight()); diff --git a/src/tools/ActionTool.java b/src/tools/ActionTool.java index e019063d..e0d957fe 100644 --- a/src/tools/ActionTool.java +++ b/src/tools/ActionTool.java @@ -15,6 +15,7 @@ import java.nio.file.attribute.FileTime; import java.util.LinkedList; import java.util.Random; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; @@ -342,6 +343,27 @@ public static void showNotification(String title, String text, Duration duration } + /** + * Shows an Alert + * + * @param title + * @param headerText + * @param contentText + */ + public static void showAlert(String title, String headerText, String contentText) { + //AtomicBoolean answer = new AtomicBoolean(false) + + // Show Alert + Alert alert = new Alert(AlertType.INFORMATION); + alert.initStyle(StageStyle.UTILITY); + alert.initOwner(Main.window); + //alert.setGraphic(questionImage) + alert.setTitle(title); + alert.setHeaderText(title); + alert.setContentText(contentText); + alert.showAndWait(); + } + /** * Makes a question to the user. * diff --git a/src/visualizer/model/Oscilloscope.java b/src/visualizer/model/Oscilloscope.java index 55c60acc..9e538db9 100644 --- a/src/visualizer/model/Oscilloscope.java +++ b/src/visualizer/model/Oscilloscope.java @@ -79,8 +79,7 @@ public Oscilloscope(VisualizerDrawer visualizerDrawer) { * Draws an Oscilloscope. * * @param stereo - * The Oscilloscope with have 2 lines->stereo or 1 line->merge - * left and right audio + * The Oscilloscope with have 2 lines->stereo or 1 line->merge left and right audio */ public void drawOscilloscope(boolean stereo) { float[] pSample1; @@ -91,10 +90,8 @@ public void drawOscilloscope(boolean stereo) { else // not?Then merge the array pSample1 = visualizerDrawer.stereoMerge(visualizerDrawer.pLeftChannel, visualizerDrawer.pRightChannel); - // backgoundImage - if (visualizerDrawer.backgroundImage != null) - visualizerDrawer.gc.drawImage(visualizerDrawer.backgroundImage, 0, 0, visualizerDrawer.canvasWidth, - visualizerDrawer.canvasHeight); + //Background + visualizerDrawer.drawBackgroundImage(); visualizerDrawer.gc.setStroke(visualizerDrawer.scopeColor); // System.out.println(pSample.length) @@ -135,6 +132,9 @@ public void drawOscilloscope(boolean stereo) { */ public void drawOscilloScopeLines() { + //Background + visualizerDrawer.drawBackgroundImage(); + // Use HSB color model colorIndex = (colorIndex == colorSize - 1) ? 0 : colorIndex + 1; visualizerDrawer.gc.setStroke(Color.hsb(colorIndex, 1.0f, 1.0f)); @@ -153,7 +153,8 @@ public void drawOscilloScopeLines() { // those of the previous sample. x = sample number; y = sample value for (int i = 0; i < newSampleCount; i++) { x = (int) (i * bandWidth); - y = halfHeight + (int) (quarterHeight * (visualizerDrawer.pLeftChannel[i] + visualizerDrawer.pRightChannel[i])); + y = halfHeight + + (int) (quarterHeight * (visualizerDrawer.pLeftChannel[i] + visualizerDrawer.pRightChannel[i])); x = Math.min(Math.max(0, x), visualizerDrawer.canvasWidth); y = Math.min(Math.max(0, y), visualizerDrawer.canvasHeight); diff --git a/src/visualizer/model/Polyspiral.java b/src/visualizer/model/Polyspiral.java index 8d92e75c..1df1c265 100644 --- a/src/visualizer/model/Polyspiral.java +++ b/src/visualizer/model/Polyspiral.java @@ -8,7 +8,6 @@ import javafx.geometry.Point2D; import javafx.scene.image.Image; import javafx.scene.paint.Color; -import javafx.scene.shape.ArcType; /** * ----------------------------------------------------------------------- @@ -135,6 +134,20 @@ public Polyspiral(VisualizerDrawer visualizerDrawer) { * ----------------------------------------------------------------------- */ + /** The color size. */ + private final int colorSize2 = 360; + + /** The color index. */ + private int colorIndex2 = 0; + + // + + /** The color size. */ + private final int colorSize3 = 360; + + /** The color index. */ + private int colorIndex3 = 0; + /** * Draws a Rosette and a Polyspiral. */ @@ -164,10 +177,8 @@ public void drawPolySpiral() { total = 1200; } - // Background image - if (visualizerDrawer.backgroundImage != null) - visualizerDrawer.gc.drawImage(visualizerDrawer.backgroundImage, 0, 0, visualizerDrawer.canvasWidth, - visualizerDrawer.canvasHeight); + // Background + visualizerDrawer.drawBackgroundImage(); // Set the background fill visualizerDrawer.gc.setFill(Color.rgb(0, 0, 0, array[0])); @@ -182,78 +193,88 @@ public void drawPolySpiral() { * error(gc.fillOval(random.nextInt(width), random.nextInt(height), * length + 2.00, length + 2.00);) */ - visualizerDrawer.gc.setFill(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))); for (int i = 0; i < total; i++) { + + //Change the Fill + colorIndex2 = (colorIndex2 == colorSize2 - 1) ? 0 : colorIndex2 + 1; + visualizerDrawer.gc.setFill(Color.hsb(colorIndex2, 1.0f, 1.0f)); + + //Draw the Oval visualizerDrawer.gc.fillOval(random.nextInt(visualizerDrawer.canvasWidth), random.nextInt(visualizerDrawer.canvasHeight), length + 2.00, length + 2.00); } - - // Draw Lights - if (visualizerDrawer.canvasWidth > greyLight.getWidth() - && visualizerDrawer.canvasHeight > greyLight.getHeight()) - if (array[0] < 0.2) { - drawLight(greyLight); - } else if (array[0] < 0.3) { - drawLight(lightBlueLight); - } else if (array[0] < 0.4) { - drawLight(blueLight); - } else if (array[0] < 0.6) { - drawLight(yellowLight); - } else if (array[0] < 0.9) { - drawLight(redLight); - - } - - // Scope - if (visualizerDrawer.canvasWidth > greyLight.getWidth() - && visualizerDrawer.canvasHeight > greyLight.getHeight()) { - visualizerDrawer.gc.setStroke(visualizerDrawer.scopeColor); - double coolW = coolEffect.getWidth(); - double coolH = coolEffect.getHeight() < visualizerDrawer.canvasHeight ? coolEffect.getHeight() - : visualizerDrawer.canvasHeight; - - // ------------------------Draw Scope---------------------------- - - // Scope 1 - int zb = (int) (50 + 100 * array[0]); - int yLast = (int) (pSample[0] * (float) zb) + zb; - int angleIncrement = 1; - for (int a = angleIncrement, c = (int) (coolW / 2 - 50); c < (visualizerDrawer.canvasWidth - - coolW / 2); a += angleIncrement, c++) { - int yNow = (int) (pSample[a] * (float) zb) + zb; - visualizerDrawer.gc.strokeLine(c, yLast, c + 1.00, yNow); - yLast = yNow; - } - - visualizerDrawer.gc - .setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), 1.0)); - - // Scope 2 - int zb2 = (int) (visualizerDrawer.canvasHeight - 50 - 100 * array[0]); - int yLast2 = (int) (pSample[0] * (float) zb2) + zb2; - int angleIncrement2 = 1; - for (int a = angleIncrement2, c = (int) (coolW / 2 - 50); c < (visualizerDrawer.canvasWidth - - coolW / 2); a += angleIncrement2, c++) { - int yNow2 = (int) (pSample[a] * (float) zb2) + zb2; - visualizerDrawer.gc.strokeLine(c, yLast2, c + 1.00, yNow2); - yLast2 = yNow2; - } - - // Cool Effects - visualizerDrawer.gc.drawImage(coolEffect, (coolW / 2 - 50) - coolW * array[0] / 2, - (visualizerDrawer.canvasHeight / 2 - coolH / 2) - coolH * array[0] / 2, coolW * array[0], - coolH * array[0]); - visualizerDrawer.gc.drawImage(coolEffect, (visualizerDrawer.canvasWidth - coolW / 2) - coolW * array[0] / 2, - (visualizerDrawer.canvasHeight / 2 - coolH / 2) - coolH * array[0] / 2, coolW * array[0], - coolH * array[0]); - - visualizerDrawer.gc.drawImage(coolEffect, (coolW / 2 - 50) - coolW * array[0] / 2, - (visualizerDrawer.canvasHeight - coolH / 2) - coolH * array[0] / 2, coolW * array[0], - coolH * array[0]); - visualizerDrawer.gc.drawImage(coolEffect, (visualizerDrawer.canvasWidth - coolW / 2) - coolW * array[0] / 2, - (visualizerDrawer.canvasHeight - coolH / 2) - coolH * array[0] / 2, coolW * array[0], - coolH * array[0]); - } + // + // // Draw Lights + // if (visualizerDrawer.canvasWidth > greyLight.getWidth() + // && visualizerDrawer.canvasHeight > greyLight.getHeight()) + // if (array[0] < 0.2) { + // drawLight(greyLight); + // } else if (array[0] < 0.3) { + // drawLight(lightBlueLight); + // } else if (array[0] < 0.4) { + // drawLight(blueLight); + // } else if (array[0] < 0.6) { + // drawLight(yellowLight); + // } else if (array[0] < 0.9) { + // drawLight(redLight); + // + // } + // + // // Scope + // if (visualizerDrawer.canvasWidth > greyLight.getWidth() + // && visualizerDrawer.canvasHeight > greyLight.getHeight()) { + // visualizerDrawer.gc.setStroke(visualizerDrawer.scopeColor); + // double coolW = coolEffect.getWidth(); + // double coolH = coolEffect.getHeight() < visualizerDrawer.canvasHeight ? coolEffect.getHeight() + // : visualizerDrawer.canvasHeight; + + // ------------------------Draw Scope---------------------------- + + // // Scope 1 + // int zb = (int) (50 + 100 * array[0]); + // int yLast = (int) (pSample[0] * (float) zb) + zb; + // int angleIncrement = 1; + // for (int a = angleIncrement, c = (int) (coolW / 2 - 50); c < (visualizerDrawer.canvasWidth + // - coolW / 2); a += angleIncrement, c++) { + // int yNow = (int) (pSample[a] * (float) zb) + zb; + // visualizerDrawer.gc.strokeLine(c, yLast, c + 1.00, yNow); + // yLast = yNow; + // } + + // visualizerDrawer.gc + // .setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), 1.0)); + // + // // Scope 2 + // int zb2 = (int) (visualizerDrawer.canvasHeight - 50 - 100 * array[0]); + // int yLast2 = (int) (pSample[0] * (float) zb2) + zb2; + // int angleIncrement2 = 1; + // for (int a = angleIncrement2, c = (int) (coolW / 2 - 50); c < (visualizerDrawer.canvasWidth + // - coolW / 2); a += angleIncrement2, c++) { + // int yNow2 = (int) (pSample[a] * (float) zb2) + zb2; + // visualizerDrawer.gc.strokeLine(c, yLast2, c + 1.00, yNow2); + // yLast2 = yNow2; + // } + + // Cool Effects + // visualizerDrawer.gc.drawImage(coolEffect, (coolW / 2 - 50) - coolW * array[0] / 2, + // (visualizerDrawer.canvasHeight / 2 - coolH / 2) - coolH * array[0] / 2, coolW * array[0], + // coolH * array[0]); + // visualizerDrawer.gc.drawImage(coolEffect, (visualizerDrawer.canvasWidth - coolW / 2) - coolW * array[0] / 2, + // (visualizerDrawer.canvasHeight / 2 - coolH / 2) - coolH * array[0] / 2, coolW * array[0], + // coolH * array[0]); + // + // visualizerDrawer.gc.drawImage(coolEffect, (coolW / 2 - 50) - coolW * array[0] / 2, + // (visualizerDrawer.canvasHeight - coolH / 2) - coolH * array[0] / 2, coolW * array[0], + // coolH * array[0]); + // visualizerDrawer.gc.drawImage(coolEffect, (visualizerDrawer.canvasWidth - coolW / 2) - coolW * array[0] / 2, + // (visualizerDrawer.canvasHeight - coolH / 2) - coolH * array[0] / 2, coolW * array[0], + // coolH * array[0]); + // } + + //Foreground + visualizerDrawer.drawForegroundImage(array); + + drawPolyspiral2(); // ------------------------Draw Rosette---------------------------- calculate(); @@ -274,8 +295,15 @@ public void drawPolySpiral() { for (int i = 0; i < numOfVertices; i++) for (int j = numOfVertices - 1; j >= 0; j--) if (j > i) { - visualizerDrawer.gc.setStroke( - Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), opacity)); + + //Set Stroke color + colorIndex3 = (colorIndex3 == colorSize3 - 1) ? 0 : colorIndex3 + 1; + visualizerDrawer.gc.setStroke(Color.hsb(colorIndex3, 1.0f, 1.0f, opacity)); + + // visualizerDrawer.gc.setStroke( + // Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), opacity)); + + //Draw the Line visualizerDrawer.gc.strokeLine(deviceX(vertices[i].getX()), deviceY(vertices[i].getY()), deviceX(vertices[j].getX()), deviceY(vertices[j].getY())); } else @@ -285,59 +313,44 @@ public void drawPolySpiral() { // if array[0]==1 it has an ugly effect of drawing one horizontal line // so i don't need this - if (array[0] < 0.99) { - - do { - polySpiralAngle = (float) Math.random() * 360; - distance = (float) Math.random(); - increment = (float) Math.random(); - } while (polySpiralAngle == 0 || distance == 0.0F || increment == 0.0F); - - distance = (float) Math.random() * array[0];// (float) 0.2// // - // array[0]*array[1]*100 - increment = (float) 0.07; // (float) Math.random() * array[1] * 100 - // + (float) 0.07 - polySpiralAngle = array[1] < 0.35 ? array[0] * 360 : array[0] * 360 * (float) Math.random() * 100; - - curX = 0.0F; - curY = 0.0F; - cd = 0.0F; - - visualizerDrawer.gc.setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), - array[0] < 0.28 ? 0.0 : 1.0)); - for (int i = 0; i < iterator; i++) { - - // draw Line - float lineAngle = TWO_PI * cd / 360.0f; - float newX = curX + distance * (float) Math.cos(lineAngle); - float newY = curY + distance * (float) Math.sin(lineAngle); - visualizerDrawer.gc.strokeLine(deviceX(curX), deviceY(curY), deviceX(newX), deviceY(newY)); - curX = newX; - curY = newY; - - cd -= polySpiralAngle; - distance = distance + increment; - } - } - - // Draw the foreground images - double imageW = visualizerDrawer.foregroundImage.getWidth(); - double imageH = visualizerDrawer.foregroundImage.getHeight(); - if (visualizerDrawer.canvasWidth < visualizerDrawer.canvasHeight) - imageW = imageH = visualizerDrawer.canvasWidth / 1.5; - else if (visualizerDrawer.canvasHeight < visualizerDrawer.canvasWidth) - imageW = imageH = visualizerDrawer.canvasHeight / 1.5; - - else { - - imageW = visualizerDrawer.getWidth() / 2; - imageH = visualizerDrawer.getHeight() / 2; - } - // System.out.println(imageW + ", h:" + imageH) - visualizerDrawer.gc.drawImage(visualizerDrawer.foregroundImage, - (visualizerDrawer.canvasWidth / 2 - imageW / 2) - imageW * array[0] / 2, - (visualizerDrawer.canvasHeight / 2 - imageH / 2) - imageH * array[0] / 2, imageW + imageW * array[0], - imageH + imageH * array[0]); + // if (array[0] < 0.99) { + // + // do { + // polySpiralAngle = (float) Math.random() * 360; + // distance = (float) Math.random(); + // increment = (float) Math.random(); + // } while (polySpiralAngle == 0 || distance == 0.0F || increment == 0.0F); + // + // distance = (float) Math.random() * array[0];// (float) 0.2// // + // // array[0]*array[1]*100 + // increment = (float) 0.07; // (float) Math.random() * array[1] * 100 + // // + (float) 0.07 + // polySpiralAngle = array[1] < 0.35 ? array[0] * 360 : array[0] * 360 * (float) Math.random() * 100; + // + // curX = 0.0F; + // curY = 0.0F; + // cd = 0.0F; + // + // colorIndex3 = (colorIndex3 == colorSize3 - 1) ? 0 : colorIndex3 + 1; + // visualizerDrawer.gc.setStroke(Color.hsb(colorIndex3, 1.0f, 1.0f,array[0] < 0.28 ? 0.0 : 1.0)); + // + //// visualizerDrawer.gc.setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255), + //// array[0] < 0.28 ? 0.0 : 1.0)); + // + // for (int i = 0; i < iterator; i++) { + // + // // draw Line + // float lineAngle = TWO_PI * cd / 360.0f; + // float newX = curX + distance * (float) Math.cos(lineAngle); + // float newY = curY + distance * (float) Math.sin(lineAngle); + // visualizerDrawer.gc.strokeLine(deviceX(curX), deviceY(curY), deviceX(newX), deviceY(newY)); + // curX = newX; + // curY = newY; + // + // cd -= polySpiralAngle; + // distance = distance + increment; + // } + // } } @@ -394,10 +407,13 @@ private int deviceY(double logicalY) { /** * Draws a polyspiral and 4 arcs */ - public void drawPolyspiral2() { + private void drawPolyspiral2() { float[] pSample = visualizerDrawer.stereoMerge(visualizerDrawer.pLeftChannel, visualizerDrawer.pRightChannel); float[] array = visualizerDrawer.returnBandsArray(pSample, 4); + //Background + //visualizerDrawer.drawBackgroundImage() + // Draw tge Oscilloscope Lines below // drawJuliaSet() // visualizerDrawer.gc.setGlobalAlpha(0.8 - Math.abs(array[0])) @@ -412,31 +428,31 @@ public void drawPolyspiral2() { double angle = angleIncrement; // visualizerDrawer.gc.setStroke(Color.RED) - visualizerDrawer.gc.setLineWidth(2); - visualizerDrawer.gc.strokeArc(5, 5, visualizerDrawer.canvasWidth - 10, visualizerDrawer.canvasHeight - 10, 90, - 360 * Math.abs(array[0]), ArcType.OPEN); - visualizerDrawer.gc.setStroke(Color.CYAN); - visualizerDrawer.gc.strokeArc(15, 15, visualizerDrawer.canvasWidth - 30, visualizerDrawer.canvasHeight - 30, - 180, 360 * Math.abs(array[1]), ArcType.OPEN); - visualizerDrawer.gc.setStroke(Color.FIREBRICK); - visualizerDrawer.gc.strokeArc(25, 25, visualizerDrawer.canvasWidth - 50, visualizerDrawer.canvasHeight - 50, - 270, 360 * Math.abs(array[2]), ArcType.OPEN); - visualizerDrawer.gc.setStroke(Color.CHARTREUSE); - visualizerDrawer.gc.strokeArc(35, 35, visualizerDrawer.canvasWidth - 70, visualizerDrawer.canvasHeight - 70, - 360, 360 * Math.abs(array[3]), ArcType.OPEN); - visualizerDrawer.gc.setLineWidth(1); + // visualizerDrawer.gc.setLineWidth(2); + // visualizerDrawer.gc.strokeArc(5, 5, visualizerDrawer.canvasWidth - 10, visualizerDrawer.canvasHeight - 10, 90, + // 360 * Math.abs(array[0]), ArcType.OPEN); + // visualizerDrawer.gc.setStroke(Color.CYAN); + // visualizerDrawer.gc.strokeArc(15, 15, visualizerDrawer.canvasWidth - 30, visualizerDrawer.canvasHeight - 30, + // 180, 360 * Math.abs(array[1]), ArcType.OPEN); + // visualizerDrawer.gc.setStroke(Color.FIREBRICK); + // visualizerDrawer.gc.strokeArc(25, 25, visualizerDrawer.canvasWidth - 50, visualizerDrawer.canvasHeight - 50, + // 270, 360 * Math.abs(array[2]), ArcType.OPEN); + // visualizerDrawer.gc.setStroke(Color.CHARTREUSE); + // visualizerDrawer.gc.strokeArc(35, 35, visualizerDrawer.canvasWidth - 70, visualizerDrawer.canvasHeight - 70, + // 360, 360 * Math.abs(array[3]), ArcType.OPEN); + // visualizerDrawer.gc.setLineWidth(1); // visualizerDrawer.gc.setLineWidth(0.5) visualizerDrawer.gc.setLineWidth(1.5); int until = (int) (x1 + y1) / 2; // (int) - // (visualizerDrawer.canvasWidth/2 * - // Math.abs(array[0])) + // (visualizerDrawer.canvasWidth/2 * + // Math.abs(array[0])) double twoPI = Math.PI * 2; int lenIncrement = (int) (3 * Math.abs(array[1])); for (int i = 0; i < until; i++) { colorIndex = (colorIndex == 360 - 1) ? 0 : colorIndex + 1; - visualizerDrawer.gc.setStroke(Color.hsb(colorIndex, 1.0f, 1.0f)); + visualizerDrawer.gc.setStroke(Color.hsb(colorIndex, 1.0f, 1.0f, 1)); double x2 = x1 + Math.cos(angle) * len; double y2 = y1 - Math.sin(angle) * len; diff --git a/src/visualizer/model/Sierpinski.java b/src/visualizer/model/Sierpinski.java index 826b3071..317daaf8 100644 --- a/src/visualizer/model/Sierpinski.java +++ b/src/visualizer/model/Sierpinski.java @@ -24,7 +24,7 @@ * @author GOXR3PLUS */ public class Sierpinski { - + Random random = new Random(); /** The sierpinski root height. */ @@ -81,10 +81,8 @@ public void drawSierpinski() { sierpinskiAcceleration = array[0] * 0.1; // System.out.println(sierpinskiAcceleration) - // Background image - if (visualizerDrawer.backgroundImage != null) - visualizerDrawer.gc.drawImage(visualizerDrawer.backgroundImage, 0, 0, visualizerDrawer.canvasWidth, - visualizerDrawer.canvasHeight); + // Background + visualizerDrawer.drawBackgroundImage(); calcTriangles(); drawTriangles(); @@ -175,16 +173,14 @@ private final void drawTriangle(Triangle triangle) { pointsX[2] = topX - h / 2; pointsY[2] = topY + h; - visualizerDrawer.gc.setFill(Color.rgb(random.nextInt(255), - random.nextInt(255), random.nextInt(255))); + visualizerDrawer.gc.setFill(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))); visualizerDrawer.gc.fillPolygon(pointsX, pointsY, 3); // gc.strokePolygon(pointsX, pointsY, 3) } /** - * --------------------------Triangle class which contains x,y of a Triangle - * and height. + * --------------------------Triangle class which contains x,y of a Triangle and height. */ private class Triangle { diff --git a/src/visualizer/model/VisualizerDrawer.java b/src/visualizer/model/VisualizerDrawer.java index fa45e4da..ee3929f0 100644 --- a/src/visualizer/model/VisualizerDrawer.java +++ b/src/visualizer/model/VisualizerDrawer.java @@ -3,9 +3,10 @@ */ package visualizer.model; +import java.util.Random; + import javafx.scene.image.Image; import javafx.scene.paint.Color; -import javafx.scene.shape.ArcType; /** * The Class VisualizerDrawer. @@ -28,6 +29,43 @@ public class VisualizerDrawer extends VisualizerModel { public Image backgroundImage;// new // Image(VisualizerModel.class.getResourceAsStream("background.gif")) + /** + * Draws the foreground image of the visualizer + * + * @param array + * The samples array + */ + public void drawForegroundImage(float[] array) { + + //!null + if (foregroundImage != null) { + + //Compute + double imageW;//= foregroundImage.getWidth() + double imageH;//= foregroundImage.getHeight() + if (canvasWidth < canvasHeight) + imageW = imageH = canvasWidth / 2.00; + else + imageW = imageH = canvasHeight / 2.00; + + //Draw it + gc.drawImage(foregroundImage, (canvasWidth / 2 - imageW / 2) - imageW * array[0] / 2, + (canvasHeight / 2 - imageH / 2) - imageH * array[0] / 2, imageW + imageW * array[0], + imageH + imageH * array[0]); + + } + } + + /** + * Draws the background image of the visualizer + */ + public void drawBackgroundImage() { + + //!null + if (backgroundImage != null) + gc.drawImage(backgroundImage, 0, 0, canvasWidth, canvasHeight); + } + // --------------------------------------------------------------------- /*----------------------------------------------------------------------- @@ -46,8 +84,7 @@ public class VisualizerDrawer extends VisualizerModel { * Draws an Oscilloscope * * @param stereo - * The Oscilloscope with have 2 lines->stereo or 1 line->merge - * left and right audio + * The Oscilloscope with have 2 lines->stereo or 1 line->merge left and right audio */ public void drawOscilloscope(boolean stereo) { oscilloscope.drawOscilloscope(stereo); @@ -79,11 +116,103 @@ public void drawPolySpiral() { polySpiral.drawPolySpiral(); } + /*----------------------------------------------------------------------- + * + * ----------------------------------------------------------------------- + * + * + * Circle With Lines + * + * ----------------------------------------------------------------------- + * + * ----------------------------------------------------------------------- + */ + + /** The color size. */ + private final int colorSize = 360; + + /** The color index. */ + private int colorIndex = 0; + /** - * Draws a Polyspiral and 4 arcs + * Draws the Round Circle with Lines on it's circumference */ - public void drawPolySpiral2() { - polySpiral.drawPolyspiral2(); + public void drawCircleWithLines() { + gc.setLineWidth(2); + + float[] pSample = stereoMerge(pLeftChannel, pRightChannel); + float[] array = returnBandsArray(pSample, 32); + + //Background + drawBackgroundImage(); + + //Calculate the radius + int radius; + if (canvasHeight > canvasWidth) + radius = canvasWidth / 2; + else + radius = canvasHeight / 2; + radius = (int) (radius / 1.5); + + gc.setLineWidth(2); + + //int previousX1 = -1 + //int previousY1 = -1 + int previousEndX = -1; + int previousEndY = -1; + + for (float angle = 0; angle <= 360; angle++) { + // Use HSB color model + colorIndex = (colorIndex == colorSize - 1) ? 0 : colorIndex + 1; + gc.setStroke(Color.hsb(colorIndex, 1.0f, 1.0f)); + //gc.setFill(Color.hsb(colorIndex, 1.0f, 1.0f)) + //System.out.println("Calculating") + //gc.setStroke(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))) + + //Code before + //int px1 = (int) (canvasWidth / 2 + Math.sin(Math.toRadians(angle)) * radius) + //int py1 = (int) (canvasHeight / 2 + Math.cos(Math.toRadians(angle)) * radius) + + //int px2 = (int) (canvasWidth / 2 + Math.sin(Math.toRadians(angle)) * (radius + Math.abs(pSample[(int) angle]) * 100)) + //int py2 = (int) (canvasHeight / 2 + Math.cos(Math.toRadians(angle)) * (radius + Math.abs(pSample[(int) angle]) * 100)) + + //Code after [ Runs faster ] + double angleRadians = Math.toRadians(angle); + double mathSin = Math.sin(angleRadians); + double mathCos = Math.cos(angleRadians); + + double centerX = canvasWidth / 2.00; + double centerY = canvasHeight / 2.00; + + int startX = (int) (centerX + mathSin * radius); //startX + int startY = (int) (centerY + mathCos * radius); //startY + + double add = Math.abs(pSample[(int) angle]) * 100; + + int endX = (int) (centerX + mathSin * (radius + add)); //endX + int endY = (int) (centerY + mathCos * (radius + add)); //endY + + //Join with the previous line + if (previousEndX != -1) { + gc.strokeLine(previousEndX, previousEndY, endX, endY); //connect with the previous line + + //gc.fillPolygon(new double[] { previousX1,previousX2, px2, px1 }, new double[] { previousY1,previousY2, py2, py1 }, 4) + } + + //previousX1 = px1 + //previousY1 = py1 + previousEndX = endX; + previousEndY = endY; + + gc.strokeLine(startX, startY, endX, endY); //draw the line + } + + //Foreground + drawForegroundImage(array); + + //Reset it so it doesn't affect the others + gc.setLineWidth(1); + } /*----------------------------------------------------------------------- @@ -107,9 +236,9 @@ public void drawSpectrumBars() { float barWidth = (float) canvasWidth / (float) saBands; float[] array = returnBandsArray(pSample, saBands); float c = 0; - // BackgroundImage - if (backgroundImage != null) - gc.drawImage(backgroundImage, 0, 0, canvasWidth, canvasHeight); + + // Background + this.drawBackgroundImage(); for (int band = 0; band < saBands; band++) { drawSpectrumBar((int) c, canvasHeight, (int) barWidth - 1, (int) (array[band] * canvasHeight), band); @@ -181,9 +310,8 @@ private void drawSpectrumBar(int pX, int pY, int pWidth, int pHeight, int band) */ public void drawVUMeter() { - // BackgroundImage - if (backgroundImage != null) - gc.drawImage(backgroundImage, 0, 0, canvasWidth, canvasHeight); + // Background + drawBackgroundImage(); float wLeft = 0.0f; float wRight = 0.0f; @@ -199,7 +327,7 @@ public void drawVUMeter() { /* * vuAverage += ( ( wLeft + wRight ) / 2.0f ); vuSamples++; if ( - * vuSamples > 128 ) { vuSamples /= 2.0f; vuAverage /= 2.0f; } + * vuSamples > 128 ) { vuSamples /= 2.0f; vuAverage /= 2.0f } */ if (wLeft >= (oldLeft - wSadfrr)) @@ -256,36 +384,6 @@ private void drawVolumeMeterBar(int x, int y, int pWidth, int pHeight) { } } - /*----------------------------------------------------------------------- - * - * ----------------------------------------------------------------------- - * - * - * Cicular - * - * ----------------------------------------------------------------------- - * - * ----------------------------------------------------------------------- - */ - - /** - * Draws an Arc or whole Circle. - */ - @Deprecated - public void drawCircular() { - float[] pSample = stereoMerge(pLeftChannel, pRightChannel); - - // backgoundImage - if (backgroundImage != null) - gc.drawImage(backgroundImage, 0, 0, canvasWidth, canvasHeight); - float[] array = returnBandsArray(pSample, 1); - int arcHeight = canvasHeight / 2; - - gc.setFill(Color.WHITE); - // gc.fillOval(iX(-w*2), iY(w*2), w, w); - gc.fillArc(canvasWidth / 2.00, canvasHeight / 2.00, arcHeight, arcHeight, 0, 360 * array[0], ArcType.ROUND); - } - /*----------------------------------------------------------------------- * * ----------------------------------------------------------------------- diff --git a/src/visualizer/model/VisualizerModel.java b/src/visualizer/model/VisualizerModel.java index ff7ce811..9fd01b12 100644 --- a/src/visualizer/model/VisualizerModel.java +++ b/src/visualizer/model/VisualizerModel.java @@ -62,7 +62,7 @@ public class VisualizerModel extends ResizableCanvas implements KJDigitalSignalP /** The display mode. */ public SimpleIntegerProperty displayMode = new SimpleIntegerProperty( - Integer.parseInt(DisplayMode.ROSETTE.toString())); + Integer.parseInt(DisplayMode.CIRCLE_WITH_LINES.toString())); /** The Constant DEFAULT_FPS. */ private static final int DEFAULT_FPS = 60; @@ -762,8 +762,8 @@ public String toString() { return "5"; } }, - /** Display a Polyspiral and 4 Arcs. */ - ROSETTE_ARCS { + /** Display A Circle With Lines on it's circumference */ + CIRCLE_WITH_LINES { @Override public String toString() { return "6"; diff --git a/src/visualizer/model/foreground.png b/src/visualizer/model/foreground.png index 1397d667..bee6f69c 100644 Binary files a/src/visualizer/model/foreground.png and b/src/visualizer/model/foreground.png differ diff --git a/src/visualizer/view/Visualizer.java b/src/visualizer/view/Visualizer.java index b0858164..51fffee3 100644 --- a/src/visualizer/view/Visualizer.java +++ b/src/visualizer/view/Visualizer.java @@ -153,8 +153,7 @@ public SimpleBooleanProperty runningProperty() { } /** - * This method is used by XPlayerController to pass a reference to the - * AnimationTimer + * This method is used by XPlayerController to pass a reference to the AnimationTimer * * @param xPlayerController * The XPlayerController Reference @@ -197,7 +196,7 @@ public void handle(long nanos) { drawPolySpiral(); break; case 6: - drawPolySpiral2(); + drawCircleWithLines(); break; case 7: drawSierpinski(); @@ -220,8 +219,11 @@ public void handle(long nanos) { framesPerSecond = 0; nextSecond = nanos + ONE_SECOND_NANOS; } - gc.setStroke(Color.YELLOW); - gc.strokeText("FPS: " + fps , 0, canvasHeight - 1.00); //+ " (FRRH: " + frameRateRatioHint + ")" + + gc.setFill(Color.BLACK); + gc.fillRect(0, canvasHeight - 15.00, 50, 28); + gc.setStroke(Color.WHITE); + gc.strokeText("FPS: " + fps, 0, canvasHeight - 3.00); //+ " (FRRH: " + frameRateRatioHint + ")" } } // END: if draw == TRUE diff --git a/src/visualizer/view/VisualizerStackController.java b/src/visualizer/view/VisualizerStackController.java index 91a57470..0cc34711 100644 --- a/src/visualizer/view/VisualizerStackController.java +++ b/src/visualizer/view/VisualizerStackController.java @@ -102,21 +102,38 @@ public void replayLabelEffect(String text) { fadeTransition.playFromStart(); } + XPlayerController xPlayerController; + /** * Add the listeners to the Next and Previous Buttons * * @param xPlayerController */ public void addListenersToButtons(XPlayerController xPlayerController) { + this.xPlayerController = xPlayerController; + // previous - previous.setOnAction(a -> xPlayerController.visualizer.displayMode - .set(xPlayerController.visualizer.displayMode.get() - 1 >= 0 - ? xPlayerController.visualizer.displayMode.get() - 1 - : VisualizerModel.DISPLAYMODE_MAXIMUM)); + previous.setOnAction(a -> previousSpectrumAnalyzer()); // next - next.setOnAction(a -> xPlayerController.visualizer.displayMode + next.setOnAction(a -> nextSpectrumAnalyzer()); + } + + /** + * Goes to the next Spectrum Analyzer + */ + public void nextSpectrumAnalyzer() { + xPlayerController.visualizer.displayMode .set((xPlayerController.visualizer.displayMode.get() + 1 > VisualizerModel.DISPLAYMODE_MAXIMUM) ? 0 - : xPlayerController.visualizer.displayMode.get() + 1)); + : xPlayerController.visualizer.displayMode.get() + 1); + } + + /** + * Goes to the previous Spectrum Analyzer + */ + public void previousSpectrumAnalyzer() { + xPlayerController.visualizer.displayMode.set(xPlayerController.visualizer.displayMode.get() - 1 >= 0 + ? xPlayerController.visualizer.displayMode.get() - 1 + : VisualizerModel.DISPLAYMODE_MAXIMUM); } } diff --git a/src/visualizer/view/VisualizerWindowController.java b/src/visualizer/view/VisualizerWindowController.java index 6623c772..baef8e1f 100644 --- a/src/visualizer/view/VisualizerWindowController.java +++ b/src/visualizer/view/VisualizerWindowController.java @@ -29,7 +29,6 @@ import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; import javafx.scene.layout.StackPane; -import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.media.MediaView; import javafx.scene.paint.Color; @@ -39,7 +38,6 @@ import tools.ActionTool; import tools.InfoTool; import tools.NotificationType; -import visualizer.model.VisualizerModel; import xplayer.presenter.XPlayerController; /** @@ -96,8 +94,7 @@ public class VisualizerWindowController extends StackPane { private StackPane progressBarStackPane; /** - * Shows the progress of the Media how much has completed from it's total - * duration + * Shows the progress of the Media how much has completed from it's total duration */ @FXML public ProgressBar progressBar; @@ -207,15 +204,10 @@ private void initialize() { else removeVisualizer(); - } else if (key.getCode() == KeyCode.RIGHT) { - xPlayerController.visualizer.displayMode.set( - (xPlayerController.visualizer.displayMode.get() + 1 > VisualizerModel.DISPLAYMODE_MAXIMUM) ? 0 - : xPlayerController.visualizer.displayMode.get() + 1); - } else if (key.getCode() == KeyCode.LEFT) { - xPlayerController.visualizer.displayMode.set(xPlayerController.visualizer.displayMode.get() - 1 >= 0 - ? xPlayerController.visualizer.displayMode.get() - 1 - : VisualizerModel.DISPLAYMODE_MAXIMUM); - } + } else if (key.getCode() == KeyCode.RIGHT) + xPlayerController.visualizerStackController.nextSpectrumAnalyzer(); + else if (key.getCode() == KeyCode.LEFT) + xPlayerController.visualizerStackController.previousSpectrumAnalyzer(); }); // ----------Drag && Drop Listeners diff --git a/src/windows/DJMode.java b/src/windows/DJMode.java index 45b2f2d0..019ec5da 100644 --- a/src/windows/DJMode.java +++ b/src/windows/DJMode.java @@ -31,7 +31,7 @@ public class DJMode extends GridPane { // public DJTabs djTabs /** The balancer. */ - //public Balancer balancer; + //public Balancer balancer /** The digital clock. */ // public DigitalClock digitalClock @@ -65,12 +65,12 @@ public void initialize() { Main.xPlayersList.addXPlayerController(new XPlayerController(1)); Main.xPlayersList.getXPlayerController(1).makeTheDisc(136, 136, Color.rgb(53, 144, 255), 45, Side.RIGHT); Main.xPlayersList.getXPlayerController(1).makeTheVisualizer(Side.LEFT); - add(Main.xPlayersList.getXPlayerController(1), 0, 0); + add(Main.xPlayersList.getXPlayerController(1).getFlipPanel(), 0, 0); Main.xPlayersList.addXPlayerController(new XPlayerController(2)); Main.xPlayersList.getXPlayerController(2).makeTheDisc(136, 136, Color.RED, 45, Side.LEFT); Main.xPlayersList.getXPlayerController(2).makeTheVisualizer(Side.RIGHT); - add(Main.xPlayersList.getXPlayerController(2), 1, 0); + add(Main.xPlayersList.getXPlayerController(2).getFlipPanel(), 1, 0); // splitPane splitPane.setStyle("-fx-background-color:transparent"); @@ -120,16 +120,16 @@ void makeDJSoundTeamTabs() { */ void makeBalancer() { -// balancer = new Balancer(InfoTool.getScreenWidth() / 2 - 100, 260, 208, 20, 100, 200); -// balancer.setOnMouseDragged(drag -> { -// balancer.onMouseDragged(drag); -// Main.xPlayersList.getXPlayerUI(1).controlVolume(); -// }); -// -// balancer.setOnScroll(scroll -> { -// balancer.onScroll(scroll); -// Main.xPlayersList.getXPlayerUI(1).controlVolume(); -// }); + // balancer = new Balancer(InfoTool.getScreenWidth() / 2 - 100, 260, 208, 20, 100, 200); + // balancer.setOnMouseDragged(drag -> { + // balancer.onMouseDragged(drag); + // Main.xPlayersList.getXPlayerUI(1).controlVolume(); + // }); + // + // balancer.setOnScroll(scroll -> { + // balancer.onScroll(scroll); + // Main.xPlayersList.getXPlayerUI(1).controlVolume(); + // }); } @@ -148,11 +148,13 @@ private final void addKeyListeners() { if (key.isShiftDown()) { if (Main.xPlayersList.getXPlayerController(1).getVolume() < 101) { - Main.xPlayersList.getXPlayerController(1).setVolume(Main.xPlayersList.getXPlayerController(1).getVolume() + 1); + Main.xPlayersList.getXPlayerController(1) + .setVolume(Main.xPlayersList.getXPlayerController(1).getVolume() + 1); } } else if (key.isControlDown()) { if (Main.xPlayersList.getXPlayerController(2).getVolume() < 101) { - Main.xPlayersList.getXPlayerController(2).setVolume(Main.xPlayersList.getXPlayerController(2).getVolume() + 1); + Main.xPlayersList.getXPlayerController(2) + .setVolume(Main.xPlayersList.getXPlayerController(2).getVolume() + 1); } } @@ -161,11 +163,13 @@ private final void addKeyListeners() { if (key.isShiftDown()) { if (Main.xPlayersList.getXPlayerController(1).getVolume() > -1) { - Main.xPlayersList.getXPlayerController(1).setVolume(Main.xPlayersList.getXPlayerController(1).getVolume() - 1); + Main.xPlayersList.getXPlayerController(1) + .setVolume(Main.xPlayersList.getXPlayerController(1).getVolume() - 1); } } else if (key.isControlDown()) { if (Main.xPlayersList.getXPlayerController(2).getVolume() > -1) { - Main.xPlayersList.getXPlayerController(2).setVolume(Main.xPlayersList.getXPlayerController(2).getVolume() - 1); + Main.xPlayersList.getXPlayerController(2) + .setVolume(Main.xPlayersList.getXPlayerController(2).getVolume() - 1); } } } diff --git a/src/windows/RenameWindow.java b/src/windows/RenameWindow.java index 43de5f99..823076a5 100644 --- a/src/windows/RenameWindow.java +++ b/src/windows/RenameWindow.java @@ -53,8 +53,8 @@ public class RenameWindow extends HBox { */ public Stage window = new Stage(); - /** The x pressed. */ - private boolean xPressed = false; + /** If it was accepted */ + private boolean accepted = false; /** The not allow. */ String[] notAllow = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "'", "." }; @@ -71,7 +71,7 @@ public RenameWindow() { window.initStyle(StageStyle.TRANSPARENT); window.getIcons().add(InfoTool.getImageFromDocuments("icon.png")); window.centerOnScreen(); - window.setOnCloseRequest(ev -> xPressed = true); + window.setOnCloseRequest(ev -> close(false)); window.setAlwaysOnTop(true); // ----------------------------------FXMLLoader @@ -90,10 +90,8 @@ public RenameWindow() { getScene().getStylesheets() .add(getClass().getResource(InfoTool.styLes + InfoTool.applicationCss).toExternalForm()); getScene().setOnKeyReleased(key -> { - if (key.getCode() == KeyCode.ESCAPE) { - xPressed = true; - window.close(); - } + if (key.getCode() == KeyCode.ESCAPE) + close(false); }); } @@ -109,8 +107,8 @@ private void initialize() { // inputField inputField.setPrefSize(290, 32); - inputField - .setTooltip(new Tooltip("Not allowed:(<) (>) (:) (\") (/) (\\) (|) (?) (*) (') (.) \n **Escape to Exit**")); + inputField.setTooltip( + new Tooltip("Not allowed:(<) (>) (:) (\") (/) (\\) (|) (?) (*) (') (.) \n **Escape to Exit**")); inputField.setPromptText("Type Here..."); inputField.setStyle("-fx-font-weight:bold; -fx-font-size:14;"); @@ -134,7 +132,7 @@ private void initialize() { // can pass? if (!inputField.getText().trim().isEmpty()) - window.close(); + close(true); else Notifications.create().text("You have to type something..").showWarning(); @@ -146,10 +144,7 @@ private void initialize() { okButton.setOnAction(myHandler); // closeButton - closeButton.setOnAction(action -> { - xPressed = true; - window.close(); - }); + closeButton.setOnAction(action -> close(false)); } @@ -163,12 +158,23 @@ public String getUserInput() { } /** - * Checks if is x pressed. + * Checks if it was cancelled + * + * @return True if it was cancelled , false if not + */ + public boolean wasAccepted() { + return accepted; + } + + /** + * Close the Window. * - * @return true, if is x pressed + * @param accepted + * True if accepted , False if not */ - public boolean isXPressed() { - return xPressed; + public void close(boolean accepted) { + this.accepted = accepted; + window.close(); } /** @@ -217,7 +223,7 @@ else if (y < 0) inputField.setText(text); inputField.end(); - xPressed = false; + accepted = true; window.show(); } diff --git a/src/windows/StarWindow.java b/src/windows/StarWindow.java index 26dbd62b..5b92bdd4 100644 --- a/src/windows/StarWindow.java +++ b/src/windows/StarWindow.java @@ -70,16 +70,16 @@ public class StarWindow extends GridPane { */ public StarWindow() { - // ----------------------------------FXMLLoader - FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.fxmls + "StarWindow.fxml")); - loader.setController(this); - loader.setRoot(this); + // ----------------------------------FXMLLoader + FXMLLoader loader = new FXMLLoader(getClass().getResource(InfoTool.fxmls + "StarWindow.fxml")); + loader.setController(this); + loader.setRoot(this); - try { - loader.load(); - } catch (IOException ex) { - ex.printStackTrace(); - } + try { + loader.load(); + } catch (IOException ex) { + ex.printStackTrace(); + } } @@ -88,38 +88,39 @@ public StarWindow() { */ private void repaintStars() { - gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); + gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); - // System.out.println("Stars--->" + getStars()); + // System.out.println("Stars--->" + getStars()); - // paint half and whole stars - if ((getStars() - 0.5) < (int) getStars()) - for (int i = 0; i < getStars(); i++) - gc.drawImage(star, starsPosition[i], 0); + // paint half and whole stars + if ((getStars() - 0.5) < (int) getStars()) + for (int i = 0; i < getStars(); i++) + gc.drawImage(star, starsPosition[i], 0); - else { - for (int i = 0; i < getStars() - 1; i++) - gc.drawImage(star, starsPosition[i], 0); + else { + for (int i = 0; i < getStars() - 1; i++) + gc.drawImage(star, starsPosition[i], 0); - gc.drawImage(halfStar, starsPosition[(int) getStars()], 0); - } + gc.drawImage(halfStar, starsPosition[(int) getStars()], 0); + } - // Paint unselected Stars - if (getStars() != 5) - for (int i = 4; i >= getStars(); i--) - gc.drawImage(noStar, starsPosition[i], 0); + // Paint unselected Stars + if (getStars() != 5) + for (int i = 4; i >= getStars(); i--) + gc.drawImage(noStar, starsPosition[i], 0); } /** * Stars must be one number from 0 to 10. * - * @param st the new stars + * @param st + * the new stars */ private void setStars(double st) { - if (getStars() != st) { - stars.set(st); - repaintStars(); - } + if (getStars() != st) { + stars.set(st); + repaintStars(); + } } /** @@ -128,7 +129,7 @@ private void setStars(double st) { * @return the stars */ public double getStars() { - return stars.get(); + return stars.get(); } /** @@ -137,7 +138,7 @@ public double getStars() { * @return the double property */ public DoubleProperty starsProperty() { - return stars; + return stars; } /** @@ -146,59 +147,65 @@ public DoubleProperty starsProperty() { * @return true, if successful */ public boolean wasAccepted() { - return accepted; + return accepted; } /** * Show. * - * @param stars the stars - * @param node the node + * @param stars + * the stars + * @param node + * the node */ public void show(double stars, Node node) { - // Auto Calculate the position - Bounds bounds = node.localToScreen(node.getBoundsInLocal()); - show(stars, bounds.getMinX() + 5, bounds.getMaxY()); + // Auto Calculate the position + Bounds bounds = node.localToScreen(node.getBoundsInLocal()); + show(stars, bounds.getMinX() + 5, bounds.getMaxY()); } /** * Show. * - * @param stars the stars - * @param x the x - * @param y the y + * @param stars + * the stars + * @param x + * the x + * @param y + * the y */ public void show(double stars, double x, double y) { - setStars(stars); - - if (x <= -1 && y <= -1) - window.centerOnScreen(); - else { - - if (x + getWidth() > InfoTool.getVisualScreenWidth()) - x = InfoTool.getVisualScreenWidth() - getWidth(); - else if (x < 0) - x = 0; - - if (y + getHeight() > InfoTool.getVisualScreenHeight()) - y = InfoTool.getVisualScreenHeight() - getHeight(); - else if (y < 0) - y = 0; - - window.setX(x); - window.setY(y); - } - window.show(); + setStars(stars); + + if (x <= -1 && y <= -1) + window.centerOnScreen(); + else { + + if (x + getWidth() > InfoTool.getVisualScreenWidth()) + x = InfoTool.getVisualScreenWidth() - getWidth(); + else if (x < 0) + x = 0; + + if (y + getHeight() > InfoTool.getVisualScreenHeight()) + y = InfoTool.getVisualScreenHeight() - getHeight(); + else if (y < 0) + y = 0; + + window.setX(x); + window.setY(y); + } + window.show(); } /** * Close the Window. * - * @param ac the ac + * @param accepted + * True if accepted , False if not */ - public void close(boolean ac) { - accepted = ac; - window.close(); + public void close(boolean accepted) { + this.accepted = accepted; + window.close(); } /** @@ -206,70 +213,65 @@ public void close(boolean ac) { */ @FXML private void initialize() { - System.out.println("StarWindow Initialized...."); - - // Window - window = new Stage(); - window.initStyle(StageStyle.TRANSPARENT); - window.initModality(Modality.APPLICATION_MODAL); - window.setAlwaysOnTop(true); - - // Graphics Context 2D - gc = canvas.getGraphicsContext2D(); - - // Root - getStyleClass().add("starWindow"); - - // Canvas - canvas.setOnMouseDragged(m -> { - int x = (int) m.getX(); - - if (x <= 5) - setStars(0); - else if (x >= 144) - setStars(5); - else if (x >= 133) - setStars(4.5); - else if (x >= 115) - setStars(4); - else if (x >= 105) - setStars(3.5); - else if (x >= 85) - setStars(3); - else if (x >= 74) - setStars(2.5); - else if (x >= 55) - setStars(2); - else if (x >= 45) - setStars(1.5); - else if (x >= 25) - setStars(1); - else if (x >= 12) - setStars(0.5); - }); - - // close - close.setOnAction(a -> { - close(false); - }); - - // OK - ok.setOnAction(a -> close(true)); - - // Scene - window.setScene(new Scene(this, Color.TRANSPARENT)); - window.getScene() - .getStylesheets() - .add(getClass().getResource(InfoTool.styLes + InfoTool.applicationCss) - .toExternalForm()); - window.getScene() - .setOnKeyReleased(key -> { - if (key.getCode() == KeyCode.ESCAPE) - close(false); - }); - - // Repaint - repaintStars(); + System.out.println("StarWindow Initialized...."); + + // Window + window = new Stage(); + window.initStyle(StageStyle.TRANSPARENT); + window.initModality(Modality.APPLICATION_MODAL); + window.setAlwaysOnTop(true); + + // Graphics Context 2D + gc = canvas.getGraphicsContext2D(); + + // Root + getStyleClass().add("starWindow"); + + // Canvas + canvas.setOnMouseDragged(m -> { + int x = (int) m.getX(); + + if (x <= 5) + setStars(0); + else if (x >= 144) + setStars(5); + else if (x >= 133) + setStars(4.5); + else if (x >= 115) + setStars(4); + else if (x >= 105) + setStars(3.5); + else if (x >= 85) + setStars(3); + else if (x >= 74) + setStars(2.5); + else if (x >= 55) + setStars(2); + else if (x >= 45) + setStars(1.5); + else if (x >= 25) + setStars(1); + else if (x >= 12) + setStars(0.5); + }); + + // close + close.setOnAction(a -> close(false)); + + // OK + ok.setOnAction(a -> close(true)); + + // Scene + window.setScene(new Scene(this, Color.TRANSPARENT)); + window.getScene().getStylesheets() + .add(getClass().getResource(InfoTool.styLes + InfoTool.applicationCss).toExternalForm()); + window.getScene().setOnKeyReleased(key -> { + if (key.getCode() == KeyCode.ESCAPE) + close(false); + }); + + // Repaint + repaintStars(); } diff --git a/src/xplayer/presenter/XPlayerController.java b/src/xplayer/presenter/XPlayerController.java index 9809b99b..3cd4fd22 100644 --- a/src/xplayer/presenter/XPlayerController.java +++ b/src/xplayer/presenter/XPlayerController.java @@ -18,11 +18,13 @@ import customnodes.Marquee; import disc.DJDisc; import disc.DJDiscListener; +import eu.hansolo.enzo.flippanel.FlipPanel; import javafx.application.Platform; import javafx.concurrent.Service; import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; +import javafx.geometry.Orientation; import javafx.geometry.Side; import javafx.scene.Cursor; import javafx.scene.ImageCursor; @@ -265,6 +267,8 @@ public XPlayerController(int key) { } + FlipPanel flipPane = new FlipPanel(Orientation.HORIZONTAL); + /** Called as soon as the .fxml has been loaded */ @FXML private void initialize() { @@ -288,8 +292,8 @@ private void initialize() { container.setOnDragDropped(drop -> dragDrop(drop, 2)); // settingsToggle - getChildren().add(xPlayerSettingsController); - xPlayerSettingsController.visibleProperty().bind(settingsToggle.selectedProperty()); + //getChildren().add(xPlayerSettingsController); + //xPlayerSettingsController.visibleProperty().bind(settingsToggle.selectedProperty()); // fxRegion,fxSpinner fxRegion.setVisible(false); @@ -330,6 +334,26 @@ private void initialize() { // } }); + //flipPane + flipPane.setFlipTime(150); + flipPane.getFront().getChildren().addAll(this); + flipPane.getBack().getChildren().addAll(xPlayerSettingsController); + + settingsToggle.selectedProperty().addListener((observable,oldValue,newValue)->{ + if(newValue) // true? + flipPane.flipToBack(); + else + flipPane.flipToFront(); + }); + + + } + + /** + * @return The FlipPanel + */ + public FlipPanel getFlipPanel() { + return flipPane; } /**