Coverage report

  %line %branch
tsukuba_bunko.peko.scenario.stage.SoundHandler
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: SoundHandler.java,v 1.2 2005/08/19 03:18:11 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.AudioPlayer;
 26  
 import	tsukuba_bunko.peko.scenario.PSMLUtil;
 27  
 
 28  
 
 29  
 /**
 30  
  * <samp>start-bgm</samp>, <samp>stop-bgm</samp>, <samp>start-se</samp>,
 31  
  * <samp>stop-se</samp> 要素を処理する <code>ElementHandler</code> です。
 32  
  * @author	$Author: ppoi $
 33  
  * @version	$Revision: 1.2 $ $Date: 2005/08/19 03:18:11 $
 34  
  */
 35  
 public class SoundHandler	extends StageElementHandler	{
 36  
 
 37  
 	/**
 38  
 	 * <code>SoundHandler</code> のインスタンスを作成します。
 39  
 	 */
 40  
 	public SoundHandler()
 41  
 	{
 42  0
 		super();
 43  0
 	}
 44  
 
 45  
 
 46  
 //
 47  
 //	ContentHandler の実装
 48  
 //
 49  
 	public void startDocument()
 50  
 	{
 51  0
 	}
 52  
 
 53  
 	public void endDocument()
 54  
 	{
 55  0
 	}
 56  
 
 57  
 	public void startElement( String namespaceURI, String localName, String qName, Attributes attrs )
 58  
 	{
 59  0
 		String	id = PSMLUtil.getAttributeValue( attrs, "id" );
 60  0
 		if( id == null )	{
 61  0
 			Logger.error( MessageIDs.SCN3003E, new Object[]{getSceneContext().getCurrentPath()} );
 62  0
 			return;
 63  
 		}
 64  
 
 65  0
 		String	clipName = null;
 66  0
 		String	loop = null;
 67  0
 		boolean	lp = false;
 68  
 
 69  0
 		StageCoordinator	coordinator = getStageCoordinator();
 70  0
 		if( "play-bgm".equals(localName) )	{
 71  0
 			clipName = PSMLUtil.getAttributeValue( attrs, "clip" );
 72  0
 			if( clipName == null )	{
 73  0
 				Logger.warn( MessageIDs.SCN3004W, new Object[]{getSceneContext().getCurrentPath()} );
 74  0
 				return;
 75  
 			}
 76  
 
 77  0
 			loop = PSMLUtil.getAttributeValue( attrs, "loop" );
 78  0
 			if( loop != null )	{
 79  0
 				lp = (loop.equalsIgnoreCase("true") || loop.equalsIgnoreCase("yes") || loop.equalsIgnoreCase("on"));
 80  0
 			}
 81  
 			else	{
 82  0
 				lp = true;
 83  
 			}
 84  
 
 85  0
 			coordinator.playBGM( id, clipName, lp );
 86  0
 		}
 87  0
 		else if( "play-se".equals(localName) )	{
 88  0
 			clipName = PSMLUtil.getAttributeValue( attrs, "clip" );
 89  0
 			if( clipName == null )	{
 90  0
 				Logger.warn( MessageIDs.SCN3004W, new Object[]{getSceneContext().getCurrentPath()} );
 91  0
 				return;
 92  
 			}
 93  
 
 94  0
 			loop = PSMLUtil.getAttributeValue( attrs, "loop" );
 95  0
 			if( loop != null )	{
 96  0
 				lp = (loop.equalsIgnoreCase("true") || loop.equalsIgnoreCase("yes") || loop.equalsIgnoreCase("on"));
 97  0
 			}
 98  
 			else	{
 99  0
 				lp = false;
 100  
 			}
 101  
 
 102  0
 			coordinator.playSE( id, clipName, lp );
 103  0
 		}
 104  0
 		else if( "stop-bgm".equals(localName) )	{
 105  0
 			int	fadeoutMode = AudioPlayer.STOP_WITH_ASYNC_FADEOUT;
 106  0
 			String	fadeout = PSMLUtil.getAttributeValue( attrs, "fadeout" );
 107  0
 			if( fadeout != null )	{
 108  0
 				if( "sync".equals(fadeout) )	{
 109  0
 					fadeoutMode = AudioPlayer.STOP_WITH_SYNC_FADEOUT;
 110  0
 				}
 111  0
 				else if( "none".equals(fadeout) )	{
 112  0
 					fadeoutMode = AudioPlayer.STOP_IMMEDIATELY;
 113  0
 				}
 114  0
 				else if( "async".equals(fadeout) )	{
 115  0
 					fadeoutMode = AudioPlayer.STOP_WITH_ASYNC_FADEOUT;
 116  0
 				}
 117  
 				else	{
 118  0
 					Logger.warn( MessageIDs.SCN3007W, new Object[]{getSceneContext().getCurrentPath(), "async"} );
 119  
 				}
 120  
 			}
 121  0
 			coordinator.stopBGM( id, fadeoutMode );
 122  0
 		}
 123  0
 		else if( "stop-se".equals(localName) )	{
 124  0
 			int	fadeoutMode = AudioPlayer.STOP_WITH_ASYNC_FADEOUT;
 125  0
 			String	fadeout = PSMLUtil.getAttributeValue( attrs, "fadeout" );
 126  0
 			if( fadeout != null )	{
 127  0
 				if( "sync".equals(fadeout) )	{
 128  0
 					fadeoutMode = AudioPlayer.STOP_WITH_SYNC_FADEOUT;
 129  0
 				}
 130  0
 				else if( "none".equals(fadeout) )	{
 131  0
 					fadeoutMode = AudioPlayer.STOP_IMMEDIATELY;
 132  0
 				}
 133  0
 				else if( "async".equals(fadeout) )	{
 134  0
 					fadeoutMode = AudioPlayer.STOP_WITH_ASYNC_FADEOUT;
 135  0
 				}
 136  
 				else	{
 137  0
 					Logger.warn( MessageIDs.SCN3007W, new Object[]{getSceneContext().getCurrentPath(), "async"} );
 138  
 				}
 139  
 			}
 140  0
 			coordinator.stopSE( id, fadeoutMode );
 141  
 		}
 142  0
 	}
 143  
 }

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