Skip to content

Commit

Permalink
#11 Import multiple tables from one image file.
Browse files Browse the repository at this point in the history
  • Loading branch information
caalador committed May 12, 2017
1 parent 9038711 commit a6467b7
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 96 deletions.
2 changes: 1 addition & 1 deletion SeatingMap-addon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>SeatingMap</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<name>Seating map add-on for showing where people are seated at the office</name>
<name>Seating map</name>

<prerequisites>
<maven>3</maven>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void setVisibleFloor(int floor) {

@Override
public void itemClick(String roomId, String tableId) {
System.out.println("Got item selection!");
Room clickedRoom = floors.get(visibleFloor).getRoomById(roomId);
Table clickedTable = clickedRoom.getTableById(tableId);

Expand All @@ -75,16 +74,54 @@ public void itemClick(String roomId, String tableId) {
});
}

/**
* Add a room to the map for given floor from lines.
*
* @param floor
* floor to add room to
* @param lines
* lines of room
* @return created room object
*/
public Room addRoom(int floor, List<Line> lines) {
FloorMap map = getFloor(floor);
return map.addRoom(lines);
}

/**
* Add room for given floor to map.
*
* @param floor
* floor to add room to
* @param room
* room to add
*/
public void addRoom(int floor, Room room) {
FloorMap map = getFloor(floor);
map.addComponent(room);
}

/**
* Add lines to map. These will be drawn, but won't have any special
* functionality.
*
* @param floor
* floor to add lines to
* @param lines
* lines to add
*/
public void addLines(int floor, List<Line> lines) {
FloorMap map = getFloor(floor);
map.addLines(lines);
}

/**
* Add listener to be notified of click selection for room and table in map.
*
* @param listener
* selection listener
* @return handler to remove listener with
*/
public RemoveHandler addSelectionListener(SelectionListener listener) {
selectionEvents.add(listener);
return () -> selectionEvents.remove(listener);
Expand All @@ -101,32 +138,6 @@ public void setAutoToggleTableName(boolean autoToggleName) {
this.autoToggleName = autoToggleName;
}

/**
* Returns first match for name
*
* @param name
* Name to search for
* @return First match or null
*/
private SearchResult getSingleByName(String name) {
SearchResult result = new SearchResult();
for (FloorMap floor : floors.values()) {
for (Room room : floor.getRooms()) {
for (Table table : room.getTables()) {
if (table.getName().toLowerCase()
.contains(name.toLowerCase())) {
result.setFloor(floor);
result.setRoom(room);
result.setTable(table);
return result;
}
}
}
}

return null;
}

/**
* Get the first match for name
*
Expand Down Expand Up @@ -327,4 +338,30 @@ private FloorMap getFloor(int floor) {
}
return map;
}

/**
* Returns first match for name
*
* @param name
* Name to search for
* @return First match or null
*/
private SearchResult getSingleByName(String name) {
SearchResult result = new SearchResult();
for (FloorMap floor : floors.values()) {
for (Room room : floor.getRooms()) {
for (Table table : room.getTables()) {
if (table.getName().toLowerCase()
.contains(name.toLowerCase())) {
result.setFloor(floor);
result.setRoom(room);
result.setTable(table);
return result;
}
}
}
}

return null;
}
}
Loading

0 comments on commit a6467b7

Please sign in to comment.