Coverage report

| %line | %branch
--- | --- | ---
tsukuba_bunko.peko.scenario.stage.ActorHandler |
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: ActorHandler.java,v 1.3 2005/08/22 02:21:38 ppoi Exp $
18 |  |
      */
19 |  |
     package tsukuba_bunko.peko.scenario.stage;
20 |  |
21 |  |
     import	org.xml.sax.Attributes;
22 |  |
23 |  |
     import	tsukuba_bunko.peko.Logger;
24 |  |
25 |  |
     import	tsukuba_bunko.peko.canvas.stage.Actor;
26 |  |
27 |  |
     import	tsukuba_bunko.peko.resource.ResourceManager;
28 |  |
29 |  |
     import	tsukuba_bunko.peko.scenario.PSMLUtil;
30 |  |
31 |  |
32 |  |
     /**
33 |  |
      * <samp>enter</samp>, <samp>move</samp>, <samp>exit</samp> を処理する <code>ElementHandler</code> です。
34 |  |
      * @author	$Author: ppoi $
35 |  |
      * @version	$Revision: 1.3 $
36 |  |
      */
37 |  |
     public class ActorHandler	extends StageElementHandler	{
38 |  |
39 |  |
     	/**
40 |  |
     	 * <code>ActorHandler</code> のインスタンスを作成します。
41 |  |
     	 */
42 |  |
     	public ActorHandler()
43 |  |
     	{
44 | 0 |
     		super();
45 | 0 |
     	}
46 |  |
47 |  |
48 |  |
     //
49 |  |
     //	ContentHandler の実装
50 |  |
     //
51 |  |
     	public void startElement( String namespaceURI, String localName, String qName, Attributes attrs )
52 |  |
     	{
53 | 0 |
     		String	name = PSMLUtil.getAttributeValue( attrs, "name" );
54 | 0 |
     		if( (name == null) || (name.length() == 0) )	{
55 | 0 |
     			Logger.error( MessageIDs.SCN3001E, new Object[]{getSceneContext().getCurrentPath()} );
56 | 0 |
     			return;
57 |  |
     		}
58 |  |
59 | 0 |
     		String	looks = PSMLUtil.getAttributeValue( attrs, "looks" );
60 | 0 |
     		String	position = PSMLUtil.getAttributeValue( attrs, "position" );
61 |  |
62 | 0 |
     		StageCoordinator	coordinator = getStageCoordinator();
63 | 0 |
     		if( localName.equals("enter") )	{
64 | 0 |
     			if( coordinator.getActor(name) != null )	{
65 | 0 |
     				Logger.warn( MessageIDs.SCN3008W, new Object[]{name, getSceneContext().getCurrentPath()} );
66 |  |
     			}
67 | 0 |
     			Actor	actor = new Actor( name );
68 | 0 |
     			actor.setLooks( looks );
69 | 0 |
     			setPosition( actor, ((position == null)?"center":position), "center" );
70 | 0 |
     			coordinator.enter( actor );
71 | 0 |
     		}
72 | 0 |
     		else if( localName.equals("action") )	{
73 | 0 |
     			Actor	actor = coordinator.getActor( name );
74 | 0 |
     			if( actor == null )	{
75 | 0 |
     				Logger.warn( MessageIDs.SCN3002W, new Object[]{name, getSceneContext().getCurrentPath()} );
76 | 0 |
     			}
77 |  |
     			else	{
78 | 0 |
     				if( looks != null )	{
79 | 0 |
     					actor.setLooks( looks );
80 |  |
     				}
81 | 0 |
     				setPosition( actor, position, null );
82 |  |
     			}
83 | 0 |
     			coordinator.action( actor );
84 | 0 |
     		}
85 | 0 |
     		else if( localName.equals("exit") )	{
86 | 0 |
     			if( coordinator.exit(name) == null )	{
87 | 0 |
     				Logger.warn( MessageIDs.SCN3002W, new Object[]{name, getSceneContext().getCurrentPath()} );
88 |  |
     			}
89 |  |
     		}
90 |  |
91 | 0 |
     		String	effect = PSMLUtil.getAttributeValue( attrs, "effect" );
92 | 0 |
     		if( effect == null )	{
93 | 0 |
     			ResourceManager	resources = ResourceManager.getInstance();
94 | 0 |
     			effect = (String)resources.getResource( ResourceIDs.DEFAULT_EFFECT_ACTOR, true );
95 |  |
     		}
96 | 0 |
     		if( !coordinator.isSlideVisible() )	{
97 | 0 |
     			coordinator.updateStage( effect );
98 |  |
     		}
99 | 0 |
     	}
100 |  |
101 |  |
     	protected void setPosition( Actor actor, String position, String defaultPosition )
102 |  |
     	{
103 | 0 |
     		if( position == null )	{
104 | 0 |
     			return;
105 |  |
     		}
106 |  |
107 | 0 |
     		if( "center".equals(position) )	{
108 | 0 |
     			actor.setPosition( Actor.POSITION_CENTER );
109 | 0 |
     		}
110 | 0 |
     		else if( "left".equals(position) )	{
111 | 0 |
     			actor.setPosition( Actor.POSITION_LEFT );
112 | 0 |
     		}
113 | 0 |
     		else if( "right".equals(position) )	{
114 | 0 |
     			actor.setPosition( Actor.POSITION_RIGHT );
115 | 0 |
     		}
116 |  |
     		else	{
117 |  |
     			try	{
118 | 0 |
     				actor.setPosition( Float.parseFloat(position) );
119 |  |
     			}
120 | 0 |
     			catch( Exception e )	{
121 | 0 |
     				Logger.warn( MessageIDs.SCN3005W, new Object[]{getSceneContext().getCurrentPath()}, e );
122 | 0 |
     				setPosition( actor, defaultPosition, null );
123 | 0 |
     			}
124 |  |
     		}
125 | 0 |
     	}
126 |  |
     }

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