KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chart2d > Properties


1 /**
2  * Chart2D, a java library for drawing two dimensional charts.
3  * Copyright (C) 2001 Jason J. Simas
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  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * The author of this library may be contacted at:
19  * E-mail: jjsimas@users.sourceforge.net
20  * Street Address: J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
21  */

22
23
24 package net.sourceforge.chart2d;
25
26
27 import java.awt.Font JavaDoc;
28 import java.util.Vector JavaDoc;
29 import java.awt.GraphicsEnvironment JavaDoc;
30
31
32 /**
33  * A data structure for holding the properties common to all Properties objects.
34  * Currently it only holds the font names vector.
35  */

36 abstract class Properties {
37
38
39   private static String JavaDoc[] fontNames;
40   private static boolean gotFontNames = false;
41
42
43   /**
44    * Returns true if the font name exists in the graphics enviornment.
45    * @param name The name of the font to determine the existence of.
46    * @return boolean If true, then the font name exists.
47    */

48   public synchronized final boolean isFontNameExists (String JavaDoc name) {
49
50     if (!gotFontNames) getFontNames();
51     for (int i = 0; i < fontNames.length; ++i) if (name.equals (fontNames[i])) return true;
52     return false;
53   }
54
55
56   private void getFontNames() {
57
58     fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
59     gotFontNames = true;
60   }
61 }
Popular Tags