37 Commits
Author SHA1 Message Date
regar42 95520bd1bb Merge branch 'refactorize' of antograb/TpMazeJava into master 2018-01-14 18:02:44 +01:00
regar42 a664c399ff Fix when path is drawn or before being animated
* Fix maze edition when path is drawn
* Clear the path before animating it
2018-01-14 18:00:45 +01:00
regar42 b1891f7118 Add message on window opening
* On lauch, explain the color of wall/empty boxes and that an example
maze can be found in data/labyrinthe.txt
* Remove legacy labyOutput.txt
* Add a tiny comment to the class Dijkstra
2018-01-14 17:26:38 +01:00
regar42 dc8de8c707 Add MazeModelInterface and Maze exceptions
* Add an interface for MazeModel
* Add MazeReadingException and MazeSavingException to handle errors when
  reading/saving a maze from/to a file (see #4)
* Useless methods removal (shallowShortest)
* Add javadoc
2018-01-14 17:05:42 +01:00
regar42 e76db727c7 Fix regression on getDimensionX and add finals
* Make all appropriate methods final
* Add new messages to MazeAppModelMessage and handle them to act more
  accurately on observers updates
* Make all buttons from 'File' menu subclasses of FileMenu in order to
  have a cleaner ui folder
* Remove legacy code (for example, the former code used to animate the
  path drawing)
* Improve delegation
2018-01-14 14:00:07 +01:00
regar42 3520bfc4ce Merge branch 'mvc'
Here's the list of functionalities added to the project :
  - Add a user interface with black, white, green and red squares to
    respectively represent empty, wall, departure and arrival boxes.
  - Add a File menu containing :
    - A quit option, who takes cares of whether the maze has been
      modified or not (*Keystroke : Ctrl-Q*)
    - A Load Maze option, which opens a file chooser dialog in order to
      load another maze (*Keystroke : Ctrl-O*)
    - A Save Maze option in order to save the maze (*Keystroke : Ctrl-S*)
    - A Save Maze As option in order to save the maze in a different
      location (*Keystroke : Ctrl-Maj-S*)
  - A Maze menu containing :
    - An option to draw the shortest path, which takes care of whether
      a path exists or not
    - An option to animate the path drawing, which then waits for the
      user input to draw the next step of the maze
    - An option to clear the shortest path
    - An option to make a new clear maze which opens a dialog containing
      two spinners (in order to select the number of lines and rows of
      the maze), and an OK button once the user has finished selecting
      the dimensions (*Keystroke : Ctrl-N*)
    - An option to clear the maze (*Keystroke : Ctrl-D*)
    - An option to add a row at the end of the maze
    - An option to add a line at the end of the maze
    - An option to delete a row at the end of the maze
    - An option to delete a line at the end of the maze
  - A context menu with :
    - Options to toggle the types of boxes
    - Options to add/delete a row/line at the given position
  - A feature which toggles the box type between wall and empty when you
    left-click on the box
2018-01-03 12:03:09 +01:00
regar42 f91f373986 Merge branch 'animateShortestPath' into mvc 2018-01-02 23:46:23 +01:00
regar42 43d58c815b Fix null pointer exception when there is no path
maze:
* Add methods to Box and Maze to reset the neighbor lists of boxes

model:
* If the neighbor list of the arrival box is null, it means that no path
  exist between departure and arrival, and we therefore display the
  pop-up which is already displayed when the user tries to draw the path
  on a maze where there is no departure and/or arrival
2018-01-01 18:32:38 +01:00
regar42 024a4f70c3 Fix add column/line and spinners, cleanup Maintest
* Remove legacy test code in MainTest

maze:
* Add methods to add/del lines and columns
* Add various calls to matrixDeepCopy, allowing to overwrite only a part
  of a matrix

model:
* Better delegation to Maze : let Maze handle column/line
  adds/deletions

ui:
* Add buttons to context menu to add/remove lines and columns
* Add buttons to Maze Menu to delete lines and columns
* Fix the spinners, it used to call a new instance of itself, which made
  impossible to simple get the values from the spinners
2017-12-31 20:25:16 +01:00
regar42 81df80e7ea Add a context menu to edit boxes type
model:
* New methods to directly set boxes type instead of only toggling
  (setXBox methods)
* toggleBox now calls setXBox methods

ui:
* Add a context menu, enabled on right click, to directly choose the
  type of a box in the maze
* Defer the calculation of the box coordinates in the matrix to two new
  methods, getBoxRow and getBoxLine
2017-12-29 12:04:15 +01:00
regar42 37def85f5b Add a toggle to dynamically change boxes type
maze:
* Fix EBox, ABox, DBox and WBox, which still used legacy coordinates
  (x for y and y for x). See 213071d3 and #20

model:
* Add a toggle method to MazeAppModel. For a box given by its
  coordinates, it toggles its type (Wall, Empty, Departure or
  Arrival), sends a notification to observers and sets the maze's
  status to 'not saved'.

ui:
* Fix SaveMazeMenuItem, which enabled itself whenever a Maze renewal
  notification was received. It now enables itself only if a filename is
  set (expected behavior).
* Add a MouseListener to MazeDrawing to catch clicks on boxes. The
  selected box is found using the x and y coordinates of where the mouse
  clicked.
* Now print a message when the user tries to draw the shortest path
  whereas the maze doesn't contain an arrival and/or a departure.
2017-12-28 18:26:20 +01:00
regar42 7c1d136856 Merge branch 'drawShortestPath' into mvc 2017-12-28 11:15:11 +01:00
regar42 11200ebed2 Fix repainting when the path is drawn
ui:
* Fix repainting when the path is supposed to be drawn. At any
  repainting (window resizing, menu unfolding), the maze was repainted
  without the shortest path. We now use the attribute stored in the
  model to know whether the path should be drawn or not when we repaint
  the panel (see #24)
2017-12-26 22:16:40 +01:00
regar42 8bef42e2a6 Closing the window now does the same as Quit
ui:
* Add a WindowListener catching the event of closing the window to ask
  the user if the maze must be saved or not (if it's not already saved)
  (same behavior as the Quit button) (see #19)
2017-12-26 16:45:47 +01:00
regar42 9b272e5f25 Ask to save before loading a new maze
model:
* Deprecate modified from MazeAppModel, which was misused and
  misunderstood
* Add saved to MazeAppModel to keep track if a maze (or some
  modification) was saved into a file or not

ui:
* Use the new saved attribute to know if the maze was saved or not
* Move the box asking whether to save the maze or not from QuitMenuItem
  to SaveBox and call SaveBox from QuitMenuItem
* SaveBox now checks if the maze has a source file or not, if not it
  prompts a box to ask where to save the maze
* If the maze was modified, the Load Maze button will pop SaveBox before
  erasing the current maze
2017-12-26 15:24:00 +01:00
regar42 7242872b83 Add a button to clear path
model:
* Add an attribute to MazeAppModel to keep track of if the path is drawn
  or not. For future use to enable/disable the Clear button depending on
  if the path is drawn or not

ui:
* Add a "Clear shortest path" button to the Maze menu
* Add a method to clear the path in MazeApp (just trigger a repainting
  of the MazeApp, which erase the path, since its not drawn by default)
  and update MazeAppModel accordingly
2017-12-24 21:27:20 +01:00
regar42 c0afbe104c Add menu button to draw the shortest path
ui:
* Add methods to draw the shortest path from MazeApp, WindowPanel and
  MazeDrawing
* Add a Maze menu with a button to draw the shortest path from departure
  to arrival
2017-12-24 20:20:40 +01:00
regar42 1e934b05e6 Fix paintShortestPath and move it into MazeDrawing
model:
* Add getShortest() to MazeAppModel, which returns the list of vertexes
  on the shortest path from departure to arrival
ui:
* Move paintShortestPath from MazeApp to MazeDrawing
* Fix a bug in paintShortestPath where a switch between width and height
  caused ellipses to be mislocated (probably still the same confusion
  between the x and y axes)
2017-12-24 19:09:14 +01:00
regar42 b5eb6b0b8c Move paintShortestPath from model to ui 2017-12-23 22:31:56 +01:00
regar42 80ffabdd69 Refresh attributes in MazeAppModel at maze loading
model:
* Add initModelFromMaze() to refresh the model attributes, such as
  arrival, departure, previous, etc, at maze change
2017-12-23 21:21:47 +01:00
regar42 97f9aa4ba0 Add generic maze generation methods
maze:
* Change emptySquareMaze() to become emptyMaze(int dimension)
* emptyMaze now takes 1 or 2 parameteres, and accordingly generate a
  square or a rectangle maze of the given dimension(s)
* Add wallMaze, which generate a maze full of walls. As emptyMaze, it
  takes one or two parameters
model:
* Update mazeAppModel tu use the new emptyMaze method
2017-12-23 21:00:03 +01:00
regar42 78dfe72e01 Open app on empty maze and improve load/save
model:
* Add a filename attribute to MazeAppModel to keep track of the file
  currently being used by the app
* Add saveToFile(filename) to save the maze into a specific file
* Rewrite saveToFile() to use the stored filename attribute to know into
  which file is to be used to save the maze, instead of the
  hardcoded path
* Remove unused models
* MazeAppModel is now initialized with an empty maze, instead of a
  maze read from a hardcoded path (see #13)
* Add a MazeAppModelMessage class to pass proper messages to observers
* Replace setMaze(maze) by loadMaze(filename) for now
* Move paintMaze into ui/MazeApp

ui:
* Add a Save As button (just a new name for the previous Save button)
  and implement an actual Save button (which saves into the file
  currently being used), disabled when no file is currently in use.
  (see #16)
* Create the FileBox class to handle file choices for the load, save,
  save as buttons
* Add keystrokes to trigger Load, Save or Save As actions from the menu

maze:
* Add a method to Maze to perform a deep copy of a matrix of boxes
* Add a static method to generate an empty maze of a fixed size (10*10)
  This behavior might change in the future
* Add a constructor to make a Maze from a matrix of boxes
2017-12-23 20:39:59 +01:00
regar42 987fb858e4 Use proper dialog type for the "Save Maze" button
Instead of using showOpenDialog(), use showSaveDialog()
2017-12-20 01:18:37 +01:00
regar42 53ee6f1565 Add a button to save the maze from the ui 2017-12-19 23:30:12 +01:00
regar42 2a4d852bac Merge branch 'fixIndexes' of antograb/TpMazeJava into mvc 2017-12-19 22:35:22 +01:00
regar42 79ed877d9d Merge branch 'boxTypeEdition' into mvc and cleanup
* Merge branch 'boxTypeEdition' into mvc
* Remove some useless spaces and blank lines
2017-12-16 20:40:27 +01:00
regar42 083962eec5 Merge branch 'menuBar' into mvc 2017-12-16 18:03:56 +01:00
regar42 bac9b54d58 Fixing lines and spaces and restoring labyOutput 2017-12-16 17:41:02 +01:00
regar42 40c05909e6 Add orange borders to the printed boxes 2017-12-16 13:15:25 +01:00
regar42 e8896556bc Normalize code and fix saveToTextFile
* Normalize spaces and blank lines according to Java Code Conventions
  from Java SE 8
* Wrap code to 80 characters per line (Java Code Conventions for Java SE
  8)
* Fix saveToTextFile() in Maze : same confusion that was fixed in bc1886ca
  for initFromTextFile() (x et y coordinates were respectively used as y
  and x)
2017-12-14 21:53:49 +01:00
regar42 b59a8436dd Merge branch 'fixUnneededCode' into lastDijsktraClasses 2017-12-10 17:48:34 +01:00
regar42 5d75a82103 Merge branch 'javadoc' into lastDijsktraClasses 2017-12-10 15:40:43 +01:00
regar42 4d1d3b39a2 Add documentation and fix Javadoc warnings
* Describe the aim of the interfaces
* Explain what are the box inherited from Box
* Fix Javadoc warnings by specifying the parameters and returns of the
  methods in the interfaces
2017-12-10 15:27:57 +01:00
regar42 ebb91b01b3 Code cleanup
* Remove unwanted getters and setters
* Properly handle object passed to constructors
* Remove redundant condition check on ASet.contains()'s return
* Make Maze.initFromTextFile() private
2017-12-10 00:02:20 +01:00
regar42 eb1e7a8bc0 Sharpen getCost and improve wallbox handling
* Rewrite getCost() from Maze to remove unneeded
  isWalkable checks on boxes
* Return an empty neighbor list for wall boxes
  (in generateNeighbours() from Maze)
2017-12-10 00:02:15 +01:00
regar42 bc1886ca94 Fix rectangle maze generation
Switch compteurColonne and compteurLigne
Despite their names, compteurColonne and compteurLigne
respectively represent the x and y coordinates
2017-12-07 10:59:07 +01:00
regar42 f252db5e3d Merge branch 'IO' of antograb/TpMazeJava into master 2017-12-03 18:19:12 +01:00