add population to systems editor
This commit is contained in:
@@ -8,6 +8,7 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.ComboBoxTableCell;
|
||||
import javafx.util.converter.DefaultStringConverter;
|
||||
import javafx.util.converter.DoubleStringConverter;
|
||||
import javafx.util.converter.LongStringConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.Main;
|
||||
@@ -43,6 +44,8 @@ public class SystemsEditorController {
|
||||
@FXML
|
||||
private TableColumn<SystemData, POWER_STATE> clnPowerState;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Long> clnPopulation;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnX;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnY;
|
||||
@@ -90,6 +93,7 @@ public class SystemsEditorController {
|
||||
clnGovernment.setCellFactory(ComboBoxTableCell.forTableColumn(new GovernmentStringConverter(), FXCollections.observableArrayList(GOVERNMENT.values())));
|
||||
clnPower.setCellFactory(ComboBoxTableCell.forTableColumn(new PowerStringConverter(), FXCollections.observableArrayList(POWER.values())));
|
||||
clnPowerState.setCellFactory(ComboBoxTableCell.forTableColumn(new PowerStateStringConverter(), FXCollections.observableArrayList(POWER_STATE.values())));
|
||||
clnPopulation.setCellFactory(TextFieldCell.forTableColumn(new LongStringConverter()));
|
||||
clnX.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnY.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnZ.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
@@ -284,6 +288,7 @@ public class SystemsEditorController {
|
||||
private final DoubleProperty x;
|
||||
private final DoubleProperty y;
|
||||
private final DoubleProperty z;
|
||||
private final LongProperty population;
|
||||
private final ObjectProperty<FACTION> faction;
|
||||
private final ObjectProperty<GOVERNMENT> government;
|
||||
private final ObjectProperty<POWER> power;
|
||||
@@ -303,6 +308,7 @@ public class SystemsEditorController {
|
||||
x = new SimpleDoubleProperty(Double.NaN);
|
||||
y = new SimpleDoubleProperty(Double.NaN);
|
||||
z = new SimpleDoubleProperty(Double.NaN);
|
||||
population = new SimpleLongProperty(0);
|
||||
faction = new SimpleObjectProperty<>(FACTION.NONE);
|
||||
government = new SimpleObjectProperty<>(GOVERNMENT.NONE);
|
||||
power = new SimpleObjectProperty<>(POWER.NONE);
|
||||
@@ -315,6 +321,7 @@ public class SystemsEditorController {
|
||||
x = new SimpleDoubleProperty(system.getX());
|
||||
y = new SimpleDoubleProperty(system.getY());
|
||||
z = new SimpleDoubleProperty(system.getZ());
|
||||
population = new SimpleLongProperty(system.getPopulation());
|
||||
faction = new SimpleObjectProperty<>(system.getFaction());
|
||||
government = new SimpleObjectProperty<>(system.getGovernment());
|
||||
power = new SimpleObjectProperty<>(system.getPower());
|
||||
@@ -337,6 +344,10 @@ public class SystemsEditorController {
|
||||
return z;
|
||||
}
|
||||
|
||||
public LongProperty populationProperty() {
|
||||
return population;
|
||||
}
|
||||
|
||||
public DoubleProperty s1Property() {
|
||||
return s1;
|
||||
}
|
||||
@@ -386,12 +397,14 @@ public class SystemsEditorController {
|
||||
if (system != null){
|
||||
system.setName(name.get());
|
||||
system.setPosition(x.get(), y.get(), z.get());
|
||||
system.setPopulation(population.get());
|
||||
system.setFaction(faction.get());
|
||||
system.setGovernment(government.get());
|
||||
system.setPower(power.get());
|
||||
system.setPowerState(powerState.get());
|
||||
} else {
|
||||
SystemModel system = market.add(name.get(), x.get(), y.get(), z.get());
|
||||
system.setPopulation(population.get());
|
||||
system.setFaction(faction.get());
|
||||
system.setGovernment(government.get());
|
||||
system.setPower(power.get());
|
||||
|
||||
@@ -220,6 +220,16 @@ public class ModelFabric {
|
||||
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPopulation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(long population) {
|
||||
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return FACTION.NONE;
|
||||
|
||||
@@ -113,6 +113,17 @@ public class SystemModel {
|
||||
system.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
public long getPopulation(){
|
||||
return system.getPopulation();
|
||||
}
|
||||
|
||||
public void setPopulation(long population){
|
||||
if (population == system.getPopulation()) return;
|
||||
LOG.info("Change population of system {} to {}", this.system, population);
|
||||
system.setPopulation(population);
|
||||
}
|
||||
|
||||
|
||||
public double getDistance(SystemModel other){
|
||||
return system.getDistance(ModelFabric.get(other));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<TableColumn minWidth="60" text="Z">
|
||||
<cellValueFactory><PropertyValueFactory property="z"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="100" text="%market.population">
|
||||
<cellValueFactory><PropertyValueFactory property="population"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="government" minWidth="100" text="%market.government">
|
||||
<cellValueFactory><WritablePropertyValueFactory property="government"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
<TableColumn fx:id="clnZ" minWidth="60.0" text="z">
|
||||
<cellValueFactory><PropertyValueFactory property="z"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnPopulation" minWidth="100" text="%market.population">
|
||||
<cellValueFactory><PropertyValueFactory property="population"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="%sEditor.table.distance">
|
||||
<columns>
|
||||
<TableColumn fx:id="clnS1" minWidth="60.0" text="">
|
||||
|
||||
Reference in New Issue
Block a user