Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/resources/gui/Window.fxml
  • Loading branch information
aekrylov committed Apr 11, 2017
2 parents 1d11021 + 02af185 commit 6a67b6b
Show file tree
Hide file tree
Showing 34 changed files with 748 additions and 362 deletions.
20 changes: 0 additions & 20 deletions .idea/artifacts/JavaFXApp.xml

This file was deleted.

26 changes: 0 additions & 26 deletions .idea/compiler.xml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/description.html

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/dictionaries/anth.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<!-- Gson: Java to Json conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.victoria2.tools.vic2sgea.main;
package org.victoria2.tools.vic2sgea.entities;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -32,19 +31,22 @@ public class Country extends EconomySubject implements Comparable<Country> {
* Summ for country
*/
public long workforceRGO;

@NonSerializable //too expensive to serialize this
private Map<String, ProductStorage> storageMap = new HashMap<>();
@NonSerializable
private String officialName = "";

private float GDPPart;

int GDPPlace;
private int GDPPlace;
/**
* Summ for country in pounds
*/
float goldIncome;
ArrayList<Province> provinces = new ArrayList<>();
private float goldIncome;
private String tag;

@NonSerializable //temporary variable
private Map<Product, Float> intermediate = new HashMap<>();

public void add(Country that) {
Expand Down Expand Up @@ -125,12 +127,17 @@ public long getPopulation() {
return population;
}

public float getUnemploymentRate() {
long totalWorkforce = workforceRGO + workforceFactory;
return (float) totalWorkforce * 4 / population * 100;
}

public float getUnemploymentRateRgo() {
return (float) ((workforceRGO - employmentRGO) * 4. / population * 100);
}

public float getUnemploymentRateFactory() {
return (workforceFactory - employmentFactory) * 4 / (float) population * 100;
return (workforceFactory - employmentFactory) / (float) workforceFactory * 100;
}

public long getWorkforceRgo() {
Expand Down Expand Up @@ -201,4 +208,23 @@ public Map<String, ProductStorage> getStorage() {
return storageMap;
}

public void setGDPPlace(int GDPPlace) {
this.GDPPlace = GDPPlace;
}

public void addPopulation(int value) {
population += value;
}

public void addEmploymentRgo(int value) {
employmentRGO += value;
}

public void addEmploymentFactory(int value) {
employmentFactory += value;
}

public void addGoldIncome(float value) {
goldIncome += value;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.victoria2.tools.vic2sgea.main;
package org.victoria2.tools.vic2sgea.entities;

/**
* By Anton Krylov (anthony.kryloff@gmail.com)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.victoria2.tools.vic2sgea.entities;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Created by anth on 12.02.2017.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface NonSerializable {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.victoria2.tools.vic2sgea.main;
package org.victoria2.tools.vic2sgea.entities;

import javafx.scene.paint.Color;

Expand Down Expand Up @@ -41,14 +41,14 @@ public class Product implements Comparable<Product> {
*/
public float actualSupply;
/**
* global, in pieces, how much was thrown to global market
* How much was thrown to the world market
*/
public float worldmarketPool;
float worldmarketPool;
/**
* global, in pieces
* How much was sold on the world market
*/
public float actualSoldWorld;
String name = "";
float actualSoldWorld;
final String name;

private Color color;

Expand All @@ -70,11 +70,7 @@ public float getPrice() {
}

public float getConsumption() {
if (supply >= consumption && consumption <= demand)
return Math.min(supply, demand);
else
return consumption;

return consumption;
}

public float getSupply() {
Expand Down Expand Up @@ -129,6 +125,10 @@ public void setConsumption(float consumption) {
this.consumption = consumption;
}

public void incConsumption(float value) {
consumption += value;
}

public void setSupply(float supply) {
this.supply = supply;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.victoria2.tools.vic2sgea.main;
package org.victoria2.tools.vic2sgea.entities;

public class ProductStorage extends EconomySubject {
public ProductStorage(Product igood) {
ProductStorage(Product igood) {
product = igood;
}

Expand Down Expand Up @@ -53,6 +53,7 @@ public double getGdpPounds() {

public void innerCalculations() {
// calculating actual supply
//todo handle common market
float thrownToMarket = (totalSupply - soldDomestic);
if (thrownToMarket <= 0)
sold = totalSupply;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.victoria2.tools.vic2sgea.main;
package org.victoria2.tools.vic2sgea.entities;

public class Province {
private int id;
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/org/victoria2/tools/vic2sgea/gui/BaseController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package org.victoria2.tools.vic2sgea.gui;

import javafx.application.Platform;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TextArea;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.util.StringConverter;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.function.Function;

/**
Expand All @@ -29,4 +37,41 @@ protected static <T, S> void setFactory(TableColumn<T, S> column, Function<? sup
protected static <T, S> void setCellFactory(TableColumn<T, S> column, StringConverter<S> converter) {
column.setCellFactory(TextFieldTableCell.forTableColumn(converter));
}

protected static void errorAlert(Throwable e, String text) {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setContentText(text);

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String exceptionText = sw.toString();

Label label = new Label("The exception stacktrace was:");

TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);

textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);

GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);

// Set expandable Exception into the dialog pane.
alert.getDialogPane().setExpandableContent(expContent);

alert.show();
});
}

public void exit() {
Platform.exit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import javafx.scene.chart.PieChart;
import javafx.scene.paint.Color;
import org.victoria2.tools.vic2sgea.main.*;
import org.victoria2.tools.vic2sgea.entities.Country;
import org.victoria2.tools.vic2sgea.entities.EconomySubject;
import org.victoria2.tools.vic2sgea.entities.Product;
import org.victoria2.tools.vic2sgea.entities.ProductStorage;
import org.victoria2.tools.vic2sgea.main.Report;

import java.util.List;
import java.util.Map;
Expand Down

0 comments on commit 6a67b6b

Please sign in to comment.