Skip to content

Commit

Permalink
Small adjustments for v1
Browse files Browse the repository at this point in the history
- Add new Gradle task launch4j
- Update README.md
- Small code improvements
  • Loading branch information
devng committed Aug 7, 2015
1 parent feb4d3c commit c512985
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 75 deletions.
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Star SUDOKU
# StarSUDOKU

## TL;DR

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

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

1. System requirements
2. How to build Star SUDOKU
3. Running Star SUDOKU on your system
2. How to build StarSUDOKU
* How to build an Windows EXE
* How to extend StarSUDOKU
3. Running StarSUDOKU
4. Features
5. Instructions
* Entering numbers in a cell
Expand All @@ -31,15 +33,15 @@ It can be used as sudoku generator, solver. You can export sudoku grids as PDF,
1. System requirements
----------------------

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).
StarSUDOKU is written in JAVA programming language, this means that it can be run on any Operating System which has JAVA Runtime Environment (JRE).

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

2. How to build Star SUDOKU
2. How to build StarSUDOKU
---------------------------
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.
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.

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

```
./gradlew build
Expand All @@ -52,7 +54,19 @@ On Windows use:

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

### How to extend Star SUDOKU
### How to build an Windows EXE
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
[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
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.

After that you can build the exe file by running:
```
./gradlew launch4j
```

The generated exe file can be found in the folder _build/launch4j_

### How to extend StarSUDOKU
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.

Generate Eclipse project:
Expand All @@ -65,18 +79,18 @@ Generate IntelliJ IDEA project:
./gradlew idea
```

3. Running Star SUDOKU on your system
-------------------------------------
3. Running StarSUDOKU
---------------------

To start Star SUDOKU try one of the following options:
To start StarSUDOKU try one of the following options:

* 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.
* 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.

* 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.
* 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.

* 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.

* Open the console go to your Star SUDOKU folder and type:
* Open the console go to your StarSUDOKU folder and type:
```
java -jar StarSUDOKU-1.0.jar
```
Expand All @@ -95,7 +109,7 @@ java -jar StarSUDOKU-1.0.jar

\* 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.

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

* Evenly filled 3x3 Squares - means all 3x3 Squares are evenly filled with numbers, when you start a new puzzle.
* 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...
Expand Down Expand Up @@ -133,7 +147,7 @@ Click on the cell with the middle mouse button.

### Design mode

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.
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.

### Additional options

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

Jivko Vantchev

And to You for using Star SUDOKU :)
And to You for using StarSUDOKU :)
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jar {

// Windows wrapper configuration to generate windows exe file with Launch4J
task launch4jConfig(type: Copy) {
from 'src/main/resources/launch4j.xml'
from 'src/main/resources/launch4j/launch4j.xml'
into 'build/launch4j'
expand(
JAR_FILE: project.jar.archivePath,
VERSION: project.version,
ICON: file('src/main/resources/sudoku-icon.ico')
ICON: file('src/main/resources/launch4j/sudoku-icon.ico')
)
}

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

33 changes: 18 additions & 15 deletions src/main/java/StarSUDOKUMain.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
/* Main created on 10.07.2006 */

import com.devng.starsudoku.GV;
import com.devng.starsudoku.gui.SudokuMainFrame;

import javax.swing.JOptionPane;
import javax.swing.UIManager;

public class StarSUDOKUMain {

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
final String os = System.getProperty("os.name").toLowerCase();

if(System.getProperty("os.name").toLowerCase().startsWith("windows")) {
try {
UIManager
.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
com.devng.starsudoku.GV.isWin = true;
} catch (Exception exc) {
com.devng.starsudoku.GV.isWin = false;
exc.printStackTrace();
}
}
if(os.startsWith("windows")) {
// The system Look and Feel only looks good on Windows
UIManager.setLookAndFeel(GV.LAF.SYSTEM.getLookAndFeelClassName());
GV.useSystemLAF = true;
} else {
UIManager.setLookAndFeel(GV.LAF.METAL.getLookAndFeelClassName());
}

String jVer = System.getProperty("java.version");
final String jVer = System.getProperty("java.version");
if(jVer.compareToIgnoreCase("1.7.0") < 0) {
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>";
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>";
JOptionPane.showMessageDialog(null,
errorMsg, "Fatal error",
JOptionPane.ERROR_MESSAGE);
return;
}

com.devng.starsudoku.gui.SudokuMainFrame f =
new com.devng.starsudoku.gui.SudokuMainFrame();
final SudokuMainFrame f = new SudokuMainFrame();
f.generateNewSudoku();
f.setVisible(true);
}
}
25 changes: 14 additions & 11 deletions src/main/java/com/devng/starsudoku/GV.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import java.awt.*;

/**
* Global Variabls
* Global Variables
*/
public class GV {

public static final String NAME = "Star SUDOKU ";
public static final String NAME = "StarSUDOKU";

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

//LOOK AND FEEL
public enum LAF {
METAL, SYSTEM
}
NIMBUS("javax.swing.plaf.nimbus.NimbusLookAndFeel"),

;
METAL("javax.swing.plaf.metal.MetalLookAndFeel"),

public static boolean isWin = false;
SYSTEM(UIManager.getSystemLookAndFeelClassName());

public final static String METAL = "javax.swing.plaf.metal.MetalLookAndFeel";
private final String lookAndFeelClassName;

public final static String SYSTEM = UIManager.getSystemLookAndFeelClassName();
LAF(String lookAndFeelClassName) {
this.lookAndFeelClassName = lookAndFeelClassName;
}

//public final static String MOTIF = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
//public final static String WIN = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
//public final static String GTK = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
public String getLookAndFeelClassName() {
return lookAndFeelClassName;
}
}

public static boolean useSystemLAF = false;
}
5 changes: 2 additions & 3 deletions src/main/java/com/devng/starsudoku/gui/SudokuGuiGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public class SudokuGuiGrid extends JPanel implements SudokuObserver {

protected boolean isPaintPause;

private class SudokuGuiCell extends JPanel
implements MouseListener, FocusListener {
private class SudokuGuiCell extends JPanel implements MouseListener, FocusListener {

private Color bg;
private Color bgSelected;
Expand Down Expand Up @@ -241,7 +240,7 @@ public SudokuGuiGrid(SudokuGrid grid, UndoRedoStack uRS) {
this.sgrid = grid;
this.dimCell = new Dimension(52, 52);
this.uRS = uRS;
this.helpingLines = true;
this.helpingLines = false;

setLayout(new GridLayout(9, 9));
cells = new SudokuGuiCell[9][9];
Expand Down
32 changes: 11 additions & 21 deletions src/main/java/com/devng/starsudoku/gui/SudokuMainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public String toString() {


public SudokuMainFrame() {
super(GV.NAME + GV.VERSION);
super(GV.NAME + " " + GV.VERSION);

bHUp = new ButtonHandlerUp();
bHDown = new ButtonHandlerDown();
Expand Down Expand Up @@ -456,7 +456,7 @@ private void initMenu() {

mOptions.addSeparator();

opHLines = new JCheckBoxMenuItem("Draw helping lines", true);
opHLines = new JCheckBoxMenuItem("Draw helping lines", false);
opHLines.addItemListener(cH);
opHLines.setMnemonic('D');
mOptions.add(opHLines);
Expand All @@ -476,13 +476,13 @@ private void initMenu() {
menu.add(mLAF);
{
ButtonGroup bGr4 = new ButtonGroup();
lafMetal = new JRadioButtonMenuItem("Java Look And Feel", !GV.isWin);
lafMetal = new JRadioButtonMenuItem("Java Look And Feel", !GV.useSystemLAF);
lafMetal.addActionListener(mH);
lafMetal.setMnemonic('M');
mLAF.add(lafMetal);
bGr4.add(lafMetal);

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

public String getDescription() {
return GV.NAME + "Save File (*.ssud)";
return GV.NAME + " Save File (*.ssud)";
}
});
fc.setAcceptAllFileFilterUsed(false);
Expand Down Expand Up @@ -836,7 +836,7 @@ private void setAboutPanel() {
about = new JPanel();
about.setLayout(new BoxLayout(about, BoxLayout.Y_AXIS));

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

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

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

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

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>"));
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>"));
about.add(new HTMLLink("https://www.mozilla.org/MPL/2.0/", false));


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

private void generateNewSud() {
public void generateNewSudoku() {
if (guiGrid.isPaintPause) {
resumePause();
}
Expand Down Expand Up @@ -1213,15 +1213,7 @@ private void setGridToFinished() {

private void setLookAndFeel(GV.LAF laf) {
try {
switch (laf) {
case METAL:
UIManager.setLookAndFeel(GV.METAL);
break;
case SYSTEM:
UIManager.setLookAndFeel(GV.SYSTEM);
break;
}

UIManager.setLookAndFeel(laf.getLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
this.pack();
} catch (Exception e) {
Expand Down Expand Up @@ -1254,7 +1246,7 @@ public void actionPerformed(ActionEvent e) {
JButton tmp = (JButton) e.getSource();

if (tmp == bUp[0]) {
generateNewSud();
generateNewSudoku();
} else if (tmp == bUp[1]) {
doNewDesign();
} else if (tmp == bUp[2]) {
Expand Down Expand Up @@ -1334,7 +1326,7 @@ public void actionPerformed(ActionEvent e) {
JMenuItem tmp = (JMenuItem) e.getSource();

if (tmp == sudNew) {
generateNewSud();
generateNewSudoku();
} else if (tmp == sudOpen) {
doLoad();
} else if (tmp == sudSaveAs) {
Expand All @@ -1361,8 +1353,6 @@ public void actionPerformed(ActionEvent e) {
setLookAndFeel(GV.LAF.METAL);
} else if (tmp == lafSys) {
setLookAndFeel(GV.LAF.SYSTEM);
} else if (tmp == lafSys) {
setLookAndFeel(GV.LAF.SYSTEM);
} else if (tmp == helpAbout) {
doAbout();
} else if (tmp == sudExit) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/devng/starsudoku/io/Export.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static String getHTMLString(SerGrid sg) {
StringBuilder sb = new StringBuilder(3000);
sb.append("<html>\n");
sb.append("<head>\n");
sb.append("\t<title>Star SUDOKU</title>\n");
sb.append("\t<title>" + GV.NAME + "</title>\n");
sb.append("\t<style type=\"text/css\">\n");
sb.append("\t\ttd {\n");
sb.append("\t\t\tfont-weight: bold;\n");
Expand Down Expand Up @@ -42,7 +42,7 @@ public static String getHTMLString(SerGrid sg) {
}

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

Expand Down Expand Up @@ -147,7 +147,7 @@ public static String getRTFString(SerGrid sg) {
sb.append("\\cell\\pard\\plain \\intbl\\ltrpar\\s10\\qc\\rtlch\\af9\\afs36\\lang255\\ltrch\\dbch\\af6\\langfe255\\hich\\fs36\\lang1031\\loch\\fs36\\lang1031 ");
}
sb.append("\\cell\\row\\pard \\pard\\plain \\ltrpar\\s1\\ql\\rtlch\\af9\\afs24\\lang255\\ltrch\\dbch\\af6\\langfe255\\hich\\fs24\\lang1031\\loch\\fs24\\lang1031 ");
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 }");
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 }");
return sb.toString();
}

Expand Down
Loading

0 comments on commit c512985

Please sign in to comment.