major gui update
This commit is contained in:
parent
48753b4859
commit
8717e07604
2 changed files with 155 additions and 10 deletions
|
@ -16,10 +16,11 @@ import org.json.JSONObject;
|
||||||
public class GuiData {
|
public class GuiData {
|
||||||
|
|
||||||
private ArrayList<String> localLevels = new ArrayList<String>();
|
private ArrayList<String> localLevels = new ArrayList<String>();
|
||||||
private ArrayList<String> completed = new ArrayList<String>();
|
private ArrayList<String> qualification = new ArrayList<String>();
|
||||||
private ArrayList<String> id = new ArrayList<String>();
|
private ArrayList<String> id = new ArrayList<String>();
|
||||||
private ArrayList<String> verifier = new ArrayList<String>();
|
private ArrayList<String> verifier = new ArrayList<String>();
|
||||||
private ArrayList<String> creator = new ArrayList<String>();
|
private ArrayList<String> creator = new ArrayList<String>();
|
||||||
|
private ArrayList<String> ytlink = new ArrayList<String>();
|
||||||
|
|
||||||
private FetchData data = new FetchData();
|
private FetchData data = new FetchData();
|
||||||
|
|
||||||
|
@ -49,6 +50,14 @@ public class GuiData {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getQualification() {
|
||||||
|
return qualification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getYoutubeLink() {
|
||||||
|
return ytlink;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void IndexLevelName() throws IOException {
|
public void IndexLevelName() throws IOException {
|
||||||
|
@ -177,6 +186,59 @@ public class GuiData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void IndexQualification() throws IOException {
|
||||||
|
|
||||||
|
FetchData data = new FetchData();
|
||||||
|
|
||||||
|
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||||
|
File[] filelengthindex = filelength.listFiles();
|
||||||
|
|
||||||
|
String jsonstring;
|
||||||
|
|
||||||
|
localLength = filelengthindex.length;
|
||||||
|
|
||||||
|
System.out.println(filelengthindex.length);
|
||||||
|
|
||||||
|
for(int i = 0; i < filelengthindex.length; i++) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8);
|
||||||
|
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject(jsonstring);
|
||||||
|
|
||||||
|
qualification.add(obj.getInt("percentToQualify") + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> IndexYoutubeLink() throws IOException {
|
||||||
|
FetchData data = new FetchData();
|
||||||
|
|
||||||
|
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||||
|
File[] filelengthindex = filelength.listFiles();
|
||||||
|
|
||||||
|
String jsonstring;
|
||||||
|
|
||||||
|
localLength = filelengthindex.length;
|
||||||
|
|
||||||
|
System.out.println(filelengthindex.length);
|
||||||
|
|
||||||
|
for(int i = 0; i < filelengthindex.length; i++) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8);
|
||||||
|
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject(jsonstring);
|
||||||
|
|
||||||
|
ytlink.add(obj.getString("verification") + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ytlink;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<String> allVictors(String levelname) throws IOException {
|
public static ArrayList<String> allVictors(String levelname) throws IOException {
|
||||||
ArrayList<String> completed = new ArrayList<>();
|
ArrayList<String> completed = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -196,4 +258,8 @@ public class GuiData {
|
||||||
|
|
||||||
return completed;
|
return completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
@ -19,11 +20,17 @@ import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
@ -51,8 +58,15 @@ public class MainGUI {
|
||||||
public JLabel level = new JLabel("Liste");
|
public JLabel level = new JLabel("Liste");
|
||||||
public JLabel creator = new JLabel("Creator");
|
public JLabel creator = new JLabel("Creator");
|
||||||
public JLabel separator = new JLabel("_______________________________________________________________________________________________________________");
|
public JLabel separator = new JLabel("_______________________________________________________________________________________________________________");
|
||||||
|
public JLabel separator2 = new JLabel("_______________________________________________________________________________________________________________");
|
||||||
|
public JLabel separator3 = new JLabel("_______________________________________________________________________________________________________________");
|
||||||
public JLabel verifier = new JLabel("Verifier");
|
public JLabel verifier = new JLabel("Verifier");
|
||||||
|
public JLabel victorcount = new JLabel("Anzahl Victors");
|
||||||
|
public JLabel victor = new JLabel("Victors: ");
|
||||||
|
public JLabel idshow = new JLabel("ID");
|
||||||
|
public JLabel qualify = new JLabel("Qualifikation");
|
||||||
public JPanel recordspanel = new JPanel();
|
public JPanel recordspanel = new JPanel();
|
||||||
|
public JLabel ytthumbnail = new JLabel();
|
||||||
public JScrollPane records = new JScrollPane(recordspanel);
|
public JScrollPane records = new JScrollPane(recordspanel);
|
||||||
public JCheckBox filtercompleted = new JCheckBox("Nach geschaft filtern");
|
public JCheckBox filtercompleted = new JCheckBox("Nach geschaft filtern");
|
||||||
public Button copyid = new Button("Level ID kopieren");
|
public Button copyid = new Button("Level ID kopieren");
|
||||||
|
@ -71,6 +85,8 @@ public class MainGUI {
|
||||||
data.IndexLevelID();
|
data.IndexLevelID();
|
||||||
data.IndexVerifiers();
|
data.IndexVerifiers();
|
||||||
data.IndexCreators();
|
data.IndexCreators();
|
||||||
|
data.IndexQualification();
|
||||||
|
data.IndexYoutubeLink();
|
||||||
|
|
||||||
gridLayout.setRows(data.getLocalLevels().size());
|
gridLayout.setRows(data.getLocalLevels().size());
|
||||||
|
|
||||||
|
@ -96,12 +112,16 @@ public class MainGUI {
|
||||||
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
levelpanel.setLayout(gridLayout);
|
levelpanel.setLayout(gridLayout);
|
||||||
|
|
||||||
|
victorcount.setBounds(10, 130, 164, 30);
|
||||||
|
|
||||||
|
idshow.setBounds(10, 150, 164, 30);
|
||||||
|
|
||||||
|
|
||||||
copyid.setBounds(10, 50, 164, 30);
|
copyid.setBounds(10, 50, 164, 30);
|
||||||
|
|
||||||
|
qualify.setBounds(10, 170, 164, 30);
|
||||||
|
|
||||||
|
victor.setBounds(1, 276, 164, 30);
|
||||||
|
|
||||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
scroll.setBounds(0, 61, 700, 600);
|
scroll.setBounds(0, 61, 700, 600);
|
||||||
|
@ -112,6 +132,8 @@ public class MainGUI {
|
||||||
elements.infopanel().setVisible(false);
|
elements.infopanel().setVisible(false);
|
||||||
|
|
||||||
separator.setBounds(0, 70, 300, 30);
|
separator.setBounds(0, 70, 300, 30);
|
||||||
|
separator2.setBounds(0 ,178, 400, 30);
|
||||||
|
separator3.setBounds(0, 263, 300, 30);
|
||||||
|
|
||||||
creator.setBounds(10, 90, 164, 30);
|
creator.setBounds(10, 90, 164, 30);
|
||||||
|
|
||||||
|
@ -121,6 +143,11 @@ public class MainGUI {
|
||||||
|
|
||||||
show.setBounds(500, 1, 200, 60);
|
show.setBounds(500, 1, 200, 60);
|
||||||
|
|
||||||
|
ytthumbnail.setBounds(0, 200, 184, 85);
|
||||||
|
|
||||||
|
recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
|
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -146,6 +173,8 @@ public class MainGUI {
|
||||||
uncompleted.setBounds(640, 17, 17, 17);
|
uncompleted.setBounds(640, 17, 17, 17);
|
||||||
uncompleted.setMargin(new Insets(0,0,0,0));
|
uncompleted.setMargin(new Insets(0,0,0,0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json");
|
File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json");
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,14 +222,60 @@ public class MainGUI {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|
||||||
|
|
||||||
|
String url = data.getYoutubeLink().get(index);
|
||||||
|
|
||||||
|
|
||||||
|
if (url != null && url.contains("v=")) {
|
||||||
|
int startIndex = url.indexOf("v=") + 2;
|
||||||
|
int endIndex = url.indexOf('&', startIndex);
|
||||||
|
if (endIndex == -1) {
|
||||||
|
endIndex = url.length();
|
||||||
|
}
|
||||||
|
String videoId = url.substring(startIndex, endIndex);
|
||||||
|
|
||||||
|
String videoThumb = "https://img.youtube.com/vi/" + videoId +"/0.jpg";
|
||||||
|
|
||||||
|
System.out.println(videoThumb);
|
||||||
|
|
||||||
|
|
||||||
|
int labelWidth = ytthumbnail.getWidth();
|
||||||
|
int labelHeight = ytthumbnail.getHeight();
|
||||||
|
|
||||||
|
URL imageget;
|
||||||
|
try {
|
||||||
|
imageget = new URL(videoThumb);
|
||||||
|
BufferedImage originalImage = ImageIO.read(imageget);
|
||||||
|
|
||||||
|
// Das Bild skalieren, um in das JLabel zu passen
|
||||||
|
Image scaledImage = originalImage.getScaledInstance(labelWidth, labelHeight, Image.SCALE_SMOOTH);
|
||||||
|
|
||||||
|
// Ein ImageIcon erstellen und dem JLabel zuweisen
|
||||||
|
ytthumbnail.setIcon(new ImageIcon(scaledImage));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
level.setText(data.getLocalLevels().get(index));
|
level.setText(data.getLocalLevels().get(index));
|
||||||
verifier.setText("Verifier: " + data.getVerifier().get(index));
|
verifier.setText("Verifier: " + data.getVerifier().get(index));
|
||||||
creator.setText("Creator: " + data.getCreator().get(index));
|
creator.setText("Creator: " + data.getCreator().get(index));
|
||||||
|
idshow.setText("ID: " + data.getId().get(index));
|
||||||
|
qualify.setText("Qualifikation: " + data.getQualification().get(index) + "%");
|
||||||
level.setVerticalAlignment(SwingConstants.CENTER);
|
level.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
FetchData fetchData = new FetchData();
|
FetchData fetchData = new FetchData();
|
||||||
|
|
||||||
recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
||||||
try {
|
try {
|
||||||
recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
|
recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
@ -217,6 +292,8 @@ public class MainGUI {
|
||||||
// Instanz der FetchData-Klasse erstellen
|
// Instanz der FetchData-Klasse erstellen
|
||||||
ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index)); // Methode allVictors aufrufen
|
ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index)); // Methode allVictors aufrufen
|
||||||
|
|
||||||
|
victorcount.setText("Anzahl Victors: " + victors.size());
|
||||||
|
|
||||||
recordspanel.setLayout(new GridLayout(victors.size(), 1));
|
recordspanel.setLayout(new GridLayout(victors.size(), 1));
|
||||||
|
|
||||||
for(String victor : victors) {
|
for(String victor : victors) {
|
||||||
|
@ -359,12 +436,7 @@ public class MainGUI {
|
||||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
if (!contents.getBackground().equals(Color.decode("#cbffbf"))) {
|
if (!contents.getBackground().equals(Color.decode("#cbffbf"))) {
|
||||||
levelpanel.remove(contents);
|
levelpanel.remove(contents);
|
||||||
try {
|
gridLayout.setRows(data.getLocalLength());
|
||||||
gridLayout.setRows(data.allVictors(data.getLocalLevels().get(index)).size());
|
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
scroll.repaint();
|
scroll.repaint();
|
||||||
scroll.revalidate();
|
scroll.revalidate();
|
||||||
}
|
}
|
||||||
|
@ -401,9 +473,16 @@ public class MainGUI {
|
||||||
elements.infopanel().add(copyid);
|
elements.infopanel().add(copyid);
|
||||||
elements.infopanel().add(level, SwingConstants.CENTER);
|
elements.infopanel().add(level, SwingConstants.CENTER);
|
||||||
elements.infopanel().add(separator);
|
elements.infopanel().add(separator);
|
||||||
|
elements.infopanel().add(separator2);
|
||||||
|
elements.infopanel().add(separator3);
|
||||||
elements.infopanel().add(creator);
|
elements.infopanel().add(creator);
|
||||||
elements.infopanel().add(verifier);
|
elements.infopanel().add(verifier);
|
||||||
elements.infopanel().add(records);
|
elements.infopanel().add(records);
|
||||||
|
elements.infopanel().add(victorcount);
|
||||||
|
elements.infopanel().add(idshow);
|
||||||
|
elements.infopanel().add(qualify);
|
||||||
|
elements.infopanel().add(victor);
|
||||||
|
elements.infopanel().add(ytthumbnail);
|
||||||
|
|
||||||
|
|
||||||
main.add(search);
|
main.add(search);
|
||||||
|
|
Loading…
Reference in a new issue