Coverage report

  %line %branch
tsukuba_bunko.peko.canvas.stage.Actor
0% 
0% 

 1  
 /*
 2  
  * All Rights Reserved.
 3  
  * Copyright (C) 1999-2005 Tsukuba Bunko.
 4  
  *
 5  
  * Licensed under the BSD License ("the License"); you may not use
 6  
  * this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *       http://www.tsukuba-bunko.org/licenses/LICENSE.txt
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  * $Id: Actor.java,v 1.2 2005/07/23 18:52:15 ppoi Exp $
 18  
  */
 19  
 package tsukuba_bunko.peko.canvas.stage;
 20  
 
 21  
 import	java.awt.Image;
 22  
 
 23  
 import	java.io.Serializable;
 24  
 
 25  
 
 26  
 /**
 27  
  * 舞台上の登場人物です。
 28  
  * @author	$Author: ppoi $
 29  
  * @version	$Revision: 1.2 $
 30  
  */
 31  
 public class Actor	implements Serializable	{
 32  
 
 33  
 	/**
 34  
 	 * serial version UID
 35  
 	 */
 36  
 	private static final long	serialVersionUID	= 2277045062381106716L;
 37  
 
 38  
 	/**
 39  
 	 * 立ち位置:中央
 40  
 	 */
 41  
 	public static final int	POSITION_CENTER = 0;
 42  
 
 43  
 	/**
 44  
 	 * 立ち位置:左
 45  
 	 */
 46  
 	public static final int	POSITION_LEFT = 1;
 47  
 
 48  
 	/**
 49  
 	 * 立ち位置:右
 50  
 	 */
 51  
 	public static final int	POSITION_RIGHT = 2;
 52  
 
 53  
 	/**
 54  
 	 * 立ち位置:絶対指定
 55  
 	 */
 56  
 	public static final int	POSITION_ABSOLUTE = 3;
 57  
 
 58  
 
 59  
 	/**
 60  
 	 * 人物名
 61  
 	 */
 62  0
 	private String	_name = null;
 63  
 
 64  
 	/**
 65  
 	 * 描画イメージ名
 66  
 	 */
 67  0
 	private String	_looks = null;
 68  
 
 69  
 	/**
 70  
 	 * 描画イメージ
 71  
 	 */
 72  0
 	transient private Image	_looksImage = null;
 73  
 
 74  
 	/**
 75  
 	 * 立ち位置
 76  
 	 */
 77  0
 	private int	_position = Actor.POSITION_CENTER;
 78  
 
 79  
 	/**
 80  
 	 * 立ち位置の絶対位置
 81  
 	 */
 82  0
 	private float	_absolutePosition = 0.0f;
 83  
 
 84  
 
 85  
 	/**
 86  
 	 * <code>Actor</code> のインスタンスを作成します。
 87  
 	 * @param	name	人物名
 88  
 	 * @throws	IllegalArgumentException	<code>name</code> が <code>null</code> の場合
 89  
 	 */
 90  
 	public Actor( String name )
 91  
 	{
 92  0
 		super();
 93  0
 		if( name == null )	{
 94  0
 			throw new IllegalArgumentException( "name is not specified." );
 95  
 		}
 96  0
 		_name = name;
 97  0
 	}
 98  
 
 99  
 
 100  
 	/**
 101  
 	 * 人物名を取得します。
 102  
 	 * @return	人物名
 103  
 	 */
 104  
 	public String getName()
 105  
 	{
 106  0
 		return _name;
 107  
 	}
 108  
 
 109  
 	/**
 110  
 	 * 表情(立ち絵)を設定します。
 111  
 	 * @param	looks	表情(立ち絵)
 112  
 	 */
 113  
 	public void setLooks( String looks )
 114  
 	{
 115  0
 		ImageManager	images = ImageManager.getInstance();
 116  0
 		if( (_looks != null) && _looks.equals(looks) )	{
 117  0
 			if( _looksImage == null )	{
 118  0
 				setLooksImage( images.getImage(looks, true) );
 119  0
 			}
 120  
 		}
 121  
 		else	{
 122  0
 			if( _looksImage != null )	{
 123  0
 				images.putImage( _looks, _looksImage );
 124  
 			}
 125  0
 			setLooksImage( images.getImage(looks, true) );
 126  
 		}
 127  0
 		_looks = looks;
 128  0
 	}
 129  
 
 130  
 	/**
 131  
 	 * 表情(立ち絵)を取得します。
 132  
 	 * @return	表情(立ち絵)
 133  
 	 */
 134  
 	public String getLooks()
 135  
 	{
 136  0
 		return _looks;
 137  
 	}
 138  
 
 139  
 	/**
 140  
 	 * 表情(立ち絵)画像を設定します。
 141  
 	 * @param	looks	表情(立ち絵)
 142  
 	 */
 143  
 	public void setLooksImage( Image looks )
 144  
 	{
 145  0
 		_looksImage = looks;
 146  0
 	}
 147  
 
 148  
 	/**
 149  
 	 * 表情(立ち絵)画像を取得します。
 150  
 	 * @return	表情(立ち絵)
 151  
 	 */
 152  
 	public Image getLooksImage()
 153  
 	{
 154  0
 		return _looksImage;
 155  
 	}
 156  
 
 157  
 	/**
 158  
 	 * 立ち位置を設定します。
 159  
 	 * @param	position	立ち位置。{@link #POSITION_CENTER}, {@link #POSITION_LEFT}, {@link #POSITION_RIGHT} から選択します。
 160  
 	 */
 161  
 	public void setPosition( int position )
 162  
 	{
 163  0
 		if( (position == Actor.POSITION_CENTER) || (position == Actor.POSITION_LEFT) || (position == Actor.POSITION_RIGHT) )	{
 164  0
 			_position = position;
 165  0
 		}
 166  
 		else	{
 167  0
 			throw new IllegalArgumentException( "invalid position type is specified." );
 168  
 		}
 169  0
 	}
 170  
 
 171  
 	/**
 172  
 	 * 立ち位置を絶対指定で設定します。
 173  
 	 * @param	absolutePosition	絶対指定された立ち位置
 174  
 	 */
 175  
 	public void setPosition( float absolutePosition )
 176  
 	{
 177  0
 		_position = Actor.POSITION_ABSOLUTE;
 178  0
 		_absolutePosition = absolutePosition;
 179  0
 	}
 180  
 
 181  
 	/**
 182  
 	 * 立ち位置を取得します。
 183  
 	 * @return	立ち位置
 184  
 	 */
 185  
 	public int getPosition()
 186  
 	{
 187  0
 		return _position;
 188  
 	}
 189  
 
 190  
 	/**
 191  
 	 * 立ち位置の絶対位置を取得します。
 192  
 	 * @return	絶対指定された立ち位置
 193  
 	 */
 194  
 	public float getAbsolutePosition()
 195  
 	{
 196  0
 		return _absolutePosition;
 197  
 	}
 198  
 
 199  
 	/**
 200  
 	 * この Actor を破棄します。
 201  
 	 */
 202  
 	void disposeLooks()
 203  
 	{
 204  0
 		if( _looksImage != null )	{
 205  0
 			ImageManager	images = ImageManager.getInstance();
 206  0
 			images.putImage( _looks, _looksImage );
 207  0
 			_looksImage = null;
 208  
 		}
 209  0
 	}
 210  
 
 211  
 	/**
 212  
 	 */
 213  
 	void prepare()
 214  
 	{
 215  0
 		setLooks( _looks );
 216  0
 	}
 217  
 
 218  
 
 219  
 	/**
 220  
 	 * 現在の状態を <code>actor</code> にコピーします。
 221  
 	 * @param	actor	コピー先の Actor オブジェクト
 222  
 	 */
 223  
 	public void copyTo( Actor actor )
 224  
 	{
 225  0
 		actor._name = _name;
 226  0
 		actor._looksImage = _looksImage;
 227  0
 		actor._looks = _looks;
 228  0
 		actor._position = _position;
 229  0
 		actor._absolutePosition = _absolutePosition;
 230  0
 	}
 231  
 }

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