Class HistoryFile


  • public class HistoryFile
    extends java.lang.Object
    The history file contains data from previous uses of Jmol.
    Author:
    Bradley A. Smith (bradley@baysmith.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.io.File file
      The location of the history file.
      (package private) java.lang.String header
      The information written to the header of the history file.
      private java.util.Properties properties
      The data stored in the history file.
    • Constructor Summary

      Constructors 
      Constructor Description
      HistoryFile​(java.io.File file, java.lang.String header)
      Creates a history file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addProperties​(java.util.Properties properties)
      Adds the given properties to the history.
      boolean addProperty​(java.lang.String key, java.lang.String value)
      Adds the given property to the history.
      private boolean addWindowBorder​(java.lang.String name, java.awt.Point border)
      Adds the window border to the history.
      private boolean addWindowDim​(java.lang.String name, java.awt.Dimension d)  
      void addWindowInfo​(java.lang.String name, java.awt.Component window, java.awt.Point border)
      Adds the window informations to the history.
      void addWindowInfo​(java.lang.String name, java.awt.Component window, java.awt.Point border, java.awt.Dimension d)  
      void addWindowInnerInfo​(java.lang.String name, java.awt.Component window, java.awt.Dimension inner)  
      private boolean addWindowPosition​(java.lang.String name, java.awt.Point position)
      Adds the window position to the history.
      private boolean addWindowSize​(java.lang.String name, java.awt.Dimension size)
      Adds the window size to the history.
      private boolean addWindowVisibility​(java.lang.String name, boolean visible)
      Adds the window visibility to the history.
      void clear()  
      java.io.File getFile()  
      java.util.Properties getProperties()  
      java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
      Get the value of a property
      java.awt.Point getWindowBorder​(java.lang.String name)  
      java.awt.Dimension getWindowInnerDimension​(java.lang.String name)  
      java.awt.Point getWindowPosition​(java.lang.String name)  
      java.awt.Dimension getWindowSize​(java.lang.String name)  
      private java.lang.Boolean getWindowVisibility​(java.lang.String name)  
      private void load()
      Loads properties from the history file.
      void repositionWindow​(java.lang.String name, java.awt.Component window)
      Uses the informations in the history to reposition the window.
      void repositionWindow​(java.lang.String name, java.awt.Component window, int minWidth, int minHeight, boolean allowVisible)
      Uses the informations in the history to reposition the window.
      void save()
      Saves properties to the history file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • properties

        private java.util.Properties properties
        The data stored in the history file.
      • file

        java.io.File file
        The location of the history file.
      • header

        java.lang.String header
        The information written to the header of the history file.
    • Constructor Detail

      • HistoryFile

        public HistoryFile​(java.io.File file,
                           java.lang.String header)
        Creates a history file.
        Parameters:
        file - the location of the file.
        header - information written to the header of the file.
    • Method Detail

      • addProperties

        public void addProperties​(java.util.Properties properties)
        Adds the given properties to the history. If a property existed previously, it will be replaced.
        Parameters:
        properties - the properties to add.
      • getProperties

        public java.util.Properties getProperties()
        Returns:
        The properties stored in the history file.
      • getProperty

        public java.lang.String getProperty​(java.lang.String key,
                                            java.lang.String defaultValue)
        Get the value of a property
        Parameters:
        key - Key of the property to find
        defaultValue - Default value to use if the property is not found
        Returns:
        The value of the property
      • addProperty

        public boolean addProperty​(java.lang.String key,
                                   java.lang.String value)
        Adds the given property to the history. If it existed previously, it will be replaced.
        Parameters:
        key - Key of the property to add
        value - Value of the property
        Returns:
        true if the property is modified
      • getWindowPosition

        public java.awt.Point getWindowPosition​(java.lang.String name)
        Parameters:
        name - Window name
        Returns:
        Position of the window stored in the history file
      • getWindowInnerDimension

        public java.awt.Dimension getWindowInnerDimension​(java.lang.String name)
        Parameters:
        name - Window name
        Returns:
        Inner dimension of the window stored in the history file
      • getWindowBorder

        public java.awt.Point getWindowBorder​(java.lang.String name)
        Parameters:
        name - window name
        Returns:
        window border stored in the history file
      • getWindowSize

        public java.awt.Dimension getWindowSize​(java.lang.String name)
        Parameters:
        name - Window name
        Returns:
        Size of the window stored in the history file
      • getWindowVisibility

        private java.lang.Boolean getWindowVisibility​(java.lang.String name)
        Parameters:
        name - Window name
        Returns:
        Visibility of the window stored in the history file
      • addWindowPosition

        private boolean addWindowPosition​(java.lang.String name,
                                          java.awt.Point position)
        Adds the window position to the history. If it existed previously, it will be replaced.
        Parameters:
        name - Window name
        position - Window position
        Returns:
        Tells if the properties are modified
      • addWindowBorder

        private boolean addWindowBorder​(java.lang.String name,
                                        java.awt.Point border)
        Adds the window border to the history. If it existed previously, it will be replaced.
        Parameters:
        name - window name
        border - Window border
        Returns:
        Tells if the properties are modified
      • addWindowDim

        private boolean addWindowDim​(java.lang.String name,
                                     java.awt.Dimension d)
      • addWindowSize

        private boolean addWindowSize​(java.lang.String name,
                                      java.awt.Dimension size)
        Adds the window size to the history. If it existed previously, it will be replaced.
        Parameters:
        name - Window name
        size - Window size
        Returns:
        Tells if the properties are modified
      • addWindowVisibility

        private boolean addWindowVisibility​(java.lang.String name,
                                            boolean visible)
        Adds the window visibility to the history. If it existed previously, it will be replaced.
        Parameters:
        name - Window name
        visible - Window visibilite
        Returns:
        Tells if the properties are modified
      • addWindowInfo

        public void addWindowInfo​(java.lang.String name,
                                  java.awt.Component window,
                                  java.awt.Point border)
        Adds the window informations to the history. If it existed previously, it will be replaced.
        Parameters:
        name - Window name
        window - Window
        border - Point border
      • addWindowInfo

        public void addWindowInfo​(java.lang.String name,
                                  java.awt.Component window,
                                  java.awt.Point border,
                                  java.awt.Dimension d)
      • addWindowInnerInfo

        public void addWindowInnerInfo​(java.lang.String name,
                                       java.awt.Component window,
                                       java.awt.Dimension inner)
      • repositionWindow

        public void repositionWindow​(java.lang.String name,
                                     java.awt.Component window,
                                     int minWidth,
                                     int minHeight,
                                     boolean allowVisible)
        Uses the informations in the history to reposition the window.
        Parameters:
        name - Window name
        window - Window
        minWidth -
        minHeight -
        allowVisible - TODO
      • repositionWindow

        public void repositionWindow​(java.lang.String name,
                                     java.awt.Component window)
        Uses the informations in the history to reposition the window.
        Parameters:
        name - Window name
        window - Window
      • getFile

        public java.io.File getFile()
      • load

        private void load()
        Loads properties from the history file.
      • save

        public void save()
        Saves properties to the history file.
      • clear

        public void clear()