com.alee.extended.label.WebStyledLabel Maven / Gradle / Ivy
Show all versions of weblaf-ui Show documentation
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see .
*/
package com.alee.extended.label;
import com.alee.painter.Paintable;
import com.alee.painter.Painter;
import com.alee.laf.WebLookAndFeel;
import com.alee.managers.hotkey.HotkeyData;
import com.alee.managers.language.LanguageManager;
import com.alee.managers.language.LanguageMethods;
import com.alee.managers.language.LanguageUtils;
import com.alee.managers.language.data.TooltipWay;
import com.alee.managers.language.updaters.LanguageUpdater;
import com.alee.managers.log.Log;
import com.alee.managers.style.*;
import com.alee.managers.style.Skin;
import com.alee.managers.style.StyleListener;
import com.alee.managers.style.Skinnable;
import com.alee.managers.tooltip.ToolTipMethods;
import com.alee.managers.tooltip.TooltipManager;
import com.alee.managers.tooltip.WebCustomTooltip;
import com.alee.utils.CollectionUtils;
import com.alee.utils.EventUtils;
import com.alee.utils.ReflectUtils;
import com.alee.utils.SwingUtils;
import com.alee.utils.swing.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Custom label component that quickly renders multi-styled text.
* Its rendering speed is superior to HTML rendering within simple JLabel and its usage is preferred.
*
* @author Mikle Garin
*/
public class WebStyledLabel extends JLabel
implements Styleable, Skinnable, Paintable, ShapeProvider, MarginSupport, PaddingSupport, EventMethods, ToolTipMethods,
LanguageMethods, FontMethods
{
/**
* Component properties.
*/
public static final String PROPERTY_STYLE_RANGE = "styleRange";
/**
* StyleRange list.
*/
protected List styleRanges;
/**
* Whether or not should enable line wrap.
*/
protected boolean lineWrap;
/**
* Amount of rows used to wrap label text.
*/
protected int rows;
/**
* Maximum amount of rows.
*/
protected int maximumRows;
/**
* Minimum amount of rows.
*/
protected int minimumRows;
/**
* Preferred width.
*/
protected int preferredWidth;
/**
* Gap between rows.
*/
protected int rowGap;
/**
* Constructs empty label.
*/
public WebStyledLabel ()
{
super ();
}
/**
* Constructs label with the specified preferences.
*
* @param icon icon
*/
public WebStyledLabel ( final Icon icon )
{
super ( icon );
}
/**
* Constructs label with the specified preferences.
*
* @param horizontalAlignment horizontal alignment
*/
public WebStyledLabel ( final int horizontalAlignment )
{
super ();
setHorizontalAlignment ( horizontalAlignment );
}
/**
* Constructs label with the specified preferences.
*
* @param icon label icon
* @param horizontalAlignment horizontal alignment
*/
public WebStyledLabel ( final Icon icon, final int horizontalAlignment )
{
super ( icon, horizontalAlignment );
}
/**
* Constructs label with the specified preferences.
*
* @param text text or translation key
* @param data language data, may not be passed
*/
public WebStyledLabel ( final String text, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ) );
LanguageUtils.registerInitialLanguage ( this, text, data );
}
/**
* Constructs label with the specified preferences.
*
* @param text text or translation key
* @param horizontalAlignment horizontal alignment
* @param data language data, may not be passed
*/
public WebStyledLabel ( final String text, final int horizontalAlignment, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), horizontalAlignment );
LanguageUtils.registerInitialLanguage ( this, text, data );
}
/**
* Constructs label with the specified preferences.
*
* @param text text or translation key
* @param icon label icon
* @param data language data, may not be passed
*/
public WebStyledLabel ( final String text, final Icon icon, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), icon, LEADING );
LanguageUtils.registerInitialLanguage ( this, text, data );
}
/**
* Constructs label with the specified preferences.
*
* @param text text or translation key
* @param icon label icon
* @param horizontalAlignment horizontal alignment
* @param data language data, may not be passed
*/
public WebStyledLabel ( final String text, final Icon icon, final int horizontalAlignment, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), icon, horizontalAlignment );
LanguageUtils.registerInitialLanguage ( this, text, data );
}
/**
* Constructs empty label.
*
* @param id style ID
*/
public WebStyledLabel ( final StyleId id )
{
super ();
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param icon icon
*/
public WebStyledLabel ( final StyleId id, final Icon icon )
{
super ( icon );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param horizontalAlignment horizontal alignment
*/
public WebStyledLabel ( final StyleId id, final int horizontalAlignment )
{
super ();
setHorizontalAlignment ( horizontalAlignment );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param icon label icon
* @param horizontalAlignment horizontal alignment
*/
public WebStyledLabel ( final StyleId id, final Icon icon, final int horizontalAlignment )
{
super ( icon, horizontalAlignment );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param text text or translation key
* @param data language data, may not be passed
*/
public WebStyledLabel ( final StyleId id, final String text, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ) );
LanguageUtils.registerInitialLanguage ( this, text, data );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param text text or translation key
* @param horizontalAlignment horizontal alignment
* @param data language data, may not be passed
*/
public WebStyledLabel ( final StyleId id, final String text, final int horizontalAlignment, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), horizontalAlignment );
LanguageUtils.registerInitialLanguage ( this, text, data );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param text text or translation key
* @param icon label icon
* @param data language data, may not be passed
*/
public WebStyledLabel ( final StyleId id, final String text, final Icon icon, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), icon, LEADING );
LanguageUtils.registerInitialLanguage ( this, text, data );
setStyleId ( id );
}
/**
* Constructs label with the specified preferences.
*
* @param id style ID
* @param text text or translation key
* @param icon label icon
* @param horizontalAlignment horizontal alignment
* @param data language data, may not be passed
*/
public WebStyledLabel ( final StyleId id, final String text, final Icon icon, final int horizontalAlignment, final Object... data )
{
super ( LanguageUtils.getInitialText ( text, data ), icon, horizontalAlignment );
LanguageUtils.registerInitialLanguage ( this, text, data );
setStyleId ( id );
}
@Override
public void setText ( final String text )
{
// Parse styles
final ArrayList styles = new ArrayList ();
final String plainText = StyledLabelUtils.getPlainText ( text, styles );
// Update text
super.setText ( plainText );
// Set styles only if they are actually found in text
if ( styles.size () > 0 )
{
setStyleRanges ( styles );
}
else
{
clearStyleRanges ();
}
}
/**
* Returns added style ranges.
*
* @return added style ranges
*/
public List getStyleRanges ()
{
return CollectionUtils.copy ( getStyleRangesImpl () );
}
/**
* Adds style range into this label.
*
* @param styleRange new style range
*/
public void addStyleRange ( final StyleRange styleRange )
{
final StyleRange removed = addStyleRangeImpl ( styleRange );
firePropertyChange ( PROPERTY_STYLE_RANGE, removed, styleRange );
}
/**
* Adds style ranges into this label.
*
* @param styleRanges new style ranges list
*/
public void addStyleRanges ( final List styleRanges )
{
addStyleRangesImpl ( styleRanges );
firePropertyChange ( PROPERTY_STYLE_RANGE, null, styleRanges );
}
/**
* Removes style range from this label.
*
* @param styleRange style range to remove
*/
public void removeStyleRange ( final StyleRange styleRange )
{
removeStyleRangeImpl ( styleRange );
firePropertyChange ( PROPERTY_STYLE_RANGE, styleRange, null );
}
/**
* Removes style ranges from this label.
*
* @param styleRanges style ranges to remove
*/
public void removeStyleRanges ( final List styleRanges )
{
removeStyleRangesImpl ( styleRanges );
firePropertyChange ( PROPERTY_STYLE_RANGE, styleRanges, null );
}
/**
* Clears all style ranges and adds new ones.
*
* @param styleRanges new style ranges
*/
public void setStyleRanges ( final List styleRanges )
{
clearStyleRangesImpl ();
addStyleRangesImpl ( styleRanges );
firePropertyChange ( PROPERTY_STYLE_RANGE, null, styleRanges );
}
/**
* Clears all style ranges.
*/
public void clearStyleRanges ()
{
clearStyleRangesImpl ();
firePropertyChange ( PROPERTY_STYLE_RANGE, null, null );
}
/**
* Returns added style ranges.
*
* @return added style ranges
*/
protected List getStyleRangesImpl ()
{
if ( styleRanges == null )
{
styleRanges = new ArrayList ( 3 );
}
return styleRanges;
}
/**
* Adds style range into this label.
*
* @param styleRange new style range
* @return removed style range
*/
protected StyleRange addStyleRangeImpl ( final StyleRange styleRange )
{
final StyleRange removed = clearSimilarRangeImpl ( styleRange.getStartIndex (), styleRange.getLength () );
getStyleRangesImpl ().add ( styleRange );
return removed;
}
/**
* Adds style ranges into this label.
*
* @param styleRanges new style ranges list
*/
protected void addStyleRangesImpl ( final List styleRanges )
{
if ( styleRanges != null )
{
for ( final StyleRange styleRange : styleRanges )
{
addStyleRangeImpl ( styleRange );
}
}
}
/**
* Removes style range from this label.
*
* @param styleRange style range to remove
*/
protected void removeStyleRangeImpl ( final StyleRange styleRange )
{
if ( !getStyleRangesImpl ().remove ( styleRange ) )
{
final Iterator iterator = getStyleRangesImpl ().iterator ();
while ( iterator.hasNext () )
{
final StyleRange range = iterator.next ();
if ( range.getStartIndex () == styleRange.getStartIndex () && range.getLength () == styleRange.getLength () )
{
iterator.remove ();
return;
}
}
}
}
/**
* Removes style ranges from this label.
*
* @param styleRanges style ranges to remove
*/
protected void removeStyleRangesImpl ( final List styleRanges )
{
if ( styleRanges != null )
{
for ( final StyleRange styleRange : styleRanges )
{
removeStyleRangeImpl ( styleRange );
}
}
}
/**
* Clears all style ranges.
*/
protected void clearStyleRangesImpl ()
{
getStyleRangesImpl ().clear ();
}
/**
* Removes any style range found in the same range as the specified one.
*
* @param start range start
* @param length range length
* @return removed style range
*/
protected StyleRange clearSimilarRangeImpl ( final int start, final int length )
{
final Iterator iterator = getStyleRangesImpl ().iterator ();
while ( iterator.hasNext () )
{
final StyleRange range = iterator.next ();
if ( range.getStartIndex () == start && range.getLength () == length )
{
iterator.remove ();
return range;
}
}
return null;
}
/**
* Returns whether text lines should be wrapped or not.
*
* @return true if text lines should be wrapped, false otherwise
*/
public boolean isLineWrap ()
{
return lineWrap;
}
/**
* Sets whether text lines should be wrapped or not.
*
* @param wrap whether text lines should be wrapped or not
*/
public void setLineWrap ( final boolean wrap )
{
this.lineWrap = wrap;
}
/**
* Returns amount of rows used to wrap label text.
*
* @return amount of rows used to wrap label text
*/
public int getRows ()
{
return rows;
}
/**
* Sets amount of rows used to wrap label text.
* By default it is set to zero.
*
* Note that it has lower priority than preferred width.
* If preferred width is set this value is ignored.
*
* @param rows amount of rows used to wrap label text
*/
public void setRows ( final int rows )
{
this.rows = rows;
}
/**
* Returns gap between text rows in pixels.
*
* @return gap between text rows in pixels
*/
public int getRowGap ()
{
return rowGap;
}
/**
* Sets gap between text rows in pixels.
*
* @param gap gap between text rows in pixels
*/
public void setRowGap ( final int gap )
{
this.rowGap = gap;
}
/**
* Returns maximum rows amount visible after wrapping.
*
* @return maximum rows amount visible after wrapping
*/
public int getMaximumRows ()
{
return maximumRows;
}
/**
* Sets maximum rows amount visible after wrapping.
* By default it is set to zero.
*
* @param maximumRows maximum rows amount visible after wrapping
*/
public void setMaximumRows ( final int maximumRows )
{
this.maximumRows = maximumRows;
}
/**
* Returns minimum rows amount visible after wrapping.
*
* @return minimum rows amount visible after wrapping
*/
public int getMinimumRows ()
{
return minimumRows;
}
/**
* Sets minimum rows amount visible after wrapping.
* By default it is set to zero.
*
* @param minimumRows minimum rows amount visible after wrapping
*/
public void setMinimumRows ( final int minimumRows )
{
this.minimumRows = minimumRows;
}
@Override
public StyleId getStyleId ()
{
return getWebUI ().getStyleId ();
}
@Override
public StyleId setStyleId ( final StyleId id )
{
return getWebUI ().setStyleId ( id );
}
@Override
public Skin getSkin ()
{
return StyleManager.getSkin ( this );
}
@Override
public Skin setSkin ( final Skin skin )
{
return StyleManager.setSkin ( this, skin );
}
@Override
public Skin setSkin ( final Skin skin, final boolean recursively )
{
return StyleManager.setSkin ( this, skin, recursively );
}
@Override
public Skin restoreSkin ()
{
return StyleManager.restoreSkin ( this );
}
@Override
public void addStyleListener ( final StyleListener listener )
{
StyleManager.addStyleListener ( this, listener );
}
@Override
public void removeStyleListener ( final StyleListener listener )
{
StyleManager.removeStyleListener ( this, listener );
}
@Override
public Map getCustomPainters ()
{
return StyleManager.getCustomPainters ( this );
}
@Override
public Painter getCustomPainter ()
{
return StyleManager.getCustomPainter ( this );
}
@Override
public Painter getCustomPainter ( final String id )
{
return StyleManager.getCustomPainter ( this, id );
}
@Override
public Painter setCustomPainter ( final Painter painter )
{
return StyleManager.setCustomPainter ( this, painter );
}
@Override
public Painter setCustomPainter ( final String id, final Painter painter )
{
return StyleManager.setCustomPainter ( this, id, painter );
}
@Override
public boolean restoreDefaultPainters ()
{
return StyleManager.restoreDefaultPainters ( this );
}
@Override
public Shape provideShape ()
{
return getWebUI ().provideShape ();
}
@Override
public Insets getMargin ()
{
return getWebUI ().getMargin ();
}
/**
* Sets new margin.
*
* @param margin new margin
*/
public void setMargin ( final int margin )
{
setMargin ( margin, margin, margin, margin );
}
/**
* Sets new margin.
*
* @param top new top margin
* @param left new left margin
* @param bottom new bottom margin
* @param right new right margin
*/
public void setMargin ( final int top, final int left, final int bottom, final int right )
{
setMargin ( new Insets ( top, left, bottom, right ) );
}
@Override
public void setMargin ( final Insets margin )
{
getWebUI ().setMargin ( margin );
}
@Override
public Insets getPadding ()
{
return getWebUI ().getPadding ();
}
/**
* Sets new padding.
*
* @param padding new padding
*/
public void setPadding ( final int padding )
{
setPadding ( padding, padding, padding, padding );
}
/**
* Sets new padding.
*
* @param top new top padding
* @param left new left padding
* @param bottom new bottom padding
* @param right new right padding
*/
public void setPadding ( final int top, final int left, final int bottom, final int right )
{
setPadding ( new Insets ( top, left, bottom, right ) );
}
@Override
public void setPadding ( final Insets padding )
{
getWebUI ().setPadding ( padding );
}
/**
* Returns Web-UI applied to this class.
*
* @return Web-UI applied to this class
*/
private WebStyledLabelUI getWebUI ()
{
return ( WebStyledLabelUI ) getUI ();
}
@Override
public void updateUI ()
{
if ( getUI () == null || !( getUI () instanceof WebStyledLabelUI ) )
{
try
{
setUI ( ( WebStyledLabelUI ) ReflectUtils.createInstance ( WebLookAndFeel.styledLabelUI ) );
}
catch ( final Throwable e )
{
Log.error ( this, e );
setUI ( new WebStyledLabelUI () );
}
}
else
{
setUI ( getUI () );
}
}
@Override
public String getUIClassID ()
{
return StyleableComponent.styledlabel.getUIClassID ();
}
@Override
public MouseAdapter onMousePress ( final MouseEventRunnable runnable )
{
return EventUtils.onMousePress ( this, runnable );
}
@Override
public MouseAdapter onMousePress ( final MouseButton mouseButton, final MouseEventRunnable runnable )
{
return EventUtils.onMousePress ( this, mouseButton, runnable );
}
@Override
public MouseAdapter onMouseEnter ( final MouseEventRunnable runnable )
{
return EventUtils.onMouseEnter ( this, runnable );
}
@Override
public MouseAdapter onMouseExit ( final MouseEventRunnable runnable )
{
return EventUtils.onMouseExit ( this, runnable );
}
@Override
public MouseAdapter onMouseDrag ( final MouseEventRunnable runnable )
{
return EventUtils.onMouseDrag ( this, runnable );
}
@Override
public MouseAdapter onMouseDrag ( final MouseButton mouseButton, final MouseEventRunnable runnable )
{
return EventUtils.onMouseDrag ( this, mouseButton, runnable );
}
@Override
public MouseAdapter onMouseClick ( final MouseEventRunnable runnable )
{
return EventUtils.onMouseClick ( this, runnable );
}
@Override
public MouseAdapter onMouseClick ( final MouseButton mouseButton, final MouseEventRunnable runnable )
{
return EventUtils.onMouseClick ( this, mouseButton, runnable );
}
@Override
public MouseAdapter onDoubleClick ( final MouseEventRunnable runnable )
{
return EventUtils.onDoubleClick ( this, runnable );
}
@Override
public MouseAdapter onMenuTrigger ( final MouseEventRunnable runnable )
{
return EventUtils.onMenuTrigger ( this, runnable );
}
@Override
public KeyAdapter onKeyType ( final KeyEventRunnable runnable )
{
return EventUtils.onKeyType ( this, runnable );
}
@Override
public KeyAdapter onKeyType ( final HotkeyData hotkey, final KeyEventRunnable runnable )
{
return EventUtils.onKeyType ( this, hotkey, runnable );
}
@Override
public KeyAdapter onKeyPress ( final KeyEventRunnable runnable )
{
return EventUtils.onKeyPress ( this, runnable );
}
@Override
public KeyAdapter onKeyPress ( final HotkeyData hotkey, final KeyEventRunnable runnable )
{
return EventUtils.onKeyPress ( this, hotkey, runnable );
}
@Override
public KeyAdapter onKeyRelease ( final KeyEventRunnable runnable )
{
return EventUtils.onKeyRelease ( this, runnable );
}
@Override
public KeyAdapter onKeyRelease ( final HotkeyData hotkey, final KeyEventRunnable runnable )
{
return EventUtils.onKeyRelease ( this, hotkey, runnable );
}
@Override
public FocusAdapter onFocusGain ( final FocusEventRunnable runnable )
{
return EventUtils.onFocusGain ( this, runnable );
}
@Override
public FocusAdapter onFocusLoss ( final FocusEventRunnable runnable )
{
return EventUtils.onFocusLoss ( this, runnable );
}
@Override
public WebCustomTooltip setToolTip ( final String tooltip )
{
return TooltipManager.setTooltip ( this, tooltip );
}
@Override
public WebCustomTooltip setToolTip ( final Icon icon, final String tooltip )
{
return TooltipManager.setTooltip ( this, icon, tooltip );
}
@Override
public WebCustomTooltip setToolTip ( final String tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.setTooltip ( this, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip setToolTip ( final Icon icon, final String tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.setTooltip ( this, icon, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip setToolTip ( final String tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.setTooltip ( this, tooltip, tooltipWay, delay );
}
@Override
public WebCustomTooltip setToolTip ( final Icon icon, final String tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.setTooltip ( this, icon, tooltip, tooltipWay, delay );
}
@Override
public WebCustomTooltip setToolTip ( final JComponent tooltip )
{
return TooltipManager.setTooltip ( this, tooltip );
}
@Override
public WebCustomTooltip setToolTip ( final JComponent tooltip, final int delay )
{
return TooltipManager.setTooltip ( this, tooltip, delay );
}
@Override
public WebCustomTooltip setToolTip ( final JComponent tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.setTooltip ( this, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip setToolTip ( final JComponent tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.setTooltip ( this, tooltip, tooltipWay, delay );
}
@Override
public WebCustomTooltip addToolTip ( final String tooltip )
{
return TooltipManager.addTooltip ( this, tooltip );
}
@Override
public WebCustomTooltip addToolTip ( final Icon icon, final String tooltip )
{
return TooltipManager.addTooltip ( this, icon, tooltip );
}
@Override
public WebCustomTooltip addToolTip ( final String tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.addTooltip ( this, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip addToolTip ( final Icon icon, final String tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.addTooltip ( this, icon, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip addToolTip ( final String tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.addTooltip ( this, tooltip, tooltipWay, delay );
}
@Override
public WebCustomTooltip addToolTip ( final Icon icon, final String tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.addTooltip ( this, icon, tooltip, tooltipWay, delay );
}
@Override
public WebCustomTooltip addToolTip ( final JComponent tooltip )
{
return TooltipManager.addTooltip ( this, tooltip );
}
@Override
public WebCustomTooltip addToolTip ( final JComponent tooltip, final int delay )
{
return TooltipManager.addTooltip ( this, tooltip, delay );
}
@Override
public WebCustomTooltip addToolTip ( final JComponent tooltip, final TooltipWay tooltipWay )
{
return TooltipManager.addTooltip ( this, tooltip, tooltipWay );
}
@Override
public WebCustomTooltip addToolTip ( final JComponent tooltip, final TooltipWay tooltipWay, final int delay )
{
return TooltipManager.addTooltip ( this, tooltip, tooltipWay, delay );
}
@Override
public void removeToolTip ( final WebCustomTooltip tooltip )
{
TooltipManager.removeTooltip ( this, tooltip );
}
@Override
public void removeToolTips ()
{
TooltipManager.removeTooltips ( this );
}
@Override
public void removeToolTips ( final WebCustomTooltip... tooltips )
{
TooltipManager.removeTooltips ( this, tooltips );
}
@Override
public void removeToolTips ( final List tooltips )
{
TooltipManager.removeTooltips ( this, tooltips );
}
@Override
public Dimension getMinimumSize ()
{
return isLineWrap () ? new Dimension ( 1, 1 ) : super.getMinimumSize ();
}
@Override
public Dimension getMaximumSize ()
{
return isLineWrap () ? new Dimension ( Integer.MAX_VALUE, Integer.MAX_VALUE ) : super.getMaximumSize ();
}
/**
* Sets preferred width of the label.
*
* @param width new preferred width of the label
*/
public void setPreferredWidth ( final int width )
{
this.preferredWidth = width;
}
/**
* Gets the preferred width of the styled label.
*
* @return the preferred width
*/
public int getPreferredWidth ()
{
return preferredWidth;
}
@Override
public void setLanguage ( final String key, final Object... data )
{
LanguageManager.registerComponent ( this, key, data );
}
@Override
public void updateLanguage ( final Object... data )
{
LanguageManager.updateComponent ( this, data );
}
@Override
public void updateLanguage ( final String key, final Object... data )
{
LanguageManager.updateComponent ( this, key, data );
}
@Override
public void removeLanguage ()
{
LanguageManager.unregisterComponent ( this );
}
@Override
public boolean isLanguageSet ()
{
return LanguageManager.isRegisteredComponent ( this );
}
@Override
public void setLanguageUpdater ( final LanguageUpdater updater )
{
LanguageManager.registerLanguageUpdater ( this, updater );
}
@Override
public void removeLanguageUpdater ()
{
LanguageManager.unregisterLanguageUpdater ( this );
}
@Override
public WebStyledLabel setPlainFont ()
{
return SwingUtils.setPlainFont ( this );
}
@Override
public WebStyledLabel setPlainFont ( final boolean apply )
{
return SwingUtils.setPlainFont ( this, apply );
}
@Override
public boolean isPlainFont ()
{
return SwingUtils.isPlainFont ( this );
}
@Override
public WebStyledLabel setBoldFont ()
{
return SwingUtils.setBoldFont ( this );
}
@Override
public WebStyledLabel setBoldFont ( final boolean apply )
{
return SwingUtils.setBoldFont ( this, apply );
}
@Override
public boolean isBoldFont ()
{
return SwingUtils.isBoldFont ( this );
}
@Override
public WebStyledLabel setItalicFont ()
{
return SwingUtils.setItalicFont ( this );
}
@Override
public WebStyledLabel setItalicFont ( final boolean apply )
{
return SwingUtils.setItalicFont ( this, apply );
}
@Override
public boolean isItalicFont ()
{
return SwingUtils.isItalicFont ( this );
}
@Override
public WebStyledLabel setFontStyle ( final boolean bold, final boolean italic )
{
return SwingUtils.setFontStyle ( this, bold, italic );
}
@Override
public WebStyledLabel setFontStyle ( final int style )
{
return SwingUtils.setFontStyle ( this, style );
}
@Override
public WebStyledLabel setFontSize ( final int fontSize )
{
return SwingUtils.setFontSize ( this, fontSize );
}
@Override
public WebStyledLabel changeFontSize ( final int change )
{
return SwingUtils.changeFontSize ( this, change );
}
@Override
public int getFontSize ()
{
return SwingUtils.getFontSize ( this );
}
@Override
public WebStyledLabel setFontSizeAndStyle ( final int fontSize, final boolean bold, final boolean italic )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, bold, italic );
}
@Override
public WebStyledLabel setFontSizeAndStyle ( final int fontSize, final int style )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, style );
}
@Override
public WebStyledLabel setFontName ( final String fontName )
{
return SwingUtils.setFontName ( this, fontName );
}
@Override
public String getFontName ()
{
return SwingUtils.getFontName ( this );
}
}