コード例 #1
0
ファイル: GridRenderer.java プロジェクト: secondflying/vtm
  @Override
  protected void update(GLViewport v) {

    // scale coordinates relative to current 'zoom-level' to
    // get the position as the nearest tile coordinate
    int z = 1 << v.pos.zoomLevel;
    int x = (int) (v.pos.x * z);
    int y = (int) (v.pos.y * z);

    // update layers when map moved by at least one tile
    if (x == mCurX && y == mCurY && z == mCurZ) return;

    mCurX = x;
    mCurY = y;
    mCurZ = z;

    mMapPosition.copy(v.pos);
    mMapPosition.x = (double) x / z;
    mMapPosition.y = (double) y / z;
    mMapPosition.scale = z;

    if (mText != null) {
      addLabels(x, y, v.pos.zoomLevel);
      layers.setBaseLayers(mLineLayer);
      mLineLayer.addLine(mLines);
      compile();

    } else if (layers.vbo == null) {
      compile();
    }
  }
コード例 #2
0
ファイル: GridRenderer.java プロジェクト: secondflying/vtm
  public GridRenderer(int numLines, LineStyle lineStyle, TextStyle textStyle) {
    int size = Tile.SIZE;

    // not needed to set but we know:
    // 16 lines 'a' two points
    mLines = new GeometryBuffer(2 * 16, 16);

    float pos = -size * 4;

    // 8 vertical lines
    for (int i = 0; i < 8 * numLines; i++) {
      float x = pos + i * size / numLines;
      mLines.startLine();
      mLines.addPoint(x, pos);
      mLines.addPoint(x, pos + size * 8);
    }

    // 8 horizontal lines
    for (int j = 0; j < 8 * numLines; j++) {
      float y = pos + j * size / numLines;
      mLines.startLine();
      mLines.addPoint(pos, y);
      mLines.addPoint(pos + size * 8, y);
    }

    mText = textStyle;

    if (mText != null) {
      mTextLayer = layers.addTextLayer(new TextLayer());
    } else {
      mTextLayer = null;
    }

    mLineLayer = layers.addLineLayer(0, lineStyle);
    mLineLayer.addLine(mLines);

    mStringBuffer = new StringBuffer(32);
  }