cz.psika.numerist
Class Manager

java.lang.Object
  extended by cz.psika.numerist.Manager
All Implemented Interfaces:
Constants, ItemObserver

public final class Manager
extends java.lang.Object
implements Constants, ItemObserver

Manager for diagrams and corresponding entries.

Author:
Tomas Psika

Nested Class Summary
static class Manager.SORT_ORDER
          Sorting order.
static class Manager.SORT_TYPE
          Type of sorting.
 
Nested classes/interfaces inherited from interface cz.psika.numerist.Constants
Constants.ItemEvents
 
Field Summary
 
Fields inherited from interface cz.psika.numerist.Constants
APPLICATION_CONFIG_FILENAME, APPNAME, AUTHORS, CONFIG_DIAGRAM_COLUMN_COLOR, CONFIG_DIAGRAM_INNER_DIAGONAL_COLOR, CONFIG_DIAGRAM_OUTER_DIAGONAL_COLOR, CONFIG_DIAGRAM_ROW_COLOR, CONFIG_FAILURE, CONFIG_MAPPING_DEFAULT, CONFIG_MAPPING_SCHEMA, CONTACT_EMAIL, DECREMENT, defaultStyleName, FILE_MODIFIED, FILE_NOT_MODIFIED, FIRST_POSITION, FULL_DIAGRAM, INCREMENT, INSERT_BEFORE, INSIDE_MAIN_PANEL, INSIDE_TOP_PANEL, LICENSE, OK, PROJECT_SUPPORT_RELATIVE_URL, PROJECT_URL, RELEASE, styleFileSuffix, stylesDirectory, THUMBNAIL, VERSION, VIEW_MODE_DUAL, VIEW_MODE_SINGLE
 
Method Summary
 void addDiagram(Item item, boolean insideContentArea, boolean insideThumbnailArea)
          Append diagram into panels.
 boolean currentSortingOrderAscending()
          Get sorting order currently set.
 void deleteAll()
          Delete all items and diagrams.
 void deleteSelected()
          Deleting of items marked as selected.
 void dragDiagram(java.awt.dnd.DragGestureEvent dge)
          Dragging the diagram.
 void dropDiagram(java.awt.dnd.DropTargetDropEvent dtde)
          Dropping the diagram.
 Diagram[] findDiagrams(Entry search)
          Find visible thumbnail and/or full diagram by it's entry.
 Diagram getDiagram(Item item, boolean isThumbnail)
          Fetch diagram for this concrete item.
 Diagram getDiagramCopy(Item item, boolean isThumbnail)
          Get diagram copy for the item.
static Manager getInstance()
          Returns singleton instance.
 int getNumberOfItems()
          Get current number of items.
 java.util.Iterator<Item> itemsIterator()
          Get iterator over all items.
 void refreshThumbnails()
          Refresh thumbnails when free space should be available inside thumbnail are, useful especially after window maximization.
 void refreshThumbnails(Item startItem)
          Refresh the thumbnail area.
 Entry registerEntry(java.lang.String entryString, Style entryStyle)
          Register new entry within collection.
 void reverseItems()
          Reverse items inside the collection and toggle current sorting order.
 void rotateThumbnails(int count)
          Rotating thumbnails.
 int selectedItems()
          Returns number of selected items.
 boolean setEntriesFromFile(java.lang.String filename)
          Load entries from file and set thumbnails.
 void sortItems(Manager.SORT_TYPE sortType, boolean ascending)
          Sort items according to selected sorting criteria.
 void update(ItemObservable observable, Constants.ItemEvents event)
          Updating the observable item.
 void updateNoOfItemsSelected(boolean increment)
          Update number of selected items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Manager getInstance()
Returns singleton instance.

Returns:
instance of the diagram manager

registerEntry

public Entry registerEntry(java.lang.String entryString,
                           Style entryStyle)
Register new entry within collection. Created entry has it's own unique identifier and is registered inside internal Vector of Items.

Parameters:
entryString - input text
entryStyle - input style
Returns:
new Entry object registered

itemsIterator

public java.util.Iterator<Item> itemsIterator()
Get iterator over all items.

Returns:
iterator

getNumberOfItems

public int getNumberOfItems()
Get current number of items.

Returns:
number of items

getDiagram

public Diagram getDiagram(Item item,
                          boolean isThumbnail)
Fetch diagram for this concrete item.

Parameters:
item -
isThumbnail - thumbnail flag
Returns:
new diagram

getDiagramCopy

public Diagram getDiagramCopy(Item item,
                              boolean isThumbnail)
Get diagram copy for the item.

Parameters:
item -
isThumbnail - thumbnail flag
Returns:
new copy of diagram

setEntriesFromFile

public boolean setEntriesFromFile(java.lang.String filename)
                           throws java.io.FileNotFoundException,
                                  java.io.IOException
Load entries from file and set thumbnails. All previous entries are going to be deleted.

Parameters:
filename -
Returns:
false on fatal error
Throws:
java.io.IOException - on some i/o error
java.io.FileNotFoundException - when file not found

currentSortingOrderAscending

public boolean currentSortingOrderAscending()
Get sorting order currently set.

Returns:
true when ascending order is active

sortItems

public void sortItems(Manager.SORT_TYPE sortType,
                      boolean ascending)
Sort items according to selected sorting criteria. Sorting order is not changed here.

Parameters:
sortType - type of sorting
ascending - true to set ascending sorting order
See Also:
reverseItems()

reverseItems

public void reverseItems()
Reverse items inside the collection and toggle current sorting order.


addDiagram

public void addDiagram(Item item,
                       boolean insideContentArea,
                       boolean insideThumbnailArea)
Append diagram into panels. We are looping over panels and then adding the diagram, diagram could be appended into both panels at once.

Parameters:
item -
insideContentArea - add diagram into main content area
insideThumbnailArea - add diagram into thumbnail area

refreshThumbnails

public void refreshThumbnails(Item startItem)
Refresh the thumbnail area.

Parameters:
startItem - set this item into the first position, or null

refreshThumbnails

public void refreshThumbnails()
Refresh thumbnails when free space should be available inside thumbnail are, useful especially after window maximization.


findDiagrams

public Diagram[] findDiagrams(Entry search)
Find visible thumbnail and/or full diagram by it's entry.

Parameters:
search - item to search
Returns:
found diagrams

rotateThumbnails

public void rotateThumbnails(int count)
Rotating thumbnails.

Parameters:
count - positive values means rotation of count items in the right direction, else the same count of rotations in the opposite direction

deleteAll

public void deleteAll()
Delete all items and diagrams.


updateNoOfItemsSelected

public void updateNoOfItemsSelected(boolean increment)
Update number of selected items.

Parameters:
increment - true on selection, false otherwise

selectedItems

public int selectedItems()
Returns number of selected items.

Returns:
number of items marked as selected

deleteSelected

public void deleteSelected()
Deleting of items marked as selected. We delete thumbnails firstly to let user know that something is in progress. Then loop over all registered items and delete the selected items internally. At least the panel with panel should be revalidated.


dragDiagram

public void dragDiagram(java.awt.dnd.DragGestureEvent dge)
Dragging the diagram.

Parameters:
dge - drag event

dropDiagram

public void dropDiagram(java.awt.dnd.DropTargetDropEvent dtde)
Dropping the diagram.

Parameters:
dtde - drop event

update

public void update(ItemObservable observable,
                   Constants.ItemEvents event)
Updating the observable item.

Specified by:
update in interface ItemObserver
Parameters:
observable - item or diagram to update
event - type of event
See Also:
Constants.ItemEvents