jdraw.jdraw
Class JDraw

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mvp.Model
              |
              +--jdraw.jdraw.JDraw
All Implemented Interfaces:
java.io.Serializable

public class JDraw
extends mvp.Model

Class JDraw is the top-level model class for the JDraw app. JDraw has references for the three main model classes of the system: Tools, Commands, and Canvas.

See Also:
Serialized Form

Field Summary
protected  int activeIndex
          An int value indicating the index of the currently active Canvas.
protected  AskSaveDialog askSaveDialog
          A Dialog for asking what the user wants to do when closing a changed file.
protected  javax.swing.JButton cancelButton
          Still working on this stuff.
protected  java.util.Vector canvas
          The Top-Level Vector of Canvases.
protected  Commands commands
          The Top-Level Commands model.
protected  boolean controlDown
          A boolean value indicating whether the control key is down.
protected  JDrawUI jdrawUI
          Local reference to the system's Top-Level View object.
protected  Tools tools
          The Top-Level Tools model.
 
Fields inherited from class mvp.Model
view
 
Constructor Summary
JDraw(JDrawUI jdrawUI)
          Construct this with the given companion view.
 
Method Summary
 void cancelButtonClicked()
          Simply Hide the AskSaveDialog.
 int getActiveWindowIndex()
           
 Canvas getCanvas(int i)
          Returns the Canvas designated by the integer parameter.
 Commands getCommands()
          Returns the Top-Level Commands object.
 boolean getControlDown()
           
 JDrawUI getJDrawUI()
          A local reference to the Top-Level View component.
 Canvas getLastCanvas()
           
 Tools getTools()
          Returns the Top-Level Tools object.
 void group()
          Calls groupSelected on the currently active Canvas.
 void newCanvas()
          Create a new Canvas by adding a new element to Canvas vector.
 void newCanvas(java.lang.String title)
          Create a new Canvas as above, but set the title of the window, given the String parameter.
 void noButton()
          Close the window without saving.
 void redo()
          Calls redoLastUndo on the currently active Canvas.
 void removeCanvas(int ind)
          Bring up the askSaveDialog if necessary.
 void removeCanvas(int ind, int cancelFlag)
          Bring up the askSaveDialog if necessary.
 void setActiveWindowIndex(int index)
           
 void setCanvas(Canvas newCanvas, CanvasWindow canWindow)
           
 void setControlDown(boolean newControlDown)
           
 void setView(JDrawUI jdrawUI)
          Set the given JDrawUI component as this.jdrawUI.
 void undo()
          Calls undoLastAction on the currently active Canvas.
 void ungroup()
          Calls ungroupSelected on the currently active Canvas.
 void yesButton()
          Close the window and save the Canvas to ...
 
Methods inherited from class mvp.Model
getView, setView
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commands

protected Commands commands
The Top-Level Commands model.

canvas

protected java.util.Vector canvas
The Top-Level Vector of Canvases.

tools

protected Tools tools
The Top-Level Tools model.

jdrawUI

protected JDrawUI jdrawUI
Local reference to the system's Top-Level View object.

askSaveDialog

protected AskSaveDialog askSaveDialog
A Dialog for asking what the user wants to do when closing a changed file.

cancelButton

protected javax.swing.JButton cancelButton
Still working on this stuff.

activeIndex

protected int activeIndex
An int value indicating the index of the currently active Canvas.

controlDown

protected boolean controlDown
A boolean value indicating whether the control key is down.
Constructor Detail

JDraw

public JDraw(JDrawUI jdrawUI)
Construct this with the given companion view. Setup the subview classes after calling the parent constructor.
Parameters:
jdrawUI - - The JDrawUI object passed to parent constructor and set as this.jdrawUI.
Method Detail

setView

public void setView(JDrawUI jdrawUI)
Set the given JDrawUI component as this.jdrawUI.
Parameters:
jdrawUI - - The JDrawUI object to be set an this.jdrawUI.

newCanvas

public void newCanvas()
Create a new Canvas by adding a new element to Canvas vector. Then create a companion Canvas Window in which to place the new canvas. Finally compose the Canvas to put it onscreen.

newCanvas

public void newCanvas(java.lang.String title)
Create a new Canvas as above, but set the title of the window, given the String parameter.
Parameters:
title - - The String used as the Title of the Window.

setCanvas

public void setCanvas(Canvas newCanvas,
                      CanvasWindow canWindow)

getLastCanvas

public Canvas getLastCanvas()

yesButton

public void yesButton()
Close the window and save the Canvas to ... filename.

noButton

public void noButton()
Close the window without saving.

cancelButtonClicked

public void cancelButtonClicked()
Simply Hide the AskSaveDialog.

removeCanvas

public void removeCanvas(int ind)
Bring up the askSaveDialog if necessary. If not, just close the window.

removeCanvas

public void removeCanvas(int ind,
                         int cancelFlag)
Bring up the askSaveDialog if necessary. If not, just close the window.

getCommands

public Commands getCommands()
Returns the Top-Level Commands object.

getCanvas

public Canvas getCanvas(int i)
Returns the Canvas designated by the integer parameter.

getTools

public Tools getTools()
Returns the Top-Level Tools object.

getJDrawUI

public JDrawUI getJDrawUI()
A local reference to the Top-Level View component.

getActiveWindowIndex

public int getActiveWindowIndex()

setActiveWindowIndex

public void setActiveWindowIndex(int index)
Parameters:
index - - The int value to store in this.activeIndex.

undo

public void undo()
Calls undoLastAction on the currently active Canvas.

redo

public void redo()
Calls redoLastUndo on the currently active Canvas.

group

public void group()
Calls groupSelected on the currently active Canvas.

ungroup

public void ungroup()
Calls ungroupSelected on the currently active Canvas.

setControlDown

public void setControlDown(boolean newControlDown)
Parameters:
newControlDown - - The boolean value to store in this.controlDown.

getControlDown

public boolean getControlDown()