001 /*
002 * $Id: AutoCompleteStyledDocument.java 3131 2008-12-05 14:18:13Z kschaefe $
003 *
004 * Copyright 2008 Sun Microsystems, Inc., 4150 Network Circle,
005 * Santa Clara, California 95054, U.S.A. All rights reserved.
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020 */
021 package org.jdesktop.swingx.autocomplete;
022
023 import java.awt.Color;
024 import java.awt.Font;
025
026 import javax.swing.text.AttributeSet;
027 import javax.swing.text.DefaultStyledDocument;
028 import javax.swing.text.Document;
029 import javax.swing.text.Element;
030 import javax.swing.text.Style;
031 import javax.swing.text.StyledDocument;
032
033 /**
034 *
035 * @author Karl George Schaefer
036 */
037 public class AutoCompleteStyledDocument extends AutoCompleteDocument implements
038 StyledDocument {
039 /**
040 * @param adaptor
041 * @param strictMatching
042 * @param stringConverter
043 * @param delegate
044 */
045 public AutoCompleteStyledDocument(AbstractAutoCompleteAdaptor adaptor,
046 boolean strictMatching, ObjectToStringConverter stringConverter,
047 StyledDocument delegate) {
048 super(adaptor, strictMatching, stringConverter, delegate);
049 }
050
051 /**
052 * @param adaptor
053 * @param strictMatching
054 * @param stringConverter
055 */
056 public AutoCompleteStyledDocument(AbstractAutoCompleteAdaptor adaptor,
057 boolean strictMatching, ObjectToStringConverter stringConverter) {
058 super(adaptor, strictMatching, stringConverter);
059 }
060
061 /**
062 * @param adaptor
063 * @param strictMatching
064 */
065 public AutoCompleteStyledDocument(AbstractAutoCompleteAdaptor adaptor,
066 boolean strictMatching) {
067 super(adaptor, strictMatching);
068 }
069
070 /**
071 * {@inheritDoc}
072 */
073 @Override
074 protected Document createDefaultDocument() {
075 return new DefaultStyledDocument();
076 }
077
078 /**
079 * {@inheritDoc}
080 */
081 public Style addStyle(String nm, Style parent) {
082 return ((StyledDocument) delegate).addStyle(nm, parent);
083 }
084
085 /**
086 * {@inheritDoc}
087 */
088 public Color getBackground(AttributeSet attr) {
089 return ((StyledDocument) delegate).getBackground(attr);
090 }
091
092 /**
093 * {@inheritDoc}
094 */
095 public Element getCharacterElement(int pos) {
096 return ((StyledDocument) delegate).getCharacterElement(pos);
097 }
098
099 /**
100 * {@inheritDoc}
101 */
102 public Font getFont(AttributeSet attr) {
103 return ((StyledDocument) delegate).getFont(attr);
104 }
105
106 /**
107 * {@inheritDoc}
108 */
109 public Color getForeground(AttributeSet attr) {
110 return ((StyledDocument) delegate).getForeground(attr);
111 }
112
113 /**
114 * {@inheritDoc}
115 */
116 public Style getLogicalStyle(int p) {
117 return ((StyledDocument) delegate).getLogicalStyle(p);
118 }
119
120 /**
121 * {@inheritDoc}
122 */
123 public Element getParagraphElement(int pos) {
124 return ((StyledDocument) delegate).getParagraphElement(pos);
125 }
126
127 /**
128 * {@inheritDoc}
129 */
130 public Style getStyle(String nm) {
131 return ((StyledDocument) delegate).getStyle(nm);
132 }
133
134 /**
135 * {@inheritDoc}
136 */
137 public void removeStyle(String nm) {
138 ((StyledDocument) delegate).removeStyle(nm);
139 }
140
141 /**
142 * {@inheritDoc}
143 */
144 public void setCharacterAttributes(int offset, int length,
145 AttributeSet s, boolean replace) {
146 ((StyledDocument) delegate).setCharacterAttributes(offset, length, s, replace);
147 }
148
149 /**
150 * {@inheritDoc}
151 */
152 public void setLogicalStyle(int pos, Style s) {
153 ((StyledDocument) delegate).setLogicalStyle(pos, s);
154 }
155
156 /**
157 * {@inheritDoc}
158 */
159 public void setParagraphAttributes(int offset, int length,
160 AttributeSet s, boolean replace) {
161 ((StyledDocument) delegate).setParagraphAttributes(offset, length, s, replace);
162 }
163 }