KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > graph > Legend


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org)
7  *
8  * Developers: Sasa Markovic (saxon@jrobin.org)
9  * Arne Vandamme (cobralord@jrobin.org)
10  *
11  * (C) Copyright 2003, by Sasa Markovic.
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25 package org.jrobin.graph;
26
27 import java.awt.Color JavaDoc;
28
29 import org.jrobin.core.RrdException;
30
31 /**
32  * <p>Represents a PlotDef legend string on the graph. A Legend item is comprised out of two parts,
33  * a text string, and a legend marker (small rectangle in the same color as the PlotDef).</p>
34  *
35  * @author Arne Vandamme (cobralord@jrobin.org)
36  */

37 class Legend extends Comment
38 {
39     // ================================================================
40
// -- Members
41
// ================================================================
42
private Color JavaDoc color = Color.WHITE;
43     private int refPlotDef = -1;
44     
45     // ================================================================
46
// -- Constructors
47
// ================================================================
48
/**
49      * Constructs a Legend object based on a specified text string.
50      * The legend marker for this Legend will be drawn in white color.
51      * @param text Text part of the legend.
52      * @throws RrdException Thrown in case of a JRobin specific error.
53      */

54     Legend( String JavaDoc text ) throws RrdException
55     {
56         super(text);
57         this.commentType = Comment.CMT_LEGEND;
58     }
59     
60     /**
61      * Constructs a Legend object based on a specified text string and marker color.
62      * @param text Text part of the legend.
63      * @param color Color to use for the rectangular legend marker.
64      * @throws RrdException Thrown in case of a JRobin specific error.
65      */

66     Legend( String JavaDoc text, Color JavaDoc color ) throws RrdException
67     {
68         super(text);
69         if ( text == null )
70             this.commentType = Comment.CMT_NOLEGEND;
71         else
72             this.commentType = Comment.CMT_LEGEND;
73         this.color = color;
74     }
75     
76     /**
77      *
78      * @param text
79      * @param color
80      * @param referredPlotDef
81      * @throws RrdException
82      */

83     Legend( String JavaDoc text, Color JavaDoc color, int referredPlotDef ) throws RrdException
84     {
85         this( text, color );
86         
87         refPlotDef = referredPlotDef;
88     }
89     
90     
91     // ================================================================
92
// -- Protected methods
93
// ================================================================
94
Color JavaDoc getColor() {
95         return color;
96     }
97     
98     int getPlofDefIndex() {
99         return refPlotDef;
100     }
101 }
102
Popular Tags