OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [java/] [awt/] [im/] [InputMethodHighlight.java] - Blame information for rev 771

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 771 jeremybenn
/* InputMethodHighlight.java -- highlights the current text selection
2
   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package java.awt.im;
39
 
40
import java.awt.Toolkit;
41
import java.text.Annotation;
42
import java.text.AttributedCharacterIterator;
43
import java.util.Map;
44
import java.awt.font.TextAttribute;
45
 
46
/**
47
 * This describes the highlight attributes of text composed in an input method.
48
 * The description includes an abstract level (whether text has been converted
49
 * yet, and whether it is selected), and a concrete level (which style
50
 * attributes are used in rendering). If no concrete level is defined, the
51
 * renderer should use
52
 * {@link Toolkit#mapInputMethodHighlight(InputMethodHighlight)}. An example
53
 * of conversion state is kana -> kanji.
54
 *
55
 * <p>Instances of this class are typically used in
56
 * AttributedCharacterIterators, and may be wrapped in Annotations to separate
57
 * text segments.
58
 *
59
 * @author Eric Blake (ebb9@email.byu.edu)
60
 * @see AttributedCharacterIterator
61
 * @see Annotation
62
 * @since 1.2
63
 * @status updated to 1.4
64
 */
65
public class InputMethodHighlight
66
{
67
  /** Raw text state (before conversion). */
68
  public static final int RAW_TEXT = 0;
69
 
70
  /** Converted text state (after conversion). */
71
  public static final int CONVERTED_TEXT = 1;
72
 
73
  /** Default do-nothing highlighting for unselected raw text. */
74
  public static final InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT
75
    = new InputMethodHighlight(false, RAW_TEXT);
76
 
77
  /** Default do-nothing highlighting for selected raw text. */
78
  public static final InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT
79
    = new InputMethodHighlight(true, RAW_TEXT);
80
 
81
  /** Default do-nothing highlighting for unselected converted text. */
82
  public static final InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
83
    = new InputMethodHighlight(false, CONVERTED_TEXT);
84
 
85
  /** Default do-nothing highlighting for selected converted text. */
86
  public static final InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT
87
    = new InputMethodHighlight(true, CONVERTED_TEXT);
88
 
89
  /** Whether the highlighting applies to selected text. */
90
  private final boolean selected;
91
 
92
  /** The state of highlighted text. */
93
  private final int state;
94
 
95
  /** Any variation on the highlighting style. */
96
  private final int variation;
97
 
98
  /** The unmodifiable map of rendering styles. */
99
  private final Map<TextAttribute, ?> style;
100
 
101
  /**
102
   * Create an input method highlight style, with variation 0 and null style
103
   * mapping.
104
   *
105
   * @param selected whether the text range is selected
106
   * @param state either {@link #RAW_TEXT} or {@link #CONVERTED_TEXT}
107
   * @throws IllegalArgumentException if state is invalid
108
   */
109
  public InputMethodHighlight(boolean selected, int state)
110
  {
111
    this(selected, state, 0, null);
112
  }
113
 
114
  /**
115
   * Create an input method highlight style, with null style mapping.
116
   *
117
   * @param selected whether the text range is selected
118
   * @param state either {@link #RAW_TEXT} or {@link #CONVERTED_TEXT}
119
   * @param variation the style variation
120
   * @throws IllegalArgumentException if state is invalid
121
   */
122
  public InputMethodHighlight(boolean selected, int state, int variation)
123
  {
124
    this(selected, state, variation, null);
125
  }
126
 
127
  /**
128
   * Create an input method highlight style.
129
   *
130
   * @param selected whether the text range is selected
131
   * @param state either {@link #RAW_TEXT} or {@link #CONVERTED_TEXT}
132
   * @param variation the style variation
133
   * @param style an unmodifiable map of rendering styles, or null
134
   * @throws IllegalArgumentException if state is invalid
135
   * @since 1.3
136
   */
137
  public InputMethodHighlight(boolean selected, int state, int variation,
138
                              Map<TextAttribute, ?> style)
139
  {
140
    if (state != RAW_TEXT && state != CONVERTED_TEXT)
141
      throw new IllegalArgumentException();
142
    this.selected = selected;
143
    this.state = state;
144
    this.variation = variation;
145
    this.style = style;
146
  }
147
 
148
  /**
149
   * Return whether the highlighting applies to selected text.
150
   *
151
   * @return the selection status
152
   */
153
  public boolean isSelected()
154
  {
155
    return selected;
156
  }
157
 
158
  /**
159
   * Return the conversion state of the highlighted text.
160
   *
161
   * @return one of {@link #RAW_TEXT} or {@link #CONVERTED_TEXT}
162
   */
163
  public int getState()
164
  {
165
    return state;
166
  }
167
 
168
  /**
169
   * Return the highlighting style variation.
170
   *
171
   * @return the variation
172
   */
173
  public int getVariation()
174
  {
175
    return variation;
176
  }
177
 
178
  /**
179
   * Return the rendering style attributes map, or null if it should be the
180
   * default mapping.
181
   *
182
   * @return the style map
183
   * @since 1.3
184
   */
185
  public Map<TextAttribute, ?> getStyle()
186
  {
187
    return style;
188
  }
189
} // class InputMethodHighlight

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.