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

Commit

Permalink
complete the function or OrderedMode.java except review
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottCTD committed Oct 9, 2020
1 parent 4a05f14 commit 0298589
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 44 deletions.
6 changes: 5 additions & 1 deletion doc/OrderedMode/ReadyLabel.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<html>
<body>
<div align="center">
Press <font color="#dc143c">HERE</font> to get start!
<font color="#ff7f50">Vocabularies as Questions</font> means you need to type <font color="#dc143c">the meaning of a
vocabulary</font>.
<br>
<font color="#ff7f50">Meanings as Questions</font> means you need to type <font color="#dc143c">the corresponding
vocabulary of it's meaning</font>.
<br>
Note: You <font color="#dc143c">can</font> check the answer and review!
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/xyz/scottc/vd/VDList.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public String getName() {
return this.VDList.getName();
}

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

public String getType() {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class FunctionalFrame extends JFrame {
protected boolean init = false;
protected boolean suspend = false;

public FunctionalFrame(String title) throws HeadlessException {
super(title);
public FunctionalFrame() throws HeadlessException {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(VDConstantsUtils.getSreenRectangle());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ public class OrderedMode extends FunctionalFrame {
private final SpringLayout suspendPanelLayout = new SpringLayout();
private final UtilJLabel suspendLabel = new UtilJLabel(ENText.ORDERED_MODE_SUSPEND_TEXT, VDConstantsUtils.MICROSOFT_YAHEI_BOLD_60);

private final UtilJLabel readyLabel = new UtilJLabel(ENText.ORDERED_MODE_READY_TEXT, VDConstantsUtils.MICROSOFT_YAHEI_BOLD_60);
private final UtilJLabel readyLabel = new UtilJLabel(ENText.ORDERED_MODE_READY_TEXT, VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJButton VQButton = new UtilJButton("Vocabularies as Questions", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJButton MQButton = new UtilJButton("Meanings as Questions", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);

private final UtilJButton nextButton = new UtilJButton("Next", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJButton preButton = new UtilJButton("Previous", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJButton answerButton = new UtilJButton("Answer", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJButton reviewButton = new UtilJButton("Review", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);
private final UtilJLabel currentListLabel = new UtilJLabel("Current VD List: ", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);

private final UtilJButton suspendButton = new UtilJButton("Suspend", VDConstantsUtils.MICROSOFT_YAHEI_BOLD_30);

Expand All @@ -44,9 +47,9 @@ public class OrderedMode extends FunctionalFrame {
private boolean isAnswerShown;

public OrderedMode(VDList vdList) throws HeadlessException {
super("Ordered Mode");
this.vdList = vdList;

this.setTitle("Ordered Mode - " + this.vdList.getSimpleName());
this.currentListLabel.setText("Current VD List: " + this.vdList.getSimpleName());
this.rootPanelHandler();
this.layoutHandler();
}
Expand All @@ -55,6 +58,7 @@ public OrderedMode(VDList vdList) throws HeadlessException {
protected void rootPanelHandler() {
super.rootPanelHandler();

//root panel
super.rootPanel.add(this.nextButton);
this.nextButton.addActionListener(e -> this.next());

Expand All @@ -70,6 +74,10 @@ protected void rootPanelHandler() {
super.rootPanel.add(this.suspendButton);
this.suspendButton.addActionListener(e -> this.suspend());

super.rootPanel.add(this.currentListLabel);
this.currentListLabel.setBackground(this.rootPanel.getBackground());

//suspend panel
super.rootPanel.add(this.suspendPanel);
this.suspendPanel.setLayout(this.suspendPanelLayout);
this.suspendPanel.setBackGround(VDConstantsUtils.SELECTED_COLOR);
Expand All @@ -89,38 +97,20 @@ public void mouseClicked(MouseEvent e) {
this.suspendPanel.add(this.suspendLabel);
this.suspendLabel.setBackground(VDConstantsUtils.SELECTED_COLOR);

//ready panel
super.readyPanel.add(this.readyLabel);
this.readyLabel.setBackground(this.readyLabel.getParent().getBackground());
super.readyPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!init) {
int result = JOptionPane.showConfirmDialog(OrderedMode.this, ENText.VOCABULARYQ_OR_NOT,
VDConstantsUtils.QUESTION_TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
vocabularyQ = true;
} else if (result == JOptionPane.NO_OPTION) {
vocabularyQ = false;
vdList.interconvertQAList();
}

readyPanel.setVisible(false);
initPanel.setVisible(true);
super.readyPanel.add(this.VQButton);
this.VQButton.addActionListener(e -> this.init());

Q.setText(vdList.getQuestion());

timer.startFromZero();
amount.setTotalAmount(vdList.getQs().size());
amount.setCurrentAmount(vdList.getIndex() + 1);

I.grabFocus();

init = true;
}
}
super.readyPanel.add(this.MQButton);
this.MQButton.addActionListener(e -> {
this.vdList.interconvertQAList();
this.init();
});


//init panel
this.initPanel.add(this.QView);
this.Q.setLineWrap(true);
this.Q.setWrapStyleWord(true);
Expand All @@ -135,14 +125,12 @@ public void mouseClicked(MouseEvent e) {
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
UtilJLabel label = (UtilJLabel) e.getSource();
label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
if (label.equals(preLabel)) {
pre();
} else if (label.equals(nextLabel)) {
next();
}
UtilJLabel label = (UtilJLabel) e.getSource();
label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
if (label.equals(preLabel)) {
pre();
} else if (label.equals(nextLabel)) {
next();
}
}

Expand Down Expand Up @@ -177,6 +165,21 @@ public void mouseExited(MouseEvent e) {
this.lineHelper01.setVisible(true);
}

private void init() {
readyPanel.setVisible(false);
initPanel.setVisible(true);

Q.setText(vdList.getQuestion());

timer.startFromZero();
amount.setTotalAmount(vdList.getQs().size());
amount.setCurrentAmount(vdList.getIndex() + 1);

I.grabFocus();

init = true;
}

private void next() {
if (super.init && !super.suspend) {
//save
Expand Down Expand Up @@ -262,6 +265,7 @@ private void suspend() {
protected void layoutHandler() {
super.layoutHandler();

//root panel
super.layout.putConstraint(SpringLayout.EAST, this.nextButton, -MARGIN, SpringLayout.EAST, super.rootPanel);
super.layout.putConstraint(SpringLayout.NORTH, this.nextButton, MARGIN, SpringLayout.NORTH, super.rootPanel);

Expand All @@ -277,6 +281,9 @@ protected void layoutHandler() {
super.layout.putConstraint(SpringLayout.NORTH, this.suspendButton, 0, SpringLayout.NORTH, super.hideTimerButton);
super.layout.putConstraint(SpringLayout.EAST, this.suspendButton, -MARGIN, SpringLayout.WEST, super.hideTimerButton);

super.layout.putConstraint(SpringLayout.WEST, this.currentListLabel, MARGIN, SpringLayout.EAST, super.backButton);
super.layout.putConstraint(SpringLayout.NORTH, this.currentListLabel, MARGIN + 4, SpringLayout.NORTH, super.rootPanel);

super.layout.putConstraint(SpringLayout.NORTH, this.suspendPanel, 0, SpringLayout.SOUTH, super.separator02);
super.layout.putConstraint(SpringLayout.SOUTH, this.suspendPanel, 0, SpringLayout.SOUTH, super.rootPanel);
super.layout.putConstraint(SpringLayout.WEST, this.suspendPanel, 0, SpringLayout.WEST, super.rootPanel);
Expand All @@ -286,6 +293,12 @@ protected void layoutHandler() {
super.readyPanelLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, this.readyLabel, 0, SpringLayout.HORIZONTAL_CENTER, super.readyPanel);
super.readyPanelLayout.putConstraint(SpringLayout.VERTICAL_CENTER, this.readyLabel, 0, SpringLayout.VERTICAL_CENTER, super.readyPanel);

super.readyPanelLayout.putConstraint(SpringLayout.SOUTH, this.VQButton, -MARGIN, SpringLayout.NORTH, this.readyLabel);
super.readyPanelLayout.putConstraint(SpringLayout.EAST, this.VQButton, -MARGIN, SpringLayout.HORIZONTAL_CENTER, super.readyPanel);

super.readyPanelLayout.putConstraint(SpringLayout.NORTH, this.MQButton, 0, SpringLayout.NORTH, this.VQButton);
super.readyPanelLayout.putConstraint(SpringLayout.WEST, this.MQButton, MARGIN, SpringLayout.HORIZONTAL_CENTER, super.readyPanel);

//suspend panel
this.suspendPanelLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, this.suspendLabel, 0, SpringLayout.HORIZONTAL_CENTER, this.suspendPanel);
this.suspendPanelLayout.putConstraint(SpringLayout.VERTICAL_CENTER, this.suspendLabel, 0, SpringLayout.VERTICAL_CENTER, this.suspendPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ public ListTreeCellRenderer() {
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
String text = value.toString();
if (text.contains(".json")) {
this.setText(text.replace(".json", VDConstantsUtils.EMPTY));
}
return this;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/xyz/scottc/vd/utils/ENText.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class ENText {
public static final String ORDERED_MODE_READY_TEXT = "<html>\n" +
"<body>\n" +
"<div align=\"center\">\n" +
" Click <font color=\"#dc143c\">HERE</font> to get start!\n" +
" <font color=\"#ff7f50\">Vocabularies as Questions</font> means you need to type <font color=\"#dc143c\">the meaning of a vocabulary</font>.\n" +
" <br>\n" +
" <font color=\"#ff7f50\">Meanings as Questions</font> means you need to type <font color=\"#dc143c\">the corresponding vocabulary of it's meaning</font>.\n" +
" <br>\n" +
" Note: You <font color=\"#dc143c\">can</font> check the answer and review!\n" +
"</div>\n" +
Expand All @@ -38,7 +40,7 @@ public class ENText {
"</body>\n" +
"</html>";

public static final String VOCABULARYQ_OR_NOT = "Do you want vocabularies serve the function of questions?\n" +
public static final String VOCABULARY_OR_NOT = "Do you want vocabularies serve the function of questions?\n" +
"Yes for Vocabularies as questions.\n" +
"No for Meanings as questions.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"utter",
"outrage",
"betray",
"affilate",
"affiliate",
"batter",
"irritate",
"oversee",
Expand Down Expand Up @@ -86,7 +86,7 @@
"brutal",
"precedent",
"memoir",
"comtempt",
"contempt",
"mighty",
"glorious",
"heir",
Expand Down

0 comments on commit 0298589

Please sign in to comment.