Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.yuxingwang.gantt.model
Class TaskTreeModel

    java.lang.Object
      javax.swing.tree.DefaultTreeModel
          com.yuxingwang.gantt.model.TaskTreeModel

All Implemented Interfaces:
  java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.tree.TreeModel

    public class TaskTreeModel

extends javax.swing.tree.DefaultTreeModel
implements java.beans.PropertyChangeListener

Part of the `GanttModel`, represent the tree structure of tasks, it is inherited from `DefaultTreeModel` to support `JTree` Swing tree view.

Version:
  1.0
Author:
  Yuxing Wang
See Also:
  Serialized Form

Constructor Summary
`TaskTreeModel()`

Method Summary
`void` | `add(Task newTask)` Add new task to the root node of the `TaskTreeModel`.
`void` | `addTo(Task parent, Task newTask)` Add new task to specified task as sub-task in the `TaskTreeModel`.
`java.util.List<Task>` | `getChildren()` Get all 1st level tasks.
`java.util.Calendar` | `getEndTimeOfLatestTask()` Get the end time of latest task in this TaskTreeModel,
`Task` | `getLatestTask()` Get the latest task by task end time.
`int` | `getLevels()`
`Task` | `getTask(int id)` Get Task by ID from given task node includes his sub-trees.
`java.util.List<Task>` | `getTasksByBFS()` Get all tasks by Breadth-First-Search principle.
`java.util.List<Task>` | `getTasksByDFS()` Get all tasks from this model by Depth-First-Search principle.
`int` | `getTasksCount()` Get count of all tasks in this model.
`com.yuxingwang.gantt.ui.TimeUnit` | `getTimeUnit()`
`void` | `propertyChange(java.beans.PropertyChangeEvent evt)` Handle the task changes.
`void` | `removeAll()` Remove all task from `TaskTreeModel`.
`void` | `removeTask(Task task)` Remove Task from root node of the `TaskTreeModel`.
`void` | `setTimeUnit(com.yuxingwang.gantt.ui.TimeUnit timeUnit)` Set TimeUnit to all tasks.

Methods inherited from class javax.swing.tree.DefaultTreeModel
`addTreeModelListener, asksAllowsChildren, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TaskTreeModel

    public TaskTreeModel()

Method Detail

### getLevels

    public int getLevels()

### getTasksCount

    public int getTasksCount()

  Get count of all tasks in this model.

  Returns:

### add

    public void add(Task newTask)

  Add new task to the root node of the `TaskTreeModel`.

  Parameters:
    `task` -

### addTo

    public void addTo(Task parent,
                      Task newTask)

  Add new task to specified task as sub-task in the `TaskTreeModel`.

  Parameters:
    `parent` -
    `newTask` -

### removeTask

    public void removeTask(Task task)

  Remove Task from root node of the `TaskTreeModel`.

  Parameters:
    `task` -

### removeAll

    public void removeAll()

  Remove all task from `TaskTreeModel`.

### getTask

    public Task getTask(int id)

  Get Task by ID from given task node includes his sub-trees.

  Parameters:
    `id` -
  Returns:

### getChildren

    public java.util.List<Task> getChildren()

  Get all 1st level tasks.

  Returns:

### getTasksByDFS

    public java.util.List<Task> getTasksByDFS()

  Get all tasks from this model by Depth-First-Search principle.

  Returns:

### getTasksByBFS

    public java.util.List<Task> getTasksByBFS()

  Get all tasks by Breadth-First-Search principle.

  Returns:

### getEndTimeOfLatestTask

    public java.util.Calendar getEndTimeOfLatestTask()

  Get the end time of latest task in this TaskTreeModel,

  Returns:
    If no tasks exist, return null.

### getLatestTask

    public Task getLatestTask()

  Get the latest task by task end time.

  Returns:
    null if no tasks there

### propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent evt)

  Handle the task changes. Fire tree node change event to GanttModel.

  Specified by:
    `propertyChange` in interface `java.beans.PropertyChangeListener`

### getTimeUnit

    public com.yuxingwang.gantt.ui.TimeUnit getTimeUnit()

### setTimeUnit

    public void setTimeUnit(com.yuxingwang.gantt.ui.TimeUnit timeUnit)

  Set TimeUnit to all tasks.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD