Skip to content

Commit

Permalink
Merge pull request #3 from DenisCobeti/develop
Browse files Browse the repository at this point in the history
Added emission config function in vehicle types and changed icons
  • Loading branch information
DenisCobeti committed Sep 9, 2020
2 parents 39cde56 + 2189d9c commit ab680a5
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 72 deletions.
Binary file modified resources/button/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/editFollow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/export2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/button/settings - copia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/button/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/control/MapConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;

import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory;
Expand All @@ -26,6 +28,7 @@
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;

import model.map.MapAPI.APIS;
import model.constants.FilesExtension;
import model.constants.Netconvert;
Expand Down
7 changes: 3 additions & 4 deletions src/control/MogenControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.Scanner;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -63,8 +61,6 @@
*/
public class MogenControl implements ViewListener{

//private static final Logger logger = Logger.getLogger(GeoMap.class.getName());

private final MogenModel model;
private final MogenView view;

Expand All @@ -77,6 +73,7 @@ public class MogenControl implements ViewListener{
private static final String VEHICLE_SPEED_XML = "maxSpeed";
private static final String VEHICLE_FOLLOW_XML = "carFollowModel";
private static final String VEHICLE_PROB_XML = "probability";
private static final String VEHICLE_EMISSION_XML = "emissionClass";


public static final String DEFAULT_MAP_NAME = "mapNetconvert";
Expand Down Expand Up @@ -599,6 +596,8 @@ public void importVehicles(File vehicles) throws FileNotFoundException,
case VEHICLE_PROB_XML:
vehicle.setProbability(Double.valueOf(attribute.getValue()));
break;
case VEHICLE_EMISSION_XML:
vehicle.setEmission(attribute.getValue());
}
}
model.addElement(idVehicle, vehicle);
Expand Down
9 changes: 0 additions & 9 deletions src/control/Simulation.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package control;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import delete.Connection;
import model.topology.Edge;
import model.topology.Junction;
import model.topology.Lane;

/**
Expand Down
1 change: 1 addition & 0 deletions src/model/routes/TAZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.LinkedList;
import java.util.List;

import model.topology.Lane;

/**
Expand Down
83 changes: 81 additions & 2 deletions src/model/routes/VType.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,51 @@ public class VType {

private static final String FILE_FORMAT_PROB = "<vType id=\"%s\" accel=\"%.2f\""
+ " decel=\"%.2f\" tau=\"%.1f\" length=\"%d\" maxSpeed=\"%d\" %s "
+ "probability=\"%.2f\" />";
+ "probability=\"%.2f\" emissionClass=\"%s\" />";


public static final String DISTRIBUTION = "dist";

public static enum EmissionType{

HEAVY_DIESEL("HBEFA3/HDV_D_EU4", "Heavy diesel"),
HEAVY_GASOLINE("HBEFA3/HDV_G", "Heavy gasoline"),

LIGHT_DIESEL("HBEFA3/LDV_D_EU4", "Light diesel"),
LIGHT_GASOLINE("HBEFA3/LDV_G_EU4", "Light gasoline"),

PASSANGER_DIESEL("HBEFA3/PC_D_EU4", "Passanger diesel"),
PASSANGER_GASOLINE("HBEFA3/PC_G_EU4", "Passanger gasoline"),

ELECTRIC("Energy", "Electric"),
ZERO("Zero", "Zero emissions");

private final String value;
private final String description;

EmissionType(String value, String description){
this.value = value;
this.description = description;
}

public String getValue() { return value; }
public String getDescription() { return description; }

public static EmissionType fromString(String value) {
for (EmissionType type : EmissionType.values()) {
if (type.getValue().equals(value)) {
return type;
}
}
return ZERO;
}

@Override
public String toString() {
return description;
}

}
private boolean enabled = true;

private double accel;
Expand All @@ -34,6 +75,7 @@ public class VType {
private double probability;

private FollowingModel model;
private EmissionType emission;

private static final double DEFAULT_ACCEL = 3;
private static final double DEFAULT_DECEL = 5;
Expand All @@ -56,6 +98,7 @@ public VType() {
this.probability = DEFAULT_PROBABILITY;

this.model = new Krauss();
this.emission = EmissionType.LIGHT_GASOLINE;
}

public VType(String id, double accel, double decel, double tau,
Expand All @@ -65,6 +108,9 @@ public VType(String id, double accel, double decel, double tau,
this.tau = tau;
this.length = length;
this.maxSpeed = maxSpeed;

this.model = new Krauss();
this.emission = EmissionType.LIGHT_GASOLINE;
}

public VType(String id, double accel, double decel, double tau,
Expand All @@ -75,6 +121,20 @@ public VType(String id, double accel, double decel, double tau,
this.length = length;
this.maxSpeed = maxSpeed;
this.model = model;

this.emission = EmissionType.LIGHT_GASOLINE;
}

public VType(String id, double accel, double decel, double tau,
int length, int maxSpeed, FollowingModel model,
EmissionType emission) {
this.accel = accel;
this.decel = decel;
this.tau = tau;
this.length = length;
this.maxSpeed = maxSpeed;
this.model = model;
this.emission = emission;
}

public void setAccel(double accel) { this.accel = accel; }
Expand All @@ -85,6 +145,13 @@ public VType(String id, double accel, double decel, double tau,
public void setModel(FollowingModel model) { this.model = model; }
public void setEnabled(boolean enabled) { this.enabled = enabled; }
public void setProbability(double probability) { this.probability = probability; }
public void setEmission(EmissionType emission) { this.emission = emission; }

public void setEmission(String emission) {
this.setEmission(EmissionType.fromString(emission));
}



public double getAccel() { return accel; }
public double getDecel() { return decel; }
Expand All @@ -93,6 +160,7 @@ public VType(String id, double accel, double decel, double tau,
public int getMaxSpeed() { return maxSpeed; }
public double getProbability() { return probability; }

public EmissionType getEmission() { return emission; }
public FollowingModel getModel() { return model; }
public boolean isEnabled() { return enabled; }

Expand All @@ -103,13 +171,24 @@ public void assignFollowingModel(String modelName, Iterator<Attribute> attribute
this.setModel(model);
}
/*
public EmissionType getType(String type){
switch(type){
case EmissionType.ELECTRIC.getValue():
return EmissionType.ELECTRIC;
break;
}
}*/
/*
public String toFile(String id) {
return String.format(FILE_FORMAT, id, accel, decel, tau, length,
maxSpeed, model.toSimulation());
}*/
public String toFile(String id) {
return String.format(FILE_FORMAT_PROB, id, accel, decel, tau, length,
maxSpeed, model.toSimulation(), probability);
maxSpeed, model.toSimulation(), probability,
emission.getValue());
}

}
68 changes: 55 additions & 13 deletions src/view/mapelements/VehicleTypePanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,29 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="emissionLabel" pref="0" max="32767" attributes="0"/>
<Component id="decelLabel" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="speedLabel" min="-2" pref="64" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="speedField" pref="45" max="32767" attributes="0"/>
<Component id="decelField" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="accelLabel" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="lengthLabel" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="accelField" pref="45" max="32767" attributes="0"/>
<Component id="lengthField" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="speedField" pref="45" max="32767" attributes="0"/>
<Component id="decelField" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="accelLabel" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="lengthLabel" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace min="18" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="accelField" pref="45" max="32767" attributes="0"/>
<Component id="lengthField" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="emissionBox" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand Down Expand Up @@ -274,7 +280,12 @@
<Component id="probabilityLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="probabilityField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="95" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="emissionBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="emissionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="64" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -454,6 +465,37 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="probabilityFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="emissionLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="view.getFont()" type="code"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="EMISSION" type="code"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="emissionBox">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="view.getFont()" type="code"/>
</Property>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="boxModel" type="code"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder/>
</Border>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="emissionBoxItemStateChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Loading

0 comments on commit ab680a5

Please sign in to comment.