001/* 002 * $Id: AutoCompleteStyledDocument.java 4045 2011-07-19 18:39:17Z 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 */ 021package org.jdesktop.swingx.autocomplete; 022 023import java.awt.Color; 024import java.awt.Font; 025 026import javax.swing.text.AttributeSet; 027import javax.swing.text.DefaultStyledDocument; 028import javax.swing.text.Document; 029import javax.swing.text.Element; 030import javax.swing.text.Style; 031import javax.swing.text.StyledDocument; 032 033/** 034 * 035 * @author Karl George Schaefer 036 */ 037public 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 @Override 082 public Style addStyle(String nm, Style parent) { 083 return ((StyledDocument) delegate).addStyle(nm, parent); 084 } 085 086 /** 087 * {@inheritDoc} 088 */ 089 @Override 090 public Color getBackground(AttributeSet attr) { 091 return ((StyledDocument) delegate).getBackground(attr); 092 } 093 094 /** 095 * {@inheritDoc} 096 */ 097 @Override 098 public Element getCharacterElement(int pos) { 099 return ((StyledDocument) delegate).getCharacterElement(pos); 100 } 101 102 /** 103 * {@inheritDoc} 104 */ 105 @Override 106 public Font getFont(AttributeSet attr) { 107 return ((StyledDocument) delegate).getFont(attr); 108 } 109 110 /** 111 * {@inheritDoc} 112 */ 113 @Override 114 public Color getForeground(AttributeSet attr) { 115 return ((StyledDocument) delegate).getForeground(attr); 116 } 117 118 /** 119 * {@inheritDoc} 120 */ 121 @Override 122 public Style getLogicalStyle(int p) { 123 return ((StyledDocument) delegate).getLogicalStyle(p); 124 } 125 126 /** 127 * {@inheritDoc} 128 */ 129 @Override 130 public Element getParagraphElement(int pos) { 131 return ((StyledDocument) delegate).getParagraphElement(pos); 132 } 133 134 /** 135 * {@inheritDoc} 136 */ 137 @Override 138 public Style getStyle(String nm) { 139 return ((StyledDocument) delegate).getStyle(nm); 140 } 141 142 /** 143 * {@inheritDoc} 144 */ 145 @Override 146 public void removeStyle(String nm) { 147 ((StyledDocument) delegate).removeStyle(nm); 148 } 149 150 /** 151 * {@inheritDoc} 152 */ 153 @Override 154 public void setCharacterAttributes(int offset, int length, 155 AttributeSet s, boolean replace) { 156 ((StyledDocument) delegate).setCharacterAttributes(offset, length, s, replace); 157 } 158 159 /** 160 * {@inheritDoc} 161 */ 162 @Override 163 public void setLogicalStyle(int pos, Style s) { 164 ((StyledDocument) delegate).setLogicalStyle(pos, s); 165 } 166 167 /** 168 * {@inheritDoc} 169 */ 170 @Override 171 public void setParagraphAttributes(int offset, int length, 172 AttributeSet s, boolean replace) { 173 ((StyledDocument) delegate).setParagraphAttributes(offset, length, s, replace); 174 } 175}