codeblockutil
Class Navigator

java.lang.Object
  extended by codeblockutil.Navigator

public final class Navigator
extends java.lang.Object

A navigator navigates between different Explorers. Though the UI holds a common theme, each explorer may represent a unique subset of the whole. Basically, say we have a bunch of canvases (100). Say that we group the canvases into 5 explorers based on some quality and have each individual explorer independently control and display its own group of canvases. The problem we run into is how do we switch from one explorer to the next. There are many ways to do this. We can have buttons that makes unused explorers hidden. Or we have shrink them. This particular implementation chooses to slide them to the side. Now that you know why we need a navigator, let's talk about what a Navigator is. A Navigator lines up a set of explorers along the x-axis. It slides between the explorers until it reaches the end. That's it. Simple? Note however, that each explorer must be UNIQUE. NO EXCEPTIONS! That is, the name of a particular explorer may not be shared by any other explorers. This check rep. is made when adding new explorer. A Navigator unfortunately makes a once dangerous assumption: the name of each explorer must remain the same forever. If the name changes, then the invariant described in the previous paragraph no longer holds.


Nested Class Summary
static class Navigator.Type
          The UI options
 
Constructor Summary
Navigator()
          Constructs new navigator with an empty collection of canvases.
Navigator(Navigator.Type UIModel)
           
 
Method Summary
 void addExlorer(java.lang.String name)
          Adds a new Explorer
 java.util.List<Explorer> getExplorers()
           
 javax.swing.JComponent getJComponent()
           
 javax.swing.JComponent getSwitcher()
           
 boolean hasExplorer(java.lang.String name)
           
static void main(java.lang.String[] args)
          Testing purposes
 void reformView()
          redraws and revalidates the size and preferred size of the viewport and scroll pane to reflect the current collection of explorers.
 void removeExplorer(java.lang.String name)
          Removes the explorer with the specified name.
 void setCanvas(java.util.List<? extends Canvas> canvases, java.lang.String explorer)
          Reassigns the canvases to the explorer with the specified name.
 void setView(java.lang.String name)
          Sets the view to the explorer with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Navigator

public Navigator()
Constructs new navigator with an empty collection of canvases.


Navigator

public Navigator(Navigator.Type UIModel)
Method Detail

addExlorer

public final void addExlorer(java.lang.String name)
Adds a new Explorer

Parameters:
name - - the name of the new explorer

removeExplorer

public final void removeExplorer(java.lang.String name)
Removes the explorer with the specified name. If no explorer is found with that name, then do nothing. If the specified name is null, then do nothing.

Parameters:
name -

getExplorers

public java.util.List<Explorer> getExplorers()

hasExplorer

public boolean hasExplorer(java.lang.String name)
Parameters:
name -
Returns:
true iff there exists an explorer whose name is equal to the specified name. If name is null, return false.

reformView

public void reformView()
redraws and revalidates the size and preferred size of the viewport and scroll pane to reflect the current collection of explorers.


setCanvas

public void setCanvas(java.util.List<? extends Canvas> canvases,
                      java.lang.String explorer)
Reassigns the canvases to the explorer with the specified name. If no explorer is found to have that name, or if the name is null, then do nothing.

Parameters:
canvases -
explorer -

setView

public void setView(java.lang.String name)
Sets the view to the explorer with the specified name. If no explorers are found with a matching name, or if the name is null, then do nothing.

Parameters:
name -

getJComponent

public javax.swing.JComponent getJComponent()
Returns:
the JCOmponent representation of this. MAY NOT BE NULL

getSwitcher

public javax.swing.JComponent getSwitcher()
Returns:
the JComponent representation of the switching tool pane.

main

public static void main(java.lang.String[] args)
Testing purposes