本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例8: getRandomStackType
import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static final int getRandomStackType()
{
return (int)((12) * Random.nextDouble());
}
示例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;
}