add columns to powerplay screen
This commit is contained in:
@@ -312,13 +312,15 @@ public class PowerPlayController {
|
|||||||
|
|
||||||
public class ResultEntry {
|
public class ResultEntry {
|
||||||
private final SystemModel starSystem;
|
private final SystemModel starSystem;
|
||||||
private final StationModel nearStation;
|
private final ReadOnlyStringProperty nearStations;
|
||||||
private final ReadOnlyDoubleProperty distance;
|
private final ReadOnlyDoubleProperty distance;
|
||||||
private final ReadOnlyDoubleProperty distanceHQ;
|
private final ReadOnlyDoubleProperty distanceHQ;
|
||||||
private final ReadOnlyStringProperty maxSizePad;
|
|
||||||
private final ReadOnlyIntegerProperty intersectCount;
|
private final ReadOnlyIntegerProperty intersectCount;
|
||||||
private final ReadOnlyStringProperty intersecting;
|
private final ReadOnlyStringProperty intersecting;
|
||||||
private final ReadOnlyStringProperty controlling;
|
private final ReadOnlyStringProperty controlling;
|
||||||
|
private final ReadOnlyLongProperty population;
|
||||||
|
private final ReadOnlyLongProperty upkeep;
|
||||||
|
private final ReadOnlyLongProperty income;
|
||||||
|
|
||||||
public ResultEntry(PowerPlayAnalyzator.IntersectData data) {
|
public ResultEntry(PowerPlayAnalyzator.IntersectData data) {
|
||||||
this(data, null);
|
this(data, null);
|
||||||
@@ -326,14 +328,17 @@ public class PowerPlayController {
|
|||||||
|
|
||||||
public ResultEntry(PowerPlayAnalyzator.IntersectData data, Place from) {
|
public ResultEntry(PowerPlayAnalyzator.IntersectData data, Place from) {
|
||||||
starSystem = world.getModeler().get(data.getStarSystem());
|
starSystem = world.getModeler().get(data.getStarSystem());
|
||||||
maxSizePad = new SimpleStringProperty(starSystem.getMaxSizePad());
|
|
||||||
intersectCount = new SimpleIntegerProperty(data.getCount());
|
intersectCount = new SimpleIntegerProperty(data.getCount());
|
||||||
nearStation = starSystem.getNear();
|
nearStations = new SimpleStringProperty(getStationsString(starSystem.getNearByType()));
|
||||||
intersecting = new SimpleStringProperty(getControllingString(data.getControllingSystems()));
|
intersecting = new SimpleStringProperty(getControllingString(data.getControllingSystems()));
|
||||||
controlling = new SimpleStringProperty(getControllingString(data.getStarSystem()));
|
controlling = new SimpleStringProperty(getControllingString(data.getStarSystem()));
|
||||||
distance = new SimpleDoubleProperty(from != null ? from.getDistance(data.getStarSystem()) : Double.NaN);
|
distance = new SimpleDoubleProperty(from != null ? from.getDistance(data.getStarSystem()) : Double.NaN);
|
||||||
Place hq = ModelFabric.get(hqSystem.orElse(null));
|
Place hq = ModelFabric.get(hqSystem.orElse(null));
|
||||||
distanceHQ = new SimpleDoubleProperty(hq != null ? hq.getDistance(data.getStarSystem()) : Double.NaN);
|
distanceHQ = new SimpleDoubleProperty(hq != null ? hq.getDistance(data.getStarSystem()) : Double.NaN);
|
||||||
|
population = new SimpleLongProperty(data.getStarSystem().getPopulation());
|
||||||
|
upkeep = new SimpleLongProperty(data.getStarSystem().getUpkeep());
|
||||||
|
income = new SimpleLongProperty(data.getStarSystem().getIncome());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getControllingString(Collection<PowerPlayAnalyzator.ControllingData> controllings) {
|
private String getControllingString(Collection<PowerPlayAnalyzator.ControllingData> controllings) {
|
||||||
@@ -356,10 +361,29 @@ public class PowerPlayController {
|
|||||||
return res.toString();
|
return res.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyStringProperty stationProperty(){
|
private String getStationsString(Collection<StationModel> stations) {
|
||||||
return new SimpleStringProperty(String.format("%s (%.0f Ls)", nearStation.getName(), nearStation.getDistance()));
|
StringBuilder res = new StringBuilder();
|
||||||
|
for (StationModel station : stations) {
|
||||||
|
if (res.length() != 0) res.append("\n");
|
||||||
|
if (station.getType() != null){
|
||||||
|
if (station.getType().isPlanetary()) {
|
||||||
|
res.append("LP");
|
||||||
|
} else
|
||||||
|
if (station.getType().hasLargeLandpad()){
|
||||||
|
res.append("L");
|
||||||
|
} else {
|
||||||
|
res.append("M");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.append("?");
|
||||||
|
}
|
||||||
|
res.append(" - ").append(station.getName());
|
||||||
|
res.append(" (").append(ViewUtils.stationDistanceToString(station.getDistance())).append(")");
|
||||||
|
}
|
||||||
|
return res.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ReadOnlyStringProperty nameProperty(){
|
public ReadOnlyStringProperty nameProperty(){
|
||||||
return starSystem.nameProperty();
|
return starSystem.nameProperty();
|
||||||
}
|
}
|
||||||
@@ -388,10 +412,6 @@ public class PowerPlayController {
|
|||||||
return distanceHQ;
|
return distanceHQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyStringProperty maxSizePadProperty() {
|
|
||||||
return maxSizePad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyIntegerProperty intersectCountProperty() {
|
public ReadOnlyIntegerProperty intersectCountProperty() {
|
||||||
return intersectCount;
|
return intersectCount;
|
||||||
}
|
}
|
||||||
@@ -403,5 +423,21 @@ public class PowerPlayController {
|
|||||||
public ReadOnlyStringProperty intersectingProperty() {
|
public ReadOnlyStringProperty intersectingProperty() {
|
||||||
return intersecting;
|
return intersecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty populationProperty() {
|
||||||
|
return population;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty upkeepProperty() {
|
||||||
|
return upkeep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty incomeProperty() {
|
||||||
|
return income;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyStringProperty nearStationsProperty() {
|
||||||
|
return nearStations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
package ru.trader.model;
|
package ru.trader.model;
|
||||||
|
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.ReadOnlyStringProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.core.*;
|
import ru.trader.core.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -187,6 +190,33 @@ public class SystemModel {
|
|||||||
return asModel(near.orElse(null));
|
return asModel(near.orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<StationModel> getNearByType(){
|
||||||
|
Collection<Vendor> stations = system.get().stream().sorted((v1, v2) -> Double.compare(v1.getDistance(), v2.getDistance())).collect(Collectors.toList());
|
||||||
|
Collection<StationModel> result = new ArrayList<>(4);
|
||||||
|
boolean findLarge = false, findMedium = false, findPlanetary = false;
|
||||||
|
for (Vendor station : stations) {
|
||||||
|
if (station.getType() != null){
|
||||||
|
if (station.getType().isPlanetary()){
|
||||||
|
if (!findPlanetary) {
|
||||||
|
result.add(asModel(station));
|
||||||
|
findPlanetary = true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (station.getType().hasLargeLandpad()){
|
||||||
|
if (!findLarge) {
|
||||||
|
result.add(asModel(station));
|
||||||
|
findLarge = true;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (!findMedium){
|
||||||
|
result.add(asModel(station));
|
||||||
|
findMedium = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (LOG.isTraceEnabled()){
|
if (LOG.isTraceEnabled()){
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package ru.trader.view.support;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import javafx.beans.NamedArg;
|
||||||
|
import javafx.util.converter.NumberStringConverter;
|
||||||
|
|
||||||
|
|
||||||
|
public class CustomNumberStringConverter extends NumberStringConverter {
|
||||||
|
|
||||||
|
public CustomNumberStringConverter(@NamedArg("pattern")String pattern) {
|
||||||
|
super(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,11 +89,11 @@
|
|||||||
<TitledPane text="Результаты анализа" collapsible="false">
|
<TitledPane text="Результаты анализа" collapsible="false">
|
||||||
<TableView fx:id="tblResults">
|
<TableView fx:id="tblResults">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn prefWidth="200" text="%market.system">
|
<TableColumn prefWidth="150" text="%market.system">
|
||||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn prefWidth="180" text="Пересекается с">
|
<TableColumn prefWidth="150" text="Пересекается с">
|
||||||
<cellValueFactory><PropertyValueFactory property="controlling"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="intersecting"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn prefWidth="90" text="Пересечений">
|
<TableColumn prefWidth="90" text="Пересечений">
|
||||||
<cellValueFactory><PropertyValueFactory property="intersectCount"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="intersectCount"/></cellValueFactory>
|
||||||
@@ -118,8 +118,20 @@
|
|||||||
<cellFactory><DistanceCell /></cellFactory>
|
<cellFactory><DistanceCell /></cellFactory>
|
||||||
<cellValueFactory><PropertyValueFactory property="distance"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="distance"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Income">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="income"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Upkeep">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="upkeep"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Население">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="population"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
<TableColumn prefWidth="100" text="Тип площадки">
|
<TableColumn prefWidth="100" text="Тип площадки">
|
||||||
<cellValueFactory><PropertyValueFactory property="maxSizePad"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="nearStations"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="150" text="Контролируется">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="controlling"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn prefWidth="80" text="Дистанция до HQ">
|
<TableColumn prefWidth="80" text="Дистанция до HQ">
|
||||||
<cellFactory><DistanceCell /></cellFactory>
|
<cellFactory><DistanceCell /></cellFactory>
|
||||||
@@ -162,6 +174,19 @@
|
|||||||
<cellFactory><TextCell><converter><FactionStringConverter /></converter></TextCell></cellFactory>
|
<cellFactory><TextCell><converter><FactionStringConverter /></converter></TextCell></cellFactory>
|
||||||
<cellValueFactory><PropertyValueFactory property="faction"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="faction"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Income">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="income"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Upkeep">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="upkeep"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="80" text="Население">
|
||||||
|
<cellFactory><TextCell><converter><CustomNumberStringConverter pattern="#,##0.##" /></converter></TextCell></cellFactory>
|
||||||
|
<cellValueFactory><PropertyValueFactory property="population"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn prefWidth="150" text="Контролируется">
|
||||||
|
<cellValueFactory><PropertyValueFactory property="controlling"/></cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
</columns>
|
</columns>
|
||||||
<columnResizePolicy>
|
<columnResizePolicy>
|
||||||
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
|
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user