eTextReader
Class ContentPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JEditorPane
                      extended by eTextReader.ContentPane
All Implemented Interfaces:
ContentContainer, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.Scrollable

public class ContentPane
extends javax.swing.JEditorPane
implements java.beans.PropertyChangeListener, ContentContainer

An extension of JScrollPane which displays text, and can display annotations. This class also is used in conjunction with the NotationEventListener interface, which allows a class to listen for events from this pane.
ContentPane is based mostly on part of the Prototype class written by Marty Kane and Carrie Halvorsen 10/2002.

Properties that affect the behavior of this class:

Version:
1.2 10/26/2002 modified many times since
Author:
Marty Kane & Emily Tennant
See Also:
NotationEventListener, Serialized Form

Nested Class Summary
(package private)  class ContentPane.HyperlinkHandler
          This class handles hyperlink events, including clicking on hyperlinks on the page, as well as mousing into and out of annotation icons
(package private)  class ContentPane.PopupMouseHandler
          Keeps track of the current mouse pointer location.
(package private)  class ContentPane.QuickActionSelectionListener
          This class listens for changes to the caret, and enables/disables the QuickAnnotation actions depending on whether a selection has been made
 class ContentPane.SelectionOffsets
          A simple wrapper class to hold the starting and ending offsets of a selection
 
Nested classes/interfaces inherited from class javax.swing.JEditorPane
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String ANNOT_ICON
           
private  java.lang.Object annotationHighlight
           
private  OEBPackageFile book
           
static int BOOK_VIEW
           
static java.lang.String BOOKMARK_ICON
           
private  DBClient client
           
private  int containerHeight
           
private  AnnotationLinkInfo currentNotationInfo
           
private  java.lang.String currentPage
           
private  java.lang.String currentPageTitle
          The title of the current page, or UNKNOWN_TITLE if not yet known
static java.lang.String DEFAULT_PAGE
           
static java.lang.String DIAGRAM_ICON
           
static java.lang.String DISCUSS_ICON
           
private  javax.swing.text.Document doc
           
static java.lang.String FIND_ICON
           
static java.lang.String GLOBAL_BOOKMARK_ICON
           
private static boolean globalSheetModified
           
static java.lang.String HIGHLIGHT_CURSOR
           
static java.lang.String HIGHLIGHT_ICON
           
private  javax.swing.text.DefaultHighlighter highlighter
           
private  java.util.ArrayList<HighlighterInfo> highlighterInfoList
           
private static java.lang.String homeDir
           
static java.lang.String INK_ICON
           
static java.lang.String INLINE_HREF
           
static int LAST_OFFSET
           
static java.lang.String LINK_ICON
           
private  java.util.Vector<NotationEventListener> listeners
           
private  boolean loadAnnotationsOnSetPage
          Determines whether annotations should be loaded after a page is loaded.
private  java.util.Map<java.lang.Integer,Notation> loadedNotations
          This map keeps track of the annotations that have been loaded into this page
private  java.lang.String loadPage
           
private  java.util.Hashtable locations
           
protected  eTextReader.loggingInterface.Logger log
          Logs open page events
private static org.apache.log4j.Logger logger
           
private static java.awt.event.ActionListener menulistener
           
private  int mouseX
           
private  int mouseY
           
private  boolean navigation
           
static java.lang.String NO_HIGHLIGHT_ICON
           
protected  boolean pageContainedReference
          Determines whether currently loaded page contained a reference when it was loaded
static java.lang.String POPUP_ICON
           
private  ContentPane.PopupMouseHandler popupMouseHandler
           
static java.lang.String PROGRAM_ICON
           
private  java.util.Vector selectAtt
           
private  javax.swing.text.SimpleAttributeSet selectedAttributes
           
private  java.util.Vector selectEnd
           
private  java.util.Vector selectStart
           
private static java.lang.String STOP_HREF
           
static java.lang.String STOP_ICON
           
static java.lang.String TAGS_URL
           
static java.lang.String UNKNOWN_TITLE
           
private  int viewMode
           
static int WEB_VIEW
           
 
Fields inherited from class javax.swing.JEditorPane
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ContentPane(OEBPackageFile currentBook)
          Default Constructor
 
Method Summary
 void activateLink()
           
 void activateLink(boolean newTab)
           
 void addNotationEventListener(NotationEventListener listener)
          Register an object as a NotationEventListener of this pane.
 void copy()
           
 void cut()
           
 boolean deleteAnnotation(Notation notation)
          Removes the specified annotation from the document (and the database) without prompting the user.
 boolean deleteAnnotation(Notation notation, boolean prompt)
          Removes the specified annotation from the document (and the database) without prompting the user.
 HighlighterInfo deleteHighlight(int offset)
          Removes any highlight located which offset is contained within.
 void deleteHighlight(int offset, boolean remove)
           
private  Browser findParentBrowser()
           
private  javax.swing.JViewport findViewport()
          Helper function for scrollToReference, which locates the JViewport element containing this content pane
 void fireErrorEvent(NotationEvent ne)
          Send a NotationEvent to all registered listeners.
 void fireNotationEvent(NotationEvent ne)
          Send a NotationEvent to all registered listeners.
 void firePageChangeEvent(NotationEvent ne)
          Send a NotationEvent to all registered listeners.
static java.lang.String getAddress(int offset, javax.swing.text.Document doc)
          calls getAddress(int offset, Document doc, boolean end) with the value of end defaulted to false
static java.lang.String getAddress(int offset, javax.swing.text.Document doc, boolean end)
          convert an offset in the document to an element-tree adress.
 java.lang.String getAddressEnd()
           
 java.lang.String getAddressEnd(boolean inline)
          Get the address of the end of the current selection in the content pane.
 java.lang.String getAddressStart()
           
 java.lang.String getAddressStart(boolean inline)
          Get the address of the start of the current selection in the content pane.
 java.lang.String getAddressTop()
          Gets the address of the element currently loaded at the top of the page
 OEBPackageFile getBook()
           
static java.awt.Color getColor(java.lang.String color)
          Convert a String of form R G B to a Color object.
 ContentPane getContent()
           
 int getCurrentNotationID()
           
 java.lang.String getCurrentPage()
          Retrieves the URL of the currently loaded page.
 javax.swing.text.DefaultHighlighter getDefaultHighlighter()
          Retrieve the default highlighter of this content pane
 int getExtraWhitespace()
           
 float getFontSize()
           
 java.util.ArrayList<HighlighterInfo> getHighlighterInfoList()
          Retrieve the list of highlighter info from this content pane
static java.lang.String getHomeDir()
          retrieve the location where icons and the textbook are being loaded from
 void getHyperlinkListener(javax.swing.event.HyperlinkListener hl)
           
private static java.lang.String getID(javax.swing.text.Element element)
           
 ContentPane getInstance()
           
private  java.lang.String getMimeTypeFromStream(java.lang.String address)
          Retrieves the content type returned by the URL at address address by making a connection to the URL and requesting the content type from the network.
 int getMode()
           
 java.awt.Point getMousePosition()
          Get the current location of the mouse pointer
static int getOffset(java.lang.String address, javax.swing.text.Document doc)
          convert an address to an offset in the document.
 java.lang.String getPageTitle()
          retrieves the title of the currently loaded page; it looks
static java.lang.String getRGBString(java.awt.Color c)
          Converts a color object object into a string of form RGB, using space as a delimiter.
static java.lang.String getRGBString(java.awt.Color c, char delimiter)
          Convert a color object into a String of form R G B.
 java.lang.String getSelectedText()
           
 java.lang.String getSelectedTextPreview(int maxLength)
           
 ContentPane.SelectionOffsets getSelectionOffsets(java.lang.String startAddress, java.lang.String endAddress)
          Looks up the starting and ending offsets for a beginning, ending pair of addresses
private  void handlePagePropertyChange(java.beans.PropertyChangeEvent pce)
           
private  void handleUnknownContentType(java.lang.String url, java.lang.String contentType)
           
protected  void insertInlineAnnotation(Notation notation, int s, int e)
           
 boolean isHyperlinkEnabled()
          Check whether hyperlink traversal is enabled in this ContentPane.
 boolean isLoadAnnotationsOnSetPage()
           
 boolean isPageContainedReference()
          Determines whether the most recently loaded page contained a reference
 void loadHighlight(java.awt.Color theColor, java.lang.String start, java.lang.String end)
          Paints a single highlight.
 void loadHighlight(java.awt.Color color, java.lang.String start, java.lang.String end, int IDtag, java.lang.String user)
           
 void loadHighlightList(java.util.Vector list)
          Takes a Vector of Notations and paints the highlights.
protected  boolean loadLink(Notation next)
          Loads an annotation of type Notation.AnnotationType.LINK into the document
 void loadNotationList(java.util.Vector list, ViewingPrefs viewCategories)
          Takes a Vector of Notations and displays the appropriate content in the pane.
protected  boolean loadReadingBookmark(Notation notation)
          Loads a reading bookmark annotation into the content.
protected  boolean loadTextAnnotation(Notation notation)
          Loads a single text annotation.
 void loadTextAnnotationList(java.util.Vector list)
          Takes a Vector of Notations and insert the icons.
private  java.lang.String makeAnnotationHREF(Notation notation)
          Constructs the anchor and image HTML associated with the given notation.
static java.lang.String makeNotationHref(int id)
          creates a file URL appropriate for the given diagram annotation
static java.lang.String makeNotationHref(java.lang.String filename)
           
protected  void markLinkVisited(Notation notation)
          Marks the notation indicated by notation as having been visited before; it does this by changing the character attributes of the linked text/image
 void propertyChange(java.beans.PropertyChangeEvent pce)
          Listens for changes in the property "page" of the content pane.
static void registerMenuListener(java.awt.event.ActionListener ml)
           
 void registerSelectionListener(javax.swing.event.CaretListener listener)
           
 void removeAllHighlights()
           
 void removeNotationEventListener(NotationEventListener listener)
          Remove an object as a NotationEventListener of this pane.
 void scrollToReference(java.lang.String reference)
           
 void setBook(OEBPackageFile book)
           
 void setContainerHeight(int height)
           
 void setCurrentPage(java.lang.String page)
           
 void setCursorToDefault()
          This method resets the cursor for this component to its default; it does this by forwarding the request to the HTMLEditorKit's getDefaultCursor method.
 void setCustomHighlight(java.awt.Color back, java.awt.Color fore)
           
 void setDefaultCursor(java.awt.Cursor cursor)
           
 void setExtraWhitespace(int amount)
           
 void setFontSize(float size)
          Sets the font size associated with this content pane.
 void setHighlighterInfoList(java.util.ArrayList al)
           
 void setHyperlinkEnabled(boolean enabled)
          Set whether or not hyperlink traversal is enabled in this ContentPane.
 void setLoadAnnotationsOnSetPage(boolean loadAnnotationsOnSetPage)
           
 void setLoadPage(java.lang.String page)
           
 void setMode(int newMode)
           
 void setPage(java.lang.String address)
           
 void setPage(java.lang.String address, boolean reload)
          loads a new page and notifies listeners when loading is complete.
 void setPage(java.net.URL url)
          Sets the current page to the URL specified.
 void setPage(java.net.URL url, boolean reload)
          Sets the page to the URL specified, potentially forcing a reload
private  void setPageTitle()
           
 void showAnnotationSelection(java.lang.String start, java.lang.String end)
           
protected  void updateDocumentStyleSheet()
           
protected  void updateGlobalStyleSheet()
          Updates the global stylesheet by removing how inline annotations should be rendered; Also removes any style information associated with links, so that we can change the styling based on user preferences
 java.util.ArrayList updateSelection(int x, int y)
           
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createDefaultEditorKit, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, setContentType, setEditorKit, setEditorKitForContentType, setText
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loadedNotations

private java.util.Map<java.lang.Integer,Notation> loadedNotations
This map keeps track of the annotations that have been loaded into this page


BOOK_VIEW

public static final int BOOK_VIEW
See Also:
Constant Field Values

WEB_VIEW

public static final int WEB_VIEW
See Also:
Constant Field Values

viewMode

private int viewMode

UNKNOWN_TITLE

public static final java.lang.String UNKNOWN_TITLE
See Also:
Constant Field Values

LAST_OFFSET

public static final int LAST_OFFSET
See Also:
Constant Field Values

globalSheetModified

private static boolean globalSheetModified

loadAnnotationsOnSetPage

private boolean loadAnnotationsOnSetPage
Determines whether annotations should be loaded after a page is loaded. Defaults to true


mouseX

private int mouseX

mouseY

private int mouseY

popupMouseHandler

private ContentPane.PopupMouseHandler popupMouseHandler

currentPage

private java.lang.String currentPage

loadPage

private java.lang.String loadPage

currentPageTitle

private java.lang.String currentPageTitle
The title of the current page, or UNKNOWN_TITLE if not yet known


doc

private javax.swing.text.Document doc

highlighter

private javax.swing.text.DefaultHighlighter highlighter

highlighterInfoList

private java.util.ArrayList<HighlighterInfo> highlighterInfoList

selectAtt

private java.util.Vector selectAtt

selectStart

private java.util.Vector selectStart

selectEnd

private java.util.Vector selectEnd

selectedAttributes

private javax.swing.text.SimpleAttributeSet selectedAttributes

locations

private java.util.Hashtable locations

listeners

private java.util.Vector<NotationEventListener> listeners

navigation

private boolean navigation

containerHeight

private int containerHeight

client

private DBClient client

logger

private static org.apache.log4j.Logger logger

INLINE_HREF

public static final java.lang.String INLINE_HREF
See Also:
Constant Field Values

STOP_HREF

private static final java.lang.String STOP_HREF
See Also:
Constant Field Values

homeDir

private static java.lang.String homeDir

ANNOT_ICON

public static final java.lang.String ANNOT_ICON
See Also:
Constant Field Values

POPUP_ICON

public static final java.lang.String POPUP_ICON
See Also:
Constant Field Values

DISCUSS_ICON

public static final java.lang.String DISCUSS_ICON
See Also:
Constant Field Values

HIGHLIGHT_ICON

public static final java.lang.String HIGHLIGHT_ICON
See Also:
Constant Field Values

HIGHLIGHT_CURSOR

public static final java.lang.String HIGHLIGHT_CURSOR
See Also:
Constant Field Values

NO_HIGHLIGHT_ICON

public static final java.lang.String NO_HIGHLIGHT_ICON
See Also:
Constant Field Values

DIAGRAM_ICON

public static final java.lang.String DIAGRAM_ICON
See Also:
Constant Field Values

LINK_ICON

public static final java.lang.String LINK_ICON
See Also:
Constant Field Values

INK_ICON

public static final java.lang.String INK_ICON
See Also:
Constant Field Values

PROGRAM_ICON

public static final java.lang.String PROGRAM_ICON
See Also:
Constant Field Values

BOOKMARK_ICON

public static final java.lang.String BOOKMARK_ICON
See Also:
Constant Field Values

GLOBAL_BOOKMARK_ICON

public static final java.lang.String GLOBAL_BOOKMARK_ICON
See Also:
Constant Field Values

FIND_ICON

public static final java.lang.String FIND_ICON
See Also:
Constant Field Values

DEFAULT_PAGE

public static final java.lang.String DEFAULT_PAGE

STOP_ICON

public static final java.lang.String STOP_ICON
See Also:
Constant Field Values

TAGS_URL

public static java.lang.String TAGS_URL

annotationHighlight

private java.lang.Object annotationHighlight

menulistener

private static java.awt.event.ActionListener menulistener

currentNotationInfo

private AnnotationLinkInfo currentNotationInfo

log

protected eTextReader.loggingInterface.Logger log
Logs open page events


book

private OEBPackageFile book

pageContainedReference

protected boolean pageContainedReference
Determines whether currently loaded page contained a reference when it was loaded

Constructor Detail

ContentPane

public ContentPane(OEBPackageFile currentBook)
Default Constructor

Method Detail

markLinkVisited

protected void markLinkVisited(Notation notation)
Marks the notation indicated by notation as having been visited before; it does this by changing the character attributes of the linked text/image

Parameters:
notation -

setCursorToDefault

public void setCursorToDefault()
This method resets the cursor for this component to its default; it does this by forwarding the request to the HTMLEditorKit's getDefaultCursor method.


setPage

public void setPage(java.net.URL url)
Sets the current page to the URL specified. This method is overridden to ensure that all setPage requests get routed through our custom setPage logic, rather than the inherited one from JEditorPane

Overrides:
setPage in class javax.swing.JEditorPane

setPage

public void setPage(java.net.URL url,
                    boolean reload)
Sets the page to the URL specified, potentially forcing a reload

Parameters:
url - the new URL to navigate to
reload - if true, forces a reload of the page, even if it is the current page

setPage

public void setPage(java.lang.String address)
Overrides:
setPage in class javax.swing.JEditorPane

setPage

public void setPage(java.lang.String address,
                    boolean reload)
loads a new page and notifies listeners when loading is complete.

Parameters:
address - the page to load
reload - if the currently displayed page and the specified address are the same, true causes the page to reload

getMimeTypeFromStream

private java.lang.String getMimeTypeFromStream(java.lang.String address)
Retrieves the content type returned by the URL at address address by making a connection to the URL and requesting the content type from the network.

Parameters:
address - the URL to retrieve
Returns:
the mime type associated with address, or null if the content type cannot be determined, or an exception occurs trying to connect

getPageTitle

public java.lang.String getPageTitle()
retrieves the title of the currently loaded page; it looks

Returns:
a string containing the current document's title element, or the constant String UNKNOWN_TITLE if none exists

getMode

public int getMode()

setMode

public void setMode(int newMode)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pce)
Listens for changes in the property "page" of the content pane. This method is called when a new page is loaded.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setPageTitle

private void setPageTitle()

handlePagePropertyChange

private void handlePagePropertyChange(java.beans.PropertyChangeEvent pce)

showAnnotationSelection

public void showAnnotationSelection(java.lang.String start,
                                    java.lang.String end)

activateLink

public void activateLink()

activateLink

public void activateLink(boolean newTab)

setLoadPage

public void setLoadPage(java.lang.String page)

setCurrentPage

public void setCurrentPage(java.lang.String page)

deleteHighlight

public HighlighterInfo deleteHighlight(int offset)
Removes any highlight located which offset is contained within. This only removes the highlight from the ContentPane's highlight list, it doesn't deal with database interaction at all

Parameters:
offset -
Returns:
the HighlighterInfo object describing the removed highlight, or null if no highlight is found

deleteHighlight

public void deleteHighlight(int offset,
                            boolean remove)

removeAllHighlights

public void removeAllHighlights()

handleUnknownContentType

private void handleUnknownContentType(java.lang.String url,
                                      java.lang.String contentType)

loadNotationList

public void loadNotationList(java.util.Vector list,
                             ViewingPrefs viewCategories)
Takes a Vector of Notations and displays the appropriate content in the pane. This method checks the type of each element in the list, so using loadHighlightList or loadTextNotationList may be faster if all the notations to be displayed are known to be of the same type.

Parameters:
list - the Vector of Notations to display.
viewCategories - a ViewingPrefs object containing the user's preferences

makeAnnotationHREF

private java.lang.String makeAnnotationHREF(Notation notation)
Constructs the anchor and image HTML associated with the given notation. The anchor tag optionally contains contains an icon, as determined by AnnotationType.displayIconForAnnotation

Parameters:
notation - the annotation whose HTML is being generated
Returns:
a string containing the anchor and an optional icon

loadTextAnnotation

protected boolean loadTextAnnotation(Notation notation)
Loads a single text annotation.

Parameters:
notation - the Notation object representing this annotation
start - the start address of the notation being loaded. If this parameter is blank, no icon will be displayed.
end - the ending address of the notation being loaded. If this parameter is blank, no icon will be displayed.
type - the type of the notation being loaded.
body - the body of the notation being loaded.
regarding - the value of the notation's regarding field - null unless it is a reply to a discussion

loadLink

protected boolean loadLink(Notation next)
Loads an annotation of type Notation.AnnotationType.LINK into the document

Parameters:
next -

loadReadingBookmark

protected boolean loadReadingBookmark(Notation notation)
Loads a reading bookmark annotation into the content. This involves inserting two icons, one to mark the beginning of the reading assignment, and the other to mark its end. This method calls loadTextAnnotation to load the beginning icon, and then inserts the stop icon in this method

Parameters:
notation -

loadHighlightList

public void loadHighlightList(java.util.Vector list)
Takes a Vector of Notations and paints the highlights. This method does not check the list contents, so only highlights should be included

Parameters:
list - the Vector of Notations to paint.

loadHighlight

public void loadHighlight(java.awt.Color theColor,
                          java.lang.String start,
                          java.lang.String end)
Paints a single highlight.

Parameters:
theColor - the color of this highlight.
start - the start address.
end - the end address.

loadHighlight

public void loadHighlight(java.awt.Color color,
                          java.lang.String start,
                          java.lang.String end,
                          int IDtag,
                          java.lang.String user)

loadTextAnnotationList

public void loadTextAnnotationList(java.util.Vector list)
Takes a Vector of Notations and insert the icons.

Parameters:
list - the Vector of Notations to insert icons for. This method does not check the list contents, so only text notations should be included. Note, the list of notations should include the id, the starting and ending addresses, the type, and the body of the annotations.

deleteAnnotation

public boolean deleteAnnotation(Notation notation)
Removes the specified annotation from the document (and the database) without prompting the user. Calling this method is equivalent to calling deleteAnnotation (notation, true).

Parameters:
notation - the annotation to delete
Returns:
true if the annotation was successfully deleted, false otherwise

deleteAnnotation

public boolean deleteAnnotation(Notation notation,
                                boolean prompt)
Removes the specified annotation from the document (and the database) without prompting the user. If specified, the user is prompted for confirmation before the annotation is deleted. If any exist, all annotation bookmarks associated with this annotation are also deleted. Registered NotationEventListeners will be notified of both deletions if they are successful.

Parameters:
notation - the annotation to delete
prompt - whether or not the user should be prompted for confirmation before deleting the annotation
Returns:
true if the annotation was successfully deleted, false otherwise. If the user is prompted and chooses not to delete the annotation, returns true

getSelectionOffsets

public ContentPane.SelectionOffsets getSelectionOffsets(java.lang.String startAddress,
                                                        java.lang.String endAddress)
                                                 throws javax.swing.text.BadLocationException
Looks up the starting and ending offsets for a beginning, ending pair of addresses

Parameters:
startAddress -
endAddress -
Returns:
Throws:
javax.swing.text.BadLocationException

insertInlineAnnotation

protected void insertInlineAnnotation(Notation notation,
                                      int s,
                                      int e)
                               throws javax.swing.text.BadLocationException,
                                      java.io.IOException
Throws:
javax.swing.text.BadLocationException
java.io.IOException

fireNotationEvent

public void fireNotationEvent(NotationEvent ne)
Send a NotationEvent to all registered listeners.

Parameters:
ne - the NotationEvent to send.

firePageChangeEvent

public void firePageChangeEvent(NotationEvent ne)
Send a NotationEvent to all registered listeners.

Parameters:
ne - the NotationEvent to send.

fireErrorEvent

public void fireErrorEvent(NotationEvent ne)
Send a NotationEvent to all registered listeners.

Parameters:
ne - the NotationEvent to send.

addNotationEventListener

public void addNotationEventListener(NotationEventListener listener)
Register an object as a NotationEventListener of this pane. If the object is already registered (as determined by ==, not .equals), it is not added a second time

Parameters:
listener - the listener object.

removeNotationEventListener

public void removeNotationEventListener(NotationEventListener listener)
Remove an object as a NotationEventListener of this pane.

Parameters:
listener - this listener object to be removed

getCurrentPage

public java.lang.String getCurrentPage()
Retrieves the URL of the currently loaded page.

Specified by:
getCurrentPage in interface ContentContainer
Parameters:
includeRef - specifies whether or not to include the ref portion of the URL
Returns:
a String version of the currently loaded page, possibly including a reference in the form #ref

getAddressStart

public java.lang.String getAddressStart(boolean inline)
Get the address of the start of the current selection in the content pane.

Returns:
the address.

getAddressStart

public java.lang.String getAddressStart()

getAddressTop

public java.lang.String getAddressTop()
Gets the address of the element currently loaded at the top of the page

Returns:
a String address object

getAddressEnd

public java.lang.String getAddressEnd(boolean inline)
Get the address of the end of the current selection in the content pane.

Returns:
the address.

getAddressEnd

public java.lang.String getAddressEnd()

isHyperlinkEnabled

public boolean isHyperlinkEnabled()
Check whether hyperlink traversal is enabled in this ContentPane.

Returns:
true if hyperlinks are enabled, false otherwise.

setHyperlinkEnabled

public void setHyperlinkEnabled(boolean enabled)
Set whether or not hyperlink traversal is enabled in this ContentPane.

Parameters:
enabled - true if hyperlinks are to be enabled, false otherwise.

getAddress

public static java.lang.String getAddress(int offset,
                                          javax.swing.text.Document doc)
calls getAddress(int offset, Document doc, boolean end) with the value of end defaulted to false

Parameters:
offset - the integer offset in the document. This tells the method where in the document the user clicked, and allows it to compute the address.
doc - the Document model to use.

makeNotationHref

public static java.lang.String makeNotationHref(int id)
creates a file URL appropriate for the given diagram annotation

Parameters:
id - the id of the notation in question
Returns:
a String that can be used as the content of an HREF () or SRC (IMG) attribute

makeNotationHref

public static java.lang.String makeNotationHref(java.lang.String filename)

getAddress

public static java.lang.String getAddress(int offset,
                                          javax.swing.text.Document doc,
                                          boolean end)
convert an offset in the document to an element-tree adress.

Parameters:
offset - the integer offset in the document. This tells the method where in the document the user clicked, and allows it to compute the address.
doc - the Document model to use.
end - if true, moves generated address to the end of the selected block
Returns:
a string representing the address in the document

getID

private static java.lang.String getID(javax.swing.text.Element element)

getOffset

public static int getOffset(java.lang.String address,
                            javax.swing.text.Document doc)
convert an address to an offset in the document.

Parameters:
address - the address to parse.
doc - the Document model to use.
Returns:
an integer representing the offset in the document addressing by address.

getColor

public static java.awt.Color getColor(java.lang.String color)
Convert a String of form R G B to a Color object.

Parameters:
color - the String to convert.
Returns:
a Color object having the given Red, Green, and Blue attributes.

getDefaultHighlighter

public javax.swing.text.DefaultHighlighter getDefaultHighlighter()
Retrieve the default highlighter of this content pane

Returns:
the DefaultHighlighter object

getHighlighterInfoList

public java.util.ArrayList<HighlighterInfo> getHighlighterInfoList()
Retrieve the list of highlighter info from this content pane

Returns:
the ArrayList object

setHighlighterInfoList

public void setHighlighterInfoList(java.util.ArrayList al)

setDefaultCursor

public void setDefaultCursor(java.awt.Cursor cursor)

getRGBString

public static java.lang.String getRGBString(java.awt.Color c)
Converts a color object object into a string of form RGB, using space as a delimiter. Equivalent to
getRGBString (c, ' ')
Parameters:
c - the Color object to convert
Returns:
a string representing the red, green and blue components of c

getRGBString

public static java.lang.String getRGBString(java.awt.Color c,
                                            char delimiter)
Convert a color object into a String of form R G B.

Parameters:
c - the Color object to convert.
delimiter - the character used to separate the various components from each other in the string
Returns:
a String representing the Red, Green, and Blue components of c.

getHyperlinkListener

public void getHyperlinkListener(javax.swing.event.HyperlinkListener hl)

copy

public void copy()
Overrides:
copy in class javax.swing.text.JTextComponent

cut

public void cut()
Overrides:
cut in class javax.swing.text.JTextComponent

setContainerHeight

public void setContainerHeight(int height)

setExtraWhitespace

public void setExtraWhitespace(int amount)

getExtraWhitespace

public int getExtraWhitespace()

setFontSize

public void setFontSize(float size)
Sets the font size associated with this content pane. Unfortunately, it looks like the views are caching style information, and so if we're already displaying a page, it won't be redisplayed. If you want to get the size to change immediately, call setPage (getCurrentPage(), true) in order to reload the page


updateGlobalStyleSheet

protected void updateGlobalStyleSheet()
Updates the global stylesheet by removing how inline annotations should be rendered; Also removes any style information associated with links, so that we can change the styling based on user preferences


updateDocumentStyleSheet

protected void updateDocumentStyleSheet()

getFontSize

public float getFontSize()

getHomeDir

public static java.lang.String getHomeDir()
retrieve the location where icons and the textbook are being loaded from


getInstance

public ContentPane getInstance()

getMousePosition

public java.awt.Point getMousePosition()
Get the current location of the mouse pointer

Overrides:
getMousePosition in class java.awt.Component
Returns:
A Point corresponding to the current location of the mouse pointer

registerSelectionListener

public void registerSelectionListener(javax.swing.event.CaretListener listener)

registerMenuListener

public static void registerMenuListener(java.awt.event.ActionListener ml)

updateSelection

public java.util.ArrayList updateSelection(int x,
                                           int y)

getSelectedTextPreview

public java.lang.String getSelectedTextPreview(int maxLength)

getSelectedText

public java.lang.String getSelectedText()
Overrides:
getSelectedText in class javax.swing.text.JTextComponent

setCustomHighlight

public void setCustomHighlight(java.awt.Color back,
                               java.awt.Color fore)

getCurrentNotationID

public int getCurrentNotationID()

getBook

public OEBPackageFile getBook()
Returns:
the book

setBook

public void setBook(OEBPackageFile book)
Parameters:
book - the book to set

scrollToReference

public void scrollToReference(java.lang.String reference)
Overrides:
scrollToReference in class javax.swing.JEditorPane

findViewport

private javax.swing.JViewport findViewport()
Helper function for scrollToReference, which locates the JViewport element containing this content pane

Returns:

isLoadAnnotationsOnSetPage

public boolean isLoadAnnotationsOnSetPage()

setLoadAnnotationsOnSetPage

public void setLoadAnnotationsOnSetPage(boolean loadAnnotationsOnSetPage)

findParentBrowser

private Browser findParentBrowser()

isPageContainedReference

public boolean isPageContainedReference()
Determines whether the most recently loaded page contained a reference

Returns:
true if the most recently loaded page contained a reference, false otherwise

getContent

public ContentPane getContent()
Specified by:
getContent in interface ContentContainer