diff --git a/jecnak-tui.jar b/jecnak-tui.jar new file mode 100644 index 0000000..d3ae7bb Binary files /dev/null and b/jecnak-tui.jar differ diff --git a/src/main/java/xyz/thastertyn/Jecna/Rozvrh.java b/src/main/java/xyz/thastertyn/Jecna/Rozvrh.java index 5b6cd4e..7f49c21 100644 --- a/src/main/java/xyz/thastertyn/Jecna/Rozvrh.java +++ b/src/main/java/xyz/thastertyn/Jecna/Rozvrh.java @@ -47,11 +47,6 @@ public class Rozvrh { * Stahne rozvrh z www.spsejecna.cz a dale ho zpracuje do formy * se kterou da pracovat * @param Jsessionid ze stranek - * @return Status code - * - * * @throws UnknownHostException kdyz neni pripojeni k internetu * @throws IOException ostatni exceptiony nejsou dulezite, tak jsou zahrnuty v jednom */ @@ -74,7 +69,6 @@ public class Rozvrh { String predmet = rozvrhDny[i].get(j).select("span.subject").text().replaceAll(" ", "/"); // Predmety jako CEL jsou trikrat, staci ale jen jednou - // V hashsetu se neopakuji prvky HashSet set = new HashSet<>(); String[] split = predmet.split("/"); @@ -96,6 +90,11 @@ public class Rozvrh { for(String s : set) { pr = s; break; } } + if(pr.isBlank()) + { + pr = "-"; + } + rozvrh[i-1][j-1] = pr; } } diff --git a/src/main/java/xyz/thastertyn/Jecna/Znamky.java b/src/main/java/xyz/thastertyn/Jecna/Znamky.java index 59b0c4f..3358bc3 100644 --- a/src/main/java/xyz/thastertyn/Jecna/Znamky.java +++ b/src/main/java/xyz/thastertyn/Jecna/Znamky.java @@ -35,8 +35,8 @@ public class Znamky { private double getAverage(ArrayList> a) { try{ - int divident = 0; - int divisor = 0; + double divident = 0; + double divisor = 0; for(Pair p : a) { if(p.getValue0() == -1) @@ -57,10 +57,11 @@ public class Znamky { } } - public void downloadZnamky(final String Jsessionid) throws UnknownHostException, IOException + public void downloadZnamky(final String Jsessionid/*, int schoolYearId, int schoolYearHalfId*/) throws UnknownHostException, IOException { wasDownloaded = true; - Document znamkyDoc = Downloader.download("https://www.spsejecna.cz" + "/score/student", Jsessionid).get(); + //String url = String.format("https://www.spsejecna.cz/score/student?schoolYearId=%d&schoolYearHalfId=%d", schoolYearId, schoolYearHalfId); + Document znamkyDoc = Downloader.download("https://www.spsejecna.cz/score/student?schoolYearId=14&schoolYearHalfId=21", Jsessionid).get(); Elements rows = znamkyDoc.select("table.score").select("tr"); diff --git a/src/main/java/xyz/thastertyn/Window/Content/JecnaContent.java b/src/main/java/xyz/thastertyn/Window/Content/JecnaContent.java index 2967d90..7994830 100644 --- a/src/main/java/xyz/thastertyn/Window/Content/JecnaContent.java +++ b/src/main/java/xyz/thastertyn/Window/Content/JecnaContent.java @@ -26,4 +26,14 @@ public class JecnaContent { { return ""; } + + public void specify(int y, int hy) + { + + } + + public void getOptions() + { + + } } diff --git a/src/main/java/xyz/thastertyn/Window/Content/Rozvrh.java b/src/main/java/xyz/thastertyn/Window/Content/Rozvrh.java index a023c73..d530078 100644 --- a/src/main/java/xyz/thastertyn/Window/Content/Rozvrh.java +++ b/src/main/java/xyz/thastertyn/Window/Content/Rozvrh.java @@ -18,7 +18,7 @@ public class Rozvrh extends JecnaContent { private String[] labels = {"Den", "7:30-8:15", "8:25-9:10", "9:20-10:05", "10:20-11:05", "11:15-12:00", "12:10-12:55", "13:05-13:50", "14:00-14:45", "14:55-15:40", "15:50-16:35"}; //private String[] labels = {"Den", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10."}; - String[] days = {"PO", "UT", "ST", "CT", "PA"}; + String[] daysLabels = {"PO", "UT", "ST", "CT", "PA"}; Table t = new Table<>(labels); @@ -28,16 +28,19 @@ public class Rozvrh extends JecnaContent { try{ rozvrh.downloadRozvrh(Jsessionid); - String[][] r = rozvrh.getRozvrh(); + String[][] rozvrhArray = rozvrh.getRozvrh(); - String[] s = new String[labels.length]; + String[] den = new String[11]; - for(int i = 0; i < r.length; i++) + for(int i = 0; i < rozvrhArray.length; i++) { - s[0] = days[i]; - for(int j = 1; j < r[i].length; j++) { s[j] = r[i][j]; } + den[0] = daysLabels[i]; + for(int j = 1; j < rozvrhArray[i].length + 1; j++) + { + den[j] = (rozvrhArray[i][j - 1].isBlank()) ? " - " : rozvrhArray[i][j - 1]; + } - t.getTableModel().addRow(s); + t.getTableModel().addRow(den); } rozvrhPanel.addComponent(t); hasStarted = true; diff --git a/src/main/java/xyz/thastertyn/Window/Content/Znamky.java b/src/main/java/xyz/thastertyn/Window/Content/Znamky.java index b12beec..9c8ee5c 100644 --- a/src/main/java/xyz/thastertyn/Window/Content/Znamky.java +++ b/src/main/java/xyz/thastertyn/Window/Content/Znamky.java @@ -3,6 +3,7 @@ package xyz.thastertyn.Window.Content; import java.io.IOException; import java.util.ArrayList; +import com.googlecode.lanterna.SGR; import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.graphics.SimpleTheme; import com.googlecode.lanterna.gui2.Direction; @@ -53,20 +54,21 @@ public class Znamky extends JecnaContent { znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.WHITE, TextColor.ANSI.BLACK)); break; case 1: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.GREEN)); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(85,212,0))); break; case 2: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.BLUE)); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(196,224,80))); break; case 3: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.YELLOW)); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,213,42))); break; case 4: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.MAGENTA)); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,102,0))); break; case 5: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.RED)); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); break; + // Todo try set sgr } znamkyZPredmetu.addComponent(znamkaLabel); @@ -76,25 +78,25 @@ public class Znamky extends JecnaContent { double prumer = predmet.getValue1().getValue1(); - Label vysl = new Label("" + prumer); + Label vysl = new Label(String.format("%.2f", prumer)); if(prumer >= 1 && prumer < 1.5) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.GREEN)); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(85,212,0))); }else if(prumer >= 1.5 && prumer < 2.5) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.BLUE)); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(196,224,80))); }else if(prumer >= 2.5 && prumer < 3.5) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.YELLOW)); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,213,42))); }else if(prumer >= 3.5 && prumer < 4.5) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.MAGENTA)); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,102,0))); }else if(prumer >= 4.5) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.RED)); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); } vyslPanel.addComponent(vysl); diff --git a/src/main/java/xyz/thastertyn/Window/MainWindow.java b/src/main/java/xyz/thastertyn/Window/MainWindow.java index 0762c38..25347be 100644 --- a/src/main/java/xyz/thastertyn/Window/MainWindow.java +++ b/src/main/java/xyz/thastertyn/Window/MainWindow.java @@ -2,9 +2,9 @@ package xyz.thastertyn.Window; import java.io.IOException; import java.util.Arrays; + import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.gui2.BasicWindow; -import com.googlecode.lanterna.gui2.Border; import com.googlecode.lanterna.gui2.Borders; import com.googlecode.lanterna.gui2.DefaultWindowManager; import com.googlecode.lanterna.gui2.Direction; @@ -13,7 +13,6 @@ import com.googlecode.lanterna.gui2.Label; import com.googlecode.lanterna.gui2.LinearLayout; import com.googlecode.lanterna.gui2.MultiWindowTextGUI; import com.googlecode.lanterna.gui2.Panel; -import com.googlecode.lanterna.gui2.Separator; import com.googlecode.lanterna.gui2.Window; import com.googlecode.lanterna.screen.Screen; import com.googlecode.lanterna.screen.TerminalScreen; @@ -52,17 +51,22 @@ public class MainWindow { window.setComponent(mainPanel); - mainPanel.addComponent(new Separator(Direction.VERTICAL).setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill))); + Panel tabs = new Panel() + .setLayoutManager(new LinearLayout(Direction.HORIZONTAL)) + .addComponent(new Label("Rozvrh").withBorder(Borders.singleLine())) + .addComponent(new Label("Znamky").withBorder(Borders.singleLine())); + + mainPanel.addComponent(tabs); - String text = "Jecnak"; + String title = "Jecnak"; Panel content = new Panel(); - mainPanel.addComponent(content.withBorder(Borders.singleLine(text))); + mainPanel.addComponent(content.withBorder(Borders.singleLine(title))); Login login = new Login(); login.showDialog(textGUI); - window.addWindowListener(new WindowSwitchListener(content, login.getJessionId(), text)); + window.addWindowListener(new WindowSwitchListener(content, login.getJessionId(), tabs, title)); textGUI.addWindowAndWait(window); diff --git a/src/main/java/xyz/thastertyn/Window/WindowSwitchListener.java b/src/main/java/xyz/thastertyn/Window/WindowSwitchListener.java index fe82502..8b618a4 100644 --- a/src/main/java/xyz/thastertyn/Window/WindowSwitchListener.java +++ b/src/main/java/xyz/thastertyn/Window/WindowSwitchListener.java @@ -23,25 +23,28 @@ public class WindowSwitchListener implements WindowListener { private String JsessionId; - Panel panel; - String label; + Panel content; + Panel tabs; + + String title; int current = 0; - public WindowSwitchListener(Panel holder, String JsessionId, String label) + public WindowSwitchListener(Panel holder, String JsessionId, Panel tabs, String title) { - panel = holder; + this.content = holder; + this.tabs = tabs; + this.title = title; this.JsessionId = JsessionId; - this.label = label; defaultPanel(); } private void defaultPanel() { contents[0].download(JsessionId); - panel.removeAllComponents(); - panel.addComponent(contents[0].getPanel()); - label = contents[0].getLabel(); + content.removeAllComponents(); + content.addComponent(contents[0].getPanel()); + title = contents[0].getLabel(); } public void next() @@ -58,10 +61,10 @@ public class WindowSwitchListener implements WindowListener { contents[current].download(JsessionId); } - panel.removeAllComponents(); - panel.addComponent(contents[current].getPanel()); + content.removeAllComponents(); + content.addComponent(contents[current].getPanel()); - label = contents[current].getLabel(); + title = contents[current].getLabel(); } public void previous() @@ -77,10 +80,10 @@ public class WindowSwitchListener implements WindowListener { { contents[current].download(JsessionId); } - panel.removeAllComponents(); - panel.addComponent(contents[current].getPanel()); + content.removeAllComponents(); + content.addComponent(contents[current].getPanel()); - label = contents[current].getLabel(); + title = contents[current].getLabel(); } diff --git a/target/classes/xyz/thastertyn/Jecna/Rozvrh.class b/target/classes/xyz/thastertyn/Jecna/Rozvrh.class index a2940fd..2baaecf 100644 Binary files a/target/classes/xyz/thastertyn/Jecna/Rozvrh.class and b/target/classes/xyz/thastertyn/Jecna/Rozvrh.class differ diff --git a/target/classes/xyz/thastertyn/Jecna/Znamky.class b/target/classes/xyz/thastertyn/Jecna/Znamky.class index 0f1f0a0..9dc5e09 100644 Binary files a/target/classes/xyz/thastertyn/Jecna/Znamky.class and b/target/classes/xyz/thastertyn/Jecna/Znamky.class differ diff --git a/target/classes/xyz/thastertyn/Window/Content/JecnaContent.class b/target/classes/xyz/thastertyn/Window/Content/JecnaContent.class index 4a1dc85..0bf3b83 100644 Binary files a/target/classes/xyz/thastertyn/Window/Content/JecnaContent.class and b/target/classes/xyz/thastertyn/Window/Content/JecnaContent.class differ diff --git a/target/classes/xyz/thastertyn/Window/Content/Rozvrh.class b/target/classes/xyz/thastertyn/Window/Content/Rozvrh.class index acffc40..a60150f 100644 Binary files a/target/classes/xyz/thastertyn/Window/Content/Rozvrh.class and b/target/classes/xyz/thastertyn/Window/Content/Rozvrh.class differ diff --git a/target/classes/xyz/thastertyn/Window/Content/Znamky.class b/target/classes/xyz/thastertyn/Window/Content/Znamky.class index 7b537cd..1a537bb 100644 Binary files a/target/classes/xyz/thastertyn/Window/Content/Znamky.class and b/target/classes/xyz/thastertyn/Window/Content/Znamky.class differ diff --git a/target/classes/xyz/thastertyn/Window/MainWindow.class b/target/classes/xyz/thastertyn/Window/MainWindow.class index d0461ea..87414dc 100644 Binary files a/target/classes/xyz/thastertyn/Window/MainWindow.class and b/target/classes/xyz/thastertyn/Window/MainWindow.class differ diff --git a/target/classes/xyz/thastertyn/Window/WindowSwitchListener.class b/target/classes/xyz/thastertyn/Window/WindowSwitchListener.class index 2c554e9..c739a70 100644 Binary files a/target/classes/xyz/thastertyn/Window/WindowSwitchListener.class and b/target/classes/xyz/thastertyn/Window/WindowSwitchListener.class differ