Пример #1
0
  public void setup() {
    size(800, 600, OPENGL);
    // size(800, 600);
    smooth();

    map = new UnfoldingMap(this);
    map.zoomToLevel(3);
    map.panTo(new Location(40f, -98f));
    MapUtils.createDefaultEventDispatcher(this, map);

    Location berlinLocation = new Location(40f, -98f);
    berlinMarker = new TestMarker(berlinLocation);
    berlinMarker.setColor(color(255, 0, 0, 100));
    berlinMarker.setStrokeColor(color(255, 0, 0));
    berlinMarker.setStrokeWeight(2);
    map.addMarkers(berlinMarker);
  }
Пример #2
0
  public void draw() {
    background(240);
    map.draw();

    ScreenPosition pos = berlinMarker.getScreenPosition(map);
    fill(255, 0, 0, 100);
    stroke(255, 0, 0);
    strokeWeight(2);
    ellipse(pos.x, pos.y + 30, 20, 20);
    println("o:" + pos.x + ", " + pos.y);
    fill(0);
    text("Xylophon", pos.x + 20, pos.y + 30);
  }
  // A suggested helper method that takes in an earthquake feature and
  // returns a SimplePointMarker for that earthquake
  // Done: Implement this method and call it from setUp, if it helps
  private SimplePointMarker createMarker(PointFeature feature) {
    // finish implementing and use this method, if it helps.
    SimplePointMarker spm = new SimplePointMarker(feature.getLocation());

    Object magnitudeProp = feature.getProperty("magnitude");

    float magnitude = Float.parseFloat(magnitudeProp.toString());

    if (magnitude < 4.0) {
      spm.setColor(color(0, 0, 255));
      spm.setRadius(5);
    } else if (magnitude >= 4.0 && magnitude < 5) {
      spm.setColor(color(255, 255, 0));
      spm.setRadius(10);
    } else {
      spm.setColor(color(255, 0, 0));
      spm.setRadius(15);
    }
    return spm;
  }