KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > labelpainters > LabelPainterDefault


1 /*
2  * LabelPainterDefault.java, <enter purpose here>.
3  * Copyright (C) 2005 Achim Westermann, Achim.Westermann@gmx.de
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * If you modify or optimize the code in a useful way please let me know.
20  * Achim.Westermann@gmx.de
21  */

22 package info.monitorenter.gui.chart.labelpainters;
23
24 import info.monitorenter.gui.chart.ILabelPainter;
25
26 import java.awt.Graphics2D JavaDoc;
27
28 /**
29  * <p>
30  * Default implementation for a label painter that uses all given arguments (no
31  * proprietary behaviour).
32  * </p>
33  *
34  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
35  *
36  * @version $Revision: 1.1 $
37  *
38  */

39 public class LabelPainterDefault implements ILabelPainter {
40
41   /**
42    * @see info.monitorenter.gui.chart.ILabelPainter#paintXLabel(int, int, java.lang.String,
43    * java.awt.Graphics2D)
44    */

45   public void paintXLabel(final int x, final int y, final String JavaDoc label, final Graphics2D JavaDoc g) {
46     g.drawString(label, x, y);
47   }
48
49   /**
50    * @see info.monitorenter.gui.chart.ILabelPainter#paintXTick(int, int, boolean,
51    * java.awt.Graphics2D)
52    */

53   public void paintXTick(final int x, final int y, final boolean isMajorTick, final Graphics2D JavaDoc g) {
54     if (isMajorTick) {
55       g.drawLine(x, y, x, y + 5);
56     } else {
57       g.drawLine(x, y, x, y + 2);
58     }
59   }
60
61   /**
62    * @see info.monitorenter.gui.chart.ILabelPainter#paintYLabel(int, int, java.lang.String,
63    * java.awt.Graphics2D)
64    */

65   public void paintYLabel(final int x, final int y, final String JavaDoc label, final Graphics2D JavaDoc g) {
66     g.drawString(label, x, y);
67   }
68
69   /**
70    * @see info.monitorenter.gui.chart.ILabelPainter#paintYTick(int, int, boolean,
71    * java.awt.Graphics2D)
72    */

73   public void paintYTick(final int x, final int y, final boolean isMajorTick, final Graphics2D JavaDoc g) {
74     if (isMajorTick) {
75       g.drawLine(x, y, x - 5, y);
76     } else {
77       g.drawLine(x, y, x - 2, y);
78     }
79   }
80 }
81
Popular Tags