Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
finished the review func and modified some details
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottCTD committed Oct 10, 2020
1 parent 0298589 commit 7158f6a
Show file tree
Hide file tree
Showing 34 changed files with 526 additions and 2,187 deletions.
Binary file modified layout/Layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions src/main/java/xyz/scottc/vd/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package xyz.scottc.vd;

import xyz.scottc.vd.exceptions.FileCreatingException;
import xyz.scottc.vd.frames.transitional.ListSelection;
import xyz.scottc.vd.frames.transitional.Entry;
import xyz.scottc.vd.utils.FileUtils;
import xyz.scottc.vd.utils.VDConstantsUtils;
import xyz.scottc.vd.utils.VDConstants;

import javax.swing.*;
import java.io.File;
Expand Down Expand Up @@ -52,8 +52,8 @@ private static void initFrame() {
IllegalAccessException e) {
e.printStackTrace();
}
//Entry frame = new Entry();
ListSelection frame = new ListSelection();
Entry frame = new Entry();
//ListSelection frame = new ListSelection();
//FunctionalFrame frame = new FunctionalFrame("Functional Frame");
//OrderedMode frame = new OrderedMode();
frame.setVisible(true);
Expand All @@ -63,19 +63,19 @@ private static void initDirectory() {
//Create the library files
File directory = FileUtils.getDirectoryFile(Main.class);
if (directory != null) {
File lib = new File(directory.getAbsolutePath() + "/" + VDConstantsUtils.LIBRARY_NAME);
File lib = new File(directory.getAbsolutePath() + "/" + VDConstants.LIBRARY_NAME);
if (!lib.exists()) {
if (!lib.mkdir()) throw new FileCreatingException("Fail to create" + VDConstantsUtils.LIBRARY_NAME);
if (!lib.mkdir()) throw new FileCreatingException("Fail to create" + VDConstants.LIBRARY_NAME);
}
File exLibrary = new File(lib.getAbsolutePath() + "/" + VDConstantsUtils.EXTERNAL_LIBRARY_NAME);
File exLibrary = new File(lib.getAbsolutePath() + "/" + VDConstants.EXTERNAL_LIBRARY_NAME);
if (!exLibrary.exists()) {
if (!exLibrary.mkdir())
throw new FileCreatingException("Failed to create " + VDConstantsUtils.EXTERNAL_LIBRARY_NAME);
throw new FileCreatingException("Failed to create " + VDConstants.EXTERNAL_LIBRARY_NAME);
}
File inLibrary = new File(lib.getAbsolutePath() + "/" + VDConstantsUtils.INTERNAL_LIBRARY_NAME);
File inLibrary = new File(lib.getAbsolutePath() + "/" + VDConstants.INTERNAL_LIBRARY_NAME);
if (!inLibrary.exists()) {
if (!inLibrary.mkdir())
throw new FileCreatingException("Failed to create " + VDConstantsUtils.INTERNAL_LIBRARY_NAME);
throw new FileCreatingException("Failed to create " + VDConstants.INTERNAL_LIBRARY_NAME);
}
library = lib;
internalLibrary = inLibrary;
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/xyz/scottc/vd/VocabularyState.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xyz.scottc.vd;
package xyz.scottc.vd.core;

import xyz.scottc.vd.utils.VDConstantsUtils;
import xyz.scottc.vd.utils.VDConstants;

import java.awt.*;
import java.util.Objects;
Expand All @@ -10,24 +10,19 @@ public class Input {
private String content;
private InputState state;

public static final Color CORRECT = new Color(0x00A74A);
public static final Color INCORRECT = new Color(0xFE4365);
public static final Color CORRECT_COLOR = new Color(0x00A74A);
public static final Color INCORRECT_COLOR = new Color(0xFE4365);

public Input(String content) {
if (content.equals(VDConstantsUtils.EMPTY)) {
if (content.equals(VDConstants.EMPTY)) {
this.content = content;
this.state = InputState.NOT_ANSWERED;
} else {
this.content = content;
this.state = InputState.ANSWERED;
this.state = InputState.UNSURE;
}
}

public Input(String content, InputState state) {
this.content = content;
this.state = state;
}

public String getContent() {
return content;
}
Expand Down Expand Up @@ -63,7 +58,7 @@ public int hashCode() {
}

public enum InputState {
CORRECT, INCORRECT, NOT_ANSWERED, ANSWERED;
CORRECT, INCORRECT, NOT_ANSWERED, UNSURE;

@Override
public String toString() {
Expand All @@ -72,7 +67,7 @@ public String toString() {
return "CORRECT";
case INCORRECT:
return "INCORRECT";
case ANSWERED:
case UNSURE:
return "ANSWERED";
case NOT_ANSWERED:
return "NOT ANSWERED";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.scottc.vd;
package xyz.scottc.vd.core;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package xyz.scottc.vd;
package xyz.scottc.vd.core;

import org.json.JSONObject;
import xyz.scottc.vd.Main;
import xyz.scottc.vd.utils.JSONUtils;
import xyz.scottc.vd.utils.VDConstantsUtils;
import xyz.scottc.vd.utils.VDConstants;
import xyz.scottc.vd.utils.VDUtils;

import java.io.File;
import java.nio.file.InvalidPathException;
Expand Down Expand Up @@ -65,10 +67,6 @@ public boolean pre() {
return false;
}

public void setInputContent(String input) {
this.Is.get(this.index).setContent(input);
}

public Input judgeEn() {
Input input = this.getInput();
if (input.toString().equals(this.getAnswer())) {
Expand All @@ -80,7 +78,7 @@ public Input judgeEn() {
}

public void interconvertQAList() {
VDConstantsUtils.interconvertList(this.Qs, this.As);
VDUtils.interconvertList(this.Qs, this.As);
}

/**
Expand All @@ -95,7 +93,7 @@ public boolean toQAList() {
List<Object> answers = jsonObject.getJSONArray("answers").toList();
for (Object question : questions) {
this.Qs.add(question.toString());
this.Is.add(new Input(VDConstantsUtils.EMPTY));
this.Is.add(new Input(VDConstants.EMPTY));
}
for (Object answer : answers) {
this.As.add(answer.toString());
Expand Down Expand Up @@ -130,7 +128,7 @@ public List<String> splitType() {
int start = 0;
while ((index = this.type.indexOf("\\", index)) != -1) {
String temp = this.type.substring(start, index);
list.add(temp.replace("\\", VDConstantsUtils.EMPTY));
list.add(temp.replace("\\", VDConstants.EMPTY));
start = index;
index++;
}
Expand All @@ -141,12 +139,16 @@ public int getIndex() {
return this.index;
}

public void setIndex(int index) {
this.index = index;
}

public String getName() {
return this.VDList.getName();
}

public String getSimpleName() {
return this.VDList.getName().replace(".json", VDConstantsUtils.EMPTY);
return this.VDList.getName().replace(".json", VDConstants.EMPTY);
}

public String getType() {
Expand Down Expand Up @@ -193,6 +195,10 @@ public void setInput(Input input) {
this.Is.set(this.index, input);
}

public void setInputContent(String input) {
this.Is.get(this.index).setContent(input);
}

public List<String> getQs() {
return this.Qs;
}
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/xyz/scottc/vd/frames/functional/FunctionalFrame.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package xyz.scottc.vd.frames.functional;

import xyz.scottc.vd.frames.transitional.ListSelection;
import xyz.scottc.vd.utils.VDConstantsUtils;
import xyz.scottc.vd.utils.VDConstants;
import xyz.scottc.vd.utils.VDUtils;
import xyz.scottc.vd.utils.components.*;

import javax.swing.*;
import java.awt.*;

public class FunctionalFrame extends JFrame {

protected static final int MARGIN = VDConstantsUtils.getSreenRectangle().width / 100;
protected static final int MARGIN = VDUtils.getScreenRectangle().width / 100;
protected static final int SUB_MARGIN = MARGIN / 10;

protected final UtilJPanel rootPanel = new UtilJPanel();
Expand All @@ -21,36 +22,37 @@ public class FunctionalFrame extends JFrame {
protected final UtilJPanel readyPanel = new UtilJPanel();
protected final SpringLayout readyPanelLayout = new SpringLayout();

protected final UtilJButton backButton = new UtilJButton("Back", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30, false);
protected final UtilJButton hideTimerButton = new UtilJButton("Hide Timer", VDConstantsUtils.MICROSOFT_YAHEI_PLAIN_20);
protected final UtilJButton backButton = new UtilJButton("Back", VDConstants.MICROSOFT_YAHEI_BOLD_30, false);
protected final UtilJButton hideTimerButton = new UtilJButton("Hide Timer", VDConstants.MICROSOFT_YAHEI_PLAIN_20);

protected final VDAmountDisplay amount = new VDAmountDisplay(VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));
protected final VDAmountDisplay amount = new VDAmountDisplay(VDConstants.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));
protected final VDTimer timer = new VDTimer();

protected final LineSeparator separator01 = new LineSeparator(LineSeparator.HORIZONTAL, VDConstantsUtils.getSreenRectangle().width);
protected final LineSeparator separator02 = new LineSeparator(LineSeparator.HORIZONTAL, VDConstantsUtils.getSreenRectangle().width);
protected final LineSeparator separator01 = new LineSeparator(LineSeparator.HORIZONTAL, VDUtils.getScreenRectangle().width);
protected final LineSeparator separator02 = new LineSeparator(LineSeparator.HORIZONTAL, VDUtils.getScreenRectangle().width);

protected boolean init = false;
protected boolean suspend = false;

public FunctionalFrame() throws HeadlessException {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(VDConstantsUtils.getSreenRectangle());
this.setBounds(VDUtils.getScreenRectangle());
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}

protected void rootPanelHandler() {
this.setContentPane(this.rootPanel);

this.rootPanel.add(this.backButton);
this.backButton.addActionListener(e -> VDConstantsUtils.switchFrame(this, new ListSelection()));
this.backButton.addActionListener(e -> VDUtils.switchFrame(this, new ListSelection()));

this.rootPanel.add(this.separator01);

this.rootPanel.add(this.timer);
this.timer.setFont(VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));
this.timer.setFont(VDConstants.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));

this.rootPanel.add(this.hideTimerButton);
this.hideTimerButton.setFont(VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));
this.hideTimerButton.setFont(VDConstants.MICROSOFT_YAHEI_BOLD_30.deriveFont(Font.PLAIN));
this.hideTimerButton.addActionListener(e -> {
String hide = "Hide Timer";
String display = "Display Timer";
Expand All @@ -69,7 +71,7 @@ protected void rootPanelHandler() {

this.rootPanel.add(this.readyPanel);
this.readyPanel.setLayout(this.readyPanelLayout);
this.readyPanel.setBackGround(VDConstantsUtils.SELECTED_COLOR);
this.readyPanel.setBackGround(VDConstants.SELECTED_COLOR);

this.rootPanel.add(this.initPanel);
this.initPanel.setLayout(initPanelLayout);
Expand Down
Loading

0 comments on commit 7158f6a

Please sign in to comment.