/** * Adds the specified builder of a {@link Renderer}. * @param builder The builder to add. * @return A new builder instance. */ @CheckReturnValue public Builder with(ModelBuilder<? extends Renderer, ?> builder) { return create(ImmutableSet .<ModelBuilder<? extends Renderer, ?>>builder() .addAll(renderers()) .add(builder) .build(), viewOptions(), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Change the resolution of the window. Default resolution: * {@link #DEFAULT_WINDOW_SIZE}. * @param width The new width to use. * @param height The new height to use. * @return A new builder instance. */ @CheckReturnValue public Builder withResolution(int width, int height) { checkArgument(width > 0 && height > 0, "Only positive dimensions are allowed, input: %s x %s.", width, height); return create(renderers(), viewOptions(), accelerators(), speedUp(), stopTime(), title(), new Point(width, height), callback(), monitor(), display()); }
/** * Allows to register a {@link Listener} for stop events of the simulator. * @param l The listener to register, overwrites previous listeners if any. * @return A new builder instance. */ @CheckReturnValue public Builder withCallback(Listener l) { return create(renderers(), viewOptions(), accelerators(), speedUp(), stopTime(), title(), screenSize(), Optional.of(l), monitor(), display()); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof View.Builder) { View.Builder that = (View.Builder) o; return (this.renderers.equals(that.renderers())) && (this.viewOptions.equals(that.viewOptions())) && (this.accelerators.equals(that.accelerators())) && (this.speedUp == that.speedUp()) && (this.stopTime == that.stopTime()) && (this.title.equals(that.title())) && (this.screenSize.equals(that.screenSize())) && (this.callback.equals(that.callback())) && (this.monitor.equals(that.monitor())) && (this.display.equals(that.display())); } return false; }
/** * This takes precedence over any calls to {@link #withResolution(int, int)} * . * @return A new builder instance. */ @CheckReturnValue public Builder withFullScreen() { return create( renderers(), Sets.immutableEnumSet(ViewOption.FULL_SCREEN, viewOptions().toArray(new ViewOption[] {})), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Allows to change the accelerators (aka shortcuts) of the menu items. Each * accelerator is set to its respective menu item via * {@link org.eclipse.swt.widgets.MenuItem#setAccelerator(int)}. By default * the accelerators are set to {@link MenuItems#QWERTY_ACCELERATORS} unless * a keyboard for the French language is detected (probably using an AZERTY * layout), then {@link MenuItems#AZERTY_ACCELERATORS} is used. * @param acc The accelerators to set. * @return A new builder instance. */ @CheckReturnValue public Builder withAccelerators(Map<MenuItems, Integer> acc) { return create(renderers(), viewOptions(), ImmutableMap.copyOf(acc), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Don't allow the user to resize the application window. Default: * <i>allowed</i>. * @return A new builder instance. */ @CheckReturnValue public Builder withNoResizing() { return create( renderers(), Sets.immutableEnumSet(ViewOption.DISALLOW_RESIZE, viewOptions().toArray(new ViewOption[] {})), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Sets the view into asynchronous mode. This means that the call to * {@link #show()} is non-blocking and will return immediately. By default * the {@link #show()} is synchronous. * @return A new builder instance. */ @CheckReturnValue public Builder withAsync() { return create( renderers(), Sets.immutableEnumSet(ViewOption.ASYNC, viewOptions().toArray(new ViewOption[] {})), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Specify on which monitor the application should be positioned. If this * method is not called SWT decides where the screen is positioned, usually * on the primary monitor. * @param m The monitor. * @return A new builder instance. */ @CheckReturnValue public Builder withMonitor(Monitor m) { return create(renderers(), viewOptions(), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), Optional.of(m), display()); }
/** * When <i>auto play</i> is enabled the {@link Simulator} will be started * directly when {@link #show()} is called. Default: <code>disabled</code>. * @return A new builder instance. */ @CheckReturnValue public Builder withAutoPlay() { return create( renderers(), Sets.immutableEnumSet(ViewOption.AUTO_PLAY, viewOptions().toArray(new ViewOption[] {})), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * When <i>auto close</i> is enabled the view will be closed as soon as the * {@link Simulator} is stopped. This is useful for creating automated GUIs. * Default: <code>disabled</code>. * @return A new builder instance. */ @CheckReturnValue public Builder withAutoClose() { return create( renderers(), Sets.immutableEnumSet(ViewOption.AUTO_CLOSE, viewOptions().toArray(new ViewOption[] {})), accelerators(), speedUp(), stopTime(), title(), screenSize(), callback(), monitor(), display()); }
/** * Changes the title appendix of the view. The default title is <i>RinSim - * Simulator</i>, the title appendix is everything after the dash. * @param titleAppendix The new appendix to use. * @return A new builder instance. */ @CheckReturnValue public Builder withTitleAppendix(String titleAppendix) { return create(renderers(), viewOptions(), accelerators(), speedUp(), stopTime(), titleAppendix, screenSize(), callback(), monitor(), display()); }
/** * Stops the simulator at the specified time. * @param simulationTime The time to stop, must be positive. * @return A new builder instance. */ @CheckReturnValue public Builder withSimulatorEndTime(long simulationTime) { checkArgument(simulationTime > 0); return create(renderers(), viewOptions(), accelerators(), speedUp(), simulationTime, title(), screenSize(), callback(), monitor(), display()); }
/** * Speed up defines the simulation time between two respective GUI draw * operations. Default: <code>1</code>. * @param speed The speed to use. * @return A new builder instance. */ @CheckReturnValue public Builder withSpeedUp(int speed) { return create(renderers(), viewOptions(), accelerators(), speed, stopTime(), title(), screenSize(), callback(), monitor(), display()); }