亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pedometer.java

?? 一套j2me的UI界面庫
?? JAVA
字號:
package org.j4me.examples.bluetoothgps;

import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import org.j4me.bluetoothgps.*;
import org.j4me.examples.log.*;
import org.j4me.logging.*;
import org.j4me.ui.*;
import org.j4me.ui.components.*;

/**
 * Shows the current location information.  At the top of the screen is a
 * pedometer showing the total distance traveled and the average speed.  Note
 * this is a poor pedometer because it does not attempt to remove inaccuracies
 * from the location updates.  The remainder of the screen shows the location
 * data as it is returned from the provider including:
 * <ul>
 *  <li>Coordinates
 *  <li>Altitude
 *  <li>Speed
 *  <li>Course
 *  <li>Timestamp
 * </ul>
 */
public class Pedometer
	extends Dialog
	implements LocationListener
{
	/**
	 * The number of yards in a meter.
	 */
	private static final float YARDS_PER_METER = 1.09361329833771f;

	/**
	 * How many seconds between getting new location information.
	 */
	private static final int INTERVAL = 5;
	
	/**
	 * How many seconds to wait for new location information before
	 * giving up.
	 */
	private static final int TIMEOUT = -1;  // Default
	
	/**
	 * The maximum number of seconds ago a location can be for it to
	 * be valid.  We will never get locations older than this.
	 */
	private static final int MAX_AGE = -1;  // Default

	/**
	 * A large font used for section headings.
	 */
	private static final Font LARGE_FONT = Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE );
	
	/**
	 * The normal font used for data.
	 */
	private static final Font NORMAL_FONT = Font.getFont( Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM );

	/**
	 * The location information for this application.
	 */
	private final LocationModel model;
	
	/**
	 * The current state of the location provider.  This is "out of service",
	 * "temporarily unavailable", or "available".
	 */
	private Label state = new Label();
	
	/**
	 * The total distance traveled in meters.
	 */
	private FieldValue traveled = new FieldValue( "Traveled (ft)" );
	
	/**
	 * The average speed traveled in meters per second.
	 */
	private FieldValue avgSpeed = new FieldValue( "Avg speed (MPH)" );
	
	/**
	 * The current latitude.
	 */
	private FieldValue latitude = new FieldValue( "Latitude" );
	
	/**
	 * The current longitude.
	 */
	private FieldValue longitude = new FieldValue( "Longitude" );
	
	/**
	 * The current accuracy of the latitude and longitude in meters.
	 */
	private FieldValue horizontalAccuracy = new FieldValue( "Horizontal accuracy (ft)" );
	
	/**
	 * The current altitude in meters.
	 */
	private FieldValue altitude = new FieldValue( "Altitude (ft)" );
	
	/**
	 * The current accuracy of the altitude in meters.
	 */
	private FieldValue verticalAccuracy = new FieldValue( "Vertical accuracy (ft)" );
	
	/**
	 * The current speed in meters per second.
	 */
	private FieldValue speed = new FieldValue( "Speed (MPH)" );
	
	/**
	 * The current compass bearing in degrees where 0.0 is true north.
	 */
	private FieldValue course = new FieldValue( "Course (deg)" );
	
	/**
	 * The time of the last location.
	 */
	private FieldValue time = new FieldValue( "Timestamp" );
	
	/**
	 * The total distance traveled in meters.
	 */
	private float totalDistance;
	
	/**
	 * The time when the first distance was recorded.  Dividing this into
	 * <code>totalDistance</code> gives the average speed.
	 */
	private long startTime;
	
	/**
	 * The last coordinates recorded.
	 */
	private QualifiedCoordinates lastCoordinates;

	/**
	 * Constructs the "Pedometer" screen.
	 * 
	 * @param model is the application's location data.
	 */
	public Pedometer (LocationModel model)
	{
		this.model = model;
		
		// Set the menu bar options.
		setMenuText( null, "Menu" );
		
		// Show the state of the location provider.
		state.setHorizontalAlignment( Graphics.HCENTER );
		setStateLabel( model.getLocationProvider().getState() );
		append( state );
		
		// Create a UI section for pedometer information.
		createNewSection( "Pedometer" );
		append( traveled );
		append( avgSpeed );
		
		// Create a UI section for location information.
		createNewSection( "Location" );
		append( latitude );
		append( longitude );
		append( horizontalAccuracy );
		append( new Label() );  // Blank line
		append( altitude );
		append( verticalAccuracy );
		
		// Create a section for movement information.
		createNewSection( "Movement" );
		append( speed );
		append( course );
		
		// Create a section for the time.
		createNewSection( "Time" );
		append( time );
		
		// Register for location updates.
		LocationProvider provider = model.getLocationProvider();
		provider.setLocationListener( this, INTERVAL, TIMEOUT, MAX_AGE );
	}

	/**
	 * Adds components for a new section of information.
	 * 
	 * @param title is the name of the section.
	 */
	private void createNewSection (String title)
	{
		append( new HorizontalRule() );
		
		Label header = new Label();
		header.setFont( LARGE_FONT );
		header.setLabel( title );
		append( header );
	}
	
	/**
	 * Called when the user presses the "Menu" menu option.
	 * 
	 * @see org.j4me.ui.DeviceScreen#acceptNotify()
	 */
	protected void acceptNotify ()
	{
		Menu menu = new Menu( "Menu", this );
		
		// Choose different location provider criteria.
		menu.appendMenuOption( new CriteriaSelectionScreen(model) );
		
		// Reset the current location provider.
		menu.appendMenuOption( new MenuItem()
			{
				public String getText ()
				{
					return "Reset Location Provider";
				}

				public void onSelection ()
				{
					// Reset the location provider.
					try
					{
						model.getLocationProvider().reset();
					}
					catch (IOException e)
					{
						Log.warn("Could not reset the location provider", e);
					}
					
					show();
				}
			} );
		
		// See the application's log.
		menu.appendMenuOption( new LogScreen(this) );
		
		menu.show();
		
		// Continue processing the event.
		super.acceptNotify();
	}

	/**
	 * Updates the screen whenever a new location is updated.
	 * <p>
	 * This gets called on a different thread from the main UI thread.
	 * 
	 * @see org.j4me.bluetoothgps.LocationListener#locationUpdated(org.j4me.bluetoothgps.LocationProvider, org.j4me.bluetoothgps.Location)
	 */
	public void locationUpdated (LocationProvider provider, Location location)
	{
		// Throw out invalid location updates.
		if ( location.isValid() )
		{
			// Update the pedometer data.
			QualifiedCoordinates coordinates = location.getQualifiedCoordinates();
			
			if ( lastCoordinates == null )
			{
				// Just starting.
				lastCoordinates = coordinates;
				startTime = System.currentTimeMillis();
			}
			else
			{
				// Record another position.
				totalDistance += lastCoordinates.distance( coordinates );
				float averageSpeed = totalDistance / (System.currentTimeMillis() - startTime) * 1000;
				lastCoordinates = coordinates;

				float distance = convertMetersToFeet( totalDistance );
				traveled.setLabel( distance );
				
				averageSpeed = convertMPStoMPH( averageSpeed );
				avgSpeed.setLabel( averageSpeed );
			}
			
			// Update the location data.
			double lat = coordinates.getLatitude();
			latitude.setLabel( lat );
			
			double lon = coordinates.getLongitude();
			longitude.setLabel( lon );
			
			float ha = coordinates.getHorizontalAccuracy();
			ha = convertMetersToFeet( ha );
			horizontalAccuracy.setLabel( ha );
			
			float alt = coordinates.getAltitude();
			alt = convertMetersToFeet( alt );
			altitude.setLabel( alt );
			
			float va = coordinates.getVerticalAccuracy();
			va = convertMetersToFeet( va );
			verticalAccuracy.setLabel( va );
			
			float s = location.getSpeed();
			s = convertMPStoMPH( s );
			speed.setLabel( s );
			
			float c = location.getCourse();
			course.setLabel( c );
			
			long t = location.getTimestamp();
			time.setLabel( t );
			
			// Update this screen.
			invalidate();
			repaint();
		}
	}

	/**
	 * Updates the screen whenever the location provider changes state.
	 * <p>
	 * This gets called on a different thread from the main UI thread.
	 * 
	 * @see org.j4me.bluetoothgps.LocationListener#providerStateChanged(org.j4me.bluetoothgps.LocationProvider, int)
	 */
	public void providerStateChanged (LocationProvider provider, int newState)
	{
		// Display the state.
		setStateLabel( newState );
		repaint();
	}
	
	/**
	 * Sets the <code>state</code> label with the location provider's state.
	 * 
	 * @param newState is the location provider's state.
	 */
	private void setStateLabel (int newState)
	{
		switch ( newState )
		{
		case LocationProvider.AVAILABLE:
			state.setLabel("Available");
			break;
		case LocationProvider.TEMPORARILY_UNAVAILABLE:
			state.setLabel("Temporarily unavailable");
			break;
		case LocationProvider.OUT_OF_SERVICE:
			state.setLabel("Out of service");
			break;
		}
	}
	
	/**
	 * Shows a field and its value such as "Speed (m/s):  5.0".
	 */
	private static final class FieldValue
		extends Label
	{
		private final String name;
		
		public FieldValue (String name)
		{
			this.name = name;
			
			setFont( NORMAL_FONT );
		}
		
		public void setLabel (String label)
		{
			super.setLabel( name + ":  " + label );
		}
		
		public void setLabel (double d)
		{
			String s = Double.toString( d );
			setLabel( s );
		}
		
		public void setLabel (float f)
		{
			String s = Float.toString( f );
			setLabel( s );
		}
		
		public void setLabel (long l)
		{
			Date d = new Date( l );
			String s = d.toString();
			setLabel( s );
		}
	}
	
	/**
	 * Converts between meters and feet.
	 * 
	 * @param meters is the number of meters.
	 * @return The number of feet in <code>meters</code>.
	 */
	public static float convertMetersToFeet (float meters)
	{
		float yards = meters * YARDS_PER_METER;
		float feet = yards * 3.0f;
		return feet;
	}

	/**
	 * Converts meters per second to miles per hour.
	 * 
	 * @param metersPerSecond is a speed in meters/second.
	 * @return MPH.
	 */
	public static float convertMPStoMPH (float metersPerSecond)
	{
		float feetPerSecond = convertMetersToFeet( metersPerSecond );
		float feetPerHour = feetPerSecond * 3600;
		float milesPerHour = feetPerHour / 5280;
		return milesPerHour;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日本欧洲亚洲| 国产视频911| 高清视频一区二区| 亚洲v日本v欧美v久久精品| 欧美激情一区二区三区四区| 91极品视觉盛宴| 国产成人免费视频网站高清观看视频| 亚洲免费伊人电影| 国产欧美一区二区精品婷婷| 欧美日韩国产综合久久| 不卡视频在线观看| 久草中文综合在线| 亚洲午夜在线观看视频在线| 国产精品卡一卡二| 精品国产乱码久久久久久夜甘婷婷| 欧洲av在线精品| 国产999精品久久久久久绿帽| 日韩二区三区四区| 亚洲综合色成人| 国产精品黄色在线观看| 欧美精品一区二区三区蜜桃| 欧美日韩在线综合| 色哟哟一区二区三区| 懂色av噜噜一区二区三区av| 久久99热99| 奇米四色…亚洲| 婷婷久久综合九色综合伊人色| 亚洲视频1区2区| 国产欧美一区二区精品性色 | 欧美一区日韩一区| 色8久久人人97超碰香蕉987| jiyouzz国产精品久久| 国内国产精品久久| 久久爱另类一区二区小说| 美女一区二区久久| 日韩电影在线观看一区| 亚洲妇熟xx妇色黄| 亚洲国产va精品久久久不卡综合| 亚洲免费资源在线播放| 亚洲欧美日韩中文字幕一区二区三区| 中文字幕av一区二区三区免费看| 国产日韩欧美综合一区| 久久精品一二三| 久久久久久久久久电影| 久久麻豆一区二区| 久久久蜜桃精品| 国产三级一区二区| 欧美国产日韩亚洲一区| 国产精品传媒入口麻豆| 综合在线观看色| 亚洲柠檬福利资源导航| 一区二区中文视频| 国产精品传媒在线| 一区二区三区四区高清精品免费观看 | 亚洲福利视频三区| 亚洲成人激情自拍| 日韩成人精品在线| 久久精品国产亚洲a| 精品一区二区免费在线观看| 国产毛片精品视频| 丁香六月久久综合狠狠色| 成人激情免费视频| 日本精品一区二区三区高清 | 亚洲精品在线免费观看视频| 久久久三级国产网站| 国产精品乱人伦| 亚洲一区二区三区视频在线| 香蕉av福利精品导航| 日本亚洲一区二区| 国内精品视频一区二区三区八戒| 国产精品99久| 色天使色偷偷av一区二区| 欧美性生活大片视频| 欧美成人乱码一区二区三区| 日本一区免费视频| 一区二区三区四区激情| 免费成人在线网站| 福利一区在线观看| 色婷婷亚洲精品| 91精品国产日韩91久久久久久| 日韩欧美一区二区不卡| 欧美激情一区二区三区在线| 亚洲国产日日夜夜| 激情小说欧美图片| 97久久超碰国产精品电影| 欧美一区二区三区在线观看 | 国产精品久久久久久久久快鸭 | 久久精品国内一区二区三区| www.日韩大片| 在线不卡a资源高清| 中文字幕第一区二区| 亚洲h精品动漫在线观看| 国内一区二区视频| 欧美日韩亚洲综合一区二区三区| 久久香蕉国产线看观看99| 亚洲伊人色欲综合网| 国产一区二区三区免费播放| 欧美日韩一区不卡| 国产女人aaa级久久久级| 日本伊人午夜精品| 91蜜桃网址入口| 久久噜噜亚洲综合| 爽好久久久欧美精品| 99re在线精品| 国产亚洲精品精华液| 日韩和欧美一区二区| 9l国产精品久久久久麻豆| 精品久久久久久无| 亚洲bt欧美bt精品| 97se亚洲国产综合在线| 久久久天堂av| 老司机午夜精品| 欧美视频一区二区三区在线观看 | 亚洲男人的天堂在线观看| 国产麻豆精品theporn| 制服丝袜亚洲播放| 亚洲精品视频在线观看免费| 成人综合日日夜夜| 精品人在线二区三区| 丝袜美腿亚洲一区| 欧美在线观看视频一区二区| 中文一区二区完整视频在线观看| 蜜桃一区二区三区四区| 欧美剧情电影在线观看完整版免费励志电影| 久久久国产午夜精品| 精品一二线国产| 91精品国产一区二区三区香蕉| 一区二区三区日本| 色综合久久六月婷婷中文字幕| 国产欧美精品在线观看| 国产美女在线观看一区| 久久综合中文字幕| 激情成人综合网| 精品久久国产老人久久综合| 日本欧美一区二区在线观看| 在线播放视频一区| 日韩国产成人精品| 7777精品伊人久久久大香线蕉经典版下载| 依依成人综合视频| 在线观看一区日韩| 亚洲第一福利一区| 欧美日韩视频专区在线播放| 亚洲电影在线免费观看| 欧美日韩成人综合| 日韩电影在线一区二区| 日韩精品影音先锋| 国模娜娜一区二区三区| 久久人人97超碰com| 国产精品中文字幕日韩精品 | 蜜臀a∨国产成人精品| 日韩精品综合一本久道在线视频| 麻豆精品视频在线观看免费| 26uuu国产电影一区二区| 国产一区二区伦理| 中文字幕免费不卡| 日本韩国欧美国产| 五月天久久比比资源色| 日韩免费在线观看| 国产成人一级电影| 亚洲天天做日日做天天谢日日欢 | 国产精品毛片a∨一区二区三区| 成人av中文字幕| 亚洲国产日日夜夜| 日韩精品一区二区三区四区视频| 国产很黄免费观看久久| 日韩理论片在线| 欧美日韩在线观看一区二区| 看电影不卡的网站| 中国色在线观看另类| 欧美在线不卡视频| 美女视频网站久久| 亚洲国产精品ⅴa在线观看| 91麻豆swag| 日韩不卡一二三区| 国产欧美日本一区二区三区| 一本高清dvd不卡在线观看 | 99久久婷婷国产| 亚洲国产美女搞黄色| 精品欧美一区二区在线观看| 99精品欧美一区二区蜜桃免费 | 欧美变态口味重另类| 不卡欧美aaaaa| 婷婷成人综合网| 国产农村妇女精品| 欧美浪妇xxxx高跟鞋交| 懂色av一区二区在线播放| 香蕉成人啪国产精品视频综合网 | 久久亚洲影视婷婷| 在线观看区一区二| 国产精品一二三区在线| 亚洲国产美女搞黄色| 久久精品欧美一区二区三区不卡 | 成人伦理片在线| 日本欧美一区二区在线观看| 中文字幕一区二区三| 日韩精品一区二区三区在线观看 | a级精品国产片在线观看| 婷婷六月综合网| 日韩毛片高清在线播放| 精品国产一区二区亚洲人成毛片|