change for new analyzer
This commit is contained in:
@@ -13,13 +13,17 @@ public class Settings {
|
|||||||
|
|
||||||
private final Properties values = new Properties();
|
private final Properties values = new Properties();
|
||||||
private final File file;
|
private final File file;
|
||||||
|
private Profile profile;
|
||||||
|
|
||||||
|
|
||||||
public Settings() {
|
public Settings() {
|
||||||
this.file = null;
|
this.file = null;
|
||||||
|
profile = new Profile(new Ship());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings(File file) {
|
public Settings(File file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
profile = new Profile(new Ship());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
@@ -30,10 +34,12 @@ public class Settings {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error on load settings", e);
|
LOG.error("Error on load settings", e);
|
||||||
}
|
}
|
||||||
|
profile = Profile.readFrom(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(){
|
public void save(){
|
||||||
try (OutputStream os = new FileOutputStream(file)) {
|
try (OutputStream os = new FileOutputStream(file)) {
|
||||||
|
profile.writeTo(values);
|
||||||
values.store(os,"settings");
|
values.store(os,"settings");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error on load settings", e);
|
LOG.error("Error on load settings", e);
|
||||||
@@ -82,59 +88,43 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBalance(double balance){
|
public void setBalance(double balance){
|
||||||
values.setProperty("ship.balance", String.valueOf(balance));
|
profile.setBalance(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBalance(){
|
public double getBalance(){
|
||||||
return Double.valueOf(values.getProperty("ship.balance","1000"));
|
return profile.getBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCargo(int cargo){
|
public void setCargo(int cargo){
|
||||||
values.setProperty("ship.cargo", String.valueOf(cargo));
|
profile.getShip().setCargo(cargo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCargo(){
|
public int getCargo(){
|
||||||
return Integer.valueOf(values.getProperty("ship.cargo","4"));
|
return profile.getShip().getCargo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTank(double tank){
|
public void setTank(double tank){
|
||||||
values.setProperty("ship.tank", String.valueOf(tank));
|
profile.getShip().setTank(tank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTank(){
|
public double getTank(){
|
||||||
return Double.valueOf(values.getProperty("ship.tank","20"));
|
return profile.getShip().getTank();
|
||||||
}
|
|
||||||
|
|
||||||
public void setDistance(double distance){
|
|
||||||
values.setProperty("ship.distance", String.valueOf(distance));
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDistance(){
|
|
||||||
return Double.valueOf(values.getProperty("ship.distance","7"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJumps(int jumps){
|
public void setJumps(int jumps){
|
||||||
values.setProperty("ship.jumps", String.valueOf(jumps));
|
profile.setJumps(jumps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getJumps(){
|
public int getJumps(){
|
||||||
return Integer.valueOf(values.getProperty("ship.jumps","3"));
|
return profile.getJumps();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSegmentSize(int segmentSize){
|
public void setRoutesCount(int routesCount){
|
||||||
values.setProperty("performance.segment", String.valueOf(segmentSize));
|
profile.setRoutesCount(routesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSegmentSize(){
|
public int getRoutesCount(){
|
||||||
return Integer.valueOf(values.getProperty("performance.segment","0"));
|
return profile.getRoutesCount();
|
||||||
}
|
|
||||||
|
|
||||||
public void setPathsCount(int pathsCount){
|
|
||||||
values.setProperty("performance.limit", String.valueOf(pathsCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPathsCount(){
|
|
||||||
return Integer.valueOf(values.getProperty("performance.limit","100"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MarketFilter getFilter(Market market){
|
public MarketFilter getFilter(Market market){
|
||||||
@@ -144,4 +134,8 @@ public class Settings {
|
|||||||
public void setFilter(MarketFilter filter){
|
public void setFilter(MarketFilter filter){
|
||||||
filter.writeTo(values);
|
filter.writeTo(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Profile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ru.trader;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
import ru.trader.analysis.FilteredMarket;
|
||||||
import ru.trader.core.Market;
|
import ru.trader.core.Market;
|
||||||
import ru.trader.core.MarketAnalyzer;
|
import ru.trader.core.MarketAnalyzer;
|
||||||
import ru.trader.store.simple.SimpleMarket;
|
import ru.trader.store.simple.SimpleMarket;
|
||||||
@@ -59,14 +60,7 @@ public class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MarketAnalyzer buildAnalyzer(Market market){
|
public static MarketAnalyzer buildAnalyzer(Market market){
|
||||||
MarketAnalyzer analyzer = new MarketAnalyzer(market);
|
FilteredMarket fMarket = new FilteredMarket(market, Main.SETTINGS.getFilter(market));
|
||||||
analyzer.setSegmentSize(Main.SETTINGS.getSegmentSize());
|
return new MarketAnalyzer(fMarket, Main.SETTINGS.getProfile());
|
||||||
analyzer.setPathsCount(Main.SETTINGS.getPathsCount());
|
|
||||||
analyzer.setFilter(Main.SETTINGS.getFilter(market));
|
|
||||||
analyzer.setCargo(Main.SETTINGS.getCargo());
|
|
||||||
analyzer.setTank(Main.SETTINGS.getTank());
|
|
||||||
analyzer.setMaxDistance(Main.SETTINGS.getDistance());
|
|
||||||
analyzer.setJumps(Main.SETTINGS.getJumps());
|
|
||||||
return analyzer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void editFilter(){
|
public void editFilter(){
|
||||||
Screeners.showFilter(market.getAnalyzer().getFilter());
|
//TODO: implement
|
||||||
|
//Screeners.showFilter(market.getFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void impMadSystems(ActionEvent actionEvent) {
|
public void impMadSystems(ActionEvent actionEvent) {
|
||||||
|
|||||||
@@ -10,19 +10,18 @@ import org.controlsfx.control.ButtonBar;
|
|||||||
import org.controlsfx.control.action.Action;
|
import org.controlsfx.control.action.Action;
|
||||||
import org.controlsfx.dialog.Dialog;
|
import org.controlsfx.dialog.Dialog;
|
||||||
import org.controlsfx.dialog.DialogAction;
|
import org.controlsfx.dialog.DialogAction;
|
||||||
import ru.trader.model.PathRouteModel;
|
import ru.trader.model.RouteModel;
|
||||||
import ru.trader.model.support.BindingsHelper;
|
import ru.trader.model.support.BindingsHelper;
|
||||||
import ru.trader.view.support.Localization;
|
import ru.trader.view.support.Localization;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PathsController {
|
public class PathsController {
|
||||||
private final Action OK = new DialogAction("OK", ButtonBar.ButtonType.OK_DONE, false, true, false);
|
private final Action OK = new DialogAction("OK", ButtonBar.ButtonType.OK_DONE, false, true, false);
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<PathRouteModel> tblPaths;
|
private TableView<RouteModel> tblPaths;
|
||||||
private final List<PathRouteModel> paths = FXCollections.observableArrayList();
|
private final List<RouteModel> paths = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -31,7 +30,7 @@ public class PathsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PathRouteModel showDialog(Parent parent, Parent content, ObservableList<PathRouteModel> paths) {
|
public RouteModel showDialog(Parent parent, Parent content, ObservableList<RouteModel> paths) {
|
||||||
|
|
||||||
init(paths);
|
init(paths);
|
||||||
|
|
||||||
@@ -39,20 +38,20 @@ public class PathsController {
|
|||||||
dlg.setContent(content);
|
dlg.setContent(content);
|
||||||
dlg.getActions().addAll(OK, Dialog.ACTION_CANCEL);
|
dlg.getActions().addAll(OK, Dialog.ACTION_CANCEL);
|
||||||
dlg.setResizable(false);
|
dlg.setResizable(false);
|
||||||
PathRouteModel res = dlg.show() == OK ? getPath() : null;
|
RouteModel res = dlg.show() == OK ? getPath() : null;
|
||||||
paths.clear();
|
paths.clear();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathRouteModel getPath(){
|
public RouteModel getPath(){
|
||||||
return tblPaths.getSelectionModel().getSelectedItem();
|
return tblPaths.getSelectionModel().getSelectedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(ObservableList<PathRouteModel> paths) {
|
private void init(ObservableList<RouteModel> paths) {
|
||||||
tblPaths.getSelectionModel().clearSelection();
|
tblPaths.getSelectionModel().clearSelection();
|
||||||
this.paths.clear();
|
this.paths.clear();
|
||||||
this.paths.addAll(paths);
|
this.paths.addAll(paths);
|
||||||
paths.addListener((ListChangeListener<PathRouteModel>) l -> {
|
paths.addListener((ListChangeListener<RouteModel>) l -> {
|
||||||
while (l.next()) {
|
while (l.next()) {
|
||||||
if (l.wasAdded()) {
|
if (l.wasAdded()) {
|
||||||
this.paths.addAll(l.getAddedSubList());
|
this.paths.addAll(l.getAddedSubList());
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class RouterController {
|
|||||||
private NumberField totalBalance;
|
private NumberField totalBalance;
|
||||||
|
|
||||||
private MarketModel market;
|
private MarketModel market;
|
||||||
private PathRouteModel route;
|
private RouteModel route;
|
||||||
private final ObservableList<OrderModel> orders = FXCollections.observableArrayList();
|
private final ObservableList<OrderModel> orders = FXCollections.observableArrayList();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -75,22 +75,9 @@ public class RouterController {
|
|||||||
totalBalance.setValue(n);
|
totalBalance.setValue(n);
|
||||||
Main.SETTINGS.setBalance(n.doubleValue());
|
Main.SETTINGS.setBalance(n.doubleValue());
|
||||||
});
|
});
|
||||||
cargo.numberProperty().addListener((ov, o, n) -> {
|
cargo.numberProperty().addListener((ov, o, n) -> Main.SETTINGS.setCargo(n.intValue()));
|
||||||
market.getAnalyzer().setCargo(n.intValue());
|
tank.numberProperty().addListener((ov, o, n) -> Main.SETTINGS.setTank(n.doubleValue()));
|
||||||
Main.SETTINGS.setCargo(n.intValue());
|
jumps.numberProperty().addListener((ov, o, n) -> Main.SETTINGS.setJumps(n.intValue()));
|
||||||
});
|
|
||||||
tank.numberProperty().addListener((ov, o, n) -> {
|
|
||||||
market.getAnalyzer().setTank(n.doubleValue());
|
|
||||||
Main.SETTINGS.setTank(n.doubleValue());
|
|
||||||
});
|
|
||||||
distance.numberProperty().addListener((ov, o, n) -> {
|
|
||||||
market.getAnalyzer().setMaxDistance(n.doubleValue());
|
|
||||||
Main.SETTINGS.setDistance(n.doubleValue());
|
|
||||||
});
|
|
||||||
jumps.numberProperty().addListener((ov, o, n) -> {
|
|
||||||
market.getAnalyzer().setJumps(n.intValue());
|
|
||||||
Main.SETTINGS.setJumps(n.intValue());
|
|
||||||
});
|
|
||||||
source.valueProperty().addListener((ov, o, n) -> {
|
source.valueProperty().addListener((ov, o, n) -> {
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
sStation.setItems(n.getStationsList());
|
sStation.setItems(n.getStationsList());
|
||||||
@@ -116,7 +103,6 @@ public class RouterController {
|
|||||||
balance.setValue(Main.SETTINGS.getBalance());
|
balance.setValue(Main.SETTINGS.getBalance());
|
||||||
cargo.setValue(Main.SETTINGS.getCargo());
|
cargo.setValue(Main.SETTINGS.getCargo());
|
||||||
tank.setValue(Main.SETTINGS.getTank());
|
tank.setValue(Main.SETTINGS.getTank());
|
||||||
distance.setValue(Main.SETTINGS.getDistance());
|
|
||||||
jumps.setValue(Main.SETTINGS.getJumps());
|
jumps.setValue(Main.SETTINGS.getJumps());
|
||||||
|
|
||||||
addBtn.disableProperty().bind(Bindings.createBooleanBinding(()-> {
|
addBtn.disableProperty().bind(Bindings.createBooleanBinding(()-> {
|
||||||
@@ -181,10 +167,10 @@ public class RouterController {
|
|||||||
public void addStationToRoute(){
|
public void addStationToRoute(){
|
||||||
StationModel sS = sStation.getValue();
|
StationModel sS = sStation.getValue();
|
||||||
StationModel tS = tStation.getValue();
|
StationModel tS = tStation.getValue();
|
||||||
PathRouteModel r = market.getPath(sS, tS);
|
RouteModel r = market.getPath(sS, tS);
|
||||||
if (r == null) return;
|
if (r == null) return;
|
||||||
if (route != null){
|
if (route != null){
|
||||||
route = route.add(r);
|
route.add(r);
|
||||||
} else {
|
} else {
|
||||||
route = r;
|
route = r;
|
||||||
}
|
}
|
||||||
@@ -196,13 +182,14 @@ public class RouterController {
|
|||||||
public void editOrders(){
|
public void editOrders(){
|
||||||
OrderModel sel = tblOrders.getSelectionModel().getSelectedItem();
|
OrderModel sel = tblOrders.getSelectionModel().getSelectedItem();
|
||||||
int index = tblOrders.getSelectionModel().getSelectedIndex();
|
int index = tblOrders.getSelectionModel().getSelectedIndex();
|
||||||
market.getOrders(sel.getStation(), sel.getBuyer(), sel.getBalance(), result -> {
|
//TODO: implement
|
||||||
|
/* market.getOrders(sel.getStation(), sel.getBuyer(), sel.getBalance(), result -> {
|
||||||
OrderModel order = Screeners.showOrders(result);
|
OrderModel order = Screeners.showOrders(result);
|
||||||
if (order!=null){
|
if (order!=null){
|
||||||
orders.set(index, order);
|
orders.set(index, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSelected(){
|
public void removeSelected(){
|
||||||
@@ -210,7 +197,7 @@ public class RouterController {
|
|||||||
if (!select.isEmpty()){
|
if (!select.isEmpty()){
|
||||||
int index = select.getSelectedIndex();
|
int index = select.getSelectedIndex();
|
||||||
if (index > 0){
|
if (index > 0){
|
||||||
route = route.remove(select.getSelectedItem());
|
route.remove(select.getSelectedItem());
|
||||||
} else {
|
} else {
|
||||||
route = null;
|
route = null;
|
||||||
}
|
}
|
||||||
@@ -221,7 +208,8 @@ public class RouterController {
|
|||||||
|
|
||||||
public void recompute(){
|
public void recompute(){
|
||||||
if (route != null){
|
if (route != null){
|
||||||
route.recompute(balance.getValue().doubleValue(), cargo.getValue().longValue());
|
//TODO: implement
|
||||||
|
/// route.recompute(balance.getValue().doubleValue(), cargo.getValue().longValue());
|
||||||
orders.clear();
|
orders.clear();
|
||||||
orders.addAll(route.getOrders());
|
orders.addAll(route.getOrders());
|
||||||
refreshPath();
|
refreshPath();
|
||||||
@@ -230,7 +218,7 @@ public class RouterController {
|
|||||||
|
|
||||||
public void rebuild(){
|
public void rebuild(){
|
||||||
if (route != null){
|
if (route != null){
|
||||||
PathRouteModel r = market.getRoute(route, balance.getValue().doubleValue());
|
RouteModel r = market.getRoute(route, balance.getValue().doubleValue());
|
||||||
if (r != null){
|
if (r != null){
|
||||||
route = r;
|
route = r;
|
||||||
orders.clear();
|
orders.clear();
|
||||||
@@ -281,7 +269,7 @@ public class RouterController {
|
|||||||
StationModel sS = sStation.getValue();
|
StationModel sS = sStation.getValue();
|
||||||
StationModel tS = tStation.getValue();
|
StationModel tS = tStation.getValue();
|
||||||
market.getRoutes(s, sS, t, tS, totalBalance.getValue().doubleValue(), routes -> {
|
market.getRoutes(s, sS, t, tS, totalBalance.getValue().doubleValue(), routes -> {
|
||||||
PathRouteModel path = Screeners.showRouters(routes);
|
RouteModel path = Screeners.showRouters(routes);
|
||||||
if (path!=null){
|
if (path!=null){
|
||||||
orders.addAll(path.getOrders());
|
orders.addAll(path.getOrders());
|
||||||
addRouteToPath(path);
|
addRouteToPath(path);
|
||||||
@@ -291,7 +279,7 @@ public class RouterController {
|
|||||||
|
|
||||||
public void showTopRoutes(){
|
public void showTopRoutes(){
|
||||||
market.getTopRoutes(totalBalance.getValue().doubleValue(), routes -> {
|
market.getTopRoutes(totalBalance.getValue().doubleValue(), routes -> {
|
||||||
PathRouteModel path = Screeners.showRouters(routes);
|
RouteModel path = Screeners.showRouters(routes);
|
||||||
if (path!=null){
|
if (path!=null){
|
||||||
orders.addAll(path.getOrders());
|
orders.addAll(path.getOrders());
|
||||||
addRouteToPath(path);
|
addRouteToPath(path);
|
||||||
@@ -299,18 +287,18 @@ public class RouterController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRouteToPath(PathRouteModel route){
|
private void addRouteToPath(RouteModel route){
|
||||||
if (this.route == null){
|
if (this.route == null){
|
||||||
this.route = route;
|
this.route = route;
|
||||||
} else {
|
} else {
|
||||||
this.route = this.route.add(route);
|
this.route.add(route);
|
||||||
}
|
}
|
||||||
refreshPath();
|
refreshPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOrderToPath(OrderModel order){
|
private void addOrderToPath(OrderModel order){
|
||||||
if (route != null){
|
if (route != null){
|
||||||
route = route.add(order);
|
route.add(order);
|
||||||
} else {
|
} else {
|
||||||
route = market.getPath(order);
|
route = market.getPath(order);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class Screeners {
|
|||||||
return topOrdersController.showDialog(mainScreen, topOrdersScreen, orders);
|
return topOrdersController.showDialog(mainScreen, topOrdersScreen, orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PathRouteModel showRouters(ObservableList<PathRouteModel> routers) {
|
public static RouteModel showRouters(ObservableList<RouteModel> routers) {
|
||||||
return pathsController.showDialog(mainScreen, pathsScreen, routers);
|
return pathsController.showDialog(mainScreen, pathsScreen, routers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.EMDNUpdater;
|
import ru.trader.EMDNUpdater;
|
||||||
import ru.trader.Main;
|
import ru.trader.Main;
|
||||||
import ru.trader.core.MarketAnalyzer;
|
|
||||||
import ru.trader.model.MarketModel;
|
|
||||||
import ru.trader.view.support.Localization;
|
import ru.trader.view.support.Localization;
|
||||||
import ru.trader.view.support.NumberField;
|
import ru.trader.view.support.NumberField;
|
||||||
|
|
||||||
@@ -47,8 +45,7 @@ public class SettingsController {
|
|||||||
emdnOn.setSelected(Main.SETTINGS.getEMDNActive());
|
emdnOn.setSelected(Main.SETTINGS.getEMDNActive());
|
||||||
emdnUpdateOnly.setSelected(Main.SETTINGS.getEMDNUpdateOnly());
|
emdnUpdateOnly.setSelected(Main.SETTINGS.getEMDNUpdateOnly());
|
||||||
emdnUpdateTime.setValue(Main.SETTINGS.getEMDNAutoUpdate());
|
emdnUpdateTime.setValue(Main.SETTINGS.getEMDNAutoUpdate());
|
||||||
segmentSize.setValue(Main.SETTINGS.getSegmentSize());
|
pathsCount.setValue(Main.SETTINGS.getRoutesCount());
|
||||||
pathsCount.setValue(Main.SETTINGS.getPathsCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
@@ -60,12 +57,6 @@ public class SettingsController {
|
|||||||
EMDNUpdater.setUpdateOnly(emdnUpdateOnly.isSelected());
|
EMDNUpdater.setUpdateOnly(emdnUpdateOnly.isSelected());
|
||||||
Main.SETTINGS.setEMDNAutoUpdate(emdnUpdateTime.getValue().longValue());
|
Main.SETTINGS.setEMDNAutoUpdate(emdnUpdateTime.getValue().longValue());
|
||||||
EMDNUpdater.setInterval(emdnUpdateTime.getValue().longValue());
|
EMDNUpdater.setInterval(emdnUpdateTime.getValue().longValue());
|
||||||
MarketAnalyzer analyzer = MainController.getMarket().getAnalyzer();
|
|
||||||
Main.SETTINGS.setSegmentSize(segmentSize.getValue().intValue());
|
|
||||||
analyzer.setSegmentSize(segmentSize.getValue().intValue());
|
|
||||||
Main.SETTINGS.setPathsCount(pathsCount.getValue().intValue());
|
|
||||||
analyzer.setPathsCount(pathsCount.getValue().intValue());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action showDialog(Parent parent, Parent content){
|
public Action showDialog(Parent parent, Parent content){
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import javafx.collections.ObservableList;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.World;
|
import ru.trader.World;
|
||||||
|
import ru.trader.analysis.Route;
|
||||||
import ru.trader.controllers.ProgressController;
|
import ru.trader.controllers.ProgressController;
|
||||||
import ru.trader.controllers.Screeners;
|
import ru.trader.controllers.Screeners;
|
||||||
import ru.trader.core.*;
|
import ru.trader.core.*;
|
||||||
import ru.trader.graph.PathRoute;
|
|
||||||
import ru.trader.model.support.BindingsHelper;
|
import ru.trader.model.support.BindingsHelper;
|
||||||
import ru.trader.model.support.Notificator;
|
import ru.trader.model.support.Notificator;
|
||||||
import ru.trader.services.OrdersSearchTask;
|
import ru.trader.services.OrdersSearchTask;
|
||||||
@@ -45,7 +45,7 @@ public class MarketModel {
|
|||||||
notificator = new Notificator();
|
notificator = new Notificator();
|
||||||
groups = new SimpleListProperty<>(BindingsHelper.observableList(market.getGroups(), modeler::get));
|
groups = new SimpleListProperty<>(BindingsHelper.observableList(market.getGroups(), modeler::get));
|
||||||
items = new SimpleListProperty<>(BindingsHelper.observableList(market.getItems(), modeler::get));
|
items = new SimpleListProperty<>(BindingsHelper.observableList(market.getItems(), modeler::get));
|
||||||
items.sort((i1, i2) -> i1.compareTo(i2));
|
items.sort(ItemModel::compareTo);
|
||||||
systems = new SimpleListProperty<>(BindingsHelper.observableList(market.get(), modeler::get));
|
systems = new SimpleListProperty<>(BindingsHelper.observableList(market.get(), modeler::get));
|
||||||
systemsList = new SimpleListProperty<>(FXCollections.observableArrayList(ModelFabric.NONE_SYSTEM));
|
systemsList = new SimpleListProperty<>(FXCollections.observableArrayList(ModelFabric.NONE_SYSTEM));
|
||||||
systemsList.addAll(systems);
|
systemsList.addAll(systems);
|
||||||
@@ -168,15 +168,15 @@ public class MarketModel {
|
|||||||
getOrders(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
getOrders(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getRoutes(SystemModel from, double balance, Consumer<ObservableList<PathRouteModel>> result){
|
public void getRoutes(SystemModel from, double balance, Consumer<ObservableList<RouteModel>> result){
|
||||||
getRoutes(from, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
getRoutes(from, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getRoutes(SystemModel from, SystemModel to, double balance, Consumer<ObservableList<PathRouteModel>> result){
|
public void getRoutes(SystemModel from, SystemModel to, double balance, Consumer<ObservableList<RouteModel>> result){
|
||||||
getRoutes(from, ModelFabric.NONE_STATION, to, ModelFabric.NONE_STATION, balance, result);
|
getRoutes(from, ModelFabric.NONE_STATION, to, ModelFabric.NONE_STATION, balance, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, Consumer<ObservableList<PathRouteModel>> result) {
|
public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, Consumer<ObservableList<RouteModel>> result) {
|
||||||
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title"));
|
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title"));
|
||||||
RoutesSearchTask task = new RoutesSearchTask(this,
|
RoutesSearchTask task = new RoutesSearchTask(this,
|
||||||
from == null || from == ModelFabric.NONE_SYSTEM ? null : from.getSystem(),
|
from == null || from == ModelFabric.NONE_SYSTEM ? null : from.getSystem(),
|
||||||
@@ -187,7 +187,7 @@ public class MarketModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
progress.run(task, route -> {
|
progress.run(task, route -> {
|
||||||
ObservableList<PathRouteModel> res = BindingsHelper.observableList(route, modeler::get);
|
ObservableList<RouteModel> res = BindingsHelper.observableList(route, modeler::get);
|
||||||
if (Platform.isFxApplicationThread()){
|
if (Platform.isFxApplicationThread()){
|
||||||
result.accept(res);
|
result.accept(res);
|
||||||
} else {
|
} else {
|
||||||
@@ -196,30 +196,29 @@ public class MarketModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTopRoutes(double balance, Consumer<ObservableList<PathRouteModel>> result){
|
public void getTopRoutes(double balance, Consumer<ObservableList<RouteModel>> result){
|
||||||
getRoutes(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
getRoutes(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathRouteModel getRoute(PathRouteModel path, double balance) {
|
public RouteModel getRoute(RouteModel path, double balance) {
|
||||||
PathRoute p = analyzer.getPath(path.getPath().getEntries(), balance);
|
//TODO: implement
|
||||||
if (p == null) return null;
|
/*Route r = analyzer.getRoute(path.getRoute());
|
||||||
|
if (r == null) return null;
|
||||||
|
return modeler.get(r);*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Route _getPath(OrderModel order) {
|
||||||
|
return analyzer.getPath(order.getOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RouteModel getPath(StationModel from, StationModel to) {
|
||||||
|
Route p = analyzer.getPath(from.getStation(), to.getStation());
|
||||||
return modeler.get(p);
|
return modeler.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathRoute _getPath(StationModel from, StationModel to) {
|
public RouteModel getPath(OrderModel order) {
|
||||||
return analyzer.getPath(from.getStation(), to.getStation());
|
Route p = analyzer.getPath(order.getOrder());
|
||||||
}
|
|
||||||
|
|
||||||
public PathRouteModel getPath(StationModel from, StationModel to) {
|
|
||||||
PathRoute p = analyzer.getPath(from.getStation(), to.getStation());
|
|
||||||
if (p == null) return null;
|
|
||||||
return modeler.get(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathRouteModel getPath(OrderModel order) {
|
|
||||||
PathRoute p = analyzer.getPath(order.getStation().getStation(), order.getBuyer().getStation());
|
|
||||||
if (p == null) return null;
|
|
||||||
p.getRoot().getNext().setOrder(new Order(order.getOffer().getOffer(), order.getBuyOffer().getOffer(), order.getCount()));
|
|
||||||
return modeler.get(p);
|
return modeler.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import javafx.beans.property.ReadOnlyObjectProperty;
|
|||||||
import javafx.beans.property.ReadOnlyStringProperty;
|
import javafx.beans.property.ReadOnlyStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import ru.trader.analysis.Route;
|
||||||
import ru.trader.core.*;
|
import ru.trader.core.*;
|
||||||
import ru.trader.graph.PathRoute;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -29,8 +29,8 @@ public class ModelFabric {
|
|||||||
return new OrderModel(get(order.getSell()), get(order.getBuy()), order.getCount());
|
return new OrderModel(get(order.getSell()), get(order.getBuy()), order.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathRouteModel get(PathRoute path) {
|
public RouteModel get(Route route) {
|
||||||
return new PathRouteModel(path, market);
|
return new RouteModel(route, market);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemModel get(Place system){
|
public SystemModel get(Place system){
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import javafx.beans.binding.Bindings;
|
|||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import ru.trader.core.Order;
|
import ru.trader.core.Order;
|
||||||
import ru.trader.graph.PathRoute;
|
|
||||||
import ru.trader.model.support.ModelBindings;
|
import ru.trader.model.support.ModelBindings;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,7 +18,6 @@ public class OrderModel {
|
|||||||
private DoubleProperty profit;
|
private DoubleProperty profit;
|
||||||
private DoubleProperty distance;
|
private DoubleProperty distance;
|
||||||
private DoubleProperty bestProfit;
|
private DoubleProperty bestProfit;
|
||||||
private PathRoute path;
|
|
||||||
|
|
||||||
public OrderModel(OfferModel offer) {
|
public OrderModel(OfferModel offer) {
|
||||||
this.offer = offer;
|
this.offer = offer;
|
||||||
@@ -49,15 +47,10 @@ public class OrderModel {
|
|||||||
this.max.setValue(Order.getMaxCount(offer.getOffer(), balance, limit));
|
this.max.setValue(Order.getMaxCount(offer.getOffer(), balance, limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
PathRoute getPath() {
|
Order getOrder(){
|
||||||
return path;
|
return new Order(getOffer().getOffer(), getBuyOffer().getOffer(), getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPath(PathRoute path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public OfferModel getOffer() {
|
public OfferModel getOffer() {
|
||||||
return offer;
|
return offer;
|
||||||
}
|
}
|
||||||
@@ -160,9 +153,4 @@ public class OrderModel {
|
|||||||
}
|
}
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBalance(){
|
|
||||||
return path != null ? path.getRoot().getBalance() : getMax() * offer.getPrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
package ru.trader.model;
|
|
||||||
|
|
||||||
import ru.trader.core.Order;
|
|
||||||
import ru.trader.graph.PathRoute;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class PathRouteModel {
|
|
||||||
private final MarketModel market;
|
|
||||||
private final double distance;
|
|
||||||
private final double totalProfit;
|
|
||||||
private final int jumps;
|
|
||||||
private final int refuels;
|
|
||||||
private final int lands;
|
|
||||||
|
|
||||||
private final PathRoute _path;
|
|
||||||
|
|
||||||
PathRouteModel(PathRoute path, MarketModel market) {
|
|
||||||
this.market = market;
|
|
||||||
this._path = path;
|
|
||||||
PathRoute p = path.getRoot();
|
|
||||||
totalProfit = p.getProfit();
|
|
||||||
lands = p.getLandsCount();
|
|
||||||
double d = 0; int j = 0, r = 0;
|
|
||||||
while (p.hasNext()){
|
|
||||||
p = p.getNext();
|
|
||||||
d += p.getDistance();
|
|
||||||
j++;
|
|
||||||
if (p.isRefill()) r++;
|
|
||||||
}
|
|
||||||
distance = d;
|
|
||||||
jumps = j;
|
|
||||||
refuels = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDistance() {
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTotalProfit() {
|
|
||||||
return totalProfit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getJumps() {
|
|
||||||
return jumps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRefuels() {
|
|
||||||
return refuels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathRoute getPath() {
|
|
||||||
return _path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLands() {
|
|
||||||
return lands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAvgProfit(){
|
|
||||||
return totalProfit/lands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<OrderModel> getOrders(){
|
|
||||||
Collection<OrderModel> res = new ArrayList<>(lands);
|
|
||||||
PathRoute path = _path.getRoot();
|
|
||||||
Order cargo = null;
|
|
||||||
while (path.hasNext()){
|
|
||||||
path = path.getNext();
|
|
||||||
if (cargo == null && path.getBest()!=null){
|
|
||||||
cargo = path.getBest();
|
|
||||||
OrderModel order = market.getModeler().get(cargo);
|
|
||||||
order.setPath(path);
|
|
||||||
res.add(order);
|
|
||||||
}
|
|
||||||
if (cargo!=null && cargo.isBuyer(path.get())){
|
|
||||||
cargo = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
PathRoute _add(PathRoute route){
|
|
||||||
return _path.add(route, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathRouteModel add(OrderModel order){
|
|
||||||
PathRoute path = market._getPath(order.getStation(), order.getBuyer());
|
|
||||||
if (path == null) return this;
|
|
||||||
path.getRoot().getNext().setOrder(new Order(order.getOffer().getOffer(), order.getBuyOffer().getOffer(), order.getCount()));
|
|
||||||
PathRoute head = _path.getEnd();
|
|
||||||
PathRouteModel res = new PathRouteModel(_add(path), market);
|
|
||||||
order.setPath(head);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathRouteModel add(PathRouteModel route){
|
|
||||||
return new PathRouteModel(_add(route.getPath()), market);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathRouteModel remove(OrderModel order) {
|
|
||||||
return new PathRouteModel(_path.dropTo(order.getStation().getStation()), market);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recompute(double balance, long cargo) {
|
|
||||||
_path.refresh();
|
|
||||||
_path.sort(balance, cargo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
72
client/src/main/java/ru/trader/model/RouteModel.java
Normal file
72
client/src/main/java/ru/trader/model/RouteModel.java
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package ru.trader.model;
|
||||||
|
|
||||||
|
import ru.trader.analysis.Route;
|
||||||
|
import ru.trader.analysis.RouteEntry;
|
||||||
|
import ru.trader.core.Order;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class RouteModel {
|
||||||
|
private final MarketModel market;
|
||||||
|
private final Route _route;
|
||||||
|
|
||||||
|
RouteModel(Route route, MarketModel market) {
|
||||||
|
this.market = market;
|
||||||
|
this._route = route;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDistance() {
|
||||||
|
return _route.getDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTotalProfit() {
|
||||||
|
return _route.getProfit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJumps() {
|
||||||
|
return _route.getLands();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRefuels() {
|
||||||
|
return _route.getRefills();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Route getRoute() {
|
||||||
|
return _route;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLands() {
|
||||||
|
return _route.getLands();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAvgProfit(){
|
||||||
|
return _route.getProfit()/_route.getLands();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<OrderModel> getOrders(){
|
||||||
|
Collection<OrderModel> res = new ArrayList<>();
|
||||||
|
for (RouteEntry entry : _route.getEntries()) {
|
||||||
|
for (Order o : entry.getOrders()) {
|
||||||
|
OrderModel order = market.getModeler().get(o);
|
||||||
|
res.add(order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(OrderModel order){
|
||||||
|
Route path = market._getPath(order);
|
||||||
|
if (path == null) return;
|
||||||
|
_route.join(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(RouteModel route){
|
||||||
|
_route.join(route.getRoute());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(OrderModel order) {
|
||||||
|
_route.dropTo(order.getStation().getStation());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,25 +28,25 @@ public class OrdersSearchTask extends AnalyzerTask<Collection<Order>>{
|
|||||||
Collection<Order> orders;
|
Collection<Order> orders;
|
||||||
if (stationFrom != null){
|
if (stationFrom != null){
|
||||||
if (stationTo != null){
|
if (stationTo != null){
|
||||||
orders = analyzer.getOrders(stationFrom, stationTo, balance);
|
orders = analyzer.getOrders(stationFrom, stationTo);
|
||||||
} else {
|
} else {
|
||||||
if (to != null){
|
if (to != null){
|
||||||
orders = analyzer.getOrders(stationFrom, to, balance);
|
orders = analyzer.getOrders(stationFrom, to);
|
||||||
} else {
|
} else {
|
||||||
orders = analyzer.getOrders(stationFrom, balance);
|
orders = analyzer.getOrders(stationFrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (stationTo != null){
|
if (stationTo != null){
|
||||||
orders = analyzer.getOrders(from, stationTo, balance);
|
orders = analyzer.getOrders(from, stationTo);
|
||||||
} else {
|
} else {
|
||||||
if (to != null){
|
if (to != null){
|
||||||
orders = analyzer.getOrders(from, to, balance);
|
orders = analyzer.getOrders(from, to);
|
||||||
} else {
|
} else {
|
||||||
if (from != null){
|
if (from != null){
|
||||||
orders = analyzer.getOrders(from, balance);
|
orders = analyzer.getOrders(from);
|
||||||
} else {
|
} else {
|
||||||
orders = analyzer.getTop(balance);
|
orders = analyzer.getTop(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package ru.trader.services;
|
package ru.trader.services;
|
||||||
|
|
||||||
|
import ru.trader.analysis.Route;
|
||||||
import ru.trader.core.Place;
|
import ru.trader.core.Place;
|
||||||
import ru.trader.core.Vendor;
|
import ru.trader.core.Vendor;
|
||||||
import ru.trader.graph.PathRoute;
|
|
||||||
import ru.trader.model.MarketModel;
|
import ru.trader.model.MarketModel;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class RoutesSearchTask extends AnalyzerTask<Collection<PathRoute>>{
|
public class RoutesSearchTask extends AnalyzerTask<Collection<Route>>{
|
||||||
private final Place from;
|
private final Place from;
|
||||||
private final Vendor stationFrom;
|
private final Vendor stationFrom;
|
||||||
private final Place to;
|
private final Place to;
|
||||||
private final Vendor stationTo;
|
private final Vendor stationTo;
|
||||||
private final double balance;
|
|
||||||
|
|
||||||
public RoutesSearchTask(MarketModel market, Place from, Vendor stationFrom, Place to, Vendor stationTo, double balance) {
|
public RoutesSearchTask(MarketModel market, Place from, Vendor stationFrom, Place to, Vendor stationTo, double balance) {
|
||||||
super(market);
|
super(market);
|
||||||
@@ -20,34 +19,34 @@ public class RoutesSearchTask extends AnalyzerTask<Collection<PathRoute>>{
|
|||||||
this.stationFrom = stationFrom;
|
this.stationFrom = stationFrom;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
this.stationTo = stationTo;
|
this.stationTo = stationTo;
|
||||||
this.balance = balance;
|
market.getAnalyzer().getProfile().setBalance(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<PathRoute> call() throws Exception {
|
protected Collection<Route> call() throws Exception {
|
||||||
Collection<PathRoute> routes;
|
Collection<Route> routes;
|
||||||
|
|
||||||
if (stationFrom != null) {
|
if (stationFrom != null) {
|
||||||
if (stationTo != null) {
|
if (stationTo != null) {
|
||||||
routes = analyzer.getPaths(stationFrom, stationTo, balance);
|
routes = analyzer.getRoutes(stationFrom, stationTo);
|
||||||
} else {
|
} else {
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
routes = analyzer.getPaths(stationFrom, to, balance);
|
routes = analyzer.getRoutes(stationFrom, to);
|
||||||
} else {
|
} else {
|
||||||
routes = analyzer.getPaths(stationFrom, balance);
|
routes = analyzer.getRoutes(stationFrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (stationTo != null) {
|
if (stationTo != null) {
|
||||||
routes = analyzer.getPaths(from, stationTo, balance);
|
routes = analyzer.getRoutes(from, stationTo);
|
||||||
} else {
|
} else {
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
routes = analyzer.getPaths(from, to, balance);
|
routes = analyzer.getRoutes(from, to);
|
||||||
} else {
|
} else {
|
||||||
if (from != null){
|
if (from != null){
|
||||||
routes = analyzer.getPaths(from, balance);
|
routes = analyzer.getRoutes(from);
|
||||||
} else {
|
} else {
|
||||||
routes = analyzer.getTopPaths(balance);
|
routes = analyzer.getTopRoutes(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import javafx.scene.layout.Priority;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import org.controlsfx.glyphfont.Glyph;
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
import ru.trader.core.Order;
|
import ru.trader.analysis.Route;
|
||||||
|
import ru.trader.analysis.RouteEntry;
|
||||||
import ru.trader.core.Vendor;
|
import ru.trader.core.Vendor;
|
||||||
import ru.trader.graph.PathRoute;
|
import ru.trader.model.RouteModel;
|
||||||
import ru.trader.model.PathRouteModel;
|
|
||||||
import ru.trader.view.support.cells.DistanceCell;
|
import ru.trader.view.support.cells.DistanceCell;
|
||||||
|
|
||||||
public class RouteNode {
|
public class RouteNode {
|
||||||
@@ -22,67 +22,51 @@ public class RouteNode {
|
|||||||
private final static String CSS_SYSTEM_TEXT = "path-system-text";
|
private final static String CSS_SYSTEM_TEXT = "path-system-text";
|
||||||
private final static String CSS_STATION_TEXT = "path-station-text";
|
private final static String CSS_STATION_TEXT = "path-station-text";
|
||||||
|
|
||||||
private final PathRoute path;
|
private final Route route;
|
||||||
private final HBox node = new HBox();
|
private final HBox node = new HBox();
|
||||||
|
|
||||||
public RouteNode(PathRouteModel path) {
|
public RouteNode(RouteModel route) {
|
||||||
this.path = path.getPath();
|
this.route = route.getRoute();
|
||||||
node.getStyleClass().add(CSS_PATH);
|
node.getStyleClass().add(CSS_PATH);
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void build(){
|
private void build(){
|
||||||
HBox v = new HBox();
|
Vendor prev = null;
|
||||||
VBox icons = new VBox();
|
for (RouteEntry entry : route.getEntries()) {
|
||||||
VBox track = new VBox();
|
if (prev != null){
|
||||||
VBox.setVgrow(track, Priority.ALWAYS);
|
VBox track = new VBox();
|
||||||
VBox.setVgrow(icons, Priority.ALWAYS);
|
VBox.setVgrow(track, Priority.ALWAYS);
|
||||||
|
track.getStyleClass().add(CSS_TRACK);
|
||||||
|
|
||||||
v.getStyleClass().add(CSS_SYSTEM);
|
Text t = new Text(DistanceCell.distanceToString(entry.getVendor().getDistance(prev)));
|
||||||
icons.getStyleClass().add(CSS_ICONS);
|
t.getStyleClass().add(CSS_TRACK_TEXT);
|
||||||
track.getStyleClass().add(CSS_TRACK);
|
track.getChildren().addAll(t, Glyph.create("FontAwesome|LONG_ARROW_RIGHT"));
|
||||||
|
|
||||||
PathRoute p = path.getRoot();
|
node.getChildren().addAll(track);
|
||||||
|
|
||||||
v.getChildren().add(buildText(p.get()));
|
|
||||||
Order cargo = null;
|
|
||||||
while (p.hasNext()){
|
|
||||||
p = p.getNext();
|
|
||||||
if (cargo == null && p.getBest() != null){
|
|
||||||
cargo = p.getBest();
|
|
||||||
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
|
|
||||||
}
|
}
|
||||||
if (p.isRefill()) icons.getChildren().add(Glyph.create("FontAwesome|REFRESH"));
|
HBox v = new HBox();
|
||||||
|
VBox icons = new VBox();
|
||||||
node.getChildren().addAll(v, icons);
|
|
||||||
|
|
||||||
Text t = new Text(DistanceCell.distanceToString(p.getDistance()));
|
|
||||||
t.getStyleClass().add(CSS_TRACK_TEXT);
|
|
||||||
|
|
||||||
track.getChildren().addAll(t, Glyph.create("FontAwesome|LONG_ARROW_RIGHT"));
|
|
||||||
|
|
||||||
node.getChildren().addAll(track);
|
|
||||||
|
|
||||||
v = new HBox();
|
|
||||||
icons = new VBox();
|
|
||||||
track = new VBox(0);
|
|
||||||
VBox.setVgrow(track, Priority.ALWAYS);
|
|
||||||
VBox.setVgrow(icons, Priority.ALWAYS);
|
VBox.setVgrow(icons, Priority.ALWAYS);
|
||||||
|
|
||||||
v.getStyleClass().add(CSS_SYSTEM);
|
v.getStyleClass().add(CSS_SYSTEM);
|
||||||
icons.getStyleClass().add(CSS_ICONS);
|
icons.getStyleClass().add(CSS_ICONS);
|
||||||
track.getStyleClass().add(CSS_TRACK);
|
|
||||||
|
|
||||||
|
v.getChildren().add(buildText(entry.getVendor()));
|
||||||
|
|
||||||
v.getChildren().add(buildText(p.get()));
|
if (!entry.getOrders().isEmpty()){
|
||||||
v.getChildren().add(icons);
|
v.getChildren().add(new Text(String.format(" (%+.0f) ", entry.getProfit())));
|
||||||
if (cargo != null && cargo.isBuyer(p.get())){
|
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
|
||||||
v.getChildren().add(new Text(String.format(" (%+.0f) ", cargo.getProfit())));
|
}
|
||||||
cargo = null;
|
if (entry.isRefill()){
|
||||||
|
icons.getChildren().add(Glyph.create("FontAwesome|REFRESH"));
|
||||||
|
}
|
||||||
|
if (!entry.isRefill() && entry.isLand()){
|
||||||
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
|
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
|
||||||
}
|
}
|
||||||
|
node.getChildren().addAll(v, icons);
|
||||||
|
prev = entry.getVendor();
|
||||||
}
|
}
|
||||||
node.getChildren().addAll(v, icons);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private VBox buildText(Vendor vendor){
|
private VBox buildText(Vendor vendor){
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import javafx.scene.control.TableCell;
|
|||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableRow;
|
import javafx.scene.control.TableRow;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import ru.trader.model.PathRouteModel;
|
import ru.trader.model.RouteModel;
|
||||||
import ru.trader.view.support.RouteNode;
|
import ru.trader.view.support.RouteNode;
|
||||||
|
|
||||||
public class PathRouteCell<T> implements Callback<TableColumn<PathRouteModel, T>, TableCell<PathRouteModel, T>> {
|
public class PathRouteCell<T> implements Callback<TableColumn<RouteModel, T>, TableCell<RouteModel, T>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableCell<PathRouteModel, T> call(TableColumn<PathRouteModel, T> param) {
|
public TableCell<RouteModel, T> call(TableColumn<RouteModel, T> param) {
|
||||||
return new TableCell<PathRouteModel, T>(){
|
return new TableCell<RouteModel, T>(){
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(T value, boolean empty) {
|
public void updateItem(T value, boolean empty) {
|
||||||
super.updateItem(value, empty);
|
super.updateItem(value, empty);
|
||||||
TableRow row = getTableRow();
|
TableRow row = getTableRow();
|
||||||
if (!empty && row !=null && row.getItem() != null){
|
if (!empty && row !=null && row.getItem() != null){
|
||||||
RouteNode route = new RouteNode((PathRouteModel) row.getItem());
|
RouteNode route = new RouteNode((RouteModel) row.getItem());
|
||||||
setText(null);
|
setText(null);
|
||||||
setGraphic(route.getNode());
|
setGraphic(route.getNode());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public class FilteredMarket {
|
|||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MarketFilter getFilter() {
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
public void disableFilter(boolean disableFilter) {
|
public void disableFilter(boolean disableFilter) {
|
||||||
this.disableFilter = disableFilter;
|
this.disableFilter = disableFilter;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user