Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2011-2014 Rinde van Lon, iMinds DistriNet, KU Leuven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.rinde.rinsim.examples.demo;
import static com.google.common.collect.Lists.newArrayList;
import java.io.IOException;
import java.math.RoundingMode;
import java.util.List;
import javax.annotation.Nullable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.github.rinde.rinsim.core.Simulator;
import com.github.rinde.rinsim.examples.core.taxi.TaxiExample;
import com.github.rinde.rinsim.examples.demo.factory.FactoryExample;
import com.google.common.collect.ImmutableList;
import com.google.common.math.DoubleMath;
/**
* @author Rinde van Lon
*
*/
public class Demo {
private Demo() {}
public static void main(String[] args) throws IOException,
InterruptedException {
final long time = 6 * 60 * 60 * 1000L;
Display.setAppName("RinSim");
final Display d = new Display();
final List demoRunners = newArrayList();
final Shell shell = new Shell(d, SWT.TITLE | SWT.CLOSE | SWT.RESIZE);
shell.setText("AgentWise Demo Control Center™");
shell.setLayout(new RowLayout(SWT.VERTICAL));
final Monitor primary = d.getPrimaryMonitor();
shell.setLocation(primary.getClientArea().x, primary.getClientArea().y);
shell
.setSize(primary.getClientArea().width, primary.getClientArea().height);
final Composite controlsComposite = new Composite(shell, SWT.NONE);
controlsComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
final Label timeLabel = new Label(controlsComposite, SWT.NONE);
timeLabel.setText("End simulation time (in hours): ");
final Text timeText = new Text(controlsComposite, SWT.NONE);
timeText.setText("6.0");
timeText.setLayoutData(new RowData(40, SWT.DEFAULT));
timeText.addListener(SWT.Verify, new Listener() {
@Override
public void handleEvent(Event e) {
final String string = e.text;
final char[] chars = new char[string.length()];
string.getChars(0, chars.length, chars, 0);
for (int i = 0; i < chars.length; i++) {
if (!('0' <= chars[i] && chars[i] <= '9') && chars[i] != '.') {
e.doit = false;
return;
}
}
for (final DemoRunner dr : demoRunners) {
dr.setTime(Double.parseDouble(e.text));
}
}
});
final List