Skip to content

Commit c512985

Browse files
committed
Small adjustments for v1
- Add new Gradle task launch4j - Update README.md - Small code improvements
1 parent feb4d3c commit c512985

10 files changed

Lines changed: 83 additions & 75 deletions

File tree

README.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Star SUDOKU
1+
# StarSUDOKU
22

33
## TL;DR
44

55
Java version of the popular Sudoku puzzle game. Intends to provide an advanced user interface.
6-
With Star SUDOKU you can create random sudoku grids or design your own to play/solve.
6+
With StarSUDOKU you can create random sudoku grids or design your own to play/solve.
77
It can be used as sudoku generator, solver. You can export sudoku grids as PDF, RTF, HTML, XML and CSV.
88

99
![](screen1.png?raw=true)
@@ -13,8 +13,10 @@ It can be used as sudoku generator, solver. You can export sudoku grids as PDF,
1313
### This Readme includes:
1414

1515
1. System requirements
16-
2. How to build Star SUDOKU
17-
3. Running Star SUDOKU on your system
16+
2. How to build StarSUDOKU
17+
* How to build an Windows EXE
18+
* How to extend StarSUDOKU
19+
3. Running StarSUDOKU
1820
4. Features
1921
5. Instructions
2022
* Entering numbers in a cell
@@ -31,15 +33,15 @@ It can be used as sudoku generator, solver. You can export sudoku grids as PDF,
3133
1. System requirements
3234
----------------------
3335

34-
Star SUDOKU is written in JAVA programming language, this means that it can be run on any Operating System which has JAVA Runtime Environment (JRE).
36+
StarSUDOKU is written in JAVA programming language, this means that it can be run on any Operating System which has JAVA Runtime Environment (JRE).
3537

3638
You need JRE 1.7.0 (also know as JRE 7) or above. You can download JRE for free at www.java.com
3739

38-
2. How to build Star SUDOKU
40+
2. How to build StarSUDOKU
3941
---------------------------
40-
If you want to build Star SUDOKU on your local machine you need to install the Java Development Kit (JDK). You need JDK 1.7.0 or above.
42+
If you want to build StarSUDOKU on your local machine you need to install the Java Development Kit (JDK). You need JDK 1.7.0 or above.
4143

42-
Star SUDOKU uses the Gradle build system, you can build the project locally just by typing the following in the console:
44+
StarSUDOKU uses the Gradle build system, you can build the project locally just by typing the following in the console:
4345

4446
```
4547
./gradlew build
@@ -52,7 +54,19 @@ On Windows use:
5254

5355
The generated jar file can be found in the folder _build/libs_
5456

55-
### How to extend Star SUDOKU
57+
### How to build an Windows EXE
58+
The Gradle build script provides a way to build an Windows executable. You can even do this on a non-Windows machine. For that purpose you need an external application called
59+
[Launch4j](http://launch4j.sourceforge.net/). Download it and install it on your local machine. The version used to test this feature is 3.8, but it will probably work with
60+
other versions too. In addition to this, you need to create an environment variable called `LAUNCH4J_HOME` which points to the folder where you have installed the application.
61+
62+
After that you can build the exe file by running:
63+
```
64+
./gradlew launch4j
65+
```
66+
67+
The generated exe file can be found in the folder _build/launch4j_
68+
69+
### How to extend StarSUDOKU
5670
If you want to import the project in an IDE such as Eclipse or IntelliJ IDEA then Gradle provides a way to generate all the necessary project files.
5771

5872
Generate Eclipse project:
@@ -65,18 +79,18 @@ Generate IntelliJ IDEA project:
6579
./gradlew idea
6680
```
6781

68-
3. Running Star SUDOKU on your system
69-
-------------------------------------
82+
3. Running StarSUDOKU
83+
---------------------
7084

71-
To start Star SUDOKU try one of the following options:
85+
To start StarSUDOKU try one of the following options:
7286

73-
* Double click on the jar File to start Star SUDOKU. If this didn't work, then you didn't associate your jar Files with your JRE.
87+
* For Windows users we also provide an exe file, which ist just a wrapper for the jar file. Double click on the exe file to start the application.
7488

75-
* For Windows users we also provide an exe file, which ist just a wrapper for the JAR file. Double click on the exe file to start the application.
89+
* Double click on the jar File to start StarSUDOKU. If this didn't work, then you didn't associate your jar Files with your JRE.
7690

7791
* Double click on `StarSUDOKU.bat` for Windows users or on `StarSUDOKU` for Linux users. This will start the application, but only if you have built it with Gradle first.
7892

79-
* Open the console go to your Star SUDOKU folder and type:
93+
* Open the console go to your StarSUDOKU folder and type:
8094
```
8195
java -jar StarSUDOKU-1.0.jar
8296
```
@@ -95,7 +109,7 @@ java -jar StarSUDOKU-1.0.jar
95109

96110
\* An user custom level means that you can enter a number between 1 and 81. And next time you generate a new puzzle exactly that many numbers will be shown at the Sudoku grid. So if you enter 81 then the next puzzle will already be solved when you generate it.
97111

98-
\*\* Number distribution in Star SUDOKU means, how are the numbers distributed when you generate a new puzzle. There are 3 numbers distributions:
112+
\*\* Number distribution in StarSUDOKU means, how are the numbers distributed when you generate a new puzzle. There are 3 numbers distributions:
99113

100114
* Evenly filled 3x3 Squares - means all 3x3 Squares are evenly filled with numbers, when you start a new puzzle.
101115
* Evenly distributed numbers - means that all numbers from 1 to 9 are evenly distributed. So when you generate a new puzzle there will be even number of 1s, 2s, 3s and so on...
@@ -133,7 +147,7 @@ Click on the cell with the middle mouse button.
133147

134148
### Design mode
135149

136-
Click on the 'Design New Sudoku' Button to start the Design Mode, by default Star Sudoku starts with Design Mode on. Enter Your numbers in the Grid and hit 'Play the designed Sudoku' button, if the game cannot find any solution to the numbers you've just entered then a dialog window is shown, otherwise You can begin solving the Sudoku puzzle.
150+
Click on the 'Design New Sudoku' Button to start the Design Mode, by default StarSUDOKU starts with Design Mode on. Enter Your numbers in the Grid and hit 'Play the designed Sudoku' button, if the game cannot find any solution to the numbers you've just entered then a dialog window is shown, otherwise You can begin solving the Sudoku puzzle.
137151

138152
### Additional options
139153

@@ -156,4 +170,4 @@ If you complete the puzzle successfully you will be informed by a pop up window
156170

157171
Jivko Vantchev
158172

159-
And to You for using Star SUDOKU :)
173+
And to You for using StarSUDOKU :)

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ jar {
3939

4040
// Windows wrapper configuration to generate windows exe file with Launch4J
4141
task launch4jConfig(type: Copy) {
42-
from 'src/main/resources/launch4j.xml'
42+
from 'src/main/resources/launch4j/launch4j.xml'
4343
into 'build/launch4j'
4444
expand(
4545
JAR_FILE: project.jar.archivePath,
4646
VERSION: project.version,
47-
ICON: file('src/main/resources/sudoku-icon.ico')
47+
ICON: file('src/main/resources/launch4j/sudoku-icon.ico')
4848
)
4949
}
5050

@@ -63,4 +63,3 @@ task launch4j(type: Exec, dependsOn: [':jar', ':launch4jConfig']) {
6363
commandLine launch4jDir + "/launch4j", launch4jCfg
6464
}
6565
}
66-

src/main/java/StarSUDOKUMain.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
/* Main created on 10.07.2006 */
22

3+
import com.devng.starsudoku.GV;
4+
import com.devng.starsudoku.gui.SudokuMainFrame;
5+
36
import javax.swing.JOptionPane;
47
import javax.swing.UIManager;
58

69
public class StarSUDOKUMain {
710

8-
public static void main(String[] args) {
11+
public static void main(String[] args) throws Exception {
12+
final String os = System.getProperty("os.name").toLowerCase();
913

10-
if(System.getProperty("os.name").toLowerCase().startsWith("windows")) {
11-
try {
12-
UIManager
13-
.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
14-
com.devng.starsudoku.GV.isWin = true;
15-
} catch (Exception exc) {
16-
com.devng.starsudoku.GV.isWin = false;
17-
exc.printStackTrace();
18-
}
19-
}
14+
if(os.startsWith("windows")) {
15+
// The system Look and Feel only looks good on Windows
16+
UIManager.setLookAndFeel(GV.LAF.SYSTEM.getLookAndFeelClassName());
17+
GV.useSystemLAF = true;
18+
} else {
19+
UIManager.setLookAndFeel(GV.LAF.METAL.getLookAndFeelClassName());
20+
}
2021

21-
String jVer = System.getProperty("java.version");
22+
final String jVer = System.getProperty("java.version");
2223
if(jVer.compareToIgnoreCase("1.7.0") < 0) {
23-
String errorMsg = "<HTML><FONT COLOR=\"RED\">Your Java version is too old!</FONT><BR><BR>Star SUDOKU requires JAVA Runtime Environment JRE 1.7.0 / JRE 7 or above.<BR> Please download the latest JRE at <FONT COLOR=\"#0000ff\">www.java.com</FONT></HTML>";
24+
String errorMsg = "<HTML><FONT COLOR=\"RED\">Your Java version is too old!</FONT><BR><BR> " +
25+
"Star SUDOKU requires JAVA Runtime Environment JRE 1.7.0 / JRE 7 or above.<BR> " +
26+
"Please download the latest JRE at <FONT COLOR=\"#0000ff\">www.java.com</FONT></HTML>";
2427
JOptionPane.showMessageDialog(null,
2528
errorMsg, "Fatal error",
2629
JOptionPane.ERROR_MESSAGE);
2730
return;
2831
}
2932

30-
com.devng.starsudoku.gui.SudokuMainFrame f =
31-
new com.devng.starsudoku.gui.SudokuMainFrame();
33+
final SudokuMainFrame f = new SudokuMainFrame();
34+
f.generateNewSudoku();
3235
f.setVisible(true);
3336
}
3437
}

src/main/java/com/devng/starsudoku/GV.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import java.awt.*;
77

88
/**
9-
* Global Variabls
9+
* Global Variables
1010
*/
1111
public class GV {
1212

13-
public static final String NAME = "Star SUDOKU ";
13+
public static final String NAME = "StarSUDOKU";
1414

1515
// Keep in sync with the build.gradle
1616
public static final String VERSION = "1.0";
@@ -84,19 +84,22 @@ public enum NumDistributuon {evenlyDistributedNumbers, evenlyFilled3x3Square3, r
8484

8585
//LOOK AND FEEL
8686
public enum LAF {
87-
METAL, SYSTEM
88-
}
87+
NIMBUS("javax.swing.plaf.nimbus.NimbusLookAndFeel"),
8988

90-
;
89+
METAL("javax.swing.plaf.metal.MetalLookAndFeel"),
9190

92-
public static boolean isWin = false;
91+
SYSTEM(UIManager.getSystemLookAndFeelClassName());
9392

94-
public final static String METAL = "javax.swing.plaf.metal.MetalLookAndFeel";
93+
private final String lookAndFeelClassName;
9594

96-
public final static String SYSTEM = UIManager.getSystemLookAndFeelClassName();
95+
LAF(String lookAndFeelClassName) {
96+
this.lookAndFeelClassName = lookAndFeelClassName;
97+
}
9798

98-
//public final static String MOTIF = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
99-
//public final static String WIN = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
100-
//public final static String GTK = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
99+
public String getLookAndFeelClassName() {
100+
return lookAndFeelClassName;
101+
}
102+
}
101103

104+
public static boolean useSystemLAF = false;
102105
}

src/main/java/com/devng/starsudoku/gui/SudokuGuiGrid.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public class SudokuGuiGrid extends JPanel implements SudokuObserver {
3131

3232
protected boolean isPaintPause;
3333

34-
private class SudokuGuiCell extends JPanel
35-
implements MouseListener, FocusListener {
34+
private class SudokuGuiCell extends JPanel implements MouseListener, FocusListener {
3635

3736
private Color bg;
3837
private Color bgSelected;
@@ -241,7 +240,7 @@ public SudokuGuiGrid(SudokuGrid grid, UndoRedoStack uRS) {
241240
this.sgrid = grid;
242241
this.dimCell = new Dimension(52, 52);
243242
this.uRS = uRS;
244-
this.helpingLines = true;
243+
this.helpingLines = false;
245244

246245
setLayout(new GridLayout(9, 9));
247246
cells = new SudokuGuiCell[9][9];

src/main/java/com/devng/starsudoku/gui/SudokuMainFrame.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public String toString() {
223223

224224

225225
public SudokuMainFrame() {
226-
super(GV.NAME + GV.VERSION);
226+
super(GV.NAME + " " + GV.VERSION);
227227

228228
bHUp = new ButtonHandlerUp();
229229
bHDown = new ButtonHandlerDown();
@@ -456,7 +456,7 @@ private void initMenu() {
456456

457457
mOptions.addSeparator();
458458

459-
opHLines = new JCheckBoxMenuItem("Draw helping lines", true);
459+
opHLines = new JCheckBoxMenuItem("Draw helping lines", false);
460460
opHLines.addItemListener(cH);
461461
opHLines.setMnemonic('D');
462462
mOptions.add(opHLines);
@@ -476,13 +476,13 @@ private void initMenu() {
476476
menu.add(mLAF);
477477
{
478478
ButtonGroup bGr4 = new ButtonGroup();
479-
lafMetal = new JRadioButtonMenuItem("Java Look And Feel", !GV.isWin);
479+
lafMetal = new JRadioButtonMenuItem("Java Look And Feel", !GV.useSystemLAF);
480480
lafMetal.addActionListener(mH);
481481
lafMetal.setMnemonic('M');
482482
mLAF.add(lafMetal);
483483
bGr4.add(lafMetal);
484484

485-
lafSys = new JRadioButtonMenuItem("System Look And Feel", GV.isWin);
485+
lafSys = new JRadioButtonMenuItem("System Look And Feel", GV.useSystemLAF);
486486
lafSys.addActionListener(mH);
487487
lafSys.setMnemonic('S');
488488
mLAF.add(lafSys);
@@ -659,7 +659,7 @@ public boolean accept(File f) {
659659
}
660660

661661
public String getDescription() {
662-
return GV.NAME + "Save File (*.ssud)";
662+
return GV.NAME + " Save File (*.ssud)";
663663
}
664664
});
665665
fc.setAcceptAllFileFilterUsed(false);
@@ -836,7 +836,7 @@ private void setAboutPanel() {
836836
about = new JPanel();
837837
about.setLayout(new BoxLayout(about, BoxLayout.Y_AXIS));
838838

839-
about.add(new JLabel("<HTML><B>" + GV.NAME + GV.VERSION + "</B> Copyright (c) 2006 - 2015 Nikolay G. Georgiev</HTML>"));
839+
about.add(new JLabel("<HTML><B>" + GV.NAME + " " + GV.VERSION + "</B> Copyright (c) 2006 - 2015 Nikolay Georgiev</HTML>"));
840840

841841
about.add(Box.createVerticalStrut(10));
842842

@@ -845,7 +845,7 @@ private void setAboutPanel() {
845845

846846
about.add(Box.createVerticalStrut(20));
847847

848-
about.add(new JLabel("<HTML>This program is released under the Mozilla Public License 2.0 .<BR> A copy of this is included with your copy of Star SUDOKU<BR>and can also be found at:</HTML>"));
848+
about.add(new JLabel("<HTML>This program is released under the Mozilla Public License 2.0 .<BR> A copy of this is included with your copy of StarSUDOKU<BR>and can also be found at:</HTML>"));
849849
about.add(new HTMLLink("https://www.mozilla.org/MPL/2.0/", false));
850850

851851

@@ -855,7 +855,7 @@ private void setAboutPanel() {
855855
about.add(new HTMLLink("http://www.lowagie.com/iText/", false));
856856
}
857857

858-
private void generateNewSud() {
858+
public void generateNewSudoku() {
859859
if (guiGrid.isPaintPause) {
860860
resumePause();
861861
}
@@ -1213,15 +1213,7 @@ private void setGridToFinished() {
12131213

12141214
private void setLookAndFeel(GV.LAF laf) {
12151215
try {
1216-
switch (laf) {
1217-
case METAL:
1218-
UIManager.setLookAndFeel(GV.METAL);
1219-
break;
1220-
case SYSTEM:
1221-
UIManager.setLookAndFeel(GV.SYSTEM);
1222-
break;
1223-
}
1224-
1216+
UIManager.setLookAndFeel(laf.getLookAndFeelClassName());
12251217
SwingUtilities.updateComponentTreeUI(this);
12261218
this.pack();
12271219
} catch (Exception e) {
@@ -1254,7 +1246,7 @@ public void actionPerformed(ActionEvent e) {
12541246
JButton tmp = (JButton) e.getSource();
12551247

12561248
if (tmp == bUp[0]) {
1257-
generateNewSud();
1249+
generateNewSudoku();
12581250
} else if (tmp == bUp[1]) {
12591251
doNewDesign();
12601252
} else if (tmp == bUp[2]) {
@@ -1334,7 +1326,7 @@ public void actionPerformed(ActionEvent e) {
13341326
JMenuItem tmp = (JMenuItem) e.getSource();
13351327

13361328
if (tmp == sudNew) {
1337-
generateNewSud();
1329+
generateNewSudoku();
13381330
} else if (tmp == sudOpen) {
13391331
doLoad();
13401332
} else if (tmp == sudSaveAs) {
@@ -1361,8 +1353,6 @@ public void actionPerformed(ActionEvent e) {
13611353
setLookAndFeel(GV.LAF.METAL);
13621354
} else if (tmp == lafSys) {
13631355
setLookAndFeel(GV.LAF.SYSTEM);
1364-
} else if (tmp == lafSys) {
1365-
setLookAndFeel(GV.LAF.SYSTEM);
13661356
} else if (tmp == helpAbout) {
13671357
doAbout();
13681358
} else if (tmp == sudExit) {

src/main/java/com/devng/starsudoku/io/Export.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static String getHTMLString(SerGrid sg) {
1414
StringBuilder sb = new StringBuilder(3000);
1515
sb.append("<html>\n");
1616
sb.append("<head>\n");
17-
sb.append("\t<title>Star SUDOKU</title>\n");
17+
sb.append("\t<title>" + GV.NAME + "</title>\n");
1818
sb.append("\t<style type=\"text/css\">\n");
1919
sb.append("\t\ttd {\n");
2020
sb.append("\t\t\tfont-weight: bold;\n");
@@ -42,7 +42,7 @@ public static String getHTMLString(SerGrid sg) {
4242
}
4343

4444
sb.append("</table>\n");
45-
sb.append("<p>Generated with Star SUDOKU (<a href=\"" + GV.WEB_PAGE + "\" target=\"_blank\">" + GV.WEB_PAGE + "</a>)</p>\n");
45+
sb.append("<p>Generated with " + GV.NAME + " (<a href=\"" + GV.WEB_PAGE + "\" target=\"_blank\">" + GV.WEB_PAGE + "</a>)</p>\n");
4646
sb.append("</body>\n");
4747
sb.append("</html>\n");
4848

@@ -147,7 +147,7 @@ public static String getRTFString(SerGrid sg) {
147147
sb.append("\\cell\\pard\\plain \\intbl\\ltrpar\\s10\\qc\\rtlch\\af9\\afs36\\lang255\\ltrch\\dbch\\af6\\langfe255\\hich\\fs36\\lang1031\\loch\\fs36\\lang1031 ");
148148
}
149149
sb.append("\\cell\\row\\pard \\pard\\plain \\ltrpar\\s1\\ql\\rtlch\\af9\\afs24\\lang255\\ltrch\\dbch\\af6\\langfe255\\hich\\fs24\\lang1031\\loch\\fs24\\lang1031 ");
150-
sb.append("\\par \\pard\\plain \\ltrpar\\s1\\cf0{\\*\\hyphen2\\hyphlead2\\hyphtrail2\\hyphmax0}\\ql {\\rtlch \\ltrch\\loch\\f1\\fs20\\lang1031\\i0\\b0 Generated with Star SUDOKU (" + GV.WEB_PAGE + ")}\\par }");
150+
sb.append("\\par \\pard\\plain \\ltrpar\\s1\\cf0{\\*\\hyphen2\\hyphlead2\\hyphtrail2\\hyphmax0}\\ql {\\rtlch \\ltrch\\loch\\f1\\fs20\\lang1031\\i0\\b0 Generated with " + GV.NAME + " (" + GV.WEB_PAGE + ")}\\par }");
151151
return sb.toString();
152152
}
153153

0 commit comments

Comments
 (0)