forked from mit-cml/appinventor-sources
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Map and Navigation component enums (#16)
* Add Units def * Upgrade Map * Add MapType def * Upgrade Map to use MapType * Add TransportMethod def * Upgrade Navigation * Add map-related upgraders * Fix indent & rename Units to ScaleUnits
- Loading branch information
Showing
11 changed files
with
325 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
appinventor/components/src/com/google/appinventor/components/common/MapType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2020 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.components.common; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Defines a MapType type used by the Map component. | ||
*/ | ||
public enum MapType implements OptionList<Integer> { | ||
Road(1), | ||
Aerial(2), | ||
Terrain(3); | ||
|
||
private Integer value; | ||
|
||
MapType(Integer value) { | ||
this.value = value; | ||
} | ||
|
||
public Integer toUnderlyingValue() { | ||
return value; | ||
} | ||
|
||
private static final Map<Integer, MapType> lookup = new HashMap<>(); | ||
|
||
static { | ||
for(MapType type : MapType.values()) { | ||
lookup.put(type.toUnderlyingValue(), type); | ||
} | ||
} | ||
|
||
public static MapType fromUnderlyingValue(Integer type) { | ||
return lookup.get(type); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
appinventor/components/src/com/google/appinventor/components/common/ScaleUnits.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2020 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.components.common; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Defines a ScaleUnits type used by the Map component. | ||
*/ | ||
public enum ScaleUnits implements OptionList<Integer> { | ||
Metric(1), | ||
Imperial(2); | ||
|
||
private Integer value; | ||
|
||
ScaleUnits(Integer value) { | ||
this.value = value; | ||
} | ||
|
||
public Integer toUnderlyingValue() { | ||
return value; | ||
} | ||
|
||
private static final Map<Integer, ScaleUnits> lookup = new HashMap<>(); | ||
|
||
static { | ||
for(ScaleUnits unit : ScaleUnits.values()) { | ||
lookup.put(unit.toUnderlyingValue(), unit); | ||
} | ||
} | ||
|
||
public static ScaleUnits fromUnderlyingValue(Integer unit) { | ||
return lookup.get(unit); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
appinventor/components/src/com/google/appinventor/components/common/TransportMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2020 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.components.common; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Defines a TransportMethod type used by the Navigation component. | ||
*/ | ||
public enum TransportMethod implements OptionList<String> { | ||
Foot("foot-walking"), | ||
Car("driving-car"), | ||
Bicycle("cycling-regular"), | ||
Wheelchair("wheelchair"); | ||
|
||
private String value; | ||
|
||
TransportMethod(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String toUnderlyingValue() { | ||
return value; | ||
} | ||
|
||
private static final Map<String, TransportMethod> lookup = new HashMap<>(); | ||
|
||
static { | ||
for(TransportMethod method : TransportMethod.values()) { | ||
lookup.put(method.toUnderlyingValue(), method); | ||
} | ||
} | ||
|
||
public static TransportMethod fromUnderlyingValue(String method) { | ||
return lookup.get(method); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.