com.alee.laf.table.renderers.WebTableDoubleCellRenderer Maven / Gradle / Ivy
/*
* 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.laf.table.renderers;
import com.alee.laf.table.TableCellParameters;
import com.alee.managers.style.StyleId;
import javax.swing.*;
import java.text.NumberFormat;
/**
* Default {@link javax.swing.table.TableCellRenderer} implementation for {@link Double} values.
*
* @param {@link Double} type
* @param {@link JTable} type
* @param {@link TableCellParameters} type
* @author Mikle Garin
*/
public class WebTableDoubleCellRenderer>
extends WebTableNumberCellRenderer
{
/**
* {@link NumberFormat}.
*/
protected NumberFormat numberFormat;
@Override
protected void updateStyleId ( final P parameters )
{
setStyleId ( StyleId.tableCellRendererDouble.at ( parameters.table () ) );
}
@Override
protected String textForValue ( final P parameters )
{
return parameters.value () != null ? getNumberFormat ().format ( parameters.value () ) : "";
}
/**
* Returns {@link NumberFormat}.
*
* @return {@link NumberFormat}
*/
protected NumberFormat getNumberFormat ()
{
if ( numberFormat == null )
{
numberFormat = NumberFormat.getInstance ();
}
return numberFormat;
}
/**
* A subclass of {@link WebTableDoubleCellRenderer} that implements {@link javax.swing.plaf.UIResource}.
* It is used to determine cell renderer provided by the UI class to properly uninstall it on UI uninstall.
*
* @param {@link Double} type
* @param {@link JTable} type
* @param {@link TableCellParameters} type
*/
public static final class UIResource>
extends WebTableDoubleCellRenderer implements javax.swing.plaf.UIResource
{
/**
* Implementation is used completely from {@link WebTableDoubleCellRenderer}.
*/
}
}