Module org.jpo

Class PictureCollection

java.lang.Object
org.jpo.datamodel.PictureCollection

public class PictureCollection extends Object
This object holds the state of the picture collection
  • Constructor Details

    • PictureCollection

      public PictureCollection()
      Constructs a new PictureCollection object with a root object
  • Method Details

    • fileLoad

      public static void fileLoad(File fileToLoad, SortableDefaultMutableTreeNode node) throws FileNotFoundException
      Loads the collection indicated by the File at the supplied node
      Parameters:
      fileToLoad - The File object that is to be loaded.
      node - the node to load it into
      Throws:
      FileNotFoundException - When no good
    • streamLoad

      public static void streamLoad(InputStream is, SortableDefaultMutableTreeNode node)
      Loads the collection indicated by the Input stream at the "this" node.
      Parameters:
      is - The InputStream that is to be loaded.
      node - the node to load it into
    • clearCollection

      public void clearCollection()
      This method wipes out the data in the picture collection. As it updates the TreeModel it has been made synchronous on the EDT.
    • getTreeModel

      public DefaultTreeModel getTreeModel()
      The DefaultTreeModel allows notification of tree change events to listening objects.
      Returns:
      The tree Model
    • getSendModelUpdates

      public boolean getSendModelUpdates()
      Returns true if model updates should be sent to the listeners
      Returns:
      true if model updates are sent around
    • setSendModelUpdates

      public void setSendModelUpdates(boolean status)
      Sets the flag whether to send model updates or not
      Parameters:
      status - the new flag value
    • sendNodeStructureChanged

      public void sendNodeStructureChanged(TreeNode changedNode)
      This method sends a nodeStructureChanged event through to the listeners of the Collection's model. It makes sure the event is sent on the EDT
      Parameters:
      changedNode - The node that was changed
    • sendNodeChanged

      public void sendNodeChanged(TreeNode changedNode)
      This method sends a nodeChanged event through to the listeners of the Collection's model. It makes sure the event is sent on the EDT
      Parameters:
      changedNode - The node that was changed
    • sendNodesWereInserted

      public void sendNodesWereInserted(TreeNode changedNode, int[] childIndices)
      This method sends a nodesWereInserted event through to the listeners of the Collection's model.
      Parameters:
      changedNode - The node that was inserted
      childIndices - The Child indices
    • sendNodesWereRemoved

      public void sendNodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren)
      This method sends a nodesWereRemoved event through to the listeners of the Collection's model. It makes sure the event is sent on the EDT
      Parameters:
      node - parent node
      childIndices - The Child indices
      removedChildren - the removed nodes
    • getRootNode

      public SortableDefaultMutableTreeNode getRootNode()
      This method returns the root node of the collection
      Returns:
      the root node
    • setUnsavedUpdates

      public void setUnsavedUpdates()
      This method marks the collection as having unsaved updates.
      See Also:
      • unsavedUpdates
    • getUnsavedUpdates

      public boolean getUnsavedUpdates()
      This method returns true if the collection has unsaved updates, false if it has none
      Returns:
      true if there are unsaved updates, false if there are none
      See Also:
      • unsavedUpdates
    • setUnsavedUpdates

      public void setUnsavedUpdates(boolean unsavedUpdates)
      This method allows the programmer to set whether the tree has unsaved updates or not.
      Parameters:
      unsavedUpdates - Set to true if there are unsaved updates, false if there are none
      See Also:
      • unsavedUpdates
    • getAllowEdits

      public boolean getAllowEdits()
      Returns true if edits are allowed on this collection
      Returns:
      true if edits are allowed on this collection
    • setAllowEdits

      public void setAllowEdits(boolean newAllowEdits)
      sets the allow-edit allowedEdits of this collection
      Parameters:
      newAllowEdits - pass true to allow edits, false to forbid
    • getQueriesTreeModel

      public DefaultTreeModel getQueriesTreeModel()
      Call this method when you need the TreeModel for the queries
      Returns:
      The treemodel of the queries
    • setQueriesTreeModel

      public void setQueriesTreeModel(DefaultTreeModel defaultTreeModel)
      Call this method when you need to set the TreeModel for the queries
      Parameters:
      defaultTreeModel - the tree model
    • getQueriesRootNode

      public DefaultMutableTreeNode getQueriesRootNode()
      Call this method when you need the root Node for the queries
      Returns:
      the root node
    • createQueriesTreeModel

      public void createQueriesTreeModel()
      Call this method when you need to create a new TreeModel for the queries.
    • getYearsTreeNode

      public DefaultMutableTreeNode getYearsTreeNode()
      Node for the Years tree
      Returns:
      the node
    • getCategoriesTreeNode

      public DefaultMutableTreeNode getCategoriesTreeNode()
      Node for the Years tree
      Returns:
      the node
    • addYearQuery

      public void addYearQuery(String year)
      Adds a year query
      Parameters:
      year - the year
    • clearQueriesTreeModel

      public void clearQueriesTreeModel()
      Clear out the nodes in the existing queries Tree Model
    • addQueryToTreeModel

      public void addQueryToTreeModel(Query query)
      Adds a query to the Query Tree Model.
      Parameters:
      query - The new Query to add
    • addCategoryQueryToTreeModel

      public void addCategoryQueryToTreeModel(Query query)
      Adds a query to the Query Category Tree Model.
      Parameters:
      query - The new Query to add
    • addCategory

      public void addCategory(Integer index, String category)
      This adds a category to the HashMap
      Parameters:
      index - The index
      category - The category
    • addCategory

      public Integer addCategory(String category)
      This adds a category to the HashMap if it doesn't already exist and returns the corresponding Integer code for the category.
      Parameters:
      category - The category to save or look up
      Returns:
      the number at which the category was added
    • renameCategory

      public void renameCategory(Integer key, String category)
      Renames a category in the HashMap
      Parameters:
      key - The Key
      category - The category
    • getCategoryIterator

      public Iterator<Integer> getCategoryIterator()
      Returns an iterator through the categories keys
      Returns:
      an iterator over the categories keys
    • getCategoryKeySet

      public Set<Integer> getCategoryKeySet()
      Returns a set of category keys
      Returns:
      a set of category keys
    • getSortedCategoryStream

      public Stream<Map.Entry<Integer,String>> getSortedCategoryStream()
      Returns a Java Stream of sorted categories suitable for presenting the categories in a sorted pick list.
      Returns:
      A Steam of Category entries
    • getCategory

      public String getCategory(Integer key)
      Returns the Value for the key
      Parameters:
      key - the key for the value to be returned-
      Returns:
      Returns the Value for the Key
    • removeCategory

      public void removeCategory(Integer key)
      Removes the category associated with the
      Parameters:
      key - The Key to be removed
    • removeCategoryUsage

      public void removeCategoryUsage(Object key, SortableDefaultMutableTreeNode startNode)
      Removes the category from the nodes using it
      Parameters:
      key - The category to poll
      startNode - The node from which to start
    • addToMailSelection

      public void addToMailSelection(SortableDefaultMutableTreeNode node)
      This method places the current SDMTN into the mailSelection HashSet.
      Parameters:
      node - The node going into the selection
    • toggleMailSelected

      public void toggleMailSelected(SortableDefaultMutableTreeNode node)
      This method inverts the status of the node on the mail selection HashSet
      Parameters:
      node - The node
    • clearMailSelection

      public void clearMailSelection()
      This method clears the mailSelection HashSet.
    • removeFromMailSelection

      public void removeFromMailSelection(SortableDefaultMutableTreeNode node)
      This method removes the current SDMTN from the mailSelection HashSet.
      Parameters:
      node - the node to poll from the mail selection
    • isMailSelected

      public boolean isMailSelected(SortableDefaultMutableTreeNode node)
      This returns whether the SDMTN is part of the mailSelection HashSet.
      Parameters:
      node - The node
      Returns:
      true if part of the mailing set, false if not
    • countMailSelectedNodes

      public int countMailSelectedNodes()
      returns the count of mail-selected nodes
      Returns:
      the count of selected nodes
    • getMailSelectedNodes

      public List<SortableDefaultMutableTreeNode> getMailSelectedNodes()
      Returns the email-selected nodes
      Returns:
      the nodes selected for emailing
    • isInCollection

      public boolean isInCollection(File file)
      This method returns true if the indicated picture file is already a member of the collection. Otherwise, it returns false.
      Parameters:
      file - The File object of the file to check for
      Returns:
      true if found, false if not
    • isInCollection

      public boolean isInCollection(String sha256)
      This method returns true if the indicated checksum is already a member of the collection. Otherwise, it returns false.
      Parameters:
      sha256 - The checksum of the picture to check for
      Returns:
      true if found, false if not
    • isFileLoading

      public boolean isFileLoading()
      Is a thread loading a file?
      Returns:
      true if a thread is loading a file
    • getXmlFile

      public File getXmlFile()
      This method returns the xml file for the collection
      Returns:
      The xml file of the collection
    • setXmlFile

      public void setXmlFile(File file)
      This method sets the file which represents the current collection. It updates the title of the main application window too.
      Parameters:
      file - set the file name
    • fileLoad

      public void fileLoad(File file) throws FileNotFoundException
      Loads the specified file into the root node of the collection. It ought to be called off the EDT. Then the clearCollection runs on the same thread.
      Parameters:
      file - The file
      Throws:
      FileNotFoundException - bubble-up exception
    • fileSave

      public void fileSave()
      method that saves the entire index in XML format.
    • findLinkingGroups

      public Set<SortableDefaultMutableTreeNode> findLinkingGroups(SortableDefaultMutableTreeNode suppliedNode)
      This method returns a Set of the group nodes that hold a reference to the picture filename of the supplied node. This is used in the Navigate-to function of the pop-up menu
      Parameters:
      suppliedNode - The node with the picture for which the owning parent nodes need to be found
      Returns:
      group nodes that have a child with the same picture
    • addToSelectedNodes

      public void addToSelectedNodes(SortableDefaultMutableTreeNode node)
      This method places the current SortableDefaultMutableTreeNode into the selection HashSet.
      Parameters:
      node - The node
    • removeFromSelection

      public void removeFromSelection(SortableDefaultMutableTreeNode node)
      This method removes the current SDMTN from the selection
      Parameters:
      node - the node to poll
    • clearSelection

      public void clearSelection()
      This method clears selection that refers to the selected highlighted thumbnails and fires unselectedEvents
    • isSelected

      public boolean isSelected(SortableDefaultMutableTreeNode node)
      This returns whether the SDMTN is part of the selection HashSet.
      Parameters:
      node - the node
      Returns:
      true if the node is selected
    • getSelection

      public List<SortableDefaultMutableTreeNode> getSelection()
      returns an array of the selected nodes.
      Returns:
      an array of the selected nodes
    • countSelectedNodes

      public int countSelectedNodes()
      returns the count of selected nodes
      Returns:
      the count of selected nodes
    • addTreeModelListener

      public void addTreeModelListener(TreeModelListener treeModelListener)
      Adds a treeModelListener to the collection. Uses the treeModel associated with the PictureCollection to handle the details
      Parameters:
      treeModelListener - The listener to add
    • removeTreeModelListener

      public void removeTreeModelListener(TreeModelListener treeModelListener)
      Removes a treeModelListener from the collection. Uses the treeModel associated with the PictureCollection to handle the details
      Parameters:
      treeModelListener - The listener to remove