Skip to content

Commit

Permalink
labels for mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
fbielejec committed May 27, 2015
1 parent 21cdfcf commit a1fc8a0
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 16 deletions.
6 changes: 2 additions & 4 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ h4. LINES
# map line colors to duration attribute values, use supplied color sheet (RGB or RGBA values). Duration attribute applies to a whole branch and colors are not interpolated to reflect that:
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping duration -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -output test.kml

-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -output test.kml

# specify alpha channel for lines, this option overwrites all previous settings, including those in color sheet:
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealpha 150 -output test.kml

Expand All @@ -79,10 +77,10 @@ h4. LINES
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealphamapping host -linewidthmapping duration -output test.kml

# override default line altitude settings:
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealphamapping host -linewidth 2 -linealtitude 5000 -output test.kml
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealphamapping host -linewidth 2 -linealtitude 50000 -output test.kml

# map lines altitude to distance attribute values. Altitude can only be mapped to attributes which apply to a whole branch.
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealphamapping host -linewidth 2 -linealtitudemapping distance -output test.kml
-render -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -linecolormapping host -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -linealphamapping host -linewidthmapping duration -linealtitudemapping distance -output test.kml


h3. DISCRETE TREE
Expand Down
3 changes: 3 additions & 0 deletions data/3colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Gal 255 0 0
Ans 255 128 0
Neo 255 255 0
3 changes: 3 additions & 0 deletions data/3colors2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Gal 0 255 100 100
Ans 0 128 255 100
Neo 0 0 255 100
25 changes: 25 additions & 0 deletions src/exceptions/MissingAttributeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package exceptions;

@SuppressWarnings("serial")
public class MissingAttributeException extends Exception {

public static final String LINE = "line";
public static final String POLYGON = "polygon";

private String attributeName;
private String name;

public MissingAttributeException(String attributeName, String name) {

this.attributeName = attributeName;
this.name = name;

}//END: Constructor

@Override
public String getMessage() {
String message = "Attribute " + attributeName + " missing from " + name +" attributes";
return message;
}

}//END: class
21 changes: 13 additions & 8 deletions src/renderers/KmlRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ private Feature generateLine(
}

Object startKey = startTrait.isNumber() ? startTrait.getValue()[0] : (String) startTrait.getId();

if (lineColorMap.containsKey(startKey)) {

// read the supplied color map, or re-use already mapped values
Expand Down Expand Up @@ -283,7 +282,6 @@ private Feature generateLine(
}

Object endKey = endTrait.isNumber() ? endTrait.getValue()[0] : (String) endTrait.getId();

if (lineColorMap.containsKey(endKey)) {

endColor = lineColorMap.get(endKey);
Expand All @@ -304,7 +302,7 @@ private Feature generateLine(

}// END: endkey check

label += (", "+settings.lineColorMapping + "="+startKey.toString().concat(" to ").concat(endKey.toString()));
label += ( "color[" + settings.lineColorMapping + "=" + startKey.toString() + " to " + endKey.toString() +"]" );

} else { // use defaults or user defined color

Expand Down Expand Up @@ -336,7 +334,6 @@ private Feature generateLine(
}

Object startKey = startTrait.isNumber() ? startTrait.getValue()[0] : (String) startTrait.getId();

if (lineAlphaMap.containsKey(startKey)) {

startAlpha = lineAlphaMap.get(startKey);
Expand All @@ -361,7 +358,6 @@ private Feature generateLine(
}

Object endKey = endTrait.isNumber() ? endTrait.getValue()[0] : (String) endTrait.getId();

if (lineAlphaMap.containsKey(endKey)) {

endAlpha = lineAlphaMap.get(endKey);
Expand All @@ -375,7 +371,12 @@ private Feature generateLine(

}// END: endkey check

label += (", "+settings.lineAlphaMapping + "="+startKey.toString().concat(" to ").concat(endKey.toString()));
label += (", alpha[" + settings.lineAlphaMapping + "=" + startKey.toString() + " to " + endKey.toString() + "]");

} else { // use defaults

startAlpha = (int) settings.lineAlpha;
endAlpha = startAlpha;

} // END: settings check

Expand Down Expand Up @@ -416,6 +417,8 @@ private Feature generateLine(

}// END: key check

label += (", altitude[" + settings.lineAltitudeMapping + "=" + key.toString() +"]");

} else { // use defaults or user defined color

altitude = settings.lineAltitude;
Expand Down Expand Up @@ -450,6 +453,8 @@ private Feature generateLine(

}// END: key check

label += (", width[" + settings.lineWidthMapping + "=" + key.toString() +"]");

} else { // use defaults or user defined color

width = settings.lineWidth;
Expand Down Expand Up @@ -631,7 +636,7 @@ private Feature generatePolygons(List<Polygon> polygons) throws IOException, Mis

}// END: key check

label = settings.polygonColorMapping + "=" + key.toString();
label = "color[" + settings.polygonColorMapping + "=" + key.toString() +"]";

} else {// use defaults or user defined color

Expand Down Expand Up @@ -665,7 +670,7 @@ private Feature generatePolygons(List<Polygon> polygons) throws IOException, Mis

}// END: key check

label += (", "+settings.polygonAlphaMapping + "="+key.toString());
label += (", alpha[" + settings.polygonAlphaMapping + "="+key.toString()+"]");

} // END: settings check

Expand Down
8 changes: 4 additions & 4 deletions src/settings/KmlRendererSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class KmlRendererSettings {

// For continuous attributes
public String lineAlphaMapping;
public Double minLineAlpha = 50.0; public Double maxLineAlpha = 100.0;
public Double minLineAlpha = 100.0; public Double maxLineAlpha = 150.0;

// Fixed
public double lineAlpha = 100;
public double lineAlpha = 255;
public boolean lineAlphaChanged = false;


Expand All @@ -47,7 +47,7 @@ public class KmlRendererSettings {

// For continuous attributes
public String lineAltitudeMapping = null;
public Double minLineAltitude = 500.0; public Double maxLineAltitude = 500000.0;
public Double minLineAltitude = 50000.0; public Double maxLineAltitude = 500000.0;

// Fixed
public Double lineAltitude = 500000.0;
Expand All @@ -56,7 +56,7 @@ public class KmlRendererSettings {

// For continuous attributes
public String lineWidthMapping = null;
public Double minLineWidth = 1.0; public Double maxLineWidth = 10.0;
public Double minLineWidth = 2.0; public Double maxLineWidth = 10.0;

// Fixed
public Double lineWidth = 2.0;
Expand Down

0 comments on commit a1fc8a0

Please sign in to comment.