Difference between revisions of "CSC212 Lab 15 2014"
(→Explore the Code) |
(→Run) |
||
Line 15: | Line 15: | ||
* This [[Tutorial:_A_Model-View-Controller_in_Processing| tutorial]] contains the code for all three classes. Copy/paste the code into your three classes. | * This [[Tutorial:_A_Model-View-Controller_in_Processing| tutorial]] contains the code for all three classes. Copy/paste the code into your three classes. | ||
<br /> | <br /> | ||
− | ==Run== | + | ==Run the Applet== |
<br /> | <br /> | ||
* The starting class is the viewer. It's the applet class. | * The starting class is the viewer. It's the applet class. | ||
* Run it. Play with the applet to understand how it works. | * Run it. Play with the applet to understand how it works. | ||
<br /> | <br /> | ||
+ | |||
==Explore the Code== | ==Explore the Code== | ||
<br /> | <br /> |
Revision as of 09:59, 27 November 2014
--D. Thiebaut (talk) 09:43, 27 November 2014 (EST)
This lab introduces the Model-View-Controller (MVC) system for implementing Graphical User Interfaces (GUI). Please review the slides from the MVC lecture notes if necessary.
First Contact
- Create a new project, or add new files to an existing project. You will need to import core.jar from the Processing 2 app into your project, and then add it to the build path.
- You need to create 3 different classes, one for the controller, one for the viewer, and one for the model.
- MVC1_controller.java
- MVC1_viewer.java
- MVC1_model.java
- This tutorial contains the code for all three classes. Copy/paste the code into your three classes.
Run the Applet
- The starting class is the viewer. It's the applet class.
- Run it. Play with the applet to understand how it works.
Explore the Code
- Read the code for the model. Notice that it contains the bare definition of a graph, its vertices, and its edges, and not much else. That's what a model should contain.
- Look at the main public methods. They are few. They mostly allow one to
- initialize a graph, if we want one already made.
- add an edge
- get the dimension of the grid
- get the adjacency list of a vertex
- Change the probability100 variable; it controls the probability of creating an edge between a vertex and its neighbors. The lower the value, the less connected the graph is. The closest to 100, the more fully interconnected the vertices get. Run the applet again.