hashes; //validation hashes for the files in fileID arraylist, same indexes.
- private boolean isSignedIn;
- private LiteraClient client;
-
- public ServerDataManager( String user, String pass, String path)
- {
- //Initiate user data
- username = user;
- password = pass;
- //create and initiate client
- client = new LiteraClient( username, password);
-
- }
-
/**
* @param username lowercase string
* @param password
* @return true when provided user credentials are true
* @description sets the current user. returns true when provided credentials are true.
*/
- public int setUser(String user, String pass)
+ public static boolean setUser(String username, String password)
{
- username = user;
- password = pass;
- return connect();
+ return true;
}
/**
* @return
* @description return the note names for the provided user credentials. return array of 0 length if the user doesn't have any notes
*/
- public String[] getNoteList()
+ public static String[] getNoteList()
{
return null;
}
@@ -53,7 +31,7 @@ public String[] getNoteList()
* @return true when upload is successful
* @description uploads the folder containing noteName. Including all files inside <5MB. DO THIS ASYNCHRONOUSLY!!
*/
- public boolean uploadNoteDirectory(String osFilePath, String noteName)
+ public static boolean uploadNoteDirectory(String osFilePath, String noteName)
{
return true;
}
@@ -64,7 +42,7 @@ public boolean uploadNoteDirectory(String osFilePath, String noteName)
* @return true when download & save operation is successful
* @description downloads the directory containing the noteName. DO THIS ASYNCHRONOUSLY!!
*/
- public boolean downloadNoteDirectory(String osFilePath, String noteName)
+ public static boolean downloadNoteDirectory(String osFilePath, String noteName)
{
return true;
}
@@ -75,7 +53,7 @@ public boolean downloadNoteDirectory(String osFilePath, String noteName)
* @return true when download & save operation is successful
* @description only downloads the HTML file containing the note DO THIS ASYNCHRONOUSLY!!
*/
- public boolean downloadNoteHTMLOnly( String noteName)
+ public static boolean downloadNoteHTMLOnly(String osFilePath, String noteName)
{
return true;
}
@@ -86,29 +64,27 @@ public boolean downloadNoteHTMLOnly( String noteName)
* @return true when upload operation is successful
* @description only uploads the HTML file containing the note DO THIS ASYNCHRONOUSLY!!
*/
- public boolean uploadNoteHTMLOnly( String noteName)
+ public static boolean uploadNoteHTMLOnly(String osFilePath, String noteName)
{
return true;
}
-
- public int connect()
- {
- //try login
- //set isSignedIn bit to true if login succesful
- int state = -1;
- state = client.login( usernmae, password);
- isSignedIn = ( state == 0);
- return state;
- }
-
/**
- * @return 0 if possible 1 if duplicate username, 2 if duplicate email, 3 if connection not possible
+ * @return
* @description checks if the username and password is valid, then creates a new user and its directories on the server
*/
- public int createNewUser(String user, String pass, String email)
+ public static boolean createNewUser(String username, String password)
{
- return 0;
+ return true;
}
-}
+ /**
+ * @return true if the username is available for usage
+ * @description checks for the username on the database when creating a new user
+ * @description Makes sure the application directory exists for file operations. Creates directory, then returns false if first run.
+ */
+ private static boolean usernameExists()
+ {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/litera/Defaults/Default.css b/src/litera/Defaults/Default.css
new file mode 100644
index 0000000..7651f75
--- /dev/null
+++ b/src/litera/Defaults/Default.css
@@ -0,0 +1,17 @@
+.list-cell:filled:selected:focused, .list-cell:filled:selected {
+ -fx-background-color: #99B4D1;
+ -fx-text-fill: white;
+}
+
+.list-cell:filled:hover {
+ -fx-background-color: #d2d2d2;
+ -fx-text-fill: white;
+}
+
+.list-view {
+ -fx-border-color: #99B4D1;
+}
+
+.border-pane {
+ -fx-background-color: #99B4D1;
+}
\ No newline at end of file
diff --git a/src/litera/Defaults/Defaults.java b/src/litera/Defaults/Defaults.java
index 0642337..5fd23b5 100755
--- a/src/litera/Defaults/Defaults.java
+++ b/src/litera/Defaults/Defaults.java
@@ -1,7 +1,15 @@
package litera.Defaults;
import javafx.scene.paint.Color;
-import minerva.Note;
+
+import java.util.Locale;
+
+/**
+ * contains default parameters for the HTML page and some other essential functions for Litera
+ *
+ * @author Çelik Köseoğlu
+ * @version 2
+ */
public class Defaults
{
@@ -17,7 +25,6 @@ public class Defaults
"" +
"Celik Koseoglu";
- // HTML Style Commands
public static final String CUT_COMMAND = "cut";
public static final String COPY_COMMAND = "copy";
public static final String PASTE_COMMAND = "paste";
@@ -25,23 +32,8 @@ public class Defaults
public static final String UNDO_COMMAND = "undo";
public static final String REDO_COMMAND = "redo";
- public static final String INSERT_HORIZONTAL_RULE_COMMAND = "inserthorizontalrule";
-
- public static final String ALIGN_LEFT_COMMAND = "justifyleft";
- public static final String ALIGN_CENTER_COMMAND = "justifycenter";
- public static final String ALIGN_RIGHT_COMMAND = "justifyright";
- public static final String ALIGN_JUSTIFY_COMMAND = "justifyfull";
-
- public static final String BULLETS_COMMAND = "insertUnorderedList";
public static final String NUMBERS_COMMAND = "insertOrderedList";
- public static final String INDENT_COMMAND = "indent";
- public static final String OUTDENT_COMMAND = "outdent";
-
- public static final String FORMAT_COMMAND = "formatblock";
- public static final String FONT_FAMILY_COMMAND = "fontname";
- public static final String FONT_SIZE_COMMAND = "fontsize";
-
public static final String BOLD_COMMAND = "bold";
public static final String ITALIC_COMMAND = "italic";
public static final String UNDERLINE_COMMAND = "underline";
@@ -50,26 +42,22 @@ public class Defaults
public static final String FOREGROUND_COLOR_COMMAND = "forecolor";
public static final String BACKGROUND_COLOR_COMMAND = "backcolor";
- public static final Color DEFAULT_BG_COLOR = Color.WHITE;
- public static final Color DEFAULT_FG_COLOR = Color.BLACK;
-
- public static final String FORMAT_PARAGRAPH = "";
- public static final String FORMAT_HEADING_1 = "
";
- public static final String FORMAT_HEADING_2 = "";
- public static final String FORMAT_HEADING_3 = "";
- public static final String FORMAT_HEADING_4 = "";
- public static final String FORMAT_HEADING_5 = "";
- public static final String FORMAT_HEADING_6 = "";
-
- public static final String SIZE_XX_SMALL = "1";
- public static final String SIZE_X_SMALL = "2";
- public static final String SIZE_SMALL = "3";
- public static final String SIZE_MEDIUM = "4";
- public static final String SIZE_LARGE = "5";
- public static final String SIZE_X_LARGE = "6";
- public static final String SIZE_XX_LARGE = "7";
+ public static final String COLOR_SCHEME_CSS_1 = ".list-cell:filled:selected:focused,.list-cell:filled:selected {-fx-background-color:";
+ public static final String COLOR_SCHEME_CSS_2 = ";-fx-text-fill: white;}.list-cell:filled:hover {-fx-background-color: #d2d2d2;-fx-text-fill: white;}.list-view{-fx-border-color:";
+ public static final String COLOR_SCHEME_CSS_3 = ";}.border-pane{-fx-background-color:";
+ public static final String COLOR_SCHEME_CSS_4 = ";}";
+
+ /**
+ * @param c Color to be converted
+ * @return String containing Hex representation of the color
+ * @description converts the Color object c to a Hex representation of th color
+ */
+ public static String colorValueToHex(Color c)
+ {
+ return String.format((Locale) null, "#%02x%02x%02x",
+ Math.round(c.getRed() * 255),
+ Math.round(c.getGreen() * 255),
+ Math.round(c.getBlue() * 255));
+ }
- public static final String INSERT_NEW_LINE_COMMAND = "insertnewline";
- public static final String INSERT_TAB_COMMAND = "inserttab";
- // end of HTML style commands
}
diff --git a/src/litera/Icons/20px20px.png b/src/litera/Icons/20px20px.png
new file mode 100755
index 0000000..34044db
Binary files /dev/null and b/src/litera/Icons/20px20px.png differ
diff --git a/src/litera/Icons/Picture-Frame-16.png b/src/litera/Icons/Picture-Frame-16.png
new file mode 100755
index 0000000..c89aac2
Binary files /dev/null and b/src/litera/Icons/Picture-Frame-16.png differ
diff --git a/out/production/ProjectLitera/minerva/Sync.png b/src/litera/Icons/Sync.png
similarity index 100%
rename from out/production/ProjectLitera/minerva/Sync.png
rename to src/litera/Icons/Sync.png
diff --git a/out/production/ProjectLitera/minerva/Trash-light_resized.png b/src/litera/Icons/Trash-light_resized.png
similarity index 100%
rename from out/production/ProjectLitera/minerva/Trash-light_resized.png
rename to src/litera/Icons/Trash-light_resized.png
diff --git a/src/litera/Icons/audio.png b/src/litera/Icons/audio.png
new file mode 100755
index 0000000..4239590
Binary files /dev/null and b/src/litera/Icons/audio.png differ
diff --git a/src/litera/Icons/bold.png b/src/litera/Icons/bold.png
new file mode 100755
index 0000000..370fe21
Binary files /dev/null and b/src/litera/Icons/bold.png differ
diff --git a/src/litera/Icons/italic.png b/src/litera/Icons/italic.png
new file mode 100755
index 0000000..53696d8
Binary files /dev/null and b/src/litera/Icons/italic.png differ
diff --git a/src/litera/Icons/microphone.png b/src/litera/Icons/microphone.png
new file mode 100755
index 0000000..dc602a5
Binary files /dev/null and b/src/litera/Icons/microphone.png differ
diff --git a/src/litera/Icons/orderedList.png b/src/litera/Icons/orderedList.png
new file mode 100644
index 0000000..0c9f446
Binary files /dev/null and b/src/litera/Icons/orderedList.png differ
diff --git a/src/litera/Icons/picture.png b/src/litera/Icons/picture.png
new file mode 100755
index 0000000..f5950d4
Binary files /dev/null and b/src/litera/Icons/picture.png differ
diff --git a/src/litera/Icons/strikethrough.png b/src/litera/Icons/strikethrough.png
new file mode 100644
index 0000000..754fe43
Binary files /dev/null and b/src/litera/Icons/strikethrough.png differ
diff --git a/src/minerva/Trash-light_resized.png b/src/litera/Icons/trash.png
similarity index 100%
rename from src/minerva/Trash-light_resized.png
rename to src/litera/Icons/trash.png
diff --git a/src/litera/Icons/underline.png b/src/litera/Icons/underline.png
new file mode 100755
index 0000000..5f5ea2c
Binary files /dev/null and b/src/litera/Icons/underline.png differ
diff --git a/src/litera/Icons/video.png b/src/litera/Icons/video.png
new file mode 100755
index 0000000..097356d
Binary files /dev/null and b/src/litera/Icons/video.png differ
diff --git a/src/litera/MainFrame/Controller.java b/src/litera/MainFrame/Controller.java
new file mode 100755
index 0000000..3a9adb5
--- /dev/null
+++ b/src/litera/MainFrame/Controller.java
@@ -0,0 +1,333 @@
+package litera.MainFrame;
+
+import com.sun.javafx.webkit.Accessor;
+import com.sun.webkit.WebPage;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.EventHandler;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.fxml.Initializable;
+import javafx.geometry.Side;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.*;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.paint.Color;
+import javafx.scene.web.WebEvent;
+import javafx.scene.web.WebView;
+import javafx.stage.FileChooser;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+import litera.Data.LocalDataManager;
+import litera.Defaults.Defaults;
+import litera.Multimedia.AudioController;
+import litera.Multimedia.PlayerController;
+
+import java.io.File;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.ResourceBundle;
+
+/**
+ * UI Controller for the Main Frame
+ *
+ * @author Çelik Köseoğlu - all except below
+ * @author Caner Çalışkaner - buttonFeedback method and styling toolbar listeners
+ * @author Orhun Çağlayan - rename algorithm
+ */
+
+public class Controller implements Initializable
+{
+ private static Note currentNote;
+ private static WebPage webPage;
+ private ObservableList noteListScrollPaneItems;
+ private boolean isNoteChanged;
+
+ @FXML
+ private ToggleButton boldToggleButton, italicToggleButton, underlineToggleButton, strikethroughToggleButton, insertOrderedListToggleButton;
+ @FXML
+ private Button addAudioButton, addVideoButton, addImageButton;
+ @FXML
+ private Button addNoteButton, deleteNoteButton, trashButton, optionsButton;
+ @FXML
+ private BorderPane borderPane;
+ @FXML
+ private ListView noteListView, trashNoteListView;
+ @FXML
+ private TextField noteNameTextField;
+ @FXML
+ private ColorPicker foregroundColorPicker, notePadColorPicker;
+ @FXML
+ private WebView editor;
+ @FXML
+ private ContextMenu trashContextMenu;
+ @FXML
+ private MenuItem recoverMenuItem, deleteMenuItem;
+ @FXML
+ private ToolBar optionsToolbar;
+
+ //Stage closing event calls this function to save the last note so Litera can start with the latest edited note next time.
+ public static void onExit()
+ {
+ currentNote.setHtmlNote(webPage.getHtml(webPage.getMainFrame()));
+ LocalDataManager.saveLastNote(currentNote);
+ }
+
+ public static void addAudio(/*File file*/)
+ {
+ webPage.executeScript(webPage.getMainFrame(), "document.write('')");
+ }
+
+ @Override // This method is called by the FXMLLoader when initialization is complete
+ public void initialize(URL fxmlFileLocation, ResourceBundle resources)
+ {
+ webPage = Accessor.getPageFor(editor.getEngine()); //webPage is the controller for the webView for executing scripts etc.
+ isNoteChanged = false;
+
+ // Button Listeners for Style
+ boldToggleButton.setOnAction(event -> addStyle(Defaults.BOLD_COMMAND, null));
+ italicToggleButton.setOnAction(event -> addStyle(Defaults.ITALIC_COMMAND, null));
+ underlineToggleButton.setOnAction(event -> addStyle(Defaults.UNDERLINE_COMMAND, null));
+ strikethroughToggleButton.setOnAction(event -> addStyle(Defaults.STRIKETHROUGH_COMMAND, null));
+ insertOrderedListToggleButton.setOnAction(event -> addStyle(Defaults.NUMBERS_COMMAND, null));
+
+ // Listeners for Style buttons
+ editor.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> buttonFeedback());
+ editor.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> buttonFeedback());
+ editor.addEventHandler(KeyEvent.KEY_RELEASED, event -> buttonFeedback());
+ editor.addEventHandler(KeyEvent.KEY_PRESSED, event -> buttonFeedback());
+
+ trashButton.setOnAction(event -> {
+ trashNoteListView.setItems(FXCollections.observableArrayList(LocalDataManager.getNoteNames(LocalDataManager.getLocalTrashFilePath())));
+ trashContextMenu.show(trashButton, Side.RIGHT, -20, -20); //show the trash menu on left click at the correct location
+ });
+
+ recoverMenuItem.setOnAction(event -> {
+ LocalDataManager.moveNotes(trashNoteListView.getSelectionModel().getSelectedItems(), false);
+ populateNoteListbox(); //load recovered notes back while keeping the alphabetical order
+ });
+
+ deleteMenuItem.setOnAction(event -> LocalDataManager.deleteNote(trashNoteListView.getSelectionModel().getSelectedItems()));
+
+ optionsButton.setOnAction(event -> loadWindow("/litera/Options/options.fxml", "Litera Options"));
+
+ addAudioButton.setOnAction(event -> {
+ try
+ {
+ addAudio();
+ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("../Multimedia/audio.fxml"));
+ fxmlLoader.setController(new AudioController(currentNote));
+ Parent root = fxmlLoader.load();
+ Stage stage = new Stage();
+ stage.initModality(Modality.APPLICATION_MODAL);
+ stage.setTitle("Audio");
+ stage.setScene(new Scene(root));
+ stage.show();
+ }
+ catch ( Exception ex )
+ {
+ System.out.println(ex.toString());
+ }
+ });
+
+ addVideoButton.setOnAction(event -> {
+ try
+ {
+ try
+ {
+ FileChooser fileChooser = new FileChooser();
+ fileChooser.setTitle("Choose Video");
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("MP4 Files", "*.mp4", "*.m4v"));
+ File selectedFile = fileChooser.showOpenDialog(addVideoButton.getScene().getWindow());
+ System.out.println(Paths.get(selectedFile.toURI()));
+ System.out.println(Paths.get(LocalDataManager.getLocalNotesFilePath() + currentNote.getNoteName() + "/"));
+ Files.copy(Paths.get(selectedFile.toURI()), new File(LocalDataManager.getLocalNotesFilePath() + currentNote.getNoteName() + "\\" + selectedFile.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
+
+ PlayerController a = new PlayerController(selectedFile, currentNote);
+ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("../Multimedia/player.fxml"));
+ fxmlLoader.setController(a);
+ Parent root = fxmlLoader.load();
+ Stage stage = new Stage();
+ stage.initModality(Modality.APPLICATION_MODAL);
+ stage.setTitle("Litera Player");
+ stage.setScene(new Scene(root));
+ stage.show();
+ stage.setOnCloseRequest(new EventHandler() {
+ public void handle(WindowEvent we)
+ {
+ System.out.println("Stage is closing");
+ a.disposeThis();
+ }
+ });
+ }
+ catch ( Exception ex )
+ {
+ System.out.println(ex.toString());
+ }
+ }
+ catch ( Exception ex )
+ {
+ System.out.println("File copy operation fail!");
+ }
+ });
+
+ addImageButton.setOnAction(event -> {
+ loadWindow("/litera/Multimedia/video.fxml", "Litera Player");
+ });
+
+ foregroundColorPicker.setOnAction(event -> {
+ Color newValue = foregroundColorPicker.getValue();
+ if ( newValue != null )
+ addStyle(Defaults.FOREGROUND_COLOR_COMMAND, Defaults.colorValueToHex(newValue));
+ });
+
+ notePadColorPicker.setOnAction(event -> {
+ Color newValue = notePadColorPicker.getValue();
+ if ( newValue != null )
+ {
+ LocalDataManager.saveNoteCSS(currentNote, Defaults.colorValueToHex(newValue));
+ loadCSS(currentNote);
+ }
+ });
+
+ addNoteButton.setOnAction(event -> {
+ noteListScrollPaneItems.add(LocalDataManager.createNewNote());
+ noteListView.getSelectionModel().select(noteListView.getItems().size() - 1);
+ });
+
+ deleteNoteButton.setOnAction(event -> {
+ LocalDataManager.moveNotes(noteListView.getSelectionModel().getSelectedItems(), true);
+ noteListScrollPaneItems.remove(noteListView.getSelectionModel().getSelectedItem());
+ noteListView.getSelectionModel().select(noteListView.getItems().size() - 1);
+ });
+
+ noteListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener()
+ {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue)
+ {
+ if ( isNoteChanged ) //there is no need for a save operation if you didn't change anything
+ {
+ currentNote.setHtmlNote(webPage.getHtml(webPage.getMainFrame()));
+ LocalDataManager.saveNote(currentNote);
+ isNoteChanged = false;
+ }
+ currentNote = LocalDataManager.getNote(newValue);
+ editor.getEngine().loadContent(currentNote.getHtmlNote());
+ noteNameTextField.setText(newValue);
+ loadCSS(currentNote);
+ }
+ });
+
+ //Event handler for button clicks on the note
+ editor.getEngine().setOnAlert((WebEvent wEvent) -> {
+ System.out.println("Alert Event - Message: " + wEvent.getData());
+ });
+
+ noteNameTextField.addEventHandler(KeyEvent.KEY_RELEASED, event -> {
+ //do not try to change the name if textField is empty or the note with the same name exists
+ if ( !noteNameTextField.getText().isEmpty() && !noteListScrollPaneItems.contains(noteNameTextField.getText()) )
+ {
+ LocalDataManager.renameNote(currentNote, noteNameTextField.getText());
+ populateNoteListbox(); //need this to retain the alphabetical order
+ }
+ });
+ /*** *** *** *** *** END OF Button Listeners *** *** *** *** ***/
+
+ // Start up of the program
+ borderPane.getStyleClass().add("border-pane"); //border-pane has the background-color property
+ noteNameTextField.getStyleClass().add("list-view"); //list-view has the border-color property
+ optionsToolbar.getStyleClass().add("list-view");
+ populateNoteListbox();
+ loadLastNote();
+ }
+
+ private void loadWindow(String windowPath, String windowTitle)
+ {
+ try
+ {
+ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(windowPath));
+ Parent root = fxmlLoader.load();
+ Stage stage = new Stage();
+ stage.initModality(Modality.APPLICATION_MODAL);
+ stage.setTitle(windowTitle);
+ stage.setScene(new Scene(root));
+ stage.show();
+ }
+ catch ( Exception ex )
+ {
+ ex.toString();
+ }
+ }
+
+ /**
+ * @param command some commands are located in the Defaults class
+ * @param commandComplement Color commands may go here
+ * @description adds style to the selected text. It is a low-level function. Not much to say here.
+ */
+ private void addStyle(String command, String commandComplement)
+ {
+ webPage.executeCommand(command, commandComplement);
+ editor.requestFocus();
+ buttonFeedback();
+ }
+
+ /**
+ * @return true if the operation is a success
+ * @description loads saved notes into the list note list view
+ */
+ private boolean populateNoteListbox()
+ {
+ String[] noteList = LocalDataManager.getNoteNames(LocalDataManager.getLocalNotesFilePath());
+ if ( noteList == null )
+ {
+ currentNote = new Note(Defaults.welcomeList[0], Defaults.welcomePage);
+ LocalDataManager.saveNote(currentNote);
+ LocalDataManager.generateAndSaveID(currentNote);
+ noteList = LocalDataManager.getNoteNames(LocalDataManager.getLocalNotesFilePath());
+ }
+ noteListScrollPaneItems = FXCollections.observableArrayList(noteList);
+ noteListView.setItems(noteListScrollPaneItems);
+ return true;
+ }
+
+ /**
+ * returns the last note name of
+ *
+ * @return
+ */
+ private boolean loadLastNote()
+ {
+ String lastNoteName = LocalDataManager.getLastNote();
+ if ( noteListView.getItems().contains(lastNoteName) )
+ noteListView.getSelectionModel().select(lastNoteName);
+ else
+ noteListView.getSelectionModel().selectFirst();
+ return true;
+ }
+
+ //changes button states according to the currently edited text. For instance if the text you are working on is Italic, toggles the Italic button.
+ private void buttonFeedback()
+ {
+ isNoteChanged = true;
+ boldToggleButton.setSelected(webPage.queryCommandState(Defaults.BOLD_COMMAND));
+ italicToggleButton.setSelected(webPage.queryCommandState(Defaults.ITALIC_COMMAND));
+ underlineToggleButton.setSelected(webPage.queryCommandState(Defaults.UNDERLINE_COMMAND));
+ strikethroughToggleButton.setSelected(webPage.queryCommandState(Defaults.STRIKETHROUGH_COMMAND));
+ insertOrderedListToggleButton.setSelected(webPage.queryCommandState(Defaults.NUMBERS_COMMAND));
+ }
+
+ private void loadCSS(Note n)
+ {
+ borderPane.getStylesheets().clear();
+ borderPane.getStylesheets().add(LocalDataManager.getNoteCSS(n).replace(" ", "%20"));
+ }
+}
\ No newline at end of file
diff --git a/src/minerva/Main.java b/src/litera/MainFrame/Main.java
similarity index 53%
rename from src/minerva/Main.java
rename to src/litera/MainFrame/Main.java
index 1bf7d38..275d582 100755
--- a/src/minerva/Main.java
+++ b/src/litera/MainFrame/Main.java
@@ -1,58 +1,63 @@
-package minerva;
+package litera.MainFrame;
import javafx.application.Application;
-import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
-import javafx.scene.input.MouseEvent;
-import javafx.stage.Modality;
import javafx.stage.Stage;
-import javafx.stage.StageStyle;
-import javafx.stage.Window;
import litera.Data.LocalDataManager;
+/**
+ * Starts the Main stage of Litera
+ *
+ * @author Çelik Köseoğlu
+ * @version 2
+ */
+
public class Main extends Application
{
+ private static Stage primaryStage;
private double xOffset = 0;
private double yOffset = 0;
+
+ public static void main(String[] args) throws Exception
+ {
+ LocalDataManager.setOS_FILE_PATH();
+ launch(args);
+ }
+
+ public static Stage getPrimaryStage()
+ {
+ return primaryStage;
+ }
+
@Override
public void start(Stage primaryStage) throws Exception
{
+ Main.primaryStage = primaryStage;
Parent root = FXMLLoader.load(getClass().getResource("minerva.fxml"));
primaryStage.setTitle("Project Litera");
primaryStage.setScene(new Scene(root, 800, 600));
primaryStage.setMinHeight(576);
primaryStage.setMinWidth(720);
-
primaryStage.show();
- root.setOnMousePressed(new EventHandler()
- {
- @Override
- public void handle(MouseEvent event)
- {
- xOffset = primaryStage.getX() - event.getScreenX();
- yOffset = primaryStage.getY() - event.getScreenY();
- }
+ //DragMove support
+ root.setOnMousePressed(event -> {
+ xOffset = primaryStage.getX() - event.getScreenX();
+ yOffset = primaryStage.getY() - event.getScreenY();
});
- root.setOnMouseDragged(new EventHandler() {
- @Override
- public void handle(MouseEvent event) {
- primaryStage.setX(event.getScreenX() + xOffset);
- primaryStage.setY(event.getScreenY() + yOffset);
- }
+ root.setOnMouseDragged(event -> {
+ primaryStage.setX(event.getScreenX() + xOffset);
+ primaryStage.setY(event.getScreenY() + yOffset);
});
+ //End of DragMove support
+ //Stage Closing event handler
primaryStage.setOnCloseRequest(we -> {
System.out.println("Stage is closing");
Controller.onExit();
System.out.println("Closed!");
});
}
-
- public static void main(String[] args) throws Exception {
- LocalDataManager.setOS_FILE_PATH();
- launch(args);
- }
}
\ No newline at end of file
diff --git a/src/minerva/Note.java b/src/litera/MainFrame/Note.java
similarity index 58%
rename from src/minerva/Note.java
rename to src/litera/MainFrame/Note.java
index e07cf7f..231e9ce 100755
--- a/src/minerva/Note.java
+++ b/src/litera/MainFrame/Note.java
@@ -1,27 +1,21 @@
-package minerva;
+package litera.MainFrame;
-import javafx.scene.paint.Color;
+/**
+ * Note class for Litera. Contains Note properties
+ *
+ * @author Çelik Köseoğlu
+ * @version 1
+ */
public class Note
{
private String noteName, htmlNote;
- private boolean isEncrypted;
- private Color noteColor, notePadColor;
+ private boolean isPasswordEncrypted;
public Note(String noteName, String htmlNote)
{
this.noteName = noteName;
this.htmlNote = htmlNote;
- this.notePadColor = Color.WHITE;
- }
-
- public void setHtmlNote(String htmlNote)
- {
- this.htmlNote = htmlNote;
- }
- public void setNoteName(String newName)
- {
- noteName = newName;
}
public String getHtmlNote()
@@ -29,23 +23,23 @@ public String getHtmlNote()
return htmlNote;
}
- public String getNoteName()
+ public void setHtmlNote(String htmlNote)
{
- return noteName;
+ this.htmlNote = htmlNote;
}
- public boolean isEncrypted()
+ public String getNoteName()
{
- return isEncrypted;
+ return noteName;
}
- public Color getNoteColor()
+ public void setNoteName(String newName)
{
- return noteColor;
+ noteName = newName;
}
- public Color getNotePadColor()
+ public boolean isPasswordEncrypted()
{
- return notePadColor;
+ return isPasswordEncrypted;
}
}
diff --git a/src/minerva/minerva.fxml b/src/litera/MainFrame/minerva.fxml
similarity index 51%
rename from src/minerva/minerva.fxml
rename to src/litera/MainFrame/minerva.fxml
index 4c4f221..605a3f9 100755
--- a/src/minerva/minerva.fxml
+++ b/src/litera/MainFrame/minerva.fxml
@@ -1,21 +1,20 @@
-
-
-
-
+
-
-
+
+
+
-
+
-
-
+
+
@@ -23,7 +22,8 @@
-
+
@@ -31,18 +31,20 @@
-
+
-
+
+
+
@@ -61,34 +63,105 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/litera/Multimedia/Audio.java b/src/litera/Multimedia/Audio.java
new file mode 100644
index 0000000..d7efb46
--- /dev/null
+++ b/src/litera/Multimedia/Audio.java
@@ -0,0 +1,263 @@
+package litera.Multimedia;
+
+import javax.sound.sampled.*;
+import java.io.*;
+
+/**
+ * Created by orhun on 23.04.2015.
+ */
+public class Audio
+{
+ final AudioFormat format = getFormat();
+ protected boolean running;
+ private ByteArrayOutputStream out;
+ private ByteArrayOutputStream recordBytes;
+ private String fileName;
+
+ public Audio(String fileName)
+ {
+ this.fileName = fileName;
+ }
+
+ /**
+ *
+ */
+ public static void playSound(String strFilename)
+ {
+
+ final int BUFFER_SIZE = 128000;
+ File soundFile = null;
+ AudioInputStream audioStream = null;
+ AudioFormat audioFormat;
+ SourceDataLine sourceLine = null;
+ try
+ {
+ soundFile = new File(strFilename);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try
+ {
+ audioStream = AudioSystem.getAudioInputStream(soundFile);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ audioFormat = audioStream.getFormat();
+
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
+ try
+ {
+ sourceLine = (SourceDataLine) AudioSystem.getLine(info);
+ sourceLine.open(audioFormat);
+ }
+ catch ( LineUnavailableException e )
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ sourceLine.start();
+
+ int nBytesRead = 0;
+ byte[] abData = new byte[BUFFER_SIZE];
+ while ( nBytesRead != -1 )
+ {
+ try
+ {
+ nBytesRead = audioStream.read(abData, 0, abData.length);
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ }
+ if ( nBytesRead >= 0 )
+ {
+ @SuppressWarnings( "unused" )
+ int nBytesWritten = sourceLine.write(abData, 0, nBytesRead);
+ }
+ }
+
+ sourceLine.drain();
+ sourceLine.close();
+ }
+
+ public void captureAudio()
+ {
+ try
+ {
+
+ DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
+ final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
+ line.open(format);
+ line.start();
+ Runnable runner = new Runnable()
+ {
+ int bufferSize = (int) format.getSampleRate() * format.getFrameSize();
+ byte buffer[] = new byte[bufferSize];
+
+ public void run()
+ {
+ out = new ByteArrayOutputStream();
+ running = true;
+ try
+ {
+ while ( running )
+ {
+ int count =
+ line.read(buffer, 0, buffer.length);
+ if ( count > 0 )
+ {
+ out.write(buffer, 0, count);
+ }
+ }
+ out.close();
+ line.drain();
+ line.close();
+
+ }
+ catch ( IOException e )
+ {
+ System.err.println("I/O problems: " + e);
+ System.exit(-1);
+ }
+ }
+ };
+ Thread captureThread = new Thread(runner);
+ captureThread.start();
+ }
+ catch ( LineUnavailableException e )
+ {
+ System.err.println("Line unavailable: " + e);
+ System.exit(-2);
+ }
+ }
+
+ /* ben playe basınca kaydedilsin gibi düşünüp buraya attım kayıt kodunu ama capture metoduna da koyulabilir gibi.
+ * Bir de muhtemelen metodu playe attım diye play çalışmıyor ama biraz uğraşırsam altından kalkabilirim gibime geliyor
+ *
+ *File path'i değiştir - orrun
+ * */
+ public void saveAudio()
+ {
+ try
+ {
+ byte audio[] = out.toByteArray();
+ InputStream input = new ByteArrayInputStream(audio);
+ final AudioFormat format = getFormat();
+ final AudioInputStream ais = new AudioInputStream(input, format, audio.length / format.getFrameSize());
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
+ final SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
+ File wavFile = new File(fileName);//saved place
+ line.open(format);
+ line.start();
+ //System.out.println("Start recording...");
+
+ // start recording
+ AudioSystem.write(ais, AudioFileFormat.Type.WAVE, wavFile);//starts writing into wav file
+ Runnable runner = new Runnable()
+ {
+ int bufferSize = (int) format.getSampleRate() * format.getFrameSize();
+ byte buffer[] = new byte[bufferSize];
+
+ public void run()
+ {
+ try
+ {
+ int count;
+ while ( (count = ais.read(buffer, 0, buffer.length)) != -1 )
+ {
+ if ( count > 0 )
+ {
+ line.write(buffer, 0, count);
+ }
+ }
+ line.drain();
+ line.close();
+ }
+ catch ( IOException e )
+ {
+ System.err.println("I/O problems: " + e);
+ System.exit(-3);
+ }
+ }
+ };
+ Thread playThread = new Thread(runner);
+ playThread.start();
+ }
+ catch ( LineUnavailableException e )
+ {
+ System.err.println("Line unavailable: " + e);
+ System.exit(-4);
+ }
+ catch ( IOException e )
+ {
+ System.err.println("I/O problems: " + e);
+ System.exit(-3);
+ }
+ }
+
+ public void stopCapture()
+ {
+ running = false;
+ }
+
+ private AudioFormat getFormat()
+ {
+ float sampleRate = 8000;//44100;
+ int sampleSizeInBits = 8;//16;
+ int channels = 1;
+ boolean signed = true;
+ boolean bigEndian = true;//false;
+ return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);
+ }
+
+ public String getFileName()
+ {
+ return fileName;
+ }
+
+ public void setFileName(String name)
+ {
+ fileName = name;
+ }
+ /*public double getDuration(){
+ try
+ {
+ stream = AudioSystem.getAudioInputStream(file);
+
+ AudioFormat format = stream.getFormat();
+
+ return file.length() / format.getSampleRate() / (format.getSampleSizeInBits() / 8.0) / format.getChannels();
+ }
+ catch (Exception e)
+ {
+ // log an error
+ return -1;
+ }
+ finally
+ {
+ try { stream.close(); } catch (Exception ex) { }
+ }
+
+ }*/
+
+
+}
+
+
+
+
+
diff --git a/src/minerva/AudioController.java b/src/litera/Multimedia/AudioController.java
similarity index 52%
rename from src/minerva/AudioController.java
rename to src/litera/Multimedia/AudioController.java
index 43b81ad..d99cff7 100755
--- a/src/minerva/AudioController.java
+++ b/src/litera/Multimedia/AudioController.java
@@ -1,17 +1,17 @@
-package minerva;
+package litera.Multimedia;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
-import javafx.scene.Node;
import javafx.scene.control.Button;
+import javafx.scene.control.Slider;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
-import litera.Data.EncryptionManager;
import litera.Data.LocalDataManager;
+import litera.MainFrame.Note;
import java.io.File;
-import java.io.FileWriter;
import java.net.URL;
+import java.time.Duration;
import java.util.ResourceBundle;
/**
@@ -28,19 +28,40 @@ public class AudioController implements Initializable {
Button choose;
@FXML
Button ok;
+ @FXML
+ Slider timeSlider;
File file;
+ Audio record;
+ String path;
+ Note current;
+ private Duration duration;
+
+ /**
+ * @param currentNote takes currentNote as a parameter and uses it to save audio to right file path
+ */
+ public AudioController(Note currentNote)
+ {
+ super();
+ current = currentNote;
+ //record = new Audio(path);
+ }
@Override // This method is called by the FXMLLoader when initialization is complete
public void initialize(URL fxmlFileLocation, ResourceBundle resources)
{
+
rec.setDisable(false);
play.setDisable(true);
stop.setDisable(true);
choose.setDisable(false);
ok.setDisable(false);
-
rec.setOnAction(event -> {
+
+ //change path in every record not to override audio files
+ path = LocalDataManager.getLocalNotesFilePath() + current.getNoteName()/*.replace( " ", "%20")*/ + "/" + java.time.LocalDateTime.now() + ".wav";
+ record = new Audio(path);
+ record.captureAudio();
rec.setDisable(true);
play.setDisable(true);
stop.setDisable(false);
@@ -54,9 +75,13 @@ public void initialize(URL fxmlFileLocation, ResourceBundle resources)
stop.setDisable(false);
choose.setDisable(true);
ok.setDisable(true);
+ Audio.playSound(record.getFileName());
+
});
stop.setOnAction(event ->{
+ record.stopCapture();
+ record.saveAudio();
rec.setDisable(false);
play.setDisable(false);
stop.setDisable(true);
@@ -84,9 +109,42 @@ public void initialize(URL fxmlFileLocation, ResourceBundle resources)
ok.setOnAction(event ->{
if( file != null){
- Controller.addAudio( LocalDataManager.addAudio( file, null));
+ //Controller.addAudio( LocalDataManager.addAudio( file, null));
}
((Stage) ok.getScene().getWindow()).close();
});
+
+ // Add time slider
+ /* timeSlider.valueProperty().addListener(new InvalidationListener()
+ {
+ public void invalidated(Observable ov)
+ {
+ if ( timeSlider.isValueChanging() )
+ {
+ // multiply duration by percentage calculated by slider position
+ mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
+ }
+ }
+ });
+ }*/
+ /* protected void updateValues(){
+ if ( timeSlider != null)
+ {
+ Platform.runLater(new Runnable() {
+ public void run() {
+ javafx.util.Duration currentTime = mp.getCurrentTime();
+ timeSlider.setDisable(duration.isUnknown());
+ if (!timeSlider.isDisabled()
+ && duration.greaterThan(javafx.util.Duration.ZERO)
+ && !timeSlider.isValueChanging()) {
+ timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0);
+ }
+
+ }
+ });
+ }*/
+
+
}
-}
+
+}
\ No newline at end of file
diff --git a/src/litera/Multimedia/PlayerController.java b/src/litera/Multimedia/PlayerController.java
new file mode 100644
index 0000000..ab3c9ea
--- /dev/null
+++ b/src/litera/Multimedia/PlayerController.java
@@ -0,0 +1,294 @@
+package litera.Multimedia;
+
+import javafx.application.Platform;
+import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.Slider;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+import javafx.scene.layout.Region;
+import javafx.scene.media.Media;
+import javafx.scene.media.MediaPlayer;
+import javafx.scene.media.MediaView;
+import javafx.util.Duration;
+import litera.Data.LocalDataManager;
+import litera.MainFrame.Note;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ResourceBundle;
+
+//mert aytöre
+
+public class PlayerController implements Initializable
+{
+ private final String MEDIA_URL = "http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv";
+ private final boolean repeat = false; //new added here
+ String workingDir = System.getProperty("user.dir"); // filepath
+ final File f = new File(workingDir, "/91.m4v");//"bird.wav");//"/91.m4v");//"/08.mp3");
+ private Media m;//= new Media(MEDIA_URL); //MEDIA_URL);//f.toURI().toString());
+ private MediaPlayer mp; //= new MediaPlayer(m);
+ @FXML
+ private BorderPane playerBorderPane;
+ @FXML
+ private Button playButton;
+ @FXML
+ private Slider timeSlider, volumeSlider;
+ @FXML
+ private Label playTime;
+ @FXML
+ private MediaView mediaView;
+ private boolean stopRequested = false;
+ private boolean atEndOfMedia = false;
+ private Duration duration;
+ private Note note;
+
+ public PlayerController(File f, Note note)
+ {
+ this.note = note;
+ String colorCode = LocalDataManager.getNoteCSS(note).substring(8);
+ System.out.println(colorCode);
+ colorCode = colorCode.substring(colorCode.indexOf('#') + 1, colorCode.indexOf('#') + 7);
+ File file;
+ file = f;
+ m = new Media(file.toURI().toString());
+ mp = new MediaPlayer(m);
+ playButton.setStyle("-fx-background-color: transparent;");
+ //playButton.getStyleClass().add("????");
+ playButton.setStyle(colorCode);
+ }
+
+
+ private static String formatTime(Duration elapsed, Duration duration)
+ {
+ int intElapsed = (int) Math.floor(elapsed.toSeconds());
+ int elapsedHours = intElapsed / (60 * 60);
+ if ( elapsedHours > 0 )
+ {
+ intElapsed -= elapsedHours * 60 * 60;
+ }
+ int elapsedMinutes = intElapsed / 60;
+ int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;
+
+ if ( duration.greaterThan(Duration.ZERO) )
+ {
+ int intDuration = (int) Math.floor(duration.toSeconds());
+ int durationHours = intDuration / (60 * 60);
+ if ( durationHours > 0 )
+ {
+ intDuration -= durationHours * 60 * 60;
+ }
+ int durationMinutes = intDuration / 60;
+ int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;
+ if ( durationHours > 0 )
+ {
+ return String.format("%d:%02d:%02d/%d:%02d:%02d",
+ elapsedHours, elapsedMinutes, elapsedSeconds, durationHours, durationMinutes, durationSeconds);
+ }
+ else
+ {
+ return String.format("%02d:%02d/%02d:%02d",
+ elapsedMinutes, elapsedSeconds, durationMinutes, durationSeconds);
+ }
+ }
+ else
+ {
+ if ( elapsedHours > 0 )
+ {
+ return String.format("%d:%02d:%02d", elapsedHours, elapsedMinutes, elapsedSeconds);
+ }
+ else
+ {
+ return String.format("%02d:%02d", elapsedMinutes, elapsedSeconds);
+ }
+ }
+ }
+
+ public void disposeThis()
+ {
+ this.mp.dispose();
+ }
+
+ @Override // This method is called by the FXMLLoader when initialization is complete
+ public void initialize(URL fxmlFileLocation, ResourceBundle resources)
+ {
+ mediaView.setMediaPlayer(mp);
+
+ playButton.setOnAction(new EventHandler()
+ {
+ public void handle(ActionEvent e)
+ {
+ MediaPlayer.Status status = mp.getStatus();
+
+ if ( status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED )
+ {
+ // don't do anything in these states
+ return;
+ }
+
+ if ( status == MediaPlayer.Status.PAUSED
+ || status == MediaPlayer.Status.READY
+ || status == MediaPlayer.Status.STOPPED )
+ {
+ // rewind the movie if we're sitting at the end
+ if ( atEndOfMedia )
+ {
+ mp.seek(mp.getStartTime());
+ atEndOfMedia = false;
+ }
+ mp.play();
+ }
+ else
+ {
+ mp.pause();
+ }
+ }
+ });
+
+ mp.currentTimeProperty().addListener(new InvalidationListener()
+ {
+ public void invalidated(Observable ov)
+ {
+ updateValues();
+ }
+ });
+
+ mp.setOnPlaying(new Runnable()
+ {
+ public void run()
+ {
+ if ( stopRequested )
+ {
+ mp.pause();
+ stopRequested = false;
+ }
+ else
+ {
+ Image im = new Image(getClass().getResourceAsStream("../Icons/pauseButton2.png"));
+ ImageView iv = new ImageView(im);
+ iv.setFitWidth(24);
+ iv.setFitHeight(24);
+ playButton.setGraphic(iv);
+ //playButton.setText("||");
+ }
+ }
+ });
+
+ mp.setOnPaused(new Runnable()
+ {
+ public void run()
+ {
+ System.out.println("onPaused");
+ Image im = new Image(getClass().getResourceAsStream("../Icons/playButton5.png"));
+ ImageView iv = new ImageView(im);
+ iv.setFitWidth(24);
+ iv.setFitHeight(24);
+ playButton.setGraphic(iv);
+ //playButton.setText(">");
+ }
+ });
+
+ mp.setOnReady(new Runnable()
+ {
+ public void run()
+ {
+ duration = mp.getMedia().getDuration();
+ updateValues();
+ }
+ });
+
+ mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
+ mp.setOnEndOfMedia(new Runnable()
+ {
+ public void run()
+ {
+ if ( !repeat )
+ {
+ Image im = new Image(getClass().getResourceAsStream("../Icons/playButton5.png"));
+ ImageView iv = new ImageView(im);
+ iv.setFitWidth(24);
+ iv.setFitHeight(24);
+ playButton.setGraphic(iv);
+ //playButton.setText(">");
+ stopRequested = true;
+ atEndOfMedia = true;
+ }
+ }
+ });
+
+ // Add time slider
+ HBox.setHgrow(timeSlider, Priority.ALWAYS);
+ timeSlider.setMinWidth(50);
+ timeSlider.setMaxWidth(Double.MAX_VALUE);
+ timeSlider.valueProperty().addListener(new InvalidationListener()
+ {
+ public void invalidated(Observable ov)
+ {
+ if ( timeSlider.isValueChanging() )
+ {
+ // multiply duration by percentage calculated by slider position
+ mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
+ }
+ }
+ });
+
+ // Adjusting the volume
+ volumeSlider.setPrefWidth(70);
+ volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
+ volumeSlider.setMinWidth(30);
+ volumeSlider.valueProperty().addListener(new InvalidationListener()
+ {
+ public void invalidated(Observable ov)
+ {
+ if ( volumeSlider.isValueChanging() )
+ {
+ mp.setVolume(volumeSlider.getValue() / 100.0);
+ }
+ }
+ });
+
+ mp.play();
+ mediaView.fitWidthProperty().bind(playerBorderPane.widthProperty());
+ mediaView.fitHeightProperty().bind(playerBorderPane.heightProperty());
+ playerBorderPane.setMinSize(500, 500);
+ System.out.println(mediaView.getFitWidth());
+ System.out.println(mediaView.getFitHeight());
+ //if() dosya uzant�s�na g�re
+ //playerBorderPane.setMinSize(500, 600);
+ }
+
+ protected void updateValues()
+ {
+ if ( playTime != null && timeSlider != null && volumeSlider != null )
+ {
+ Platform.runLater(new Runnable()
+ {
+ public void run()
+ {
+ Duration currentTime = mp.getCurrentTime();
+ playTime.setText(formatTime(currentTime, duration));
+ timeSlider.setDisable(duration.isUnknown());
+ if ( !timeSlider.isDisabled()
+ && duration.greaterThan(Duration.ZERO)
+ && !timeSlider.isValueChanging() )
+ {
+ timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0);
+ }
+ if ( !volumeSlider.isValueChanging() )
+ {
+ volumeSlider.setValue((int) Math.round(mp.getVolume() * 100));
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/litera/Multimedia/audio.fxml b/src/litera/Multimedia/audio.fxml
new file mode 100755
index 0000000..6db225d
--- /dev/null
+++ b/src/litera/Multimedia/audio.fxml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/litera/Multimedia/player.fxml b/src/litera/Multimedia/player.fxml
new file mode 100644
index 0000000..d0e0af7
--- /dev/null
+++ b/src/litera/Multimedia/player.fxml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/litera/Multimedia/video.fxml b/src/litera/Multimedia/video.fxml
new file mode 100755
index 0000000..7d7a0d1
--- /dev/null
+++ b/src/litera/Multimedia/video.fxml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/minerva/options.fxml b/src/litera/Options/options.fxml
similarity index 85%
rename from src/minerva/options.fxml
rename to src/litera/Options/options.fxml
index 29eb925..c12f62f 100755
--- a/src/minerva/options.fxml
+++ b/src/litera/Options/options.fxml
@@ -1,11 +1,10 @@
-
-
-
-
-
+
+
diff --git a/src/minerva/Controller.java b/src/minerva/Controller.java
deleted file mode 100755
index d00bb2d..0000000
--- a/src/minerva/Controller.java
+++ /dev/null
@@ -1,357 +0,0 @@
-package minerva;
-
-import com.sun.javafx.webkit.Accessor;
-import com.sun.webkit.WebPage;
-import javafx.beans.value.ChangeListener;
-import javafx.beans.value.ObservableValue;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
-import javafx.fxml.Initializable;
-import javafx.scene.Parent;
-import javafx.scene.Scene;
-import javafx.scene.control.*;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.layout.Background;
-import javafx.scene.layout.BackgroundFill;
-import javafx.scene.layout.BorderPane;
-import javafx.scene.paint.Color;
-import javafx.scene.web.WebView;
-import javafx.stage.FileChooser;
-import javafx.stage.Modality;
-import javafx.stage.Stage;
-import litera.Data.AudioLibrary;
-import litera.Data.LocalDataManager;
-import litera.Defaults.Defaults;
-import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import netscape.javascript.JSObject;
-
-public class Controller implements Initializable
-{
- // FXML StyleToolbar Declaration
- @FXML
- private ToolBar styleToolbar;
- @FXML
- private ToggleButton boldToggleButton;
- @FXML
- private ToggleButton italicToggleButton;
- @FXML
- private ToggleButton underlineToggleButton;
- @FXML
- private ToggleButton strikethroughToggleButton;
- @FXML
- private ToggleButton insertOrderedListToggleButton;
- @FXML
- private ToggleButton insertUnorderedListToggleButton;
- @FXML
- private Button addAudioButton;
- @FXML
- private Button addVideoButton;
- @FXML
- private Button addImageButton;
- @FXML
- private BorderPane borderPane;
-
- // FXML Rest of the Program Declaration
- @FXML
- private ListView noteListScrollPane;
- @FXML
- private ListView trashNoteListView;
- @FXML
- private WebView editor;
- @FXML
- private TextField noteNameTextField;
- @FXML
- private Button trashButton;
- @FXML
- private Button addNoteButton, deleteNoteButton;
- @FXML
- private Button optionsButton;
- @FXML
- private ColorPicker foregroundColorPicker;
- @FXML
- private ColorPicker notePadColorPicker;
-
- // Other variables' Declaration
- private static Note currentNote;
- private ObservableList noteListScrollPaneItems;
- private static WebPage webPage;
- private boolean isChanged;
-
- @Override // This method is called by the FXMLLoader when initialization is complete
- public void initialize(URL fxmlFileLocation, ResourceBundle resources)
- {
- // Style Buttons
- assert styleToolbar != null : "fx:id\"styleToolBar\" was not injected: check you FXML file 'minerva.fxml'.";
- assert boldToggleButton != null : "fx:id=\"bold\" was not injected: check your FXML file 'minerva.fxml'.";
- assert italicToggleButton != null : "fx:id=\"italic\" was not injected: check your FXML file 'minerva.fxml'.";
- assert underlineToggleButton != null : "fx:id=\"underline\" was not injected: check your FXML file 'minerva.fxml'.";
- assert strikethroughToggleButton != null : "fx:id=\"strikethrough\" was not injected: check your FXML file 'minerva.fxml'.";
- assert insertOrderedListToggleButton != null : "fx:id=\"insertOrderedList\" was not injected: check your FXML file 'minerva.fxml'.";
- assert insertUnorderedListToggleButton != null : "fx:id=\"insertUnorderedList\" was not injected: check your FXML file 'minerva.fxml'.";
-
- // Editor and Pane
- assert noteListScrollPane != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
- assert trashNoteListView != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
- assert editor != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
-
- // Add delete pane
- assert noteNameTextField != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
- assert trashButton != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
- assert deleteNoteButton != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
- assert optionsButton != null : "fx:id=\"noteListScrollPane\" was not injected: check your FXML file 'minerva.fxml'.";
-
- // initialize your logic here: all @FXML variables will have been injected
-
- // initializing webPage
- webPage = Accessor.getPageFor(editor.getEngine());
- isChanged = false;
-
- /*** *** *** *** *** START OF Button Listeners *** *** *** *** ***/
- // Button Listeners for Style
- boldToggleButton.setOnAction(event -> addStyle(Defaults.BOLD_COMMAND, null));
- italicToggleButton.setOnAction(event -> addStyle(Defaults.ITALIC_COMMAND, null));
- underlineToggleButton.setOnAction(event -> addStyle(Defaults.UNDERLINE_COMMAND, null));
- strikethroughToggleButton.setOnAction(event -> addStyle(Defaults.STRIKETHROUGH_COMMAND, null));
- insertOrderedListToggleButton.setOnAction(event -> addStyle(Defaults.NUMBERS_COMMAND, null));
- insertUnorderedListToggleButton.setOnAction(event -> addStyle(Defaults.BULLETS_COMMAND, null));
-
- // Listeners for Style buttons
- editor.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> buttonFeedback());
- editor.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> buttonFeedback());
- editor.addEventHandler(javafx.scene.input.KeyEvent.KEY_RELEASED, event -> buttonFeedback());
- editor.addEventHandler(javafx.scene.input.KeyEvent.KEY_PRESSED, event -> buttonFeedback());
-
- // Button Listeners for Bottom Toolbar
- trashButton.setOnAction(event -> {
- System.out.println("trashButton clicked");
- });
-
- optionsButton.setOnAction(event -> {
- try
- {
- FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("options2.fxml"));
- Parent root = fxmlLoader.load();
- Stage stage = new Stage();
- stage.initModality(Modality.APPLICATION_MODAL);
- stage.setTitle("Options");
- stage.setScene(new Scene(root));
- stage.show();
- }
- catch ( Exception ex )
- {
-
- }
- });
-
- addAudioButton.setOnAction(event -> {
- try
- {
- FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("audio.fxml"));
- fxmlLoader.setController(new AudioController());
- Parent root = fxmlLoader.load();
- Stage stage = new Stage();
- stage.initModality(Modality.APPLICATION_MODAL);
- stage.setTitle("Audio");
- stage.setScene(new Scene(root));
- stage.show();
- }
- catch ( Exception ex )
- {
-
- }
- });
-
- addVideoButton.setOnAction(event -> {
- try
- {
- FileChooser fileChooser = new FileChooser();
- fileChooser.showOpenDialog(addVideoButton.getScene().getWindow());
- }
- catch ( Exception ex )
- {
-
- }
- });
-
- addImageButton.setOnAction(event -> {
- try
- {
- FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("video.fxml"));
- Parent root = fxmlLoader.load();
- Stage stage = new Stage();
- stage.initModality(Modality.APPLICATION_MODAL);
- stage.setTitle("Picture");
- stage.setScene(new Scene(root));
- stage.show();
- }
- catch ( Exception ex )
- {
-
- }
- });
-
- foregroundColorPicker.setOnAction(ev1 -> {
- Color newValue = foregroundColorPicker.getValue();
- if ( newValue != null )
- {
- addStyle(Defaults.FOREGROUND_COLOR_COMMAND, colorValueToHex(newValue));
- foregroundColorPicker.hide();
- }
- });
-
- notePadColorPicker.setOnAction(ev1 -> {
- Color newValue = notePadColorPicker.getValue();
- if ( newValue != null )
- {
- webPage.executeScript(webPage.getMainFrame(), "document.body.style.backgroundColor = \"" + colorValueToHex(newValue) + "\";");
- borderPane.setStyle("-fx-background-color: " + colorValueToHex(newValue));
- notePadColorPicker.hide();
- }
- });
-
- addNoteButton.setOnAction(event -> {
- noteListScrollPaneItems.add(LocalDataManager.createNewNote());
- noteListScrollPane.getSelectionModel().select(noteListScrollPane.getItems().size() - 1);
- });
-
- deleteNoteButton.setOnAction(event -> {
- noteListScrollPaneItems.remove(Defaults.newNoteName);
- noteListScrollPane.getSelectionModel().select(noteListScrollPane.getItems().size() - 1);
- });
-
- // Listener for Note list selection
- noteListScrollPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener()
- {
- @Override
- public void changed(ObservableValue extends String> observable, String oldValue, String newValue)
- {
- if ( isChanged ) //there is no need for a save operation if you didn't change anything
- {
- currentNote.setHtmlNote(getWebViewContent());
- LocalDataManager.saveNote(currentNote);
- isChanged = false; //checked via webPage listeners
- }
- /* Gets the selected note from the notes directory
- * If LocalDataManager can't find the file, returns null. Either this is the first run or the user messed up with Litera directory.
- * While evaluating this statement, the note gets loaded into the currentNote object.*/
- currentNote = LocalDataManager.getNote(newValue);
- editor.getEngine().loadContent(currentNote.getHtmlNote());
-
- editor.getEngine().executeScript("document.write('" + currentNote.getHtmlNote() + "');");
- JSObject win = (JSObject) editor.getEngine().executeScript("window");
- win.setMember("audioLibrary", new AudioLibrary());
-
- noteNameTextField.setText(newValue);
- }
- });
-
- //calling populateListbox() is EXTREMELY INEFFICIENT. Will fix.
- noteNameTextField.addEventHandler(javafx.scene.input.KeyEvent.KEY_RELEASED, event -> {
- //do not try to change the name if textField is empty.
- if ( !noteNameTextField.getText().isEmpty() && !Arrays.asList(LocalDataManager.getNoteNames()).contains(noteNameTextField.getText()) )
- {
- LocalDataManager.renameNote(currentNote, noteNameTextField.getText());
- populateNoteListbox();
- }
- //LocalDataManager.getNoteNames();
- });
- /*** *** *** *** *** END OF Button Listeners *** *** *** *** ***/
-
- // Start up of the program
- populateNoteListbox();
- loadLastNote();
- }
-
- // Saves the current note on exit
- public static void onExit()
- {
- currentNote.setHtmlNote(webPage.getHtml(webPage.getMainFrame()));
- LocalDataManager.saveNote(currentNote);
- }
-
- // Returns the string version of the page
- private String getWebViewContent()
- {
- return webPage.getHtml(webPage.getMainFrame()); //old method: (String)editor.getEngine().executeScript("document.documentElement.outerHTML");
- }
-
- /**
- * @param command some commands are located in the Defaults class
- * @param commandComplement Color commands may go here
- * @description adds style to the selected text. It is a low-level function. Not much to say here.
- */
- private void addStyle(String command, String commandComplement)
- {
- webPage.executeCommand(command, commandComplement);
- editor.requestFocus();
- buttonFeedback();
- }
-
- /**
- * @return true if the operation is a success
- * @description loads saved notes into the list note list view
- */
- private boolean populateNoteListbox()
- {
- String[] noteList = LocalDataManager.getNoteNames();
- if ( noteList == null )
- {
- currentNote = new Note(Defaults.welcomeList[0], Defaults.welcomePage);
- LocalDataManager.saveNote(currentNote);
- noteList = LocalDataManager.getNoteNames();
- }
- noteListScrollPaneItems = FXCollections.observableArrayList(noteList);
- noteListScrollPane.setItems(noteListScrollPaneItems);
- trashNoteListView.setItems(noteListScrollPaneItems);
- return true;
- }
-
- /**
- * @return
- * @description the aim is to open the last note the user edited. I know it doesn't work as expected right now. (Celik)
- */
- private boolean loadLastNote()
- {
- noteListScrollPane.getSelectionModel().select(0);
- return true;
- }
-
- /**
- * @description changes button states according to the currently edited text. For instance if the text you are working on is
- * Italic, toggles the Italic button.
- */
- private void buttonFeedback()
- {
- isChanged = true;
- boldToggleButton.setSelected(webPage.queryCommandState(Defaults.BOLD_COMMAND));
- italicToggleButton.setSelected(webPage.queryCommandState(Defaults.ITALIC_COMMAND));
- underlineToggleButton.setSelected(webPage.queryCommandState(Defaults.UNDERLINE_COMMAND));
- strikethroughToggleButton.setSelected(webPage.queryCommandState(Defaults.STRIKETHROUGH_COMMAND));
- insertOrderedListToggleButton.setSelected(webPage.queryCommandState(Defaults.NUMBERS_COMMAND));
- insertUnorderedListToggleButton.setSelected(webPage.queryCommandState(Defaults.BULLETS_COMMAND));
- }
-
- /**
- * @param c Color to be converted
- * @return String containing Hex representation of the color
- * @description converts the Color object c to a Hex representation of th color
- */
- private static String colorValueToHex(Color c)
- {
- return String.format((Locale) null, "#%02x%02x%02x",
- Math.round(c.getRed() * 255),
- Math.round(c.getGreen() * 255),
- Math.round(c.getBlue() * 255));
- }
-
- public static void addAudio(File file)
- {
- webPage.executeScript(webPage.getMainFrame(), "document.write('')");
- }
-}
\ No newline at end of file
diff --git a/src/minerva/Sync.png b/src/minerva/Sync.png
deleted file mode 100755
index ff11669..0000000
Binary files a/src/minerva/Sync.png and /dev/null differ
diff --git a/src/minerva/audio.fxml b/src/minerva/audio.fxml
deleted file mode 100755
index 9c2a539..0000000
--- a/src/minerva/audio.fxml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/minerva/options2.fxml b/src/minerva/options2.fxml
deleted file mode 100755
index 2d2876e..0000000
--- a/src/minerva/options2.fxml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/minerva/video.fxml b/src/minerva/video.fxml
deleted file mode 100755
index 4475e84..0000000
--- a/src/minerva/video.fxml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/style/listView.css b/style/listView.css
deleted file mode 100644
index 28ff756..0000000
--- a/style/listView.css
+++ /dev/null
@@ -1,13 +0,0 @@
-.list-cell:filled:selected:focused, .list-cell:filled:selected {
- -fx-background-color: linear-gradient(#328BDB 0%, #207BCF 25%, #1973C9 75%, #0A65BF 100%);
- -fx-text-fill: white;
-}
-
-.list-cell:even { /* <=== changed to even */
- -fx-background-color: white;
-}
-
-.list-cell:filled:hover {
- -fx-background-color: #0093ff;
- -fx-text-fill: white;
-}
\ No newline at end of file