Java Code Examples for com.google.gwt.user.client.Random#nextInt()

The following examples show how to use com.google.gwt.user.client.Random#nextInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageButton.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
 
Example 2
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: TopologyPresenter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private List<HostInfo> generateFakeDomain() {
    String[] hostNames = new String[]{"lightning", "eeak-a-mouse", "dirty-harry"};
    String[] groupNames =
            new String[]{"staging", "production", "messaging-back-server-test", "uat", "messaging", "backoffice",
                    "starlight"};

    int numHosts = 13;
    final List<HostInfo> hostInfos = new ArrayList<HostInfo>();

    for (int i = 0; i < numHosts; i++) {
        // host info
        String name = hostNames[Random.nextInt(2)] + "-" + i;
        boolean isController = (i < 1);

        HostInfo host = new HostInfo(name, isController);
        host.setServerInstances(new ArrayList<ServerInstance>());

        // server instances
        for (int x = 0; x < (Random.nextInt(5) + 1); x++) {
            int groupIndex = Random.nextInt(groupNames.length - 1);
            ServerInstance serverInstance = beanFactory.serverInstance().as();
            serverInstance.setGroup(groupNames[groupIndex]);
            serverInstance.setRunning((groupIndex % 2 == 0));
            if (serverInstance.isRunning()) {
                if (Random.nextBoolean()) {
                    serverInstance.setFlag(Random.nextBoolean() ? RESTART_REQUIRED : RELOAD_REQUIRED);
                } else {
                    serverInstance.setFlag(null);
                }
            }
            serverInstance.setName(groupNames[groupIndex] + "-" + x);
            serverInstance.setSocketBindings(Collections.<String, String>emptyMap());
            serverInstance.setInterfaces(Collections.<String, String>emptyMap());

            host.getServerInstances().add(serverInstance);
        }
        hostInfos.add(host);
    }
    return hostInfos;
}
 
Example 4
Source File: UserCard.java    From gwt-material-demo with Apache License 2.0 4 votes vote down vote up
public int getRandomHeight(){
    return items[Random.nextInt(items.length)];
}
 
Example 5
Source File: FlowDemo.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
RandomTimedFunction(String name, boolean shouldFail)
{
    this.name = name;
    this.delayMillis = Random.nextInt(20) * 100;
    this.shouldFail = shouldFail;
}