-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSnapshotReader.java
More file actions
77 lines (65 loc) · 2.59 KB
/
SnapshotReader.java
File metadata and controls
77 lines (65 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Created by Cekis on 2/20/2017.
*/
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import swg.WSFile;
import java.io.IOException;
public class SnapshotReader extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws IOException {
primaryStage.setTitle("SWG Snapshot Viewer");
TabPane tabView = new TabPane();
Tab tab = new Tab();
tab.closableProperty().setValue(false);
tab.setText("lok.ws");
TableView dataTable = new TableView();
ObservableList cols = dataTable.getColumns();
cols.add(makeColumn("Object ID", "id",75));
cols.add(makeColumn("Parent ID", "parentId", 75));
cols.add(makeColumn("Template", "template", dataTable, 550d));
cols.add(makeColumn("Index", "nodeIndex", 50));
cols.add(makeColumn("X", "x", 50));
cols.add(makeColumn("Y", "y", 50));
cols.add(makeColumn("Z", "z", 50));
cols.add(makeColumn("QW", "objW",50));
cols.add(makeColumn("QX", "objX",50));
cols.add(makeColumn("QY", "objY",50));
cols.add(makeColumn("QZ", "objZ",50));
tab.setContent(dataTable);
tabView.getTabs().add(tab);
WSFile wsFile = new WSFile();
wsFile.readFile("snapshot/lok.ws");
tab.setText(wsFile.getAreaName() + ".ws");
ObservableList data = FXCollections.observableArrayList(wsFile.getAllNodes().toArray());
dataTable.setItems(data);
Scene scene = new Scene(tabView, 300, 275);
primaryStage.setScene(scene);
primaryStage.show();
}
private TableColumn makeColumn(String name, String property, double width){
TableColumn newCol = new TableColumn();
newCol.setPrefWidth(width);
newCol.setText(name);
newCol.setCellValueFactory(new PropertyValueFactory(property));
return newCol;
}
private TableColumn makeColumn(String name, String property, TableView dt, double diff){
TableColumn newCol = new TableColumn();
newCol.prefWidthProperty().bind(dt.widthProperty().subtract(diff));
newCol.setText(name);
newCol.setCellValueFactory(new PropertyValueFactory(property));
return newCol;
}
}