当前位置: 首页>>代码示例>>Java>>正文


Java Random.nextDouble方法代码示例

本文整理汇总了Java中com.google.gwt.user.client.Random.nextDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Random.nextDouble方法的具体用法?Java Random.nextDouble怎么用?Java Random.nextDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.client.Random的用法示例。


在下文中一共展示了Random.nextDouble方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRandomManipulatedDoubleBetween

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static double getRandomManipulatedDoubleBetween(double upper, double lower)
{
	double factor = Random.nextDouble();
	
	double max,min;
	if (upper > lower)
	{
		max = upper;
		min = lower;
	}
	else
	{
		max = lower;
		min = upper;
	}
	
	double range = (max - min) /3;
	double randomBit = factor * range;
	return min + randomBit;
}
 
开发者ID:lachlanhurst,项目名称:BikeBingle,代码行数:21,代码来源:RandomBikeStackGenerator.java

示例2: getRandomDoubleBetween

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static double getRandomDoubleBetween(double upper, double lower)
{
	double factor = Random.nextDouble();
	
	double max,min;
	if (upper > lower)
	{
		max = upper;
		min = lower;
	}
	else
	{
		max = lower;
		min = upper;
	}
	
	double range = max - min;
	double randomBit = factor * range;
	return min + randomBit;
}
 
开发者ID:lachlanhurst,项目名称:BikeBingle,代码行数:21,代码来源:RandomBikeStackGenerator.java

示例3: onRectangleBtnClicked

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
@UiHandler("rectBtn")
public void onRectangleBtnClicked(ClickEvent event) {
	if (rectangleContainer != null) {
		rectangleContainer.clear();
		List<CanvasShape> shapes = new ArrayList<CanvasShape>();
		double factor = Math.pow(count, -0.5);
		for (int i = 0; i < count; i++) {
			double x = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
			double y = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
			double width = Random.nextDouble() * SHAPE_SIZE * factor;
			double height = Random.nextDouble() * SHAPE_SIZE * factor;
			CanvasRect rect = new CanvasRect(new Bbox(x - width / 2, y - height / 2, width, height));
			rect.setFillStyle(getRandomRGB(0.5));
			rect.setStrokeStyle(getRandomRGB(1));
			shapes.add(rect);
		}
		rectangleContainer.addAll(shapes);
		rectangleContainer.repaint();
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:21,代码来源:CanvasRenderingPanel.java

示例4: refreshWatchList

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
/**
 * Generate random stock prices.
 */
private void refreshWatchList() {
	
	final double MAX_PRICE = 100.0; // $100.00
	final double MAX_PRICE_CHANGE = 0.02; // +/- 2%

	StockPrice[] prices = new StockPrice[stocks.size()];
	for (int i = 0; i < stocks.size(); i++) {
		double price = Random.nextDouble() * MAX_PRICE;
		double change = price * MAX_PRICE_CHANGE * (Random.nextDouble() * 2.0 - 1.0);

		prices[i] = new StockPrice(stocks.get(i), price, change);
	}

	updateTable(prices);
}
 
开发者ID:jbosschina,项目名称:jcommerce,代码行数:19,代码来源:StockWatcher.java

示例5: onMapInitialized

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public void onMapInitialized(MapInitializationEvent event) {
	CanvasContainer container = mapPresenter.getContainerManager().addWorldCanvasContainer();
	final TracingLayer layer = new TracingLayer(mapPresenter.getViewPort(), container);
	mapPresenter.getLayersModel().addLayer(layer);
	mapPresenter.getLayersModelRenderer().setAnimated(layer, true);
	Timer timer = new Timer() {

		private boolean zoomOut;

		@Override
		public void run() {
			View endView = mapPresenter.getViewPort().asView(getNextBounds(), ZoomOption.LEVEL_CLOSEST);
			mapPresenter.getViewPort().registerAnimation(
					NavigationAnimationFactory.createZoomIn(mapPresenter, endView));
		}

		private Bbox getNextBounds() {
			if (zoomOut) {
				layer.setEnabled(false);
				zoomOut = false;
				return new Bbox(-5000000, -5000000, 10000000, 10000000);
			} else {
				layer.setEnabled(true);
				double x = (Random.nextDouble() - 0.5) * 5000000;
				double y = (Random.nextDouble() - 0.5) * 5000000;
				double width = 5000;
				double height = 5000;
				zoomOut = true;
				return new Bbox(x, y, width, height);
			}
		}

	};
	timer.scheduleRepeating(2000);
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:36,代码来源:MapTraceNavigationPanel.java

示例6: onPolyBtnClicked

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
@UiHandler("polyBtn")
public void onPolyBtnClicked(ClickEvent event) {
	if (polygonContainer != null) {
		polygonContainer.clear();
		List<CanvasShape> shapes = new ArrayList<CanvasShape>();
		double factor = Math.pow(count, -0.5);
		for (int i = 0; i < count; i++) {
			double x1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
			double y1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
			double x2 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
			double y2 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
			double x3 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
			double y3 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
			Coordinate[] coords = new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y2),
					new Coordinate(x3, y3), new Coordinate(x1, y1) };
			Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, 5);
			ring.setCoordinates(coords);
			Geometry poly = new Geometry(Geometry.POLYGON, 0, 5);
			poly.setGeometries(new Geometry[] { ring });
			CanvasPath path = new CanvasPath(poly);
			path.setFillStyle(getRandomRGB(0.5));
			path.setStrokeStyle(getRandomRGB(1));
			shapes.add(path);
		}
		polygonContainer.addAll(shapes);
		polygonContainer.repaint();
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:29,代码来源:CanvasRenderingPanel.java

示例7: onMarkersBtnClicked

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
@UiHandler("markersBtn")
public void onMarkersBtnClicked(ClickEvent event) {
	for (int i = 0; i < 20; i++) {
		double userX = Random.nextDouble() * 40000000 - 20000000;
		double userY = Random.nextDouble() * 40000000 - 20000000;
		Marker1 marker1 = new Marker1(resources.marker1(), userX, userY, 16, 32);
		container.add(marker1);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:10,代码来源:HtmlMarkerPanel.java

示例8: getRandomStackType

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static final int getRandomStackType()
{
	return (int)((12) * Random.nextDouble());
}
 
开发者ID:lachlanhurst,项目名称:BikeBingle,代码行数:5,代码来源:RandomBikeStackGenerator.java

示例9: getLineOfStacks

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static List getLineOfStacks(int number, LatLngBounds map)
{
	LatLng northEast = map.getNorthEast();
	LatLng southWest = map.getSouthWest();
	double width = (southWest.getLatitude() - northEast.getLatitude());
	double height = (northEast.getLongitude() - southWest.getLongitude());
	
	double heightStep = height/number;
	double widthStep = width/number;
	
	List res = new ArrayList();
	
	for (int i = 0; i < number; i++)
	{
		BikeStack stack = new BikeStack();
		
		//set the user name
		if (i % 6 == 0)
			stack.setUser("one");
		else if (i % 5 == 0)
			stack.setUser("two");
		else if (i % 4 == 0)
			stack.setUser("three");
		else if (i % 3 == 0)
			stack.setUser("four");
		else if (i % 2 == 0)
			stack.setUser("five");
		else
			stack.setUser("six");
		
		double lat = -1* widthStep * i + southWest.getLatitude() + ((Random.nextDouble() * widthStep)/3);
		double lng = heightStep * i + southWest.getLongitude() + ((Random.nextDouble() * heightStep)/3);
		
		stack.setLocation(lat, lng);
		stack.setType(getRandomStackType());
		
		stack.setOccuredDate(new Date());
		
		stack.setDescription("this is the stacks desciption for stack entered by: " + stack.getUser());
		res.add(stack);
		
	}
	
	return res;
}
 
开发者ID:lachlanhurst,项目名称:BikeBingle,代码行数:46,代码来源:RandomBikeStackGenerator.java


注:本文中的com.google.gwt.user.client.Random.nextDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。