    001/* ===========================================================
    002 * JFreeChart : a free chart library for the Java(tm) platform
    003 * ===========================================================
    004 *
    005 * (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
    006 *
    007 * Project Info:  http://www.jfree.org/jfreechart/index.html
    008 *
    009 * This library is free software; you can redistribute it and/or modify it
    010 * under the terms of the GNU Lesser General Public License as published by
    011 * the Free Software Foundation; either version 2.1 of the License, or
    012 * (at your option) any later version.
    013 *
    014 * This library is distributed in the hope that it will be useful, but
    015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    017 * License for more details.
    018 *
    019 * You should have received a copy of the GNU Lesser General Public
    020 * License along with this library; if not, write to the Free Software
    021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
    022 * USA.
    023 *
    024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    025 * Other names may be trademarks of their respective owners.]
    026 *
    027 * -----------------------------
    028 * PieSectionLabelGenerator.java
    029 * -----------------------------
    030 * (C) Copyright 2001-2008, by Object Refinery Limited.
    031 *
    032 * Original Author:  David Gilbert (for Object Refinery Limited);
    033 * Contributor(s):   -;
    034 *
    035 * Changes
    036 * -------
    037 * 13-Dec-2001 : Version 1 (DG);
    038 * 16-Jan-2002 : Completed Javadocs (DG);
    039 * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
    040 * 30-Oct-2002 : Category is now a Comparable instance (DG);
    041 * 07-Mar-2003 : Changed to KeyedValuesDataset and added pieIndex
    042 *               parameter (DG);
    043 * 21-Mar-2003 : Updated Javadocs (DG);
    044 * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG);
    045 * 13-Aug-2003 : Added clone() method (DG);
    046 * 19-Aug-2003 : Renamed PieToolTipGenerator --> PieItemLabelGenerator (DG);
    047 * 11-Nov-2003 : Removed clone() method (DG);
    048 * 30-Jan-2004 : Added generateSectionLabel() method (DG);
    049 * 15-Apr-2004 : Moved generateToolTip() method into separate interface and
    050 *               renamed this interface PieSectionLabelGenerator (DG);
    051 *
    052 */
    053
    054package org.jfree.chart.labels;
    055
    056import java.awt.Font;
    057import java.awt.Paint;
    058import java.awt.font.TextAttribute;
    059import java.text.AttributedString;
    060
    061import org.jfree.data.general.PieDataset;
    062
    063/**
    064 * Interface for a label generator for plots that use data from
    065 * a {@link PieDataset}.
    066 */
    067public interface PieSectionLabelGenerator {
    068
    069    /**
    070     * Generates a label for a pie section.
    071     *
    072     * @param dataset  the dataset (<code>null</code> not permitted).
    073     * @param key  the section key (<code>null</code> not permitted).
    074     *
    075     * @return The label (possibly <code>null</code>).
    076     */
    077    public String generateSectionLabel(PieDataset dataset, Comparable key);
    078
    079    /**
    080     * Generates an attributed label for the specified series, or
    081     * <code>null</code> if no attributed label is available (in which case,
    082     * the string returned by
    083     * {@link #generateSectionLabel(PieDataset, Comparable)} will
    084     * provide the fallback).  Only certain attributes are recognised by the
    085     * code that ultimately displays the labels:
    086     * <ul>
    087     * <li>{@link TextAttribute#FONT}: will set the font;</li>
    088     * <li>{@link TextAttribute#POSTURE}: a value of
    089     *     {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to
    090     *     the current font;</li>
    091     * <li>{@link TextAttribute#WEIGHT}: a value of
    092     *     {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the
    093     *     current font;</li>
    094     * <li>{@link TextAttribute#FOREGROUND}: this will set the {@link Paint}
    095     *     for the current</li>
    096     * <li>{@link TextAttribute#SUPERSCRIPT}: the values
    097     *     {@link TextAttribute#SUPERSCRIPT_SUB} and
    098     *     {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.</li>
    099     * </ul>
    100     *
    101     * @param dataset  the dataset.
    102     * @param key  the key.
    103     *
    104     * @return An attributed label (possibly <code>null</code>).
    105     */
    106    public AttributedString generateAttributedSectionLabel(PieDataset dataset,
    107                                                           Comparable key);
    108
    109}