2
* $Id: FontHighlighter.java 1164 2009-11-03 04:22:00Z kschaefe $
4
* Copyright 2009 Sun Microsystems, Inc., 4150 Network Circle,
5
* Santa Clara, California 95054, U.S.A. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
package org.jdesktop.swingx.decorator;
24
import java.awt.Component;
27
import org.jdesktop.swingx.decorator.AbstractHighlighter;
28
import org.jdesktop.swingx.decorator.ComponentAdapter;
29
import org.jdesktop.swingx.decorator.HighlightPredicate;
32
* A Highlighter which sets the Font of the component.<p>
34
* @author Karl George Schaefer
37
public class FontHighlighter extends AbstractHighlighter {
41
* Instantiates a FontHighlighter with null Font. The Highlighter is
44
public FontHighlighter() {
45
this((HighlightPredicate) null);
49
* Instantiates a FontHighlighter with the given Font. The Highlighter is
52
* @param font the Font to apply
54
public FontHighlighter(Font font) {
59
* Instantiates a FontHighlighter with the given HighlightPredicate and null Font.
61
* @param predicate the HighlightPredicate to use, may be null to default to ALWAYS.
63
public FontHighlighter(HighlightPredicate predicate) {
64
this(predicate, null);
68
* Instantiates a FontHighlighter with the given Font and HighlightPredicate.
70
* @param predicate the HighlightPredicate to use, may be null to default to ALWAYS.
71
* @param font the Font to apply, may be null
73
public FontHighlighter(HighlightPredicate predicate, Font font) {
79
* Returns the Font used for decoration.
81
* @return the Font used for decoration
85
public Font getFont() {
90
* Sets the Font used for decoration. May be null to not decorate.
92
* @param font the Font used for decoration, may be null to not decorate.
96
public void setFont(Font font) {
97
if (areEqual(font, getFont())) return;
105
* Implemented to return false if the font property is null.
108
protected boolean canHighlight(Component component, ComponentAdapter adapter) {
115
* Implemented to set the component's Font.
118
protected Component doHighlight(Component component, ComponentAdapter adapter) {
119
component.setFont(font);