Skip to content
Snippets Groups Projects
Commit a809508b authored by Justin's avatar Justin
Browse files

Updated doxygen documentation to final version.

parent ef0a376f
No related branches found
No related tags found
No related merge requests found
......@@ -59,8 +59,6 @@
Collaboration diagram for PicPuzzle.MainFrame:</div>
<div class="dyncontent">
<div class="center"><img src="class_pic_puzzle_1_1_main_frame__coll__graph.png" border="0" usemap="#_pic_puzzle_8_main_frame_coll__map" alt="Collaboration graph"/></div>
<map name="_pic_puzzle_8_main_frame_coll__map" id="_pic_puzzle_8_main_frame_coll__map">
</map>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
......
......@@ -23,11 +23,11 @@ public class GameLogic implements NonogramEventListener, ActionListener {
* @throws IOException
*/
public GameLogic() throws IOException {
level = 1;
level = 1; // Start at level 1
won = false;
nonogramComponent = new NonogramComponent(new Nonogram(8, 8));
mainFrame = new MainFrame(nonogramComponent);
mainFrame.setTitleLabel("No level found");
mainFrame.setTitleLabel("No level found"); // Default to no level loaded
mainFrame.setMainButtonText("Next");
mainFrame.addMainButtonListener(this);
nonogramComponent.addListener(this);
......@@ -45,7 +45,9 @@ public class GameLogic implements NonogramEventListener, ActionListener {
@Override
public void nonogramClicked(int gridX, int gridY, boolean leftButton) {
// If the game is in proogress and a correct white square is clicked
if (!won && leftButton && currrentNonogram.getPixel(gridX, gridY)) {
// Set it to black and check if the level is completed
nonogramComponent.setPixel(gridX, gridY, true);
if (nonogramComponent.getBoardState().equals(currrentNonogram)) {
mainFrame.setTitleLabel("LEVEL COMPLETED");
......@@ -56,6 +58,8 @@ public class GameLogic implements NonogramEventListener, ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
// If the game is in progress, load the next level if there is one,
// or else the game is over
if (!won) {
level++;
if (!loadLevel(level)) {
......@@ -77,6 +81,7 @@ public class GameLogic implements NonogramEventListener, ActionListener {
String levelFileName = "level"+level;
File levelFile = null;
// Try load any file with the correct format and naming convention
for (int i = 0; i < LEVEL_EXTENSIONS.length; i++) {
try {
levelFile = new File(levelFileName + LEVEL_EXTENSIONS[i]);
......@@ -86,6 +91,7 @@ public class GameLogic implements NonogramEventListener, ActionListener {
} catch (Exception e) {}
}
// If the file was loaded, display the next level
if (fileLoaded) {
try {
nonogramComponent.setNonogram(currrentNonogram);
......
......@@ -40,6 +40,8 @@ public class MainFrame extends JFrame {
}
private void addComponents() {
// GUI code that creates the elements to be displayed
JPanel mainPanel = new JPanel();
setContentPane(mainPanel);
......
......@@ -43,6 +43,7 @@ public class Nonogram {
}
private int fixRGB(int rgb) {
// Check if the color is white or black within a tolerance
if (((rgb & 0x00FF0000) > 0x00F00000) && ((rgb & 0x0000FF00) > 0x0000F000) && ((rgb & 0xFF) > 0xF0)) {
return RGB_WHITE;
} else if (((rgb & 0x00FF0000) < 0x000F0000) && ((rgb & 0x0000FF00) < 0x00000F00) && ((rgb & 0xFF) < 0x0F)) {
......
......@@ -91,6 +91,7 @@ public class NonogramComponent extends JComponent implements MouseInputListener
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
// Draw the black and white squares
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (boardState.getPixel(x, y)) {
......@@ -102,6 +103,8 @@ public class NonogramComponent extends JComponent implements MouseInputListener
}
}
// Draw the grid
g2.setColor(Color.BLACK);
for (int x = 0; x <= width; x++) {
......@@ -112,6 +115,7 @@ public class NonogramComponent extends JComponent implements MouseInputListener
g2.drawLine(gridStartX, gridStartY + y*PIXELS_PER_SQUARE, gridStartX + width*PIXELS_PER_SQUARE, gridStartY + y*PIXELS_PER_SQUARE);
}
// Draw the hints
for (int pos = 0; pos < rowHints.getHintWidth(); pos++) {
for (int hint = 0; hint < rowHints.getHintCount(pos); hint++) {
g2.drawString(""+rowHints.getHint(pos, hint), gridStartX + (hint - rowHints.getHintCount(pos))*PIXELS_PER_SQUARE, gridStartY + pos*PIXELS_PER_SQUARE + 12);
......@@ -139,6 +143,7 @@ public class NonogramComponent extends JComponent implements MouseInputListener
int x = (e.getX() - gridStartX) / PIXELS_PER_SQUARE;
int y = (e.getY() - gridStartY) / PIXELS_PER_SQUARE;
// If the board is clicked, notify the listeners
if ((left || right) && x < width && y < height && x >= 0 && y >= 0) {
for (NonogramEventListener listener : listeners) {
listener.nonogramClicked(x, y, left);
......
......@@ -120,10 +120,6 @@ public class NonogramTest {
assertEquals(test6.getPixel(y, x), testImageData3[y][x]);
}
}
}
@Test(expected=NullPointerException.class)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment