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


Java Random类代码示例

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


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

示例1: initComponent

import com.google.gwt.user.client.Random; //导入依赖的package包/类
/**
 * Sets the components widget representation and initializes its properties.
 *
 * <p>To be called from implementing constructor.
 *
 * @param widget  components visual representation in designer
 */
void initComponent(Widget widget) {
  // Widget needs to be initialized before the component itself so that the component properties
  // can be reflected by the widget
  initWidget(widget);

  // Capture mouse and click events in onBrowserEvent(Event)
  sinkEvents(Event.MOUSEEVENTS | Event.ONCLICK);

  // Add the special name property and set the tooltip
  String name = componentName();
  setTitle(name);
  addProperty(PROPERTY_NAME_NAME, name, null, new TextPropertyEditor());

  // TODO(user): Ensure this value is unique within the project using a list of
  // already used UUIDs
  // Set the component's UUID
  // The default value here can be anything except 0, because YoungAndroidProjectServce
  // creates forms with an initial Uuid of 0, and Properties.java doesn't encode
  // default values when it generates JSON for a component.
  addProperty(PROPERTY_NAME_UUID, "-1", null, new TextPropertyEditor());
  changeProperty(PROPERTY_NAME_UUID, "" + Random.nextInt());

  editor.getComponentPalettePanel().configureComponent(this);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:32,代码来源:MockComponent.java

示例2: createJob

import com.google.gwt.user.client.Random; //导入依赖的package包/类
private HTMLPanel createJob(String jobType) {
    final HTMLPanel p = JobPanels.createJobPanel(jobType);
    TextBox jobName = new TextBox();
    jobName.setName("jobName");
    jobName.setText(jobType + "_" + projectName + "_" + Random.nextInt());
    jobName.setVisible(false);
    p.add(jobName);
    final Button deleteButton = new Button("delete");
    deleteButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            deletePanel(p);
        }
    });
    p.addAndReplaceElement(deleteButton, "delete");
    if(jobType.equals("cron")) {
        addCronToggleButton(p, deleteButton);
    }
    activePanels.add(p);
    return p;
}
 
开发者ID:palantir,项目名称:gerrit-ci,代码行数:22,代码来源:ProjectConfigurationScreen.java

示例3: drawAccount

import com.google.gwt.user.client.Random; //导入依赖的package包/类
private void drawAccount(Canvas cubeBin, String url) {
        if (url == null || "".equals(url.trim())) {
            url = "blue.png";
        }
        if (cubeBin != null) {
            int width = cubeBin.getWidth();
            final Img img = new Img();
            img.setLeft(Random.nextInt(width - 50));
            img.setTop(Random.nextInt(240));
            img.setWidth(48);
            img.setHeight(48);
            img.setParentElement(cubeBin);
            img.setSrc(url);
            img.setCanDragReposition(true);
//        img.addClickHandler(new ClickHandler() {
//            public void onClick(ClickEvent event) {
//                img.destroy();
//            }
//        });
            img.redraw();
        }
    }
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:23,代码来源:SingleChoiceDisplay.java

示例4: drawPicture

import com.google.gwt.user.client.Random; //导入依赖的package包/类
private void drawPicture(Canvas cubeBin, String url, String accountId) {
        if (url == null || "".equals(url.trim())) {
            url = "blue.png";
        }
        if (cubeBin != null) {
            int width = cubeBin.getWidth();

//            DrawableObjectWithAccount object = new DrawableObjectWithAccount(url, Random.nextInt(width - 100), Random.nextInt(240), cubeBin);
            if (accountMap.get(accountId) != null && accountMap.get(accountId).getPicture()!=null){
                url = accountMap.get(accountId).getPicture();
            }
            DrawableObject object = new DrawableObject(url,Random.nextInt(width - 100), Random.nextInt(240), cubeBin);
//            object.setAccount(accountMap.get(accountId));
            object.redraw();
        }
    }
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:17,代码来源:MatrixCollectionCRSDisplay.java

示例5: 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

示例6: 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

示例7: 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

示例8: createContactInfo

import com.google.gwt.user.client.Random; //导入依赖的package包/类
/**
 * Create a new random {@link ContactInfo}.
 * 
 * @return the new {@link ContactInfo}.
 */
@SuppressWarnings("deprecation")
private ContactInfo createContactInfo() {
  ContactInfo contact = new ContactInfo(nextValue(categories));
  contact.setLastName(nextValue(LAST_NAMES));
  if (Random.nextBoolean()) {
    // Male.
    contact.setFirstName(nextValue(MALE_FIRST_NAMES));
  } else {
    // Female.
    contact.setFirstName(nextValue(FEMALE_FIRST_NAMES));
  }

  // Create a birthday between 20-80 years ago.
  int year = (new Date()).getYear() - 21 - Random.nextInt(61);
  contact.setBirthday(new Date(year, Random.nextInt(12), 1 + Random.nextInt(31)));

  // Create an address.
  int addrNum = 1 + Random.nextInt(999);
  String addrStreet = nextValue(STREET_NAMES);
  String addrSuffix = nextValue(STREET_SUFFIX);
  contact.setAddress(addrNum + " " + addrStreet + " " + addrSuffix);
  return contact;
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:29,代码来源:ContactDatabase.java

示例9: createSeries

import com.google.gwt.user.client.Random; //导入依赖的package包/类
private static JsArray<AreaSeries> createSeries() {
	JsArray<AreaSeries> series = JavaScriptObject.createArray().cast();
	AreaSeries s = SeriesBuilder
			.create()
			.withFillColor("rgba(220,220,220,0.5)")
			.withStoreColor("rgba(220,220,220,1)")
			.withPointColor("rgba(220,220,220,1)")
			.withPointStrokeColor("#fff")
			.withData(
					new double[] { Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400) })
			.get();
	series.push(s);
	series.push(SeriesBuilder
			.create()
			.withFillColor("rgba(151,187,205,0.5)")
			.withStoreColor("rgba(151,187,205,1)")
			.withPointColor("rgba(151,187,205,1)")
			.withPointStrokeColor("#fff")
			.withData(
					new double[] { Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400), Random.nextInt(400) })
					.get());

	return series;
}
 
开发者ID:sidney3172,项目名称:gwt-chartjs,代码行数:25,代码来源:TestAreaChartDataProvider.java

示例10: addSymbol

import com.google.gwt.user.client.Random; //导入依赖的package包/类
protected void addSymbol() {
	symbols.type(Type.values()[Random.nextInt(Type.values().length)]);
	symbols.size(Random.nextInt(2500) + 25);

	svg.append("path")
			.classed(css.symboldemo(), true)
			.attr("transform",
					Transform
							.parse("")
							.translate(Random.nextInt(width),
									Random.nextInt(height)).toString())
			.attr("d", symbols.generate(1.0))
			.style("fill",
					Colors.rgb(Random.nextInt(255), Random.nextInt(255),
							Random.nextInt(255)).toHexaString());
}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:17,代码来源:SymbolDemo.java

示例11: testEasingFunction

import com.google.gwt.user.client.Random; //导入依赖的package包/类
protected void testEasingFunction(final EasingFunction e1, final EasingFunction e2) {
	// test the extreme values
	assertEquals(0.0, e1.ease(0));
	assertEquals(1.0, e1.ease(1));

	assertEquals(0.0, e2.ease(0));
	assertEquals(1.0, e2.ease(1));

	Selection selection = D3.select(sandbox).append("div");
	// pass it to Transition.ease1
	//		D3.select(sandbox).append("div")
	//		.attr("foo", "stuff")
	selection.transition().duration(1000).ease(e1)
	.attr("foobar", Integer.toString(Random.nextInt()))
	.transition()
	.ease(e2)
	.attr("foobar", Integer.toString(Random.nextInt()));
}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:19,代码来源:TestEasing.java

示例12: insertComments

import com.google.gwt.user.client.Random; //导入依赖的package包/类
/**
	 * 调用评论信息
	 *
	 * @access  public
	 * @return  string
	 */
	public static void insertComments(int type, String id, HttpServletRequest request, ShopConfigWrapper scw) {
		//TODO
		/* 验证码相关设置 */
//		ShopConfigWrapper.getDefaultConfig().get("captcha")
		
		if(false) {
			
			request.setAttribute("enabledCaptcha", true);
			request.setAttribute("rand", Random.nextInt());
		}
		else {
			request.setAttribute("enabledCaptcha", false);
		}
		
		request.setAttribute("username", request.getSession().getAttribute(IWebConstants.KEY_USER_NAME));
		request.setAttribute("email", request.getSession().getAttribute(IWebConstants.KEY_USER_EMAIL));
		request.setAttribute("commentType", type);
		request.setAttribute("id", id);
		Map<String, Object> cmt = LibMain.assignComment(id, type, 1, SpringUtil.getCommentManager(), scw);
		request.setAttribute("comments", cmt.get("comments"));
		request.setAttribute("pager", cmt.get("pager"));
		
		return;
	}
 
开发者ID:jbosschina,项目名称:jcommerce,代码行数:31,代码来源:LibInsert.java

示例13: 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

示例14: init

import com.google.gwt.user.client.Random; //导入依赖的package包/类
private void init() {
        setStyleName("n52_sensorweb_client_imagebutton");
//        int length = this.size + 2 * this.margin;
//        this.setWidth(length);
//        this.setHeight(length);

        String loaderId = "loader_" + (LoaderManager.getInstance().getCount() + Random.nextInt(10000));
        this.loader = new LoaderImage(loaderId, "../img/mini_loader_bright.gif", this);

        this.setID(this.id);
        this.setSrc(this.icon);
        this.setShowHover(true);
        this.setShowRollOver(this.showRollOver);
        this.setShowDownIcon(this.showDown);
        this.setShowFocusedAsOver(false);
        this.setCursor(Cursor.POINTER);
        
        if (View.getView().isShowExtendedTooltip()) {
            this.setTooltip(this.extendedTooltip);
        }
        else {
            this.setTooltip(this.shortToolTip);
        }
    }
 
开发者ID:52North,项目名称:SensorWebClient,代码行数:25,代码来源:ImageButton.java

示例15: addWidget

import com.google.gwt.user.client.Random; //导入依赖的package包/类
/**
 * Place a new widget to paint panel
 * 
 * @param widget
 */
public void addWidget(final BaseWidget widget) {
	int h = this.scrollPanel.getOffsetHeight();
	int w = this.scrollPanel.getOffsetWidth();
	int offsetx = this.scrollPanel.getHorizontalScrollPosition();
	int offsety = this.scrollPanel.getVerticalScrollPosition();
	int x = offsetx + 4 * w / 9 + Random.nextInt(100);
	int y = offsety + 2 * h / 7 + Random.nextInt(100);
	addWidget(widget, x, y);
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:15,代码来源:DiagramController.java


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