ui包中的类及代码分析
2015-11-13 16:11
381 查看
ui包(user interface)
Contains superclass for all user interfaces and a simple user interface(s).
包含所有用户接口的父类和一个简单用户接口
![](http://note.youdao.com/yws/res/1188/F3AD64448D534749800B8131E612D7A5)
ui.DTNSimUI
功能:所有用户接口的抽象父类,也包含一些仿真设置(Abstract superclass for user interfaces; contains also some simulation settings.)
public abstract class DTNSimUI
outline:
![](http://note.youdao.com/yws/res/976/03CEC09948AC4F268D66777077E69177)
意义
:
属性
public static final String NROF_REPORT_S = "Report.nrofReports";
//Number of reports(报告数量)
public static final String REPORT_S = "Report.report";
//Report class name(报告类名称)(注)Must be suffixed with numbers starting from one.
public static final String MM_WARMUP_S = movement.MovementModel.MOVEMENT_MODEL_NS + ".warmup"
//Movement model warmup time(移动模型准备时间)Defines how many seconds of movement simulation is run without connectivity etc
private static final String REPORT_PAC = "report.";
//report class' package name(报告类的包的名字)
protected World world;
//The World where all actors of the simulator are(所模拟的世界)
protected Vector<Report> reports;
//Reports that are loaded for this simulation(从模拟中获取的报告)
protected boolean simDone; //has simulation terminated normally(仿真是否正常结束)
protected boolean simCancelled; //is simulation termination requested(仿真是否求终止)
protected SimScenario scen;
//Scenario of the current simulation(正在模拟的场景)
protected double lastUpdate; //simtime of last UI update(上次更新的仿真时间)
方法
public DTNSimUI() //Constructor
public void start() //Starts the simulation(调用initModel()
和runSim(), 仿真开始
)
protected abstract void runSim();
//Runs simulation after the model has been initialized.
private void initModel() //Initializes the simulator model.(初始化移动模型)
从core.SimScenario
获得运行模拟的实例,添加多个报告(调用addReport() ),并设置模拟世界的warmupTime
。设置报错机制。
for (int i=1, n = settings.getInt(NROF_REPORT_S); i<=n; i++){
String reportClass = settings.getSetting(REPORT_S + i);
addReport((Report)settings.createObject(REPORT_PAC +
reportClass));
即所需报告的报的名字+报告类的名称class
}
public void done() //Runs maintenance jobs that are needed before exiting运行结束前所需的维护工作
public void done() {
for (Report r : this.reports) {
r.done(); //Called when the simulation is done, user requested premature termination or intervalled report generating decided that it's time for the next report.
}
}
protected void addReport(Report r) //Adds a new report for simulator(为仿真增加报告)先判断所需报告类是哪种实例,相应为所有节点增加 listener
this.reports.add(r)
类型:MessageListener,ConnectionListener, MovementListener,UpdateListener, ApplicationListener
ui.DTNSimTextUI
功能:简单的基于text的用户接口(Simple text-based user interface),是DTNSimUI 的子类
public class DTNSimTextUI extends DTNSimUI
outline:
![](http://note.youdao.com/yws/res/977/69082194472A4E6899F6AC54A6039F6E)
意义
:
属性
private --- lastUpdateRt:上一次ui更新的时间(real time of last ui update)
startTime:模拟开始时间(simulation start time)
public static --- UI_UP_INTERVAL:ui多长时间更新一次(How often the UI view is updated (milliseconds))
方法:
protected void runSim() //覆写
print("Running simulation '" + scen.getName()+"'");
在仿真时间内,更新世界内所有节点。
double duration = (System.currentTimeMillis() - startTime)/1000.0
//持续时间
this.update(true);
//调用update()强制更新
print("Simulation done in " + String.format("%.2f", duration) + "s");
private void update(boolean forced) //Updates user interface if the long enough (real)time (update interval) has passed from the previous update(更新用户接口)
ssps = ((SimClock.getTime() - lastUpdate)*1000) / diff;
//simulated seconds/second calc
print(String.format("%.1f %d: %.2f 1/s", dur,
SimClock.getIntTime(),ssps));
private void print(String txt) // 打印txt
Contains superclass for all user interfaces and a simple user interface(s).
包含所有用户接口的父类和一个简单用户接口
ui.DTNSimUI
功能:所有用户接口的抽象父类,也包含一些仿真设置(Abstract superclass for user interfaces; contains also some simulation settings.)
public abstract class DTNSimUI
outline:
意义
:
属性
public static final String NROF_REPORT_S = "Report.nrofReports";
//Number of reports(报告数量)
public static final String REPORT_S = "Report.report";
//Report class name(报告类名称)(注)Must be suffixed with numbers starting from one.
public static final String MM_WARMUP_S = movement.MovementModel.MOVEMENT_MODEL_NS + ".warmup"
//Movement model warmup time(移动模型准备时间)Defines how many seconds of movement simulation is run without connectivity etc
private static final String REPORT_PAC = "report.";
//report class' package name(报告类的包的名字)
protected World world;
//The World where all actors of the simulator are(所模拟的世界)
protected Vector<Report> reports;
//Reports that are loaded for this simulation(从模拟中获取的报告)
protected boolean simDone; //has simulation terminated normally(仿真是否正常结束)
protected boolean simCancelled; //is simulation termination requested(仿真是否求终止)
protected SimScenario scen;
//Scenario of the current simulation(正在模拟的场景)
protected double lastUpdate; //simtime of last UI update(上次更新的仿真时间)
方法
public DTNSimUI() //Constructor
public void start() //Starts the simulation(调用initModel()
和runSim(), 仿真开始
)
protected abstract void runSim();
//Runs simulation after the model has been initialized.
private void initModel() //Initializes the simulator model.(初始化移动模型)
从core.SimScenario
获得运行模拟的实例,添加多个报告(调用addReport() ),并设置模拟世界的warmupTime
。设置报错机制。
for (int i=1, n = settings.getInt(NROF_REPORT_S); i<=n; i++){
String reportClass = settings.getSetting(REPORT_S + i);
addReport((Report)settings.createObject(REPORT_PAC +
reportClass));
即所需报告的报的名字+报告类的名称class
}
public void done() //Runs maintenance jobs that are needed before exiting运行结束前所需的维护工作
public void done() {
for (Report r : this.reports) {
r.done(); //Called when the simulation is done, user requested premature termination or intervalled report generating decided that it's time for the next report.
}
}
protected void addReport(Report r) //Adds a new report for simulator(为仿真增加报告)先判断所需报告类是哪种实例,相应为所有节点增加 listener
this.reports.add(r)
类型:MessageListener,ConnectionListener, MovementListener,UpdateListener, ApplicationListener
ui.DTNSimTextUI
功能:简单的基于text的用户接口(Simple text-based user interface),是DTNSimUI 的子类
public class DTNSimTextUI extends DTNSimUI
outline:
意义
:
属性
private --- lastUpdateRt:上一次ui更新的时间(real time of last ui update)
startTime:模拟开始时间(simulation start time)
public static --- UI_UP_INTERVAL:ui多长时间更新一次(How often the UI view is updated (milliseconds))
方法:
protected void runSim() //覆写
print("Running simulation '" + scen.getName()+"'");
在仿真时间内,更新世界内所有节点。
double duration = (System.currentTimeMillis() - startTime)/1000.0
//持续时间
this.update(true);
//调用update()强制更新
print("Simulation done in " + String.format("%.2f", duration) + "s");
private void update(boolean forced) //Updates user interface if the long enough (real)time (update interval) has passed from the previous update(更新用户接口)
ssps = ((SimClock.getTime() - lastUpdate)*1000) / diff;
//simulated seconds/second calc
print(String.format("%.1f %d: %.2f 1/s", dur,
SimClock.getIntTime(),ssps));
private void print(String txt) // 打印txt
相关文章推荐
- UILabel 与 UIView
- Mysql ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in..的解决方法
- ios添加GPUImage到项目
- @RequestBody、@ResponseBody的使用方法(2)
- Apue Chapter 4 习题答案
- Android Stuido使用常见问题总结
- @RequestBody、@ResponseBody的使用方法
- Android UI优化
- eas bos editUI 刷新方法 帮助类
- Handler Looper MessageQueue 深度总结
- js判断UUID正则表达式
- Android UI开发: 横向ListView(HorizontalListView)及一个简单相册的完整实现 (附源码下载)
- 动态调整UILabel的高度或宽度
- Android UI开发第二十六篇——Fragment间的通信
- UIButton相关
- UITextField属性
- android build 模式
- Xcode7 *** does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_
- uitableview ios7和后续系统 代理执行方法差异
- Cloud Design Pattern - Queue-Based Load Leveling(队列负载均衡)