Coverage report

| %line | %branch
--- | --- | ---
tsukuba_bunko.peko.resource.ColorManager |
0% |
0% |

1 |  |
     /*
2 |  |
      * "Peko" Visual Novel System
3 |  |
      *
4 |  |
      * All Rights Reserved.
5 |  |
      * (c) Copyright 2002 by Tsukuba Bunko.
6 |  |
      *
7 |  |
      * $Id: ColorManager.java,v 1.1 2005/07/11 12:49:18 ppoi Exp $
8 |  |
      */
9 |  |
     package tsukuba_bunko.peko.resource;
10 |  |
11 |  |
     import	java.awt.Color;
12 |  |
13 |  |
     import	java.util.Map;
14 |  |
15 |  |
     import	java.lang.ref.WeakReference;
16 |  |
17 |  |
     import	tsukuba_bunko.peko.Logger;
18 |  |
19 |  |
20 |  |
     /**
21 |  |
      * 色の管理を提供します。
22 |  |
      * @author	$Author: ppoi $
23 |  |
      * @version	$Revision: 1.1 $
24 |  |
      */
25 |  |
     public class ColorManager	{
26 |  |
27 |  |
     	/**
28 |  |
     	 * 唯一のインスタンス
29 |  |
     	 */
30 | 0 |
     	private static ColorManager	_instance = null;
31 |  |
32 |  |
     	/**
33 |  |
     	 * キャッシュ
34 |  |
     	 */
35 | 0 |
     	private Map	_cache = null;
36 |  |
37 |  |
38 |  |
     	/**
39 |  |
     	 * <code>ColorManager</code> のインスタンスを作成します。
40 |  |
     	 */
41 |  |
     	private ColorManager()
42 |  |
     	{
43 | 0 |
     		super();
44 | 0 |
     	}
45 |  |
46 |  |
47 |  |
     	/**
48 |  |
     	 * 初期化を行います。
49 |  |
     	 */
50 |  |
     	private void initialize()
51 |  |
     	{
52 | 0 |
     		_cache = new java.util.HashMap( 89 );
53 | 0 |
     		_cache.put( "black", new WeakReference(Color.black) );
54 | 0 |
     		_cache.put( "white", new WeakReference(Color.white) );
55 | 0 |
     		_cache.put( "red", new WeakReference(Color.red) );
56 | 0 |
     		_cache.put( "blue", new WeakReference(Color.blue) );
57 | 0 |
     		_cache.put( "green", new WeakReference(Color.green) );
58 | 0 |
     		_cache.put( "yellow", new WeakReference(Color.yellow) );
59 | 0 |
     		_cache.put( "gray", new WeakReference(Color.gray) );
60 | 0 |
     		_cache.put( "darkGray", new WeakReference(Color.darkGray) );
61 | 0 |
     		_cache.put( "lightGray", new WeakReference(Color.lightGray) );
62 | 0 |
     		_cache.put( "cyan", new WeakReference(Color.cyan) );
63 | 0 |
     		_cache.put( "magenta", new WeakReference(Color.magenta) );
64 | 0 |
     		_cache.put( "orange", new WeakReference(Color.orange) );
65 | 0 |
     		_cache.put( "pink", new WeakReference(Color.pink) );
66 | 0 |
     		_cache.put( null, new WeakReference(Color.black) );
67 | 0 |
     	}
68 |  |
69 |  |
     	public Color getColor( String name )
70 |  |
     	{
71 | 0 |
     		Color	color = null;
72 |  |
73 | 0 |
     		Object	cache = _cache.get( name );
74 | 0 |
     		if( cache != null )	{
75 | 0 |
     			color = (Color)((WeakReference)cache).get();
76 |  |
     		}
77 |  |
78 | 0 |
     		if( color == null )	{
79 | 0 |
     			if( name.startsWith("#") )	{
80 |  |
     				try	{
81 | 0 |
     					color = new Color( Integer.parseInt(name.substring(1), 16) );
82 | 0 |
     					WeakReference	ref = new WeakReference( color );
83 | 0 |
     					_cache.put( name, ref );
84 |  |
     				}
85 | 0 |
     				catch( Exception e )	{
86 | 0 |
     					Logger.error( "[resource] invalid color value specified. :" + name, e );
87 | 0 |
     					Logger.debug( "[resource] using default color. (black)" );
88 | 0 |
     					color = Color.black;
89 | 0 |
     				}
90 | 0 |
     			}
91 |  |
     			else	{
92 | 0 |
     				Logger.error( "[resource] invalid color name specified. :" + name );
93 | 0 |
     				Logger.debug( "[resource] using default color. (black)" );
94 | 0 |
     				color = Color.black;
95 |  |
     			}
96 |  |
     		}
97 | 0 |
     		return color;
98 |  |
     	}
99 |  |
100 |  |
101 |  |
     	/**
102 |  |
     	 * 唯一の <code>ColorManager</code> インスタンスを取得します。
103 |  |
     	 * @return	唯一のインスタンス
104 |  |
     	 */
105 |  |
     	public static ColorManager getInstance()
106 |  |
     	{
107 | 0 |
     		if( _instance == null )	{
108 | 0 |
     			synchronized( ColorManager.class )	{
109 | 0 |
     				if( _instance == null )	{
110 | 0 |
     					_instance = new ColorManager();
111 | 0 |
     					_instance.initialize();
112 |  |
     				}
113 | 0 |
     			}
114 |  |
     		}
115 | 0 |
     		return _instance;
116 |  |
     	}
117 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.