KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > util > swing > MutablePositionRegion


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.editor.util.swing;
21
22 import java.util.Comparator JavaDoc;
23 import java.util.List JavaDoc;
24 import javax.swing.text.BadLocationException JavaDoc;
25 import javax.swing.text.Document JavaDoc;
26 import javax.swing.text.Position JavaDoc;
27
28 /**
29  * A pair of positions delimiting a text region in a swing document.
30  * <br/>
31  * At all times it should be satisfied that
32  * {@link #getStartOffset()} &lt;= {@link #getEndOffset()}.
33  *
34  * @author Miloslav Metelka
35  * @since 1.6
36  */

37
38 public class MutablePositionRegion extends PositionRegion {
39
40     /**
41      * Construct new mutable position region.
42      *
43      * @param startPosition non-null start position of the region &lt;= end position.
44      * @param endPosition non-null end position of the region &gt;= start position.
45      */

46     public MutablePositionRegion(Position JavaDoc startPosition, Position JavaDoc endPosition) {
47         super(startPosition, endPosition);
48     }
49     
50     /**
51      * Construct new mutable position region based on the knowledge
52      * of the document and starting and ending offset.
53      */

54     public MutablePositionRegion(Document JavaDoc doc, int startOffset, int endOffset) throws BadLocationException JavaDoc {
55         this(doc.createPosition(startOffset), doc.createPosition(endOffset));
56     }
57
58     /**
59      * Set a new start and end positions of this region.
60      * <br/>
61      * They should satisfy
62      * {@link #getStartOffset()} &lt;= {@link #getEndOffset()}.
63      *
64      * @param startPosition non-null new start position of this region.
65      * @since 1.10
66      */

67     public final void reset(Position JavaDoc startPosition, Position JavaDoc endPosition) {
68         resetImpl(startPosition, endPosition);
69     }
70     
71     /**
72      * Set a new start position of this region.
73      * <br/>
74      * It should satisfy
75      * {@link #getStartOffset()} &lt;= {@link #getEndOffset()}.
76      *
77      * @param startPosition non-null new start position of this region.
78      */

79     public final void setStartPosition(Position JavaDoc startPosition) {
80         setStartPositionImpl(startPosition);
81     }
82
83     /**
84      * Set a new end position of this region.
85      * <br/>
86      * It should satisfy
87      * {@link #getStartOffset()} &lt;= {@link #getEndOffset()}.
88      *
89      * @param endPosition non-null new start position of this region.
90      */

91     public final void setEndPosition(Position JavaDoc endPosition) {
92         setEndPositionImpl(endPosition);
93     }
94
95 }
96
Popular Tags