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


Java Random.nextInt方法代码示例

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


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

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

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

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

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

示例5: run

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
@Override
public void run() {
	//Choose the first background image randomly
	backgroundImageIndex = Random.nextInt( mainBackgroundImageURLs.size() ) ;
	//Choose the logo image randomly
	logoTimeImageIndex = Random.nextInt( logoTimeImageURLs.size() ) ;
	
	//Set the background image and its size
	updateMainImagesAndSizes();
	
	//Reschedule to run in 30 minutes
	this.schedule( 1800000 );
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:14,代码来源:SiteDynamicDecorations.java

示例6: getRandomIndexes

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
private JsArray<Integer> getRandomIndexes(int quantity, JsArray<Integer> excludes) {
    int number;

    if(excludes.length() == quantity)
        return excludes;

    do {
        number = Random.nextInt(size());
    } while (excludes.contains(number));

    return getRandomIndexes(quantity, excludes.add(number));
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:13,代码来源:Collection.java

示例7: __login

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
private void __login(String sessionId, String login) {
    LoginModel loginModel = LoginModel.getInstance();
    loginModel.setLoggedIn(true);
    loginModel.setLogin(login);
    loginModel.setSessionId(sessionId);

    if (loginView != null)
        SchedulerController.this.loginView.destroy();
    this.loginView = null;
    this.schedulerView = new SchedulerPage(this);

    this.executionController.getJobsController().fetchJobs(true);

    this.startTimer();

    String lstr = "";
    if (login != null) {
        lstr += " as " + login;
    }

    Settings.get().setSetting(SESSION_SETTING, sessionId);
    if (login != null) {
        Settings.get().setSetting(LOGIN_SETTING, login);
    } else {
        Settings.get().clearSetting(LOGIN_SETTING);
    }

    // this cookie is reset to a random int on every login:
    // if another session in another tab has a different localSessionNUm
    // than the one in the domain cookie, then we exit
    this.localSessionNum = "" + System.currentTimeMillis() + "_" + Random.nextInt();
    Cookies.setCookie(LOCAL_SESSION_COOKIE, this.localSessionNum);

    LogModel.getInstance().logMessage("Connected to " + SchedulerConfig.get().getRestUrl() + lstr + " (sessionId=" +
                                      loginModel.getSessionId() + ", login=" + loginModel.getLogin() + ")");
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:37,代码来源:SchedulerController.java

示例8: __login

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
private void __login(String sessionId, String login) {
    LoginModel loginModel = LoginModel.getInstance();
    loginModel.setLoggedIn(true);
    loginModel.setLogin(login);
    loginModel.setSessionId(sessionId);

    if (this.loginPage != null) {
        this.loginPage.destroy();
        this.loginPage = null;
    }
    this.rmPage = new RMPage(this);
    this.fetchRMMonitoring();
    this.fetchNodesLimit();
    this.startTimer();

    Settings.get().setSetting(SESSION_SETTING, sessionId);
    if (login != null) {
        Settings.get().setSetting(LOGIN_SETTING, login);
    } else {
        Settings.get().clearSetting(LOGIN_SETTING);
    }

    String lstr = "";
    if (login != null) {
        lstr += " as " + login;
    }

    // this cookie is reset to a random int on every login:
    // if another session in another tab has a different localSessionNUm
    // than the one in the domain cookie, then we exit
    this.localSessionNum = "" + System.currentTimeMillis() + "_" + Random.nextInt();
    Cookies.setCookie(LOCAL_SESSION_COOKIE, this.localSessionNum);

    LogModel.getInstance().logMessage("Connected to " + Config.get().getRestUrl() + lstr + " (sessionId=" +
                                      loginModel.getSessionId() + ")");
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:37,代码来源:RMController.java

示例9: 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);
        object.setAccount(accountMap.get(accountId));
        object.redraw();
    }
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:13,代码来源:ObjectCollectionCRSDisplay.java

示例10: generateRandomEvents

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
private void generateRandomEvents() {
    int screenX = 0; int screenY = 0;
    int x = 320; int y = 240;
    for (int i=0; i < 60; i++) {
        int xDelta = Random.nextInt(11) - 5;
        int yDelta = Random.nextInt(11) - 5;
        screenX += xDelta;
        x += xDelta;
        screenY += yDelta;
        y += yDelta;
        
        switch(Random.nextInt(4)) {
        case 0:
            Event.fireNativePreviewEvent(Document.get().createMouseOverEvent(0, screenX, screenY, x, y, false, false, false, false, 0, RootPanel.getBodyElement()));
            break;
        case 1:
            Event.fireNativePreviewEvent(Document.get().createMouseOutEvent(0, screenX, screenY, x, y, false, false, false, false, 0, RootPanel.getBodyElement()));
            break;
        case 2:
            Event.fireNativePreviewEvent(Document.get().createMouseDownEvent(0, screenX, screenY, x, y, false, false, false, false, 0));
            break;
        case 3:
            Event.fireNativePreviewEvent(Document.get().createMouseUpEvent(0, screenX, screenY, x, y, false, false, false, false, 0));
            break;
        }
    }
}
 
开发者ID:ivanceras,项目名称:crypto-gwt,代码行数:28,代码来源:GwtTstEventEntropySource.java

示例11: setRandomColour

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public void setRandomColour() {
    final int randomHue = Random.nextInt(360);
    setHue("hsl(" + randomHue + ",100%,50%)");
    final int red = Random.nextInt(255);
    final int green = Random.nextInt(255);
    final int blue = Random.nextInt(255);
    selectedColourData = new ColourData((int) red, (int) green, (int) blue);
    selectedColourPanel.getElement().setAttribute("style", "background:rgb(" + (int) red + "," + (int) green + "," + (int) blue + ")");
}
 
开发者ID:languageininteraction,项目名称:GraphemeColourSynaesthesiaApp,代码行数:10,代码来源:ColourPickerCanvasView.java

示例12: shuffleList

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
private void shuffleList(List<InfluenceAnswerViewInterface<Object>> list)
{
	int n = list.size();
	for (int i = 0; i < n; i++)
	{
		int change = i + Random.nextInt(n - i);
		InfluenceAnswerViewInterface<Object> helper = list.get(i);
		list.set(i, list.get(change));
		list.set(change, helper);
	}
}
 
开发者ID:jkonert,项目名称:socom,代码行数:12,代码来源:InfluencePresenter.java

示例13: createCaptcha

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static Image createCaptcha() {
    final Image captchaImage = new Image(
            "http://"
                    + Window.Location.getHost()
                    + CAPTCHA_URL
                    + Random.nextInt()
    );
    captchaImage.setStylePrimaryName("captchaRegister");
    return captchaImage;
}
 
开发者ID:halls,项目名称:wannatrak,代码行数:11,代码来源:Captcha.java

示例14: queryFriends

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
/**
 * Query the list of friends for the specified contact.
 * 
 * @param contact the contact
 * @return the friends of the contact
 */
public Set<ContactInfo> queryFriends(ContactInfo contact) {
  Set<ContactInfo> friends = friendsMap.get(contact.getId());
  if (friends == null) {
    // Assign some random friends.
    friends = new HashSet<ContactInfo>();
    int numContacts = dataProvider.getList().size();
    int friendCount = 2 + Random.nextInt(8);
    for (int i = 0; i < friendCount; i++) {
      friends.add(dataProvider.getList().get(Random.nextInt(numContacts)));
    }
    friendsMap.put(contact.getId(), friends);
  }
  return friends;
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:21,代码来源:ContactDatabase.java

示例15: shuffle

import com.google.gwt.user.client.Random; //导入方法依赖的package包/类
public static final void shuffle(final int[] input) {
    // --- Shuffle by exchanging each element randomly
    for (int i = 0; i < input.length; i++) {
        int randomPosition = Random.nextInt(input.length);
        int temp = input[i];
        input[i] = input[randomPosition];
        input[randomPosition] = temp;
    }
}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:10,代码来源:D3.java


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