Home | History | Annotate | Download | only in im
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 /**
     18  * @author Dmitry A. Durnev
     19  * @version $Revision$
     20  */
     21 package java.awt.im;
     22 
     23 import java.util.Map;
     24 import java.awt.font.TextAttribute;
     25 
     26 import org.apache.harmony.awt.internal.nls.Messages;
     27 
     28 /**
     29  * This class is not supported in Android 1.0. It is merely provided to maintain
     30  * interface compatibility with desktop Java implementations.
     31  *
     32  * @since Android 1.0
     33  */
     34 public class InputMethodHighlight {
     35 
     36     public static final int RAW_TEXT = 0;
     37 
     38     public static final int CONVERTED_TEXT = 1;
     39 
     40     public static final InputMethodHighlight
     41         UNSELECTED_RAW_TEXT_HIGHLIGHT = new InputMethodHighlight(false, RAW_TEXT);
     42 
     43     public static final InputMethodHighlight
     44         SELECTED_RAW_TEXT_HIGHLIGHT = new InputMethodHighlight(true, RAW_TEXT);
     45 
     46     public static final InputMethodHighlight
     47         UNSELECTED_CONVERTED_TEXT_HIGHLIGHT =
     48             new InputMethodHighlight(false, CONVERTED_TEXT);
     49 
     50     public static final InputMethodHighlight
     51         SELECTED_CONVERTED_TEXT_HIGHLIGHT =
     52             new InputMethodHighlight(true, CONVERTED_TEXT);
     53 
     54     private boolean selected;
     55     private int state;
     56     private int variation;
     57     private Map<TextAttribute,?> style;
     58 
     59     public InputMethodHighlight(boolean selected, int state, int variation) {
     60         this(selected, state, variation, null);
     61     }
     62 
     63     public InputMethodHighlight(boolean selected, int state,
     64                                 int variation, Map<java.awt.font.TextAttribute, ?> style) {
     65         if ((state != RAW_TEXT) && (state != CONVERTED_TEXT)) {
     66             // awt.20B=unknown input method highlight state
     67             throw new IllegalArgumentException(Messages.getString("awt.20B")); //$NON-NLS-1$
     68         }
     69         this.selected = selected;
     70         this.state = state;
     71         this.variation = variation;
     72         this.style = style;
     73     }
     74 
     75     public InputMethodHighlight(boolean selected, int state) {
     76         this(selected, state, 0, null);
     77     }
     78 
     79     public int getState() {
     80         return state;
     81     }
     82 
     83     public Map<java.awt.font.TextAttribute, ?> getStyle() {
     84         return style;
     85     }
     86 
     87     public int getVariation() {
     88         return variation;
     89     }
     90 
     91     public boolean isSelected() {
     92         return selected;
     93     }
     94 }
     95 
     96