|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjecteTextReader.User
public class User
This class stores attributes about a user. This class is a singleton, and a reference to the only instance can be obtained using the static method getUser (). If the user changes, then the method setUser(String) should be called, which will update the attributes to reflect the new user
Changes to information about the user are made using the various setXXX methods in this class. Other objects can learn about changes made through these methods by registering as a property change listener. The available properties are enumerated in the enum Property.
Nested Class Summary | |
---|---|
(package private) class |
User.HighlighterEntry<K,V>
Provides a simple implementation of the Map.Entry interface, allowing storage of a key and value pair |
static class |
User.Property
|
Field Summary | |
---|---|
private java.util.Map<Notation.AnnotationType,javax.swing.KeyStroke> |
acceleratorMap
The keystrokes used as accelerators to create new annotations |
private java.beans.PropertyChangeSupport |
changeSupport
|
(package private) DBClient |
client
|
private java.lang.String |
course
The course associated with the currently loaded textbook |
private OEBPackageFile |
currentBook
Maintains a reference to which book is currently open in the browser Debatable as to whether or not this should be a single value, but we're going to go with it |
private static java.awt.Color[] |
defaultHighlightColors
|
private static java.lang.String[] |
defaultHighlightNames
|
private float |
fontSize
The current font size for the user |
private java.util.Map<java.lang.String,java.awt.Color> |
highlighterColors
The set of colors used for highlighters; map is indexed by highlighter name |
(package private) static User |
instance
|
private boolean |
notationsEnabled
Are notations currently enabled for this user? |
private java.util.Hashtable<ApplicationPreferences,java.lang.Object> |
preferences
The set of application preferences associated with the current user |
private boolean |
userHadApplicationPreferences
Whether a set of application preferences were loaded from the database, or a set was loaded from the database |
private java.lang.String |
userName
The user name of the currently logged in user |
private ViewingPrefs |
viewPreferences
The set of viewing preferences for the user |
private java.util.Set<java.lang.Integer> |
visitedLinks
The links that this user has currently followed |
Constructor Summary | |
---|---|
protected |
User()
Constructs a User instance. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener to receive property change events for all properties maintained by this object |
void |
addPropertyChangeListener(User.Property propertyName,
java.beans.PropertyChangeListener listener)
Adds a listener for changes to a specific property, as specified by the propertyName parameter The possible property names are: |
boolean |
annotationVisisted(int id)
Determines whether or not the annotation identified by the given id has been previously visited by the current user |
void |
fireIndexedPropertyChange(User.Property propertyName,
int index,
boolean oldValue,
boolean newValue)
|
void |
fireIndexedPropertyChange(User.Property propertyName,
int index,
int oldValue,
int newValue)
|
void |
fireIndexedPropertyChange(User.Property propertyName,
int index,
java.lang.Object oldValue,
java.lang.Object newValue)
|
void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
|
void |
firePropertyChange(User.Property propertyName,
boolean oldValue,
boolean newValue)
|
void |
firePropertyChange(User.Property propertyName,
int oldValue,
int newValue)
|
void |
firePropertyChange(User.Property propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
|
javax.swing.KeyStroke |
getAccelerator(Notation.AnnotationType annotationType)
Retrieves the accelerator key used to create a new annotation of the given type |
java.lang.Object |
getApplicationPreference(ApplicationPreferences preferenceType)
Return the value of the given preference |
java.util.Hashtable<ApplicationPreferences,java.lang.Object> |
getApplicationPreferences()
Returns a Hashtable containing all of the application preferences |
java.lang.String |
getCourse()
Return the course associated with the currently open book |
OEBPackageFile |
getCurrentBook()
|
static java.awt.Color[] |
getDefaultHighlightColors()
|
static java.lang.String[] |
getDefaultHighlightNames()
|
float |
getFontSize()
Returns the current font size for the user |
java.awt.Color |
getHighlighterColor(java.lang.String highlighterName)
|
java.util.Set<java.util.Map.Entry<java.lang.String,java.awt.Color>> |
getHighlighters()
Retrieves the set of highlighters |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
|
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners(User.Property propertyName)
|
static User |
getUser()
Returns a User object representing the current user |
java.lang.String |
getUserName()
Retrieves the user name of the current user |
ViewingPrefs |
getViewPreferences()
|
boolean |
hasListeners(User.Property propertyName)
|
boolean |
isNotationsEnabled()
Determines whether or not notations are enabled for the current user |
boolean |
isUserHadApplicationPreferences()
|
private boolean |
loadApplicationPreferences()
Loads the user's application preferences from the database; keys that do not have values are loaded with the default values |
private void |
loadHighlighters()
Retrieves the highlighter colors from the database for the current user. |
private void |
loadViewPreferences()
Loads the current user's viewing preferences out of the database, and stores them for later use |
void |
recordAnnotationVisited(int id)
Records the fact that the specified annotation has been visited by the current user. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
removePropertyChangeListener(User.Property propertyName,
java.beans.PropertyChangeListener listener)
|
void |
setAccelerator(ApplicationPreferences key,
javax.swing.KeyStroke accelerator)
|
void |
setAccelerator(Notation.AnnotationType annotationType,
javax.swing.KeyStroke keystroke)
|
void |
setCourse(java.lang.String course)
Sets the course associated with the currently open book. |
void |
setCurrentBook(OEBPackageFile currentBook)
|
void |
setFontSize(float fontSize)
Changes the font size for the current user, in both this object and in the database Fires a property change message with a key of Property.FONT_SIZE |
void |
setNotationsEnabled(boolean notationsEnabled)
Enables or disables notations for the current user, in both this object and the database. |
void |
setUser(java.lang.String userName)
Changes the identify of the current user. |
boolean |
updateHighlighters(java.util.List<HighlighterUpdateInfo> updated)
Updates the highlighter information for each element in the updated list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static User instance
private java.beans.PropertyChangeSupport changeSupport
private static java.lang.String[] defaultHighlightNames
private static java.awt.Color[] defaultHighlightColors
private java.util.Map<java.lang.String,java.awt.Color> highlighterColors
private java.util.Map<Notation.AnnotationType,javax.swing.KeyStroke> acceleratorMap
private java.lang.String userName
private java.lang.String course
private java.util.Set<java.lang.Integer> visitedLinks
private ViewingPrefs viewPreferences
private java.util.Hashtable<ApplicationPreferences,java.lang.Object> preferences
private boolean userHadApplicationPreferences
private OEBPackageFile currentBook
private boolean notationsEnabled
private float fontSize
DBClient client
Constructor Detail |
---|
protected User()
Method Detail |
---|
public static User getUser()
public java.awt.Color getHighlighterColor(java.lang.String highlighterName)
public boolean updateHighlighters(java.util.List<HighlighterUpdateInfo> updated)
updated
-
public void setUser(java.lang.String userName)
userName
- private boolean loadApplicationPreferences()
public void setAccelerator(Notation.AnnotationType annotationType, javax.swing.KeyStroke keystroke)
public void setAccelerator(ApplicationPreferences key, javax.swing.KeyStroke accelerator)
private void loadViewPreferences()
private void loadHighlighters()
public java.util.Set<java.util.Map.Entry<java.lang.String,java.awt.Color>> getHighlighters()
public java.lang.String getUserName()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- public void addPropertyChangeListener(User.Property propertyName, java.beans.PropertyChangeListener listener)
propertyName
- listener
- public void fireIndexedPropertyChange(User.Property propertyName, int index, boolean oldValue, boolean newValue)
public void fireIndexedPropertyChange(User.Property propertyName, int index, int oldValue, int newValue)
public void fireIndexedPropertyChange(User.Property propertyName, int index, java.lang.Object oldValue, java.lang.Object newValue)
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
public void firePropertyChange(User.Property propertyName, boolean oldValue, boolean newValue)
public void firePropertyChange(User.Property propertyName, int oldValue, int newValue)
public void firePropertyChange(User.Property propertyName, java.lang.Object oldValue, java.lang.Object newValue)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(User.Property propertyName)
public boolean hasListeners(User.Property propertyName)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(User.Property propertyName, java.beans.PropertyChangeListener listener)
public static java.awt.Color[] getDefaultHighlightColors()
public static java.lang.String[] getDefaultHighlightNames()
public OEBPackageFile getCurrentBook()
public void setCurrentBook(OEBPackageFile currentBook)
public ViewingPrefs getViewPreferences()
public boolean isNotationsEnabled()
public void setNotationsEnabled(boolean notationsEnabled)
notationsEnabled
- public float getFontSize()
public void setFontSize(float fontSize)
fontSize
- public javax.swing.KeyStroke getAccelerator(Notation.AnnotationType annotationType)
annotationType
- the type of annotation that is being created
public java.util.Hashtable<ApplicationPreferences,java.lang.Object> getApplicationPreferences()
public java.lang.Object getApplicationPreference(ApplicationPreferences preferenceType)
preferenceType
-
public java.lang.String getCourse()
public void setCourse(java.lang.String course)
course
- the identifier for the new coursepublic boolean annotationVisisted(int id)
id
- the id of an annotation.public void recordAnnotationVisited(int id)
id
- the id of an annotationpublic boolean isUserHadApplicationPreferences()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |