Skip to content

Commit

Permalink
Fixed bug were map lane selection wasnt working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCobeti committed Aug 17, 2020
1 parent 6d3b531 commit aff5494
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mapNetconvert.net.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 08/17/20 16:56:58 by Eclipse SUMO netconvert Version 1.2.0
<!-- generated on 08/17/20 23:11:23 by Eclipse SUMO netconvert Version 1.2.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<input>
Expand Down
2 changes: 2 additions & 0 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/view/Settings.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/constants/Errors.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/exceptions/NoRouteConnectionException.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/warnings/NoNamedDistrictsWarning.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/view/mapsimulation/TAZFrame.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/routes/TAZ.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/topology/Edge.java</file>
Expand All @@ -27,6 +28,7 @@
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/MogenModel.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/Config.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/topology/Lane.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/model/warnings/Warning.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/view/mapsimulation/ZoomableScrollPane.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/control/MapConverter.java</file>
<file>file:/C:/Users/darkm/Documents/proyectos/Mogen/src/delete/Connection.java</file>
Expand Down
12 changes: 8 additions & 4 deletions src/control/MogenControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ public HashMap removeTAZ(String[] tazId) {
return model.getTazs();
}

public HashMap importOD(String path) throws FileNotFoundException, NoODFileFormatFoundException{
public HashMap importOD(String path) throws FileNotFoundException,
NoODFileFormatFoundException{
File file = new File(path);
HashMap<String, ODElement> map = new HashMap();

Expand All @@ -552,7 +553,7 @@ public HashMap importOD(String path) throws FileNotFoundException, NoODFileForma

while (scanner.hasNextLine()){
String data = scanner.nextLine();
// if its a coment continue and ignore it
// if its a comment continue and ignore it
if(data.startsWith("*"))continue;
if(data.startsWith(Format.OType.toString())){
format = Format.OType;
Expand All @@ -564,24 +565,26 @@ public HashMap importOD(String path) throws FileNotFoundException, NoODFileForma
}
}
switch(format){
// we scan the file differently deppending on the format
case None:
throw new NoODFileFormatFoundException(Errors.INCORRECT_MATRIX_FORMAT);
case OType:
while (scanner.hasNextLine()){
// get the line based on regular expresion
scanner.nextLine();

String result = scanner.findInLine(patternStringO);

if(result != null){
// Split the line to get the individual elements
String[] elements = result.trim().split("\\s+");

if(elements.length == 3){
// unique ID for the hash map
String uniqueID = UUID.randomUUID().toString();

ODElement ODelement = new ODElement(elements[0],
elements[1], Double.parseDouble(elements[2]));

System.out.println(ODelement.toFile());
map.put(uniqueID, ODelement);
}
}
Expand All @@ -593,6 +596,7 @@ public HashMap importOD(String path) throws FileNotFoundException, NoODFileForma
HashSet<String> notFoundTAZ = new HashSet();
Set <String> namedTAZ = model.getTazs().keySet();

// we search if any of the destinations or origins are definied in the model
map.values().forEach(element -> {
if(!namedTAZ.contains(element.getOrigin()) &&
!notFoundTAZ.contains(element.getOrigin()))
Expand Down
14 changes: 8 additions & 6 deletions src/view/MogenView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ private void addFlowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN
}
}
flowFrame = new FlowFrame(this, mapVisual, vehicleTypes);
mapVisual.addMouseHandler(false, flowFrame, MouseEvent.MOUSE_CLICKED);
mapVisual.addMouseHandler(false, flowFrame);
flowFrame.setVisible(true);

}//GEN-LAST:event_addFlowButtonActionPerformed
Expand Down Expand Up @@ -1037,14 +1037,16 @@ private void TAZAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
mapVisual = new MapPanel(currentMap);
} catch (XMLStreamException | IOException ex) {
error(MAP_ERROR);
return;
} catch (NullPointerException ex){
error(NO_MAP);
return;
}
}else{
TazFrame = new TAZFrame(this, mapVisual);
mapVisual.addMouseHandler(false, TazFrame, MouseEvent.MOUSE_CLICKED);
TazFrame.setVisible(true);
}
TazFrame = new TAZFrame(this, mapVisual);
mapVisual.addMouseHandler(false, TazFrame);
TazFrame.setVisible(true);


}//GEN-LAST:event_TAZAddButtonActionPerformed

Expand Down Expand Up @@ -1500,7 +1502,7 @@ public void editElement(TableTypes type){
Integer.valueOf(flowTable.getModel().getValueAt(selectedRow, 5).toString()),
this, mapVisual, vehicleTypes);

mapVisual.addMouseHandler(false, flowFrame, MouseEvent.MOUSE_CLICKED);
mapVisual.addMouseHandler(false, flowFrame);
flowFrame.setVisible(true);

}
Expand Down
7 changes: 3 additions & 4 deletions src/view/mapsimulation/MapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,19 @@ public void mouseDragged(java.awt.event.MouseEvent e) {
});*/
}

public void addMouseHandler(boolean rectangleSelection, MapMouseEvent handler,
EventType event){
public void addMouseHandler(boolean rectangleSelection, MapMouseEvent handler){
Platform.runLater(() -> {
group.getChildren().clear();

lanes.forEach((lane) -> {
if (!lane.isInternal()){
lane.getPolyline().setOnMousePressed(null);
lane.getPolyline().setOnMouseClicked(null);
EventHandler<MouseEvent> eventHandler = (MouseEvent e) -> {
handler.addFunctionToLanes(lane, e);
};

//Adding event Filter
lane.getPolyline().addEventFilter(event, eventHandler);
lane.getPolyline().setOnMouseClicked(eventHandler);
group.getChildren().add(lane.getPolyline());
}else {
lane.getPolyline().setStroke(Paint.valueOf(MapMouseEvent.INTERNAL_LANE_COLOR));
Expand Down

0 comments on commit aff5494

Please sign in to comment.