1 /*
2  * @(#)TextHelpModel.java	1.7 06/10/30
3  *
4  * Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6  *
7  * This code is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 only, as
9  * published by the Free Software Foundation.  Sun designates this
10  * particular file as subject to the "Classpath" exception as provided
11  * by Sun in the LICENSE file that accompanied this code.
12  *
13  * This code is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16  * version 2 for more details (a copy is included in the LICENSE file that
17  * accompanied this code).
18  *
19  * You should have received a copy of the GNU General Public License version
20  * 2 along with this work; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24  * CA 95054 USA or visit www.sun.com if you need additional information or
25  * have any questions.
26  */
27 
28 package javax.help;
29 
30 import javax.help.event.*;
31 
32 /**
33  * The interface to a HelpModel that manipulates text.
34  *
35  * It provides additional text operations.
36  */
37 
38 public interface TextHelpModel extends HelpModel {
39     /**
40      * Gets the title of the document.
41      *
42      * @return The title of document visited.
43      */
getDocumentTitle()44     public String getDocumentTitle();
45 
46     /**
47      * Sets the title of the document.
48      * A property change event is generated.
49      *
50      * @param title The title currently shown.
51      */
setDocumentTitle(String title)52     public void setDocumentTitle(String title);
53 
54 
55     /**
56      * Removes all highlights on the current document.
57      */
removeAllHighlights()58     public void removeAllHighlights();
59 
60     /**
61      * Adds a highlight to a range of positions in a document.
62      *
63      * @param pos0 Start position.
64      * @param pos1 End position.
65      */
addHighlight(int pos0, int pos1)66     public void addHighlight(int pos0, int pos1);
67 
68     /**
69      * Sets the highlights to be a range of positions in a document.
70      *
71      * @param h The array of highlight objects.
72      */
setHighlights(Highlight[] h)73     public void setHighlights(Highlight[] h);
74 
75     /**
76      * Gets all highlights.
77      */
getHighlights()78     public Highlight[] getHighlights();
79 
80     /**
81      * Adds a listener for a TextHelpModel.
82      */
addTextHelpModelListener(TextHelpModelListener l)83     public void addTextHelpModelListener(TextHelpModelListener l);
84 
85     /**
86      * Removes a listener for a TextHelpModel.
87      */
removeTextHelpModelListener(TextHelpModelListener l)88     public void removeTextHelpModelListener(TextHelpModelListener l);
89 
90     /**
91      * This is very similar to javax.swing.text.Highlighter.Highlight
92      * except that it does not use the notion of HighlightPainter.
93      */
94     public interface Highlight {
95 	/**
96 	 * Gets the starting model offset of the highlight.
97 	 *
98 	 * @return The starting offset >= 0.
99 	 */
getStartOffset()100 	public int getStartOffset();
101 
102 	/**
103 	 * Gets the ending model offset of the highlight.
104 	 *
105 	 * @return The ending offset >= 0.
106 	 */
getEndOffset()107 	public int getEndOffset();
108     }
109 }
110