Skip to content

Commit

Permalink
consistency in mapping values
Browse files Browse the repository at this point in the history
  • Loading branch information
fbielejec committed Jul 3, 2015
1 parent d74ab63 commit 4e3611d
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 133 deletions.
9 changes: 6 additions & 3 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ h3. RENDERING
h4. POLYGONS

* override default polygon color settings:
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolor 0 0 255 -output test.kml
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolor 255 255 0 -output test.kml

* map polygon colors to host attribute values, use built-in color schemes
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -output test.kml
Expand All @@ -45,7 +45,7 @@ h4. POLYGONS
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -output test.kml

* specify alpha channel for polygons, this option overwrites all previous settings, including those in color sheet:
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -polygonalpha 255 -output test.kml
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors -polygonalpha 100 -output test.kml

* map alpha channel for polygons, this option overwrites all previous settings, including those in color sheet:
-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_host.json -polygoncolormapping host -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/3colors2 -polygonalphamapping modality -output test.kml
Expand Down Expand Up @@ -83,7 +83,7 @@ h4. LINES
-render kml -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 kml -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
-render kml -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 255 -linewidthmapping duration -linealtitudemapping distance -output test.kml


h3. DISCRETE TREE
Expand Down Expand Up @@ -240,7 +240,10 @@ h1. TODO
- D3 renderer
- GeoJSON renderer
- KML renderer
- node support threshold for polygons (parse posterior support and use polygon cutoffs [TODO] )
- Show node ages in the kml
- control arc curvature [0 - 1]
* Write tests
* Non-geographic locations (e.g. antigenic locations)
* parsing BEAST2 and MrBayes output
* Restrict visual summaries or rate statistics to a particular set of nodes, like a clade or a trunk/backbone
Expand Down
6 changes: 3 additions & 3 deletions data/3colors
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Gal 255 0 0
Ans 255 128 0
Neo 255 255 0
Gal 127 0 255
Ans 255 255 0
Neo 255 0 0
32 changes: 16 additions & 16 deletions src/data/structure/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
import java.util.LinkedHashMap;
import java.util.Map;

import exceptions.MissingAttributeException;
import utils.Trait;

public class Line {

// Traits which have start and end values go here:
private final Map<String, Trait> attributes = new LinkedHashMap<String, Trait>();

private final Coordinate startCoordinate;
private final Coordinate endCoordinate;

private final Location startLocation;
private final Location endLocation;
private final boolean connectsLocations;

private final String startTime;
private final String endTime;

public Line(Location startLocation, //
Location endLocation, //
String startTime, //
Expand All @@ -30,7 +31,7 @@ public Line(Location startLocation, //
this.startLocation = startLocation;
this.endLocation = endLocation;
this.connectsLocations = true;

this.startTime = startTime;
this.endTime = endTime;

Expand All @@ -40,19 +41,18 @@ public Line(Location startLocation, //
if (attributes != null) {
this.attributes.putAll(attributes);
}

}// END: Constructor


public Line(Location startLocation, //
Location endLocation, //
Map<String, Trait> nodeAttributes //
) {
Map<String, Trait> attributes //
) {

this.startLocation = startLocation;
this.endLocation = endLocation;
this.connectsLocations = true;

this.startTime = null;
this.endTime = null;

Expand All @@ -62,9 +62,9 @@ public Line(Location startLocation, //
if (attributes != null) {
this.attributes.putAll(attributes);
}

}

public Line(Coordinate startCoordinate, //
Coordinate endCoordinate, //
String startTime, //
Expand All @@ -80,7 +80,7 @@ public Line(Coordinate startCoordinate, //
this.startLocation = null;
this.endLocation = null;
this.connectsLocations = false;

if (attributes != null) {
this.attributes.putAll(attributes);
}
Expand Down Expand Up @@ -111,12 +111,12 @@ public Location getEndLocation() {
return endLocation;
}

public boolean connectsLocations(){
public boolean connectsLocations() {
return connectsLocations;
}

public Map<String, Trait> getAttributes() {
return attributes;
}

}// END: class
3 changes: 3 additions & 0 deletions src/parsers/BayesFactorLinesParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public LinkedList<Line> parseLines() throws LocationNotFoundException {
Trait distanceTrait = new Trait(distance);
attributes.put(Utils.DISTANCE, distanceTrait);


// Utils.printMap(attributes);

Line line = new Line(fromLocation, toLocation, attributes);
linesList.add(line);

Expand Down
5 changes: 3 additions & 2 deletions src/parsers/DiscretePolygonsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class DiscretePolygonsParser {

public static final String COUNT = "count";
public static final String LOCATION = "location";
// public static final String LOCATION = "location";

private RootedTree rootedTree;
private String locationTrait;
Expand Down Expand Up @@ -142,8 +142,9 @@ public LinkedList<Polygon> parseDiscretePolygons() throws LocationNotFoundExcep
}// END: traits loop
}// END: null check

// it's just easier to add them here as well, we avoid convoluted logic in renderers
Trait locationTrait = new Trait(location.getId());
attributes.put(LOCATION, locationTrait);
attributes.put(Utils.LOCATION, locationTrait);

Trait countTrait = new Trait(locationCount);
attributes.put(COUNT, countTrait);
Expand Down
7 changes: 7 additions & 0 deletions src/parsers/DiscreteTreeLinesParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ public LinkedList<Line> parseLines() throws IOException, ImportException,
Trait distanceTrait = new Trait(distance);
attributes.put(Utils.DISTANCE, distanceTrait);

// it's just easier to add them here as well, we avoid convoluted logic in renderers
Trait startLocationTrait = new Trait(parentLocation.getId());
attributes.put(Utils.START+Utils.LOCATION, startLocationTrait);

Trait endLocationTrait = new Trait(nodeLocation.getId());
attributes.put(Utils.END+Utils.LOCATION, endLocationTrait);

Line line = new Line(parentLocation, nodeLocation,
startTime, endTime, attributes);
linesList.add(line);
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/TimeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void parseTime() throws AnalysisException {
month = Integer.valueOf(endDateFields[Utils.MONTH_INDEX]);
day = Integer.valueOf(endDateFields[Utils.DAY_INDEX]);

System.out.println("MRSD in a decimal date format and corresponds to: " + year +"-" + month + "-" + day);
System.out.println("MRSD in a decimal date format corresponds to: " + year +"-" + month + "-" + day);

} else if(mrsd.contains("-")) {

Expand Down
Loading

0 comments on commit 4e3611d

Please sign in to comment.