Skip to content

Commit 8625dec

Browse files
committed
Fixes..
* Error message, when error occures while savinng * Changed info dialog * Renamed range in clef from OptionsView (Border) * Adjust note line
1 parent 96dd028 commit 8625dec

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

src/com/burngindev/pnc/core/Config.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Config(final File configFile) {
6565
/**
6666
* Saves the settings into the configuration file.
6767
*/
68-
public void save() {
68+
public void save() throws IOException {
6969
this.properties.put("showUpperNotes", String.valueOf(showUpperNotes));
7070
this.properties.put("showLowerNotes", String.valueOf(showLowerNotes));
7171
this.properties.put("showLabels", String.valueOf(showLabels));
@@ -78,11 +78,7 @@ public void save() {
7878
this.properties.put("amountNotes", String.valueOf(amountNotes));
7979
this.properties.put("range", String.valueOf(range));
8080

81-
try {
82-
this.properties.store(new FileWriter(this.configFile), "ConfigFile of PianoNoteCoach");
83-
} catch (IOException e) {
84-
Logger.error(e, e.getMessage());
85-
}
81+
this.properties.store(new FileWriter(this.configFile), "ConfigFile of PianoNoteCoach");
8682
}
8783

8884
public Properties getProperties() {

src/com/burningdev/pnc/controller/OptionsController.java

+17-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.awt.event.ActionEvent;
77
import java.awt.event.ActionListener;
8+
import java.io.IOException;
89

910
import javax.swing.JButton;
1011
import javax.swing.JOptionPane;
@@ -69,10 +70,22 @@ public void actionPerformed(ActionEvent e) {
6970
this.config.setSecondFourthLineGray(this.optionsView.getCheckSecondFourthLineGray().isSelected());
7071
this.config.setDebugMidiInterface(this.optionsView.getCheckDebugMidi().isSelected());
7172
this.config.setBarLine(this.optionsView.getCheckBarline().isSelected());
72-
73-
this.config.save();
74-
75-
JOptionPane.showMessageDialog(null, "Options successfully saved.", "Options saved", JOptionPane.INFORMATION_MESSAGE);
73+
74+
boolean noError = true;
75+
76+
try {
77+
this.config.save();
78+
} catch (IOException e1) {
79+
JOptionPane.showMessageDialog(null, "Options not saved: " + e1.getMessage(), "Error occured",
80+
JOptionPane.ERROR_MESSAGE);
81+
Logger.error(e1, e1.getMessage());
82+
noError = false;
83+
}
84+
85+
if (noError) {
86+
JOptionPane.showMessageDialog(null, "Options successfully saved.", "Options saved",
87+
JOptionPane.INFORMATION_MESSAGE);
88+
}
7689
break;
7790
case "close":
7891
this.optionsView.getFrame().dispose();

src/com/burningdev/pnc/dialogs/InfoDialog.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class InfoDialog extends JDialog {
3535
private final JPanel contentPanel = new JPanel();
3636

3737
public InfoDialog() {
38+
setResizable(false);
3839
setIconImage(
3940
Toolkit.getDefaultToolkit().getImage(InfoDialog.class.getResource("/com/burningdev/pnc/res/Icon.png")));
4041
try {
@@ -53,7 +54,7 @@ public InfoDialog() {
5354

5455
JScrollPane scrollPane = new JScrollPane();
5556
scrollPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
56-
scrollPane.setBounds(10, 46, 414, 268);
57+
scrollPane.setBounds(10, 46, 424, 278);
5758
contentPanel.add(scrollPane);
5859

5960
JTextPane textPane = new JTextPane();
@@ -63,8 +64,8 @@ public InfoDialog() {
6364
textPane.setContentType("text/html");
6465
textPane.setText("<html>\r\n" + " <head>\r\n" + " <style>\r\n" + " table, th, td {\r\n"
6566
+ " border: 1px solid black;\r\n" + "} \r\n" + "th, td {\r\n" + " padding: 10px;\r\n"
66-
+ " text-align: left;\r\n" + "}\r\n" + " </style>\r\n" + " </head>\r\n" + "<body>\r\n"
67-
+ "<div style=\"font: SegoeUI\">\r\n"
67+
+ " text-align: left;\r\n" + "}\r\n" + "h2 {\r\n" + " margin-top: 15px;\r\n" + "}\r\n"
68+
+ " </style>\r\n" + " </head>\r\n" + "<body>\r\n" + "<div style=\"font: SegoeUI\">\r\n"
6869
+ "This application <b>helps you, to learn notes</b>. You need a midi keyboard, to work with this program. If you don't have a midi keyboard,\r\n"
6970
+ "you can use this software with the keyboard from your computer. A = C, S = D .. J = B, because there are only seven keys, there are no different keys for other octaves.\r\n"
7071
+ "This means G = G3, G4, G5 .., if you use a computer keyboard. When PianoNoteCoach is started, you click\r\n"
@@ -78,8 +79,10 @@ public InfoDialog() {
7879
+ "<h2>Support us</h2>\r\n" + "If you like this program, you can support us.<br>\r\n"
7980
+ "1. Tell your friends about this application<br>\r\n"
8081
+ "2. Give the github respository of this project a star<br>\r\n"
81-
+ "3. Tell us, if you find a bug<br>\r\n" + "<h2>License</h2>\r\n" + "Copyright 2019 BurningDev\r\n"
82-
+ "<br><br>\r\n" + "Licensed under the Apache License, Version 2.0 (the \"License\");\r\n"
82+
+ "3. Tell us, if you find a bug<br>\r\n" + "<br>\r\n"
83+
+ "<i>GitHub: https://github.com/BurningDev/PianoNoteCoach/</i>\r\n" + "<h2>License</h2>\r\n"
84+
+ "Copyright 2019 BurningDev\r\n" + "<br><br>\r\n"
85+
+ "Licensed under the Apache License, Version 2.0 (the \"License\");\r\n"
8386
+ "you may not use this file except in compliance with the License.\r\n"
8487
+ "You may obtain a copy of the License at\r\n" + "<br><br>\r\n"
8588
+ " http://www.apache.org/licenses/LICENSE-2.0\r\n" + "<br><br>\r\n"
@@ -92,13 +95,14 @@ public InfoDialog() {
9295
+ "<tr><td>JFugue</td> <td>http://www.jfugue.org/</td> <td>Apache License, version 2.0</td></tr>\r\n"
9396
+ "<tr><td>Tinylog</td> <td>https://tinylog.org/</td> <td>Apache License 2.0</td></tr>\r\n"
9497
+ "</table>\r\n" + "</div>\r\n" + "</body>\r\n" + "</html>");
98+
textPane.setCaretPosition(0);
9599

96100
JLabel lblPianonotecoach = new JLabel("PianoNoteCoach");
97101
lblPianonotecoach.setFont(new Font("Segoe UI", Font.BOLD, 18));
98102
lblPianonotecoach.setBounds(10, 11, 414, 24);
99103
contentPanel.add(lblPianonotecoach);
100104
JButton okButton = new JButton("OK");
101-
okButton.setBounds(324, 325, 100, 25);
105+
okButton.setBounds(334, 335, 100, 25);
102106
contentPanel.add(okButton);
103107
okButton.addActionListener(new ActionListener() {
104108
public void actionPerformed(ActionEvent event) {

src/com/burningdev/pnc/views/OptionsView.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import javax.swing.SpinnerNumberModel;
1717
import javax.swing.border.EtchedBorder;
1818
import javax.swing.border.TitledBorder;
19+
import javax.swing.UIManager;
20+
import java.awt.Color;
1921

2022
/**
2123
* The OptionsView has all settings from this application.
@@ -88,7 +90,7 @@ private void initialize() {
8890

8991
spinnerAmountNotes = new JSpinner();
9092
spinnerAmountNotes.setToolTipText("");
91-
spinnerAmountNotes.setModel(new SpinnerNumberModel(0, 0, 100, 1));
93+
spinnerAmountNotes.setModel(new SpinnerNumberModel(1, 1, 100, 1));
9294
spinnerAmountNotes.setBounds(4, 3, 41, 20);
9395
panelAmountNotes.add(spinnerAmountNotes);
9496

@@ -145,7 +147,7 @@ private void initialize() {
145147
panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.Y_AXIS));
146148

147149
JPanel panel_1 = new JPanel();
148-
panel_1.setBorder(new TitledBorder(null, "Range", TitledBorder.LEADING, TitledBorder.TOP, null, null));
150+
panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Clef", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
149151
panel_2.add(panel_1);
150152
panel_1.setLayout(null);
151153

src/com/burningdev/pnc/views/SheetPanel.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,14 @@ private void paintNote(int place, Note note, boolean showDesc, Graphics2D g, Col
136136
}
137137

138138
g.setColor(c);
139-
g.drawLine(ZERO_X + xShift + 24, ZERO_Y + (int) (note.getYShift() * 15) + 28, ZERO_X + xShift + 24,
140-
ZERO_Y + (int) (note.getYShift() * 15) - 20);
139+
if(note.getYShift() > 0.5 ) {
140+
g.drawLine(ZERO_X + xShift + 24, ZERO_Y + (int) (note.getYShift() * 15) + 28, ZERO_X + xShift + 24,
141+
ZERO_Y + (int) (note.getYShift() * 15) - 20);
142+
} else {
143+
g.drawLine(ZERO_X + xShift + 24, ZERO_Y + (int) (note.getYShift() * 15) + 28, ZERO_X + xShift + 24,
144+
ZERO_Y + (int) (note.getYShift() * 15) + 73);
145+
}
146+
141147
g.fillOval(ZERO_X + xShift + 5, ZERO_Y + (int) (note.getYShift() * 15) + 20, 20, 15);
142148
if (showDesc) {
143149
g.setColor(Color.WHITE);

0 commit comments

Comments
 (0)