modify track node
This commit is contained in:
@@ -203,7 +203,7 @@ public class HelperController {
|
|||||||
if (index > 0){
|
if (index > 0){
|
||||||
RouteEntryModel prev = route.get(index - 1);
|
RouteEntryModel prev = route.get(index - 1);
|
||||||
time.setText(ViewUtils.timeToString(prev.getTime()));
|
time.setText(ViewUtils.timeToString(prev.getTime()));
|
||||||
distance.setText(ViewUtils.distanceToString(prev.getStation().getSystem().getDistance(entry.getStation().getSystem())));
|
distance.setText(ViewUtils.distanceToString(entry.getDistance()));
|
||||||
if (entry.isTransit()) {
|
if (entry.isTransit()) {
|
||||||
stationDistance.setText("");
|
stationDistance.setText("");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import javafx.collections.FXCollections;
|
|||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import ru.trader.model.*;
|
import ru.trader.model.*;
|
||||||
import ru.trader.model.support.BindingsHelper;
|
import ru.trader.model.support.BindingsHelper;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package ru.trader.model;
|
package ru.trader.model;
|
||||||
|
|
||||||
import javafx.beans.property.DoubleProperty;
|
import javafx.beans.property.*;
|
||||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.collections.transformation.FilteredList;
|
import javafx.collections.transformation.FilteredList;
|
||||||
@@ -17,6 +15,8 @@ public class RouteEntryModel {
|
|||||||
private final StationModel station;
|
private final StationModel station;
|
||||||
private final RouteEntry entry;
|
private final RouteEntry entry;
|
||||||
private final DoubleProperty profit;
|
private final DoubleProperty profit;
|
||||||
|
private final LongProperty fullTime;
|
||||||
|
private final DoubleProperty distance;
|
||||||
private final ObservableList<OrderModel> orders;
|
private final ObservableList<OrderModel> orders;
|
||||||
private final ObservableList<OrderModel> sellOrders;
|
private final ObservableList<OrderModel> sellOrders;
|
||||||
private final ObservableList<MissionModel> missions;
|
private final ObservableList<MissionModel> missions;
|
||||||
@@ -30,6 +30,8 @@ public class RouteEntryModel {
|
|||||||
missions = FXCollections.observableArrayList();
|
missions = FXCollections.observableArrayList();
|
||||||
profit = new SimpleDoubleProperty();
|
profit = new SimpleDoubleProperty();
|
||||||
profit.bind(BindingsHelper.group(Double::sum, OrderModel::profitProperty, orders));
|
profit.bind(BindingsHelper.group(Double::sum, OrderModel::profitProperty, orders));
|
||||||
|
fullTime = new SimpleLongProperty();
|
||||||
|
distance = new SimpleDoubleProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSellOrder(OrderModel order){
|
void addSellOrder(OrderModel order){
|
||||||
@@ -68,8 +70,28 @@ public class RouteEntryModel {
|
|||||||
return entry.getTime();
|
return entry.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFullTime(){
|
public long getFullTime() {
|
||||||
return entry.getFullTime();
|
return fullTime.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty fullTimeProperty() {
|
||||||
|
return fullTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFullTime(long fullTime) {
|
||||||
|
this.fullTime.set(fullTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDistance() {
|
||||||
|
return distance.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyDoubleProperty distanceProperty() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDistance(double distance) {
|
||||||
|
this.distance.set(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRefill(){
|
public double getRefill(){
|
||||||
|
|||||||
@@ -25,11 +25,23 @@ public class RouteModel {
|
|||||||
this._route = route;
|
this._route = route;
|
||||||
entries = _route.getEntries().stream().map(e -> new RouteEntryModel(e, market)).collect(Collectors.toList());
|
entries = _route.getEntries().stream().map(e -> new RouteEntryModel(e, market)).collect(Collectors.toList());
|
||||||
profit = new SimpleDoubleProperty();
|
profit = new SimpleDoubleProperty();
|
||||||
profit.bind(BindingsHelper.group(Double::sum, RouteEntryModel::profitProperty, entries));
|
|
||||||
profitByTime = new SimpleDoubleProperty();
|
profitByTime = new SimpleDoubleProperty();
|
||||||
profitByTime.bind(profit.divide(_route.getTime()));
|
|
||||||
fillSellOrders();
|
|
||||||
currentEntry = new SimpleIntegerProperty(0);
|
currentEntry = new SimpleIntegerProperty(0);
|
||||||
|
fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fill(){
|
||||||
|
profit.bind(BindingsHelper.group(Double::sum, RouteEntryModel::profitProperty, entries));
|
||||||
|
profitByTime.bind(profit.divide(_route.getTime()));
|
||||||
|
long time = 0;
|
||||||
|
for (int i = 0; i < entries.size()-1; i++) {
|
||||||
|
RouteEntryModel entry = entries.get(i);
|
||||||
|
RouteEntryModel entry2 = entries.get(i+1);
|
||||||
|
time += entry.getTime();
|
||||||
|
entry2.setDistance(entry.getStation().getDistance(entry2.getStation()));
|
||||||
|
entry2.setFullTime(time);
|
||||||
|
}
|
||||||
|
fillSellOrders();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillSellOrders(){
|
private void fillSellOrders(){
|
||||||
@@ -368,12 +380,12 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RouteModel asRoute(SystemModel system){
|
public static RouteModel asRoute(SystemModel system){
|
||||||
Route route = new Route(new RouteEntry(system.getSystem().asTransit(),0,0,0));
|
Route route = Route.singletone(system.getSystem().asTransit());
|
||||||
return new RouteModel(route, system.getMarket());
|
return new RouteModel(route, system.getMarket());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RouteModel asRoute(StationModel station){
|
public static RouteModel asRoute(StationModel station){
|
||||||
Route route = new Route(new RouteEntry(station.getStation(),0,0,0));
|
Route route = Route.singletone(station.getStation());
|
||||||
return new RouteModel(route, station.getMarket());
|
return new RouteModel(route, station.getMarket());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import javafx.scene.text.Text;
|
|||||||
import org.controlsfx.glyphfont.Glyph;
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
import ru.trader.model.RouteEntryModel;
|
import ru.trader.model.RouteEntryModel;
|
||||||
import ru.trader.model.RouteModel;
|
import ru.trader.model.RouteModel;
|
||||||
import ru.trader.model.StationModel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Track {
|
public class Track {
|
||||||
private final static String CSS_ROUTE = "route";
|
private final static String CSS_ROUTE = "route";
|
||||||
|
private final static String CSS_ROUTE_ENTRY = "route-entry";
|
||||||
private final static String CSS_ROUTE_MARKER = "route-marker";
|
private final static String CSS_ROUTE_MARKER = "route-marker";
|
||||||
private final static String CSS_SYSTEM = "route-system";
|
private final static String CSS_SYSTEM = "route-system";
|
||||||
private final static String CSS_ICONS = "route-icons";
|
private final static String CSS_ICONS = "route-icons";
|
||||||
@@ -41,37 +41,26 @@ public class Track {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void build(){
|
private void build(){
|
||||||
RouteEntryModel prev = null;
|
|
||||||
for (RouteEntryModel entry : route.getEntries()) {
|
for (RouteEntryModel entry : route.getEntries()) {
|
||||||
/* if (prev != null){
|
|
||||||
VBox track = new VBox();
|
|
||||||
VBox.setVgrow(track, Priority.ALWAYS);
|
|
||||||
track.getStyleClass().add(CSS_TRACK);
|
|
||||||
|
|
||||||
Text t = new Text(DistanceCell.distanceToString(entry.getStation().getDistance(prev)));
|
|
||||||
t.getStyleClass().add(CSS_TRACK_TEXT);
|
|
||||||
track.getChildren().addAll(t, Glyph.create("FontAwesome|LONG_ARROW_RIGHT"));
|
|
||||||
|
|
||||||
node.getChildren().addAll(track);
|
|
||||||
}*/
|
|
||||||
HBox entryNode = new HBox();
|
HBox entryNode = new HBox();
|
||||||
Circle circle = new Circle(5);
|
entryNode.getStyleClass().add(CSS_ROUTE_ENTRY);
|
||||||
circle.getStyleClass().add(CSS_ROUTE_MARKER);
|
VBox marker = new VBox();
|
||||||
entryNode.getChildren().add(circle);
|
marker.getStyleClass().add(CSS_ROUTE_MARKER);
|
||||||
|
marker.getChildren().add(new Circle(5));
|
||||||
|
entryNode.getChildren().add(marker);
|
||||||
VBox stationNode = buildStationNode(entry);
|
VBox stationNode = buildStationNode(entry);
|
||||||
HBox.setHgrow(stationNode, Priority.ALWAYS);
|
HBox.setHgrow(stationNode, Priority.ALWAYS);
|
||||||
VBox icons = buildIconsNode(entry);
|
VBox icons = buildIconsNode(entry);
|
||||||
VBox info = buildInfoNode(prev, entry);
|
VBox info = buildInfoNode(entry);
|
||||||
entryNode.getChildren().addAll(stationNode, icons, info);
|
entryNode.getChildren().addAll(stationNode, icons, info);
|
||||||
node.getChildren().addAll(entryNode);
|
node.getChildren().addAll(entryNode);
|
||||||
final int curIndex = entryNodes.size();
|
final int curIndex = entryNodes.size();
|
||||||
entryNode.setOnMouseClicked(e -> {
|
entryNode.setOnMouseClicked(e -> {
|
||||||
if (e.getButton() == MouseButton.PRIMARY){
|
if (e.getButton() == MouseButton.PRIMARY) {
|
||||||
setActive(curIndex);
|
setActive(curIndex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
entryNodes.add(entryNode);
|
entryNodes.add(entryNode);
|
||||||
prev = entry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +95,12 @@ public class Track {
|
|||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VBox buildInfoNode(RouteEntryModel prevEntry, RouteEntryModel entry){
|
private VBox buildInfoNode(RouteEntryModel entry){
|
||||||
VBox node = new VBox();
|
VBox node = new VBox();
|
||||||
node.getStyleClass().add(CSS_INFO);
|
node.getStyleClass().add(CSS_INFO);
|
||||||
VBox.setVgrow(node, Priority.ALWAYS);
|
VBox.setVgrow(node, Priority.ALWAYS);
|
||||||
Text timeText = new Text(ViewUtils.timeToString(entry.getTime()));
|
Text timeText = new Text(ViewUtils.timeToString(entry.getFullTime()));
|
||||||
Text distanceText = new Text(prevEntry != null ? ViewUtils.distanceToString(prevEntry.getStation().getSystem().getDistance(entry.getStation().getSystem())): "");
|
Text distanceText = new Text(ViewUtils.distanceToString(entry.getDistance()));
|
||||||
Text stationDistanceText = new Text(entry.getStation().getSystem().getName());
|
Text stationDistanceText = new Text(entry.getStation().getSystem().getName());
|
||||||
if (entry.isTransit()) {
|
if (entry.isTransit()) {
|
||||||
stationDistanceText.setText("");
|
stationDistanceText.setText("");
|
||||||
|
|||||||
@@ -46,8 +46,9 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
</StackPane>
|
</StackPane>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
<ScrollPane minWidth="220" fitToHeight="true">
|
||||||
<VBox>
|
<VBox>
|
||||||
<VBox fx:id="track" minWidth="200"/>
|
<AnchorPane fx:id="track"/>
|
||||||
<VBox>
|
<VBox>
|
||||||
<HBox><TextField fx:id="newEntrySystemText"/></HBox>
|
<HBox><TextField fx:id="newEntrySystemText"/></HBox>
|
||||||
<HBox><ComboBox fx:id="newEntryStation"/></HBox>
|
<HBox><ComboBox fx:id="newEntryStation"/></HBox>
|
||||||
@@ -58,5 +59,6 @@
|
|||||||
</HBox>
|
</HBox>
|
||||||
</VBox>
|
</VBox>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
</ScrollPane>
|
||||||
|
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
@@ -53,16 +53,72 @@ HBox.fields-group hbox-margin{
|
|||||||
-fx-font-weight: bold;
|
-fx-font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Path */
|
/* Path */
|
||||||
.route, .path {
|
.path {
|
||||||
-fx-alignment: center-left;
|
-fx-alignment: center-left;
|
||||||
-fx-spacing: 5px;
|
-fx-spacing: 5px;
|
||||||
-fx-fill-height: true;
|
-fx-fill-height: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.path-system {
|
||||||
|
-fx-alignment: center-left;
|
||||||
|
-fx-text-alignment: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-text {
|
||||||
|
-fx-alignment: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-system-text {
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-station-text {
|
||||||
|
-fx-font-size: 8pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-icons {
|
||||||
|
-fx-alignment: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-track {
|
||||||
|
-fx-padding: 0 8;
|
||||||
|
-fx-alignment: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-track .glyph-font {
|
||||||
|
-fx-font-family: FontAwesome;
|
||||||
|
-fx-font-size: 16pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.path-track-text {
|
||||||
|
-fx-font-size: 7pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.path-pane {
|
||||||
|
-fx-padding: 10;
|
||||||
|
-fx-alignment: center-left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Route */
|
||||||
|
.route {
|
||||||
|
-fx-alignment: top-center;
|
||||||
|
-fx-spacing: 5px;
|
||||||
|
-fx-fill-height: true;
|
||||||
|
-fx-min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.route-entry {
|
||||||
|
-fx-min-height: 50px;
|
||||||
|
-fx-spacing: 4px;
|
||||||
|
-fx-border-style: solid;
|
||||||
|
-fx-border-width: 0 0 2px 0;
|
||||||
|
-fx-fill-width: true;
|
||||||
|
}
|
||||||
|
|
||||||
.route-marker {
|
.route-marker {
|
||||||
-fx-alignment: center-left;
|
-fx-alignment: center-left;
|
||||||
|
-fx-padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-system {
|
.route-system {
|
||||||
@@ -80,15 +136,17 @@ HBox.fields-group hbox-margin{
|
|||||||
|
|
||||||
.route-icons {
|
.route-icons {
|
||||||
-fx-alignment: top-right;
|
-fx-alignment: top-right;
|
||||||
|
-fx-padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-info {
|
.route-info {
|
||||||
-fx-alignment: top-right;
|
-fx-alignment: top-right;
|
||||||
-fx-font-size: 12;
|
-fx-font-size: 12;
|
||||||
|
-fx-min-width: 60px;
|
||||||
|
-fx-max-width: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-active {
|
.route-active {
|
||||||
-fx-border-style: solid;
|
|
||||||
-fx-background-color: lightskyblue;
|
-fx-background-color: lightskyblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ru.trader.analysis;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import ru.trader.core.TransitVendor;
|
||||||
import ru.trader.core.Vendor;
|
import ru.trader.core.Vendor;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -285,4 +286,14 @@ public class Route implements Comparable<Route> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Route singletone(Vendor root){
|
||||||
|
RouteEntry entry = new RouteEntry(root, 0,0,0);
|
||||||
|
if (!(root instanceof TransitVendor)){
|
||||||
|
entry.setLand(true);
|
||||||
|
}
|
||||||
|
return new Route(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user