formating and font color part 1

started work on formating and font color
*added a textflow instead of the textarea
This commit is contained in:
Seil0 2017-03-09 22:26:37 +01:00
parent bef90522ca
commit d91ef3aeac
19 changed files with 198 additions and 199 deletions

Binary file not shown.

Binary file not shown.

View File

@ -3,11 +3,11 @@
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXColorPicker?>
<?import com.jfoenix.controls.JFXSlider?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.Image?>
@ -20,9 +20,12 @@
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<TextFlow fx:id="textFlow" layoutX="496.0" layoutY="131.0" prefHeight="200.0" prefWidth="200.0" visible="false" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="220.0" AnchorPane.topAnchor="44.0" />
<ScrollPane fx:id="scrollPane" fitToWidth="true" layoutX="408.0" layoutY="44.0" prefHeight="544.0" prefWidth="320.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="408.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0">
<content>
<TextFlow fx:id="textFlow" accessibleRole="TEXT_AREA" maxHeight="544.0" maxWidth="320.0" visible="true" />
</content>
</ScrollPane>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="500.0" prefWidth="375.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="88.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
@ -31,7 +34,7 @@
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="370.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="44.0">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>

Binary file not shown.

Binary file not shown.

View File

@ -25,6 +25,9 @@ import com.eclipsesource.json.JsonValue;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class DBController {
@ -244,9 +247,9 @@ public class DBController {
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
while (rs.next()) {
if(rs.getString(8).equals("favorite_black")){
mainWindowController.streamingFilms.add(new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_black),rs.getBoolean(5)));
mainWindowController.streamingFilms.add(new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_black),rs.getBoolean(9)));
}else{
mainWindowController.streamingFilms.add(new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_border_black),rs.getBoolean(5)));
mainWindowController.streamingFilms.add(new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_border_black),rs.getBoolean(9)));
}
}
stmt.close();
@ -279,9 +282,9 @@ public class DBController {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" );
if(rs.getString(8).equals("favorite_black")){
mainWindowController.streamingFilms.set(i,new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_black),rs.getBoolean(5)));
mainWindowController.streamingFilms.set(i,new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_black),rs.getBoolean(9)));
}else{
mainWindowController.streamingFilms.set(i,new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_border_black),rs.getBoolean(5)));
mainWindowController.streamingFilms.set(i,new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_border_black),rs.getBoolean(9)));
}
stmt.close();
rs.close();
@ -291,7 +294,10 @@ public class DBController {
}
}
}
/**
* check if there are any entries that have been removed from the film-directory
* @throws SQLException
*/
private void checkRemoveEntry() throws SQLException{
System.out.println("checking for entrys to remove to DB ...");
Statement stmt = connection.createStatement();
@ -318,6 +324,12 @@ public class DBController {
}
/**
* check if there are new films in the film-directory
* @throws SQLException
* @throws FileNotFoundException
* @throws IOException
*/
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ //TODO sort alphabetical
System.out.println("checking for entrys to add to DB ...");
String[] entries = new File(mainWindowController.getPath()).list();
@ -494,7 +506,7 @@ public class DBController {
void addCache( String streamUrl, String Title, String Year, String Rated, String Released, String Runtime, String Genre, String Director,
String Writer, String Actors, String Plot, String Language, String Country, String Awards, String Metascore, String imdbRating,
String imdbVotes, String imdbID, String Type, String Poster, String Response) throws SQLException{
String Type, String imdbVotes, String imdbID, String Poster, String Response) throws SQLException{
PreparedStatement ps = connection.prepareStatement("insert into cache values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
System.out.println("adding to cache...");
@ -528,28 +540,62 @@ public class DBController {
void readCache(String streamUrl){
try{
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl='"+streamUrl+"';");
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl='"+streamUrl+"';");
ArrayList<Text> nameText = new ArrayList<Text>();
ArrayList<Text> responseText = new ArrayList<Text>();
String fontFamily = mainWindowController.fontFamily;
Image im;
int fontSize = (int) Math.round(mainWindowController.size);
int j=2;
mainWindowController.ta1.appendText(mainWindowController.title+": "+rs.getString(2)+"\n");
mainWindowController.ta1.appendText(mainWindowController.year+": "+ rs.getString(3)+"\n");
mainWindowController.ta1.appendText(mainWindowController.rating+": "+rs.getString(4)+"\n");
mainWindowController.ta1.appendText(mainWindowController.publishedOn+": "+rs.getString(5)+"\n");
mainWindowController.ta1.appendText(mainWindowController.duration+": "+rs.getString(6)+"\n");
mainWindowController.ta1.appendText(mainWindowController.genre+": "+rs.getString(7)+"\n");
mainWindowController.ta1.appendText(mainWindowController.director+": "+rs.getString(8)+"\n");
mainWindowController.ta1.appendText(mainWindowController.writer+": "+rs.getString(9)+"\n");
mainWindowController.ta1.appendText(mainWindowController.actors+": "+rs.getString(10)+"\n");
mainWindowController.ta1.appendText(mainWindowController.plot+": "+rs.getString(11)+"\n");
mainWindowController.ta1.appendText(mainWindowController.language+": "+rs.getString(12)+"\n");
mainWindowController.ta1.appendText(mainWindowController.country+": "+rs.getString(13)+"\n");
mainWindowController.ta1.appendText(mainWindowController.awards+": "+rs.getString(14)+"\n");
mainWindowController.ta1.appendText(mainWindowController.metascore+": "+rs.getString(15)+"\n");
mainWindowController.ta1.appendText(mainWindowController.imdbRating+": "+rs.getString(16)+"\n");
mainWindowController.ta1.appendText(mainWindowController.type+": "+rs.getString(19)+"\n");
nameText.add(0, new Text(mainWindowController.title+": "));
nameText.add(1, new Text(mainWindowController.year+": "));
nameText.add(2, new Text(mainWindowController.rating+": "));
nameText.add(3, new Text(mainWindowController.publishedOn+": "));
nameText.add(4, new Text(mainWindowController.duration+": "));
nameText.add(5, new Text(mainWindowController.genre+": "));
nameText.add(6, new Text(mainWindowController.director+": "));
nameText.add(7, new Text(mainWindowController.writer+": "));
nameText.add(8, new Text(mainWindowController.actors+": "));
nameText.add(9, new Text(mainWindowController.plot+": "));
nameText.add(10, new Text(mainWindowController.language+": "));
nameText.add(11, new Text(mainWindowController.country+": "));
nameText.add(12, new Text(mainWindowController.awards+": "));
nameText.add(13, new Text(mainWindowController.metascore+": "));
nameText.add(14, new Text(mainWindowController.imdbRating+": "));
nameText.add(15, new Text(mainWindowController.type+": "));
for(int i=0; i<15; i++){
responseText.add(new Text(rs.getString(j)+"\n"));
j++;
}
responseText.add(new Text(rs.getString(19)+"\n"));
im = new Image(rs.getString(20));
stmt.close();
rs.close();
for(int i=0; i<nameText.size(); i++){
nameText.get(i).setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
responseText.get(i).setFont(Font.font(fontFamily, fontSize));
}
mainWindowController.textFlow.getChildren().remove(0, mainWindowController.textFlow.getChildren().size());
for(int i=0;i<nameText.size(); i++){
mainWindowController.textFlow.getChildren().addAll(nameText.get(i),responseText.get(i));
}
//TODO separate cache for posters
try{
mainWindowController.image1.setImage(im);
}catch (Exception e){
mainWindowController.image1.setImage(new Image("recources/icons/close_black_2048x2048.png"));
e.printStackTrace();
}
mainWindowController.image1.setImage(im);
}catch (SQLException e) {
System.out.println("Ups! an error occured!");
e.printStackTrace();

View File

@ -48,7 +48,7 @@ public class Main extends Application {
private String autoUpdate = "0";
private String mode = "local"; //local or streaming
private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country");
private double size = 12;
private double size = 17;
private ResourceBundle bundle;
private MainWindowController mainWindowController;
private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); //Windows: C:/Users/"User"/Documents/HomeFlix

View File

@ -3,11 +3,11 @@
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXColorPicker?>
<?import com.jfoenix.controls.JFXSlider?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.Image?>
@ -20,9 +20,12 @@
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<TextFlow fx:id="textFlow" layoutX="496.0" layoutY="131.0" prefHeight="200.0" prefWidth="200.0" visible="false" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="220.0" AnchorPane.topAnchor="44.0" />
<ScrollPane fx:id="scrollPane" fitToWidth="true" layoutX="408.0" layoutY="44.0" prefHeight="544.0" prefWidth="320.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="408.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0">
<content>
<TextFlow fx:id="textFlow" accessibleRole="TEXT_AREA" maxHeight="544.0" maxWidth="320.0" visible="true" />
</content>
</ScrollPane>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="500.0" prefWidth="375.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="88.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
@ -31,7 +34,7 @@
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="370.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="44.0">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>

View File

@ -46,7 +46,6 @@ import org.apache.commons.lang3.SystemUtils;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXColorPicker;
import com.jfoenix.controls.JFXSlider;
import com.jfoenix.controls.JFXTextArea;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXToggleButton;
@ -103,8 +102,6 @@ public class MainWindowController {
@FXML
private TableView<tableData> tableViewStreamingdata;
@FXML
JFXTextArea ta1;
@FXML
TextFlow textFlow;
@FXML
ScrollPane scrollPane;
@ -181,7 +178,6 @@ public class MainWindowController {
private TableColumn<tableData, String> dataNameColumn = new TableColumn<>("Datei Name");
@FXML
private TableColumn<tableData, String> dataNameEndColumn = new TableColumn<>("Datei Name mit Endung");
private boolean menutrue = false; //saves the position of menubtn (opened or closed)
private boolean settingstrue = false;
@ -189,7 +185,7 @@ public class MainWindowController {
static boolean firststart = false;
private int hashA = -2055934614;
private String version = "0.5.0";
private String buildNumber = "119";
private String buildNumber = "121";
private String versionName = "plasma cow";
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt";
@ -220,6 +216,7 @@ public class MainWindowController {
@SuppressWarnings("unused")
private String ratingSortType;
private String local;
String fontFamily = "System"; //TODO -> in mainwindowcontroller machen
String title;
String year;
String rating;
@ -236,7 +233,7 @@ public class MainWindowController {
String metascore;
String imdbRating;
String type;
private double size;
double size;
private int last;
private int selected;
private int next;
@ -540,7 +537,7 @@ public class MainWindowController {
treeTableViewfilm.setShowRoot(false);
//write content into cell
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titelProperty());
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
columnResolution.setCellValueFactory(cellData -> cellData.getValue().getValue().resolutionProperty());
@ -561,7 +558,6 @@ public class MainWindowController {
next = selected + 1;
name = columnTitel.getCellData(selected); //get name of selected item
datPath = columnStreamUrl.getCellData(selected); //get file path of selected item
ta1.setText(""); //delete text in ta1
if(mode.equals("local")){
if(localFilms.get(selected).getCached()==true){
@ -571,6 +567,7 @@ public class MainWindowController {
ApiQuery.startQuery(name,datPath); // start api query
}
}else{
System.out.println(streamingFilms.size());
if(streamingFilms.get(selected).getCached()==true){
System.out.println("loading from cache: "+name);
dbController.readCache(datPath);
@ -578,7 +575,6 @@ public class MainWindowController {
ApiQuery.startQuery(name,datPath); // start api query
}
}
ta1.positionCaret(0); //set cursor position in ta1
}
});
@ -586,7 +582,7 @@ public class MainWindowController {
treeTableViewfilm.setContextMenu(menu);
//Streaming-Settings Table
dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titelProperty());
dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty());
dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty());
tableViewStreamingdata.getColumns().addAll(dataNameColumn, dataNameEndColumn);
@ -610,7 +606,7 @@ public class MainWindowController {
}
for(int i = 0; i < helpData.size(); i++){
if(helpData.get(i).getTitel().toLowerCase().contains(tfsearch.getText().toLowerCase())){
if(helpData.get(i).getTitle().toLowerCase().contains(tfsearch.getText().toLowerCase())){
filterData.add(helpData.get(i)); //add data from newDaten to filteredData where title contains search input
}
}
@ -639,7 +635,12 @@ public class MainWindowController {
@Override
public void changed(ObservableValue<? extends Number> ov,Number old_val, Number new_val) {
setSize(sliderFontSize.getValue());
ta1.setFont(Font.font("System", size));
if(name != null){
dbController.readCache(datPath);
}
// ta1.setFont(Font.font("System", size));
saveSettings();
}
});
@ -699,6 +700,7 @@ public class MainWindowController {
ArrayList<Integer> fav_false = new ArrayList<Integer>();
ObservableList<tableData> helpData;
filterData.removeAll(filterData);
// treeTableViewfilm.getSelectionModel().clearSelection(selected);
root.getChildren().remove(0,root.getChildren().size());
if(mode.equals("local")){
@ -761,10 +763,6 @@ public class MainWindowController {
}else{
autoupdateBtn.setSelected(false);
}
ta1.setWrapText(true);
ta1.setEditable(false);
ta1.setFont(Font.font("System", getSize()));
}
private void refreshTable(){
@ -780,7 +778,7 @@ public class MainWindowController {
for(int i = 0; i < localFilms.size(); i++){
root.getChildren().add(new TreeItem<tableData>(localFilms.get(i))); //add data to root-node
}
columnRating.setMaxWidth(90);
columnRating.setMaxWidth(85);
columnTitel.setMaxWidth(290);
treeTableViewfilm.getColumns().get(3).setVisible(false);
treeTableViewfilm.getColumns().get(4).setVisible(false);

View File

@ -8,20 +8,17 @@ import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Scanner;
import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonObject;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
@SuppressWarnings("unused") //TODO
public class apiQuery{
public apiQuery(MainWindowController m, DBController db){
@ -32,8 +29,9 @@ public class apiQuery{
private MainWindowController mainWindowController;
private DBController dbController;
private Image im;
private int fontSize = 20;
private String fontFamily = "System";
private String[] responseString = new String[20];
ArrayList<Text> responseText = new ArrayList<Text>();
ArrayList<Text> nameText = new ArrayList<Text>();
void startQuery(String titel, String streamUrl){
URL url = null;
@ -44,6 +42,11 @@ public class apiQuery{
String retdata = null;
InputStream is = null;
BufferedReader br = null;
String fontFamily = mainWindowController.fontFamily;
int fontSize = (int) Math.round(mainWindowController.size);
responseText.removeAll(responseText);
nameText.removeAll(nameText);
try {
@ -69,158 +72,93 @@ public class apiQuery{
is = url.openStream();
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
// lesen der Daten aus dem Antwort Stream
// read data from response Stream
while ((retdata = br.readLine()) != null) {
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
//cut the json response into separate strings
System.out.println(retdata);
JsonObject object = Json.parse(retdata).asObject();
String titelV = object.getString("Title", "");
String yearV = object.getString("Year", "");
String ratedV = object.getString("Rated", "");
String releasedV = object.getString("Released", "");
String runtimeV = object.getString("Runtime", "");
String genreV = object.getString("Genre", "");
String directorV = object.getString("Director", "");
String writerV = object.getString("Writer", "");
String actorsV = object.getString("Actors", "");
String plotV = object.getString("Plot", "");
String languageV = object.getString("Language", "");
String countryV = object.getString("Country", "");
String awardsV = object.getString("Awards", "");
String metascoreV = object.getString("Metascore", "");
String imdbRatingV = object.getString("imdbRating", "");
String imdbVotesV = object.getString("imdbVotes", "");
String imdbIDV = object.getString("imdbID", "");
String typeV = object.getString("Type", "");
String posterURL = object.getString("Poster", "");
String response = object.getString("Response", "");
responseString[0] = object.getString("Title", "");
responseString[1] = object.getString("Year", "");
responseString[2] = object.getString("Rated", "");
responseString[3] = object.getString("Released", "");
responseString[4] = object.getString("Runtime", "");
responseString[5] = object.getString("Genre", "");
responseString[6] = object.getString("Director", "");
responseString[7] = object.getString("Writer", "");
responseString[8] = object.getString("Actors", "");
responseString[9] = object.getString("Plot", "");
responseString[10] = object.getString("Language", "");
responseString[11] = object.getString("Country", "");
responseString[12] = object.getString("Awards", "");
responseString[13] = object.getString("Metascore", "");
responseString[14] = object.getString("imdbRating", "");
responseString[15] = object.getString("Type", "");
responseString[16] = object.getString("imdbVotes", "");
responseString[17] = object.getString("imdbID", "");
responseString[18] = object.getString("Poster", "");
responseString[19] = object.getString("Response", "");
dbController.addCache( streamUrl, titelV, yearV, ratedV, releasedV, runtimeV, genreV, directorV, writerV, actorsV, plotV, languageV, countryV,
awardsV, metascoreV, imdbRatingV, imdbVotesV, imdbIDV, typeV, posterURL, response);
//adding strings to the cache
dbController.addCache( streamUrl, responseString[0], responseString[1],responseString[2], responseString[3], responseString[4], responseString[5],
responseString[6], responseString[7], responseString[8], responseString[9], responseString[10],responseString[11], responseString[12],
responseString[13], responseString[14], responseString[15], responseString[16], responseString[17], responseString[18],
responseString[19]);
dbController.setCached(streamUrl);
// Text titelR = new Text (object.getString("Title", "")+"\n");
// titelR.setFont(Font.font (fontFamily, fontSize));
// Text yearR = new Text (object.getString("Year", "")+"\n");
// yearR.setFont(Font.font (fontFamily, fontSize));
// Text ratedR = new Text (object.getString("Rated", "")+"\n");
// ratedR.setFont(Font.font (fontFamily, fontSize));
// Text releasedR = new Text (object.getString("Released", "")+"\n");
// releasedR.setFont(Font.font (fontFamily, fontSize));
// Text runtimeR = new Text (object.getString("Runtime", "")+"\n");
// runtimeR.setFont(Font.font (fontFamily, fontSize));
// Text genreR = new Text (object.getString("Genre", ""));
// genreR.setFont(Font.font (fontFamily, fontSize));
// Text directorR = new Text (object.getString("Director", "")+"\n");
// directorR.setFont(Font.font (fontFamily, fontSize));
// Text writerR = new Text (object.getString("Writer", "")+"\n");
// writerR.setFont(Font.font (fontFamily, fontSize));
// Text actorsR = new Text (object.getString("Actors", "")+"\n");
// actorsR.setFont(Font.font (fontFamily, fontSize));
// Text plotR = new Text (object.getString("Plot", "")+"\n");
// plotR.setFont(Font.font (fontFamily, fontSize));
// Text languageR = new Text (object.getString("Language", "")+"\n");
// languageR.setFont(Font.font (fontFamily, fontSize));
// Text countryR = new Text (object.getString("Country", "")+"\n");
// countryR.setFont(Font.font (fontFamily, fontSize));
// Text awardsR = new Text (object.getString("Awards", "")+"\n");
// awardsR.setFont(Font.font (fontFamily, fontSize));
// Text metascoreR = new Text (object.getString("Metascore", "")+"\n");
// metascoreR.setFont(Font.font (fontFamily, fontSize));
// Text imdbRatingR = new Text (object.getString("imdbRating", "")+"\n");
// imdbRatingR.setFont(Font.font (fontFamily, fontSize));
// @SuppressWarnings("unused")
// Text imdbVotesR = new Text (object.getString("imdbVotes", "")+"\n");
// imdbVotesR.setFont(Font.font (fontFamily, fontSize));
// @SuppressWarnings("unused")
// Text imdbIDR = new Text (object.getString("imdbID", "")+"\n");
// imdbIDR.setFont(Font.font (fontFamily, fontSize));
// Text typeR = new Text (object.getString("Type", "")+"\n");
// typeR.setFont(Font.font (fontFamily, fontSize));
for(int i=0; i<20; i++){
Text text = new Text(responseString[i]+"\n");
responseText.add(text);
responseText.get(i).setFont(Font.font(fontFamily, fontSize));
}
if(response.equals("False")){
mainWindowController.ta1.appendText(mainWindowController.noFilmFound);
//if response == false then show mainWindowController.noFilmFound else create new Texts and add them to flowText
if(responseString[19].equals("False")){
mainWindowController.textFlow.getChildren().add(new Text(mainWindowController.noFilmFound));
im = new Image("recources/icons/close_black_2048x2048.png");
mainWindowController.image1.setImage(im);
}else{
//ausgabe des Textes in ta1 in jeweils neuer Zeile
mainWindowController.ta1.appendText(mainWindowController.title+": "+titelV+"\n");
mainWindowController.ta1.appendText(mainWindowController.year+": "+ yearV+"\n");
mainWindowController.ta1.appendText(mainWindowController.rating+": "+ratedV+"\n");
mainWindowController.ta1.appendText(mainWindowController.publishedOn+": "+releasedV+"\n");
mainWindowController.ta1.appendText(mainWindowController.duration+": "+runtimeV+"\n");
mainWindowController.ta1.appendText(mainWindowController.genre+": "+genreV+"\n");
mainWindowController.ta1.appendText(mainWindowController.director+": "+directorV+"\n");
mainWindowController.ta1.appendText(mainWindowController.writer+": "+writerV+"\n");
mainWindowController.ta1.appendText(mainWindowController.actors+": "+actorsV+"\n");
mainWindowController.ta1.appendText(mainWindowController.plot+": "+plotV+"\n");
mainWindowController.ta1.appendText(mainWindowController.language+": "+languageV+"\n");
mainWindowController.ta1.appendText(mainWindowController.country+": "+countryV+"\n");
mainWindowController.ta1.appendText(mainWindowController.awards+": "+awardsV+"\n");
mainWindowController.ta1.appendText(mainWindowController.metascore+": "+metascoreV+"\n");
mainWindowController.ta1.appendText(mainWindowController.imdbRating+": "+imdbRatingV+"\n");
mainWindowController.ta1.appendText(mainWindowController.type+": "+typeV+"\n");
//
nameText.add(0, new Text(mainWindowController.title+": "));
nameText.add(1, new Text(mainWindowController.year+": "));
nameText.add(2, new Text(mainWindowController.rating+": "));
nameText.add(3, new Text(mainWindowController.publishedOn+": "));
nameText.add(4, new Text(mainWindowController.duration+": "));
nameText.add(5, new Text(mainWindowController.genre+": "));
nameText.add(6, new Text(mainWindowController.director+": "));
nameText.add(7, new Text(mainWindowController.writer+": "));
nameText.add(8, new Text(mainWindowController.actors+": "));
nameText.add(9, new Text(mainWindowController.plot+": "));
nameText.add(10, new Text(mainWindowController.language+": "));
nameText.add(11, new Text(mainWindowController.country+": "));
nameText.add(12, new Text(mainWindowController.awards+": "));
nameText.add(13, new Text(mainWindowController.metascore+": "));
nameText.add(14, new Text(mainWindowController.imdbRating+": "));
nameText.add(15, new Text(mainWindowController.type+": "));
for(int i=0; i<nameText.size(); i++){
nameText.get(i).setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
}
// mainWindowController.ta1.setVisible(false);
mainWindowController.textFlow.getChildren().remove(0, mainWindowController.textFlow.getChildren().size());
// Text title = new Text(15, 20, mainWindowController.title+": ");
// title.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text year = new Text(15, 20, mainWindowController.year+": ");
// year.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text rating = new Text(15, 20, mainWindowController.rating+": ");
// rating.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text publishedOn = new Text(15, 20, mainWindowController.publishedOn+": ");
// publishedOn.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text duration = new Text(15, 20, mainWindowController.duration+": ");
// duration.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text genre = new Text(15, 20, mainWindowController.genre+": ");
// genre.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text director = new Text(15, 20, mainWindowController.director+": ");
// director.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text writer = new Text(15, 20, mainWindowController.writer+": ");
// writer.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text actors = new Text(15, 20, mainWindowController.actors+": ");
// actors.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text plot = new Text(15, 20, mainWindowController.plot+": ");
// plot.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text language = new Text(15, 20, mainWindowController.language+": ");
// language.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text country = new Text(15, 20, mainWindowController.country+": ");
// country.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text awards = new Text(15, 20, mainWindowController.awards+": ");
// awards.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text metascore = new Text(15, 20, mainWindowController.metascore+": ");
// metascore.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text imdbRating = new Text(15, 20, mainWindowController.imdbRating+": ");
// imdbRating.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
// Text type = new Text(15, 20, mainWindowController.type+": ");
// type.setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
//
// mainWindowController.textFlow.getChildren().remove(0, mainWindowController.textFlow.getChildren().size());
//
// ObservableList<Node> list = mainWindowController.textFlow.getChildren();
//
// list.addAll(title,titelR,year,yearR,rating,ratedR,
// publishedOn,releasedR,duration,runtimeR,genre,genreR,director,directorR,writer,writerR,
// actors,actorsR,plot,plotR,language,languageR,country,countryR,awards,awardsR,metascore,
// metascoreR,imdbRating,imdbRatingR,type,typeR);
//
if(posterURL.equals("N/A")){
for(int i=0;i<nameText.size(); i++){
mainWindowController.textFlow.getChildren().addAll(nameText.get(i),responseText.get(i));
}
//if there is no poster
if(responseString[18].equals("N/A")){
im = new Image("recources/icons/close_black_2048x2048.png");
}else{
im = new Image(posterURL);
im = new Image(responseString[18]);
}
mainWindowController.image1.setImage(im);
}
}
} catch (Exception e) {
mainWindowController.ta1.setText(e.toString());
mainWindowController.textFlow.getChildren().add(new Text(e.toString()));
System.out.println(e);
} finally {
//closes datainputStream, InputStream,Scanner if not already done

View File

@ -17,19 +17,30 @@ public class tableData {
private final IntegerProperty episode = new SimpleIntegerProperty();
private final DoubleProperty rating = new SimpleDoubleProperty();
private final StringProperty resolution = new SimpleStringProperty();
private final StringProperty titel = new SimpleStringProperty();
private final StringProperty title = new SimpleStringProperty();
private final StringProperty streamUrl = new SimpleStringProperty();
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
private final BooleanProperty cached = new SimpleBooleanProperty();
//tableData is the data-type of tree-table-view
public tableData (final int year, final int season, final int episode, final double rating, final String resolution, final String titel, final String streamUrl, final ImageView image, final boolean cached) {
/**
* tableData is the data-type of tree-table-view
* @param year: the release year of the film
* @param season: season if it's a series
* @param episode: episode if it's a series
* @param rating: indicator for favourites, used for sorting the items
* @param resolution: resolution of the film
* @param titel: title of the film
* @param streamUrl: the concrete path to the file or the URL
* @param image: the favourite icon
* @param cached: indicator for caching status
*/
public tableData (final int year, final int season, final int episode, final double rating, final String resolution, final String title, final String streamUrl, final ImageView image, final boolean cached) {
this.year.set(year);
this.season.set(season);
this.episode.set(episode);
this.rating.set(rating);
this.resolution.set(resolution);
this.titel.set(titel);
this.title.set(title);
this.streamUrl.set(streamUrl);
this.image.set(image);
this.cached.set(cached);
@ -55,8 +66,8 @@ public class tableData {
return resolution;
}
public StringProperty titelProperty(){
return titel;
public StringProperty titleProperty(){
return title;
}
public StringProperty streamUrlProperty(){
@ -92,8 +103,8 @@ public class tableData {
return resolutionProperty().get();
}
public final String getTitel() {
return titelProperty().get();
public final String getTitle() {
return titleProperty().get();
}
public final String getStreamUrl() {
@ -129,8 +140,8 @@ public class tableData {
resolutionProperty().set(resolution);
}
public final void setTitel(String titel) {
titelProperty().set(titel);
public final void setTitle(String title) {
titleProperty().set(title);
}
public final void setStreamUrl(String streamUrl) {