Package org.osm2world.viewer.view.debug

Source Code of org.osm2world.viewer.view.debug.InternalCoordsDebugView

package org.osm2world.viewer.view.debug;

import static java.awt.Color.*;
import static java.lang.Math.*;

import java.awt.Color;

import org.osm2world.core.math.AxisAlignedBoundingBoxXZ;
import org.osm2world.core.math.VectorXYZ;
import org.osm2world.core.target.jogl.JOGLTarget;

/**
* shows the internal world coordinate grid
*/
public class InternalCoordsDebugView extends DebugView {

  @Override
  public String getDescription() {
    return "shows the internal world coordinate grid";
  }
 
  private static final double LINE_DIST = 100;
 
  @Override
  public boolean canBeUsed() {
    return map != null;
  }

  @Override
  public void fillTarget(JOGLTarget target) {
   
    AxisAlignedBoundingBoxXZ bound = map.getDataBoundary();
   
    for (int x = (int)floor(bound.minX / LINE_DIST); x < (int)ceil(bound.maxX / LINE_DIST); x++) {
      for (int z = (int)floor(bound.minZ / LINE_DIST); z < (int)ceil(bound.maxZ / LINE_DIST); z++) {
       
        Color colorX = (z == 0 && x >= 0) ? RED : WHITE;
        int widthX = (z == 0) ? 3 : 1;
        target.drawLineStrip(colorX, widthX,
            new VectorXYZ(x * LINE_DIST, 0, z * LINE_DIST),
            new VectorXYZ((x+1) * LINE_DIST, 0, z * LINE_DIST));

        Color colorZ = (x == 0 && z >= 0) ? BLUE : WHITE;
        int widthZ = (x == 0) ? 3 : 1;
        target.drawLineStrip(colorZ, widthZ,
            new VectorXYZ(x * LINE_DIST, 0, z * LINE_DIST),
            new VectorXYZ(x * LINE_DIST, 0, (z+1) * LINE_DIST));
       
      }
    }
   
    target.drawLineStrip(GREEN, 3,
        VectorXYZ.NULL_VECTOR, new VectorXYZ(0, LINE_DIST, 0));
   
  }
 
}
TOP

Related Classes of org.osm2world.viewer.view.debug.InternalCoordsDebugView

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.