本文整理汇总了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();
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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 );
}
示例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));
}
示例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() + ")");
}
示例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() + ")");
}
示例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();
}
}
示例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;
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}