Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Stylesheets #465

Merged
merged 18 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[submodule "core/src/main/assets/styles/bubble-wrap"]
path = core/src/main/assets/styles/bubble-wrap
url = https://github.com/tangrams/bubble-wrap.git
[submodule "core/src/main/assets/styles/cinnabar-more-labels"]
path = core/src/main/assets/styles/cinnabar-more-labels
url = https://github.com/tangrams/cinnabar-style-more-labels.git
[submodule "core/src/main/assets/styles/walkabout-style-more-labels"]
path = core/src/main/assets/styles/walkabout-style-more-labels
url = https://github.com/tangrams/walkabout-style-more-labels.git
[submodule "core/src/main/assets/styles/zinc-style-more-labels"]
path = core/src/main/assets/styles/zinc-style-more-labels
url = https://github.com/tangrams/zinc-style-more-labels.git
[submodule "samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style"]
path = samples/mapzen-android-sdk-sample/src/main/assets/styles/tron-style
url = https://github.com/tangrams/tron-style.git
[submodule "core/src/main/assets/styles/refill-style"]
path = core/src/main/assets/styles/refill-style
url = https://github.com/tangrams/refill-style
[submodule "core/src/main/assets/styles/cinnabar-style"]
path = core/src/main/assets/styles/cinnabar-style
url = [email protected]:tangrams/cinnabar-style.git
[submodule "core/src/main/assets/styles/walkabout-style"]
path = core/src/main/assets/styles/walkabout-style
url = [email protected]:tangrams/walkabout-style.git
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ task checkstyle(type: Checkstyle) {
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

task submodules {
def folder = new File( 'core/src/main/assets/styles/walkabout-style-more-labels/walkabout-style-more-labels.yaml' )
def folder = new File( 'core/src/main/assets/styles/walkabout-style/walkabout-style.yaml' )
if(!folder.exists()) {
throw new GradleException("Submodules aren't present, please run:\n`git submodule init`, " +
"\n`git submodule update`\nfrom your root directory")
Expand Down
1 change: 0 additions & 1 deletion core/src/main/assets/styles/cinnabar-more-labels
Submodule cinnabar-more-labels deleted from 4b1ba0
1 change: 1 addition & 0 deletions core/src/main/assets/styles/cinnabar-style
Submodule cinnabar-style added at 079418
1 change: 1 addition & 0 deletions core/src/main/assets/styles/walkabout-style
Submodule walkabout-style added at 291d90
1 change: 0 additions & 1 deletion core/src/main/assets/styles/walkabout-style-more-labels
Submodule walkabout-style-more-labels deleted from 66bbe1
1 change: 0 additions & 1 deletion core/src/main/assets/styles/zinc-style-more-labels
Submodule zinc-style-more-labels deleted from ab5203
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.mapzen.android.graphics.model.ThemeColor;
import com.mapzen.android.graphics.model.ThemedMapStyle;

import android.util.Log;

import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;

/**
* Handles creating fully qualified import yaml for a given {@link ThemedMapStyle} so that
* it can be applied by {@link MapzenMap}.
Expand All @@ -17,26 +21,42 @@ class ImportYamlGenerator {
*/
String getImportYaml(ThemedMapStyle themedMapStyle, int labelLevel, int detailLevel,
ThemeColor color) {
String labelFileName = new StringBuilder()
.append("label-")
.append(labelLevel)
.append(".yaml")
.toString();
String detailFileName = new StringBuilder()
.append("detail-")
.append(detailLevel)
.append(".yaml")
.toString();
String colorFileName = new StringBuilder()
.append("color-")
.append(color.toString())
.append(".yaml")
.toString();
return "{ import: [ "
+ themedMapStyle.getBaseStyleFilename() + ", "
+ themedMapStyle.getThemesPath() + labelFileName + ", "
+ themedMapStyle.getThemesPath() + detailFileName + ", "
+ themedMapStyle.getThemesPath() + colorFileName
+ " ] }";
StringBuilder importBuilder = new StringBuilder()
.append("{ import: [ ")
.append(themedMapStyle.getBaseStyleFilename())
.append(", ");

if (labelLevel != NONE) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("label-");
importBuilder.append(labelLevel);
importBuilder.append(".yaml");
}

if (labelLevel != NONE && (detailLevel != NONE || color != null)) {
importBuilder.append(", ");
}

if (detailLevel != NONE) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("detail-");
importBuilder.append(detailLevel);
importBuilder.append(".yaml");
}

if (detailLevel != NONE && color != null) {
importBuilder.append(", ");
}

if (color != null) {
importBuilder.append(themedMapStyle.getThemesPath());
importBuilder.append("color-");
importBuilder.append(color.toString());
importBuilder.append(".yaml");
}

importBuilder.append(" ] }");
Log.d("sarah", "IMPORT STR: " + importBuilder.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello sarah :D

I guess put for debugging purposes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Removed

return importBuilder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ private void loadMap(final MapView mapView, MapStyle mapStyle, boolean styleExpl
mapStyle = restoredMapStyle;
}
mapStateManager.setMapStyle(mapStyle);
if (mapStyle instanceof ThemedMapStyle) {
ThemedMapStyle themedStyle = (ThemedMapStyle) mapStyle;
mapStateManager.setLabelLevel(themedStyle.getDefaultLabelLevel());
mapStateManager.setLod(themedStyle.getDefaultLod());
mapStateManager.setThemeColor(themedStyle.getDefaultColor());
}
loadMap(mapView, mapStyle, callback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.mapzen.android.graphics.model.ThemeColor;
import com.mapzen.tangram.LngLat;

import static com.mapzen.android.graphics.model.ThemedMapStyle.NONE;

/**
* Manages parameters around {@link MapzenMap}'s state so that it can be restore upon orientation
* change.
Expand All @@ -15,8 +17,8 @@ class MapStateManager {
private boolean persistMapState = true;
private LngLat position = new LngLat(0, 0);
private MapStyle mapStyle = new BubbleWrapStyle();
private int labelLevel = 0;
private int lod = 0;
private int labelLevel = NONE;
private int lod = NONE;
private ThemeColor themeColor = null;
private float zoom = 0;
private float rotation = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
package com.mapzen.android.graphics.model;

import java.util.Set;

/**
* BubbleWrap default map style.
*/
public class BubbleWrapStyle extends MapStyle {
public class BubbleWrapStyle extends ThemedMapStyle {

/**
* Creates a new instance.
*/
public BubbleWrapStyle() {
super("styles/bubble-wrap/bubble-wrap-style-more-labels.yaml");
super("styles/bubble-wrap/bubble-wrap-style.yaml");
}

@Override public String getBaseStyleFilename() {
return "bubble-wrap-style.yaml";
}

@Override public String getStyleRootPath() {
return "styles/bubble-wrap/";
}

@Override public String getThemesPath() {
return "themes/";
}

@Override public int getDefaultLod() {
return NONE;
}

@Override public int getLodCount() {
return NONE;
}

@Override public int getDefaultLabelLevel() {
return 5;
}

@Override public int getLabelCount() {
return 12;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 11 or 12?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its zero indexed and there are 12 label levels for bubble wrap: https://mapzen.com/documentation/cartography/themes/#bubble-wrap

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops :D

}

@Override public ThemeColor getDefaultColor() {
return null;
}

@Override public Set<ThemeColor> getColors() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
package com.mapzen.android.graphics.model;

import java.util.HashSet;
import java.util.Set;

import static com.mapzen.android.graphics.model.ThemeColor.CINNABAR;

/**
* Cinnabar default map style.
*/
public class CinnabarStyle extends MapStyle {
public class CinnabarStyle extends ThemedMapStyle {

private final Set<ThemeColor> supportedColors = new HashSet<ThemeColor>() { {
add(CINNABAR);
} };

/**
* Creates a new instance.
*/
public CinnabarStyle() {
super("styles/cinnabar-more-labels/cinnabar-style-more-labels.yaml");
super("styles/cinnabar-style/cinnabar-style.yaml");
}

@Override public String getBaseStyleFilename() {
return "cinnabar-style.yaml";
}

@Override public String getStyleRootPath() {
return "styles/cinnabar-style/";
}

@Override public String getThemesPath() {
return "themes/";
}

@Override public int getDefaultLod() {
return NONE;
}

@Override public int getLodCount() {
return NONE;
}

@Override public int getDefaultLabelLevel() {
return 5;
}

@Override public int getLabelCount() {
return 12;
}

@Override public ThemeColor getDefaultColor() {
return CINNABAR;
}

@Override public Set<ThemeColor> getColors() {
return supportedColors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.mapzen.android.graphics.model.ThemeColor.PINKYELLOW;
import static com.mapzen.android.graphics.model.ThemeColor.PURPLEGREEN;
import static com.mapzen.android.graphics.model.ThemeColor.SEPIA;
import static com.mapzen.android.graphics.model.ThemeColor.ZINC;

/**
* Refill default map style.
Expand All @@ -36,6 +37,7 @@ public class RefillStyle extends ThemedMapStyle {
add(PINKYELLOW);
add(PURPLEGREEN);
add(SEPIA);
add(ZINC);
} };

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public enum ThemeColor {
PINK("pink"),
PINKYELLOW("pink-yellow"),
PURPLEGREEN("purple-green"),
SEPIA("sepia");
SEPIA("sepia"),
CINNABAR("cinnabar"),
ZINC("zinc");

private final String color;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public abstract class ThemedMapStyle extends MapStyle {

public static final int NONE = -1;

/**
* Constructor.
* @param baseSceneFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
package com.mapzen.android.graphics.model;

import java.util.Set;

/**
* Walkabout outdoor map style.
*/
public class WalkaboutStyle extends MapStyle {
public class WalkaboutStyle extends ThemedMapStyle {

/**
* Creates a new instance.
*/
public WalkaboutStyle() {
super("styles/walkabout-style-more-labels/walkabout-style-more-labels.yaml");
}

@Override public String getBaseStyleFilename() {
return "walkabout-style.yaml";
}

@Override public String getStyleRootPath() {
return "styles/walkabout-style/";
}

@Override public String getThemesPath() {
return "themes/";
}

@Override public int getDefaultLod() {
return NONE;
}

@Override public int getLodCount() {
return NONE;
}

@Override public int getDefaultLabelLevel() {
return 5;
}

@Override public int getLabelCount() {
return 12;
}

@Override public ThemeColor getDefaultColor() {
return null;
}

@Override public Set<ThemeColor> getColors() {
return null;
}
}
Loading