diff --git a/0.json b/0.json new file mode 100644 index 0000000..20420fb --- /dev/null +++ b/0.json @@ -0,0 +1,50 @@ +[ + { + "name": "周日课程01", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周日课程02", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周日课程03", + "index": 3, + "timeStart": "10:20:00", + "timeEnd": "11:05:00" + }, + { + "name": "周日课程04", + "index": 4, + "timeStart": "11:15:00", + "timeEnd": "12:00:00" + }, + { + "name": "周日课程05", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周日课程06", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周日课程07", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周日课程08", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/1.json b/1.json new file mode 100644 index 0000000..75042c8 --- /dev/null +++ b/1.json @@ -0,0 +1,50 @@ +[ + { + "name": "周一课程1", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周一课程2", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周一课程3", + "index": 3, + "timeStart": "10:30:00", + "timeEnd": "11:15:00" + }, + { + "name": "周一课程4", + "index": 4, + "timeStart": "11:25:00", + "timeEnd": "12:10:00" + }, + { + "name": "周一课程5", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周一课程6", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周一课程7", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周一课程8", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/2.json b/2.json new file mode 100644 index 0000000..6c1a971 --- /dev/null +++ b/2.json @@ -0,0 +1,50 @@ +[ + { + "name": "周二课程1", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周二课程2", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周二课程3", + "index": 3, + "timeStart": "10:30:00", + "timeEnd": "11:15:00" + }, + { + "name": "周二课程4", + "index": 4, + "timeStart": "11:25:00", + "timeEnd": "12:10:00" + }, + { + "name": "周二课程5", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周二课程6", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周二课程7", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周二课程8", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/3.json b/3.json new file mode 100644 index 0000000..7628370 --- /dev/null +++ b/3.json @@ -0,0 +1,50 @@ +[ + { + "name": "周三课程1", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周三课程2", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周三课程3", + "index": 3, + "timeStart": "10:30:00", + "timeEnd": "11:15:00" + }, + { + "name": "周三课程4", + "index": 4, + "timeStart": "11:25:00", + "timeEnd": "12:10:00" + }, + { + "name": "周三课程5", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周三课程6", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周三课程7", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周三课程8", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/4.json b/4.json new file mode 100644 index 0000000..6dfe43c --- /dev/null +++ b/4.json @@ -0,0 +1,50 @@ +[ + { + "name": "周四课程1", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周四课程2", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周四课程3", + "index": 3, + "timeStart": "10:30:00", + "timeEnd": "11:15:00" + }, + { + "name": "周四课程4", + "index": 4, + "timeStart": "11:25:00", + "timeEnd": "12:10:00" + }, + { + "name": "周四课程5", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周四课程6", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周四课程7", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周四课程8", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/5.json b/5.json new file mode 100644 index 0000000..b2be9ad --- /dev/null +++ b/5.json @@ -0,0 +1,50 @@ +[ + { + "name": "周五课程1", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周五课程2", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周五课程3", + "index": 3, + "timeStart": "10:30:00", + "timeEnd": "11:15:00" + }, + { + "name": "周五课程4", + "index": 4, + "timeStart": "11:25:00", + "timeEnd": "12:10:00" + }, + { + "name": "周五课程5", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周五课程6", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周五课程7", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周五课程8", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/6.json b/6.json new file mode 100644 index 0000000..0688d21 --- /dev/null +++ b/6.json @@ -0,0 +1,50 @@ +[ + { + "name": "周六课程01", + "index": 1, + "timeStart": "8:00:00", + "timeEnd": "8:45:00" + }, + { + "name": "周六课程02", + "index": 2, + "timeStart": "8:55:00", + "timeEnd": "9:40:00" + }, + { + "name": "周六课程03", + "index": 3, + "timeStart": "10:20:00", + "timeEnd": "11:05:00" + }, + { + "name": "周六课程04", + "index": 4, + "timeStart": "11:15:00", + "timeEnd": "12:00:00" + }, + { + "name": "周六课程05", + "index": 5, + "timeStart": "13:30:00", + "timeEnd": "14:15:00" + }, + { + "name": "周六课程06", + "index": 6, + "timeStart": "14:25:00", + "timeEnd": "15:10:00" + }, + { + "name": "周六课程07", + "index": 7, + "timeStart": "15:30:00", + "timeEnd": "16:15:00" + }, + { + "name": "周六课程08", + "index": 8, + "timeStart": "16:30:00", + "timeEnd": "17:30:00" + } +] \ No newline at end of file diff --git a/about.png b/about.png new file mode 100644 index 0000000..52bf148 Binary files /dev/null and b/about.png differ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..5bdad2f --- /dev/null +++ b/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java' +} + +group 'com.wudji' +version '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + implementation group: 'com.alibaba', name: 'fastjson', version: '2.0.9' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/notice/0.json b/notice/0.json new file mode 100644 index 0000000..1268d95 --- /dev/null +++ b/notice/0.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周日值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/1.json b/notice/1.json new file mode 100644 index 0000000..976c7bb --- /dev/null +++ b/notice/1.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周一值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/2.json b/notice/2.json new file mode 100644 index 0000000..0de7575 --- /dev/null +++ b/notice/2.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周二值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/3.json b/notice/3.json new file mode 100644 index 0000000..775523d --- /dev/null +++ b/notice/3.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周三值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/4.json b/notice/4.json new file mode 100644 index 0000000..49af7e5 --- /dev/null +++ b/notice/4.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周四值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/5.json b/notice/5.json new file mode 100644 index 0000000..18fc09e --- /dev/null +++ b/notice/5.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周五值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/notice/6.json b/notice/6.json new file mode 100644 index 0000000..3df133b --- /dev/null +++ b/notice/6.json @@ -0,0 +1,43 @@ +[ + { + "messageInfo" : "终古闲情归落照", + "index": 0 + }, + { + "messageInfo" : "一春幽梦逐游丝", + "index": 1 + }, + { + "messageInfo" : "0123456789", + "index": 2 + }, + { + "messageInfo" : "Bold font style", + "textStyle": "bold", + "index": 3 + }, + { + "messageInfo" : "Italic font style", + "textStyle": "italic", + "index": 4 + }, + { + "messageInfo" : "Custom Color", + "colorR" : "43", + "colorG" : "162", + "colorB" : "69", + "index": 5 + }, + { + "messageInfo" : "周六值日表:", + "index": 6 + }, + { + "messageInfo" : "张三", + "index": 7 + }, + { + "messageInfo" : "🆗 <- emoji test", + "index": 8 + } +] \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..6ea518b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'LList' + diff --git a/src/main/java/com/wudji/ClockButtonManager.java b/src/main/java/com/wudji/ClockButtonManager.java new file mode 100644 index 0000000..4f6ab4f --- /dev/null +++ b/src/main/java/com/wudji/ClockButtonManager.java @@ -0,0 +1,61 @@ +package com.wudji; + +import com.wudji.Screens.AboutScreen; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Calendar; +import java.util.Date; + +public class ClockButtonManager { + static String[] weeks = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; + + static SimpleDateFormat formatter= new SimpleDateFormat("HH:mm:ss"); + + public static JButton getTimeButton(){ + JButton j = new JButton(" 时间:" + formatter.format(new Date(System.currentTimeMillis())) +" "); + j.setFont(new Font(null, Font.BOLD,MainActivity.globalConfig.getClockFontsize())); + j.setBackground(MainActivity.globalConfig.getWindowBgColor()); + j.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + AboutScreen s = new AboutScreen(); + s.setVisible(true); + } + }); + return j; + } + public static JButton getWeekButton(int week){ + JButton j = new JButton(weeks[week - 1]); + j.setFont(new Font(null, Font.BOLD,MainActivity.globalConfig.getClockFontsize())); + j.setBackground(MainActivity.globalConfig.getWindowBgColor()); + return j; + + } + + public static JButton getCountdownButton(){ + Date d = Calendar.getInstance().getTime(); + LocalDateTime dateStart = LocalDateTime.of(MainActivity.globalConfig.getCountDownYear(), MainActivity.globalConfig.getCountDownMonth() - 1 , MainActivity.globalConfig.getCountDownDate(),8,1); + LocalDateTime dateEnd = LocalDateTime.of(d.getYear() + 1900, d.getMonth(), d.getDate(), 8, 1); + + Duration duration = Duration.between(dateStart, dateEnd); + + int day = Math.abs((int)duration.toDays()); + JButton j = new JButton(String.valueOf(day) + " 天"); + j.setFont(new Font(null, Font.BOLD,MainActivity.globalConfig.getClockFontsize() - 1)); + j.setBackground(MainActivity.globalConfig.getWindowBgColor()); + return j; + } + + public static JButton getCountDownInfoButton(){ + JButton j = new JButton(MainActivity.globalConfig.getCountDownInfo()); + j.setFont(new Font(null, Font.BOLD,MainActivity.globalConfig.getClockFontsize() - 1)); + j.setBackground(MainActivity.globalConfig.getWindowBgColor()); + return j; + } +} diff --git a/src/main/java/com/wudji/Lesson.java b/src/main/java/com/wudji/Lesson.java new file mode 100644 index 0000000..ba8fdf6 --- /dev/null +++ b/src/main/java/com/wudji/Lesson.java @@ -0,0 +1,55 @@ +package com.wudji; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class Lesson { + // public String week; + private String name = "Innovation in China 中国智造,慧及全球 0123456789"; + private int index; + + private String timeStart; + private String timeEnd; + + public String getName() { + return name; + } + + public int getIndex() { + return index; + } + + public long getTimeStart() throws ParseException { + return stringToMillis(timeStart); + } + + public long getTimeEnd() throws ParseException { + return stringToMillis(timeEnd); + } + + public void setName(String name) { + this.name = name; + } + + public void setIndex(int index) { + this.index = index; + } + + public void setTimeStart(String timeStart) { + this.timeStart = timeStart; + } + + public void setTimeEnd(String timeEnd) { + this.timeEnd = timeEnd; + } + + private long stringToMillis(String timeString) throws ParseException { + Calendar c = Calendar.getInstance(); + SimpleDateFormat tf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat cf = new SimpleDateFormat("yyyy-MM-dd"); + c.setTime(tf.parse(cf.format(new Date(System.currentTimeMillis())) + " " + timeString)); + return c.getTimeInMillis(); + } +} diff --git a/src/main/java/com/wudji/MainActivity.java b/src/main/java/com/wudji/MainActivity.java new file mode 100644 index 0000000..99fa30c --- /dev/null +++ b/src/main/java/com/wudji/MainActivity.java @@ -0,0 +1,60 @@ +package com.wudji; + +import java.awt.*; +import java.text.ParseException; +import java.util.*; +import java.util.Timer; + +import com.wudji.Screens.MainWindow; +import com.wudji.Screens.NoticeScreen; +import com.wudji.Screens.WelcomeScreen; +import com.wudji.Utils.FileControl; + + +public class MainActivity { + public static WindowConfig globalConfig = FileControl.getWindowConfig(); + public static Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + public static String version = "v1.1.2"; + + public static void main(String args[]){ + MainWindow window = new MainWindow((int)d.getWidth() - globalConfig.getPosx(),globalConfig.getPosy(),globalConfig.getWeight(),(int)d.getHeight() - globalConfig.getHeight()); + WelcomeScreen welcomeScreen = new WelcomeScreen(); + NoticeScreen noticeScreen = new NoticeScreen(window.getLocation()); + Timer timer = new Timer(); + + // 欢迎界面 + timer.schedule(new TimerTask() { + @Override + public void run() { + showDelayScreen(welcomeScreen, noticeScreen); + } + + private void showDelayScreen(WelcomeScreen welcomeScreen,NoticeScreen noticeScreen){ + // 隐藏欢迎页面 + welcomeScreen.setVisible(false); + if(MainActivity.globalConfig.isEnableNotice()){ + // 显示公告框 + noticeScreen.setVisible(true); + } + } + },4000); + + welcomeScreen.setVisible(true); + + // 主循环 + timer.schedule(new TimerTask() { + @Override + public void run() { + try { + updateA(window); + } catch (ParseException e) { + e.printStackTrace(); + } + } + + private void updateA(MainWindow w) throws ParseException { + w.update(); + } + },1,1000); + } +} \ No newline at end of file diff --git a/src/main/java/com/wudji/NoticeLine.java b/src/main/java/com/wudji/NoticeLine.java new file mode 100644 index 0000000..8bc5a7a --- /dev/null +++ b/src/main/java/com/wudji/NoticeLine.java @@ -0,0 +1,46 @@ +package com.wudji; + +import java.awt.*; + +public class NoticeLine { + String messageInfo = "Innovation in China 中国智造,慧及全球 0123456789"; + String textStyle = "default"; + + int colorR = 0; + int colorG = 0; + int colorB = 0; + + int index; + + public String getMessageInfo() { + return messageInfo; + } + + public void setMessageInfo(String messageInfo) { + this.messageInfo = messageInfo; + } + + public String getTextStyle() { + return textStyle; + } + + public void setTextStyle(String textStyle) { + this.textStyle = textStyle; + } + + public void setColorR(int colorR) { + this.colorR = colorR; + } + + public void setColorG(int colorG) { + this.colorG = colorG; + } + + public void setColorB(int colorB) { + this.colorB = colorB; + } + + public Color getFontColor(){ + return new Color(colorR,colorG,colorB); + } +} diff --git a/src/main/java/com/wudji/Screens/AboutScreen.java b/src/main/java/com/wudji/Screens/AboutScreen.java new file mode 100644 index 0000000..22fd62a --- /dev/null +++ b/src/main/java/com/wudji/Screens/AboutScreen.java @@ -0,0 +1,72 @@ +package com.wudji.Screens; + +import com.wudji.MainActivity; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URI; + +public class AboutScreen extends JDialog { + JPanel infoPanel = new JPanel(); + public AboutScreen() { + super((Frame) null, "", true); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + ImageIcon icon = new ImageIcon("about.png"); + JLabel label = new JLabel(icon); + + this.setSize(icon.getIconWidth(), icon.getIconHeight() + 200); + + infoPanel.add(label, BorderLayout.CENTER); + + this.setLocationRelativeTo(null); + infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS)); + + // 我在写什么¿ + JLabel label1 = new JLabel("电子课表" + MainActivity.version + "by Wudji(吾爱破解@YooooooDaLi)"); + label1.setFont(new Font(null,0,25)); + + + JLabel label2 = new JLabel("本软件由Wudji@tjyz利用课余时间开发,感谢使用~"); + label2.setFont(new Font(null,0,25)); + + JLabel linkLabelGithub = new JLabel("开源地址:https://github.com/Wudji/Desktop-Lesson-List/,欢迎提issue(和star)"); + linkLabelGithub.setForeground(new Color(40, 112, 215)); + linkLabelGithub.setFont(new Font(null,0,25)); + linkLabelGithub.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI("https://github.com/Wudji/Desktop-Lesson-List/")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + JLabel linkLable52pojie = new JLabel("吾爱破解:https://www.52pojie.cn/thread-1780607-1-1.html"); + linkLable52pojie.setForeground(new Color(40, 112, 215)); + linkLable52pojie.setFont(new Font(null,0,25)); + linkLable52pojie.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI("https://www.52pojie.cn/thread-1780607-1-1.html")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + infoPanel.add(label1); + infoPanel.add(label2); + infoPanel.add(linkLabelGithub); + infoPanel.add(linkLable52pojie); + + this.add(infoPanel); + this.setTitle("电子课表" + MainActivity.version + "by Wudji(吾爱破解@YooooooDaLi)"); + + } +} diff --git a/src/main/java/com/wudji/Screens/LessonConfigScreen.java b/src/main/java/com/wudji/Screens/LessonConfigScreen.java new file mode 100644 index 0000000..bd7cd92 --- /dev/null +++ b/src/main/java/com/wudji/Screens/LessonConfigScreen.java @@ -0,0 +1,5 @@ +package com.wudji.Screens; + +public class LessonConfigScreen { + /* todo 配置页面 */ +} diff --git a/src/main/java/com/wudji/Screens/MainConfigScreen.java b/src/main/java/com/wudji/Screens/MainConfigScreen.java new file mode 100644 index 0000000..5651a38 --- /dev/null +++ b/src/main/java/com/wudji/Screens/MainConfigScreen.java @@ -0,0 +1,5 @@ +package com.wudji.Screens; + +public class MainConfigScreen { + /* todo 配置页面 */ +} diff --git a/src/main/java/com/wudji/Screens/MainWindow.java b/src/main/java/com/wudji/Screens/MainWindow.java new file mode 100644 index 0000000..6deeb84 --- /dev/null +++ b/src/main/java/com/wudji/Screens/MainWindow.java @@ -0,0 +1,106 @@ +package com.wudji.Screens; + + +import com.wudji.ClockButtonManager; +import com.wudji.Lesson; +import com.wudji.MainActivity; +import com.wudji.Utils.FileControl; + +import javax.swing.*; +import java.awt.*; +import java.text.ParseException; +import java.util.Calendar; + +public class MainWindow extends JDialog { + + Calendar c = Calendar.getInstance(); + int week = c.get(Calendar.DAY_OF_WEEK); + + // clock + WPanel clockPanel = new WPanel(2,28); + + // lessonPanel + WPanel lessonPanel = new WPanel(16,28); + + WPanel countDownPanel = new WPanel(2,28); + + Lesson[] lessonList = FileControl.getLessonListFromJSON(week - 1); + + JButton separateLine = new JButton("============"); + public MainWindow(int x,int y,int w,int h) throws HeadlessException { + + this.setUndecorated(true); + this.setVisible(true); + this.setName("MainScreen"); + this.setTitle("MainScreen"); + this.setBackground(new Color(0,0,0,0)); + + this.setDefaultCloseOperation(this.HIDE_ON_CLOSE); + this.setBounds(x,y,w,h); + + // this.setBounds(150,150,150,150); + this.setLayout(new FlowLayout(FlowLayout.CENTER)); + + this.separateLine.setFont(new Font(null, Font.BOLD, MainActivity.globalConfig.getLessonFontSize())); + this.separateLine.setBackground(MainActivity.globalConfig.getWindowBgColor());// config + + this.add(clockPanel); + if (MainActivity.globalConfig.isEnableCountDown()) {this.add(countDownPanel);} + this.add(lessonPanel); + + } + public void update() throws ParseException { + this.updateLessonStatus(); + this.updateClockStatus(); + if (MainActivity.globalConfig.isEnableCountDown()) {this.updateCountdownStatus();} + this.validate(); + this.repaint(); + + // System.out.println("step 5 passed"); + } + + private void updateLessonStatus() throws ParseException { + + lessonPanel.removeAll(); + + for(int i = 0;i < lessonList.length;i++){ + + long sysMillis = System.currentTimeMillis(); + + JButton lessonButt = new JButton(lessonList[i].getIndex() + "." + lessonList[i].getName()); + + lessonButt.setFont(new Font(null, Font.BOLD,MainActivity.globalConfig.getLessonFontSize())); + lessonButt.setBackground(MainActivity.globalConfig.getWindowBgColor()); + + if (lessonList[i].getTimeEnd() < sysMillis){ + lessonButt.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0,17,0,0,MainActivity.globalConfig.getPastLessonColor()/*new Color(148, 248, 125)*/),BorderFactory.createEmptyBorder(5,17,5,17))); + }else if(lessonList[i].getTimeStart() > sysMillis){ + lessonButt.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0,17,0,0,MainActivity.globalConfig.getNextLessonColor()/*new Color(255, 88, 79)*/),BorderFactory.createEmptyBorder(5,17,5,17))); + }else if(lessonList[i].getTimeStart() < sysMillis && lessonList[i].getTimeEnd() > sysMillis){ + lessonButt.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0,17,0,0,MainActivity.globalConfig.getPresentLessonColor()/*new Color(234, 170, 99)*/),BorderFactory.createEmptyBorder(5,17,5,17))); + } + + lessonPanel.add(lessonButt); + lessonPanel.add(this.getSeparateLine()); + } + } + + private void updateClockStatus(){ + clockPanel.removeAll(); + clockPanel.add(ClockButtonManager.getTimeButton()); + clockPanel.add(ClockButtonManager.getWeekButton(week)); + } + + private void updateCountdownStatus(){ + countDownPanel.removeAll(); + countDownPanel.add(ClockButtonManager.getCountDownInfoButton()); + countDownPanel.add(ClockButtonManager.getCountdownButton()); + } + + private JButton getSeparateLine(){ + JButton j = new JButton("============"); + j.setFont(new Font(null, Font.BOLD, MainActivity.globalConfig.getLessonFontSize())); + j.setBackground(MainActivity.globalConfig.getWindowBgColor()); + return j; + } +} \ No newline at end of file diff --git a/src/main/java/com/wudji/Screens/NoticeScreen.java b/src/main/java/com/wudji/Screens/NoticeScreen.java new file mode 100644 index 0000000..21100c6 --- /dev/null +++ b/src/main/java/com/wudji/Screens/NoticeScreen.java @@ -0,0 +1,55 @@ +package com.wudji.Screens; + +import com.wudji.MainActivity; +import com.wudji.NoticeLine; +import com.wudji.Utils.FileControl; + +import javax.swing.*; +import java.awt.*; +import java.util.Calendar; + +public class NoticeScreen extends JDialog { + Calendar c = Calendar.getInstance(); + int week = c.get(7); + + JPanel panel = new JPanel(); + public NoticeScreen(Point mainWindowLocation) { + + this.setTitle("Notice Screen"); + + this.setUndecorated(true); + + this.setSize(MainActivity.globalConfig.getNoticeWeight(), MainActivity.globalConfig.getNoticeHeight()); + + this.setLocationRelativeTo(null); + + this.setLocation(mainWindowLocation.x - this.getWidth(), mainWindowLocation.y); + + this.setUndecorated(true); + + this.setVisible(false); + + this.updateNoticeList(FileControl.getNoticeLinesFromJSON(week - 1)); + } + + private void updateNoticeList(NoticeLine[] lines){ + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + for (NoticeLine line : lines) { + JLabel label = new JLabel(line.getMessageInfo()); + switch (line.getTextStyle()){ + case "bold": + label.setFont(new Font(null, Font.BOLD, MainActivity.globalConfig.getNoticeFontSize())); + break; + case "italic": + label.setFont(new Font(null, Font.ITALIC, MainActivity.globalConfig.getNoticeFontSize())); + break; + case "default": + default: + label.setFont(new Font(null, Font.PLAIN, MainActivity.globalConfig.getNoticeFontSize())); + } + label.setForeground(line.getFontColor()); + panel.add(label); + } + this.add(panel); + } +} diff --git a/src/main/java/com/wudji/Screens/WPanel.java b/src/main/java/com/wudji/Screens/WPanel.java new file mode 100644 index 0000000..45a6bab --- /dev/null +++ b/src/main/java/com/wudji/Screens/WPanel.java @@ -0,0 +1,15 @@ +package com.wudji.Screens; + +import javax.swing.*; +import java.awt.*; + +public class WPanel extends JPanel { + public WPanel(int lines,int fontSize){ + this.setFont(new Font(null, Font.BOLD,fontSize)); + this.setLayout(new GridLayout(lines,1)); + for(int i = 0;i