本文整理汇总了Java中com.codename1.maps.Coord类的典型用法代码示例。如果您正苦于以下问题:Java Coord类的具体用法?Java Coord怎么用?Java Coord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Coord类属于com.codename1.maps包,在下文中一共展示了Coord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintSegment
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Paint a segment.
*
* @param g a Graphics Object to paint on
* @param segment array of Coord to draw a Line.
* @param tile
*/
protected void paintSegment(Graphics g, Coord[] segment, Tile tile) {
int pointsNo = segment.length;
for (int i = 1; i < pointsNo; i++) {
Coord start = (Coord) segment[i - 1];
Coord end = (Coord) segment[i];
Point s = tile.pointPosition(start);
Point e = tile.pointPosition(end);
g.drawLine(s.getX(), s.getY(), e.getX(), e.getY());
// lame & simple way to make line thicker
g.drawLine(s.getX() - 1, s.getY(), e.getX() - 1, e.getY());
g.drawLine(s.getX() + 1, s.getY(), e.getX() + 1, e.getY());
g.drawLine(s.getX(), s.getY() - 1, e.getX(), e.getY() - 1);
g.drawLine(s.getX(), s.getY() + 1, e.getX(), e.getY() + 1);
}
}
示例2: updateFormMap
import com.codename1.maps.Coord; //导入依赖的package包/类
private void updateFormMap(Form root) {
MapComponent m = findMapEntry(root);
Coord crd = new Coord(current.lat,current.lon);
m.zoomTo(crd, 16);
PointLayer lay = new PointLayer(crd, current.name, fetchResourceFile().getImage("pinhead.png"));
PointsLayer points = new PointsLayer(current.name);
points.addPoint(lay);
m.addLayer(points);
}
示例3: decodePoly
import com.codename1.maps.Coord; //导入依赖的package包/类
private ArrayList decodePoly(String encoded) {
ArrayList poly = new ArrayList();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
Coord p = new Coord(lat / 1E5, lng / 1E5);
poly.add(p);
}
return poly;
}
示例4: getDirections
import com.codename1.maps.Coord; //导入依赖的package包/类
private String getDirections(Coord origin, Coord destination) throws IOException {
ConnectionRequest req = new ConnectionRequest();
req.setUrl("http://maps.googleapis.com/maps/api/directions/json");
req.setUserAgent("Opera/8.0 (Windows NT 5.1; U; en)");
req.setPost(false);
req.addArgument("origin", "" + origin.getLatitude() + " " + origin.getLongitude());
req.addArgument("destination", "" + destination.getLatitude() + " " + destination.getLongitude());
req.addArgument("mode", "walking");
req.addArgument("sensor", "false");
NetworkManager.getInstance().addToQueueAndWait(req);
JSONParser p = new JSONParser();
Hashtable h = p.parse(new InputStreamReader(new ByteArrayInputStream(req.getResponseData())));
System.out.println(h.toString());
return ((Hashtable) ((Hashtable) ((Vector) h.get("routes")).firstElement()).get("overview_polyline")).get("points").toString();
}
示例5: tileFor
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Tile tileFor(BoundingBox bbox) {
StringBuilder sb = new StringBuilder(_url);
Coord ne = bbox.getNorthEast();
Coord c = projection().toWGS84(new Coord(ne.getLatitude() - bbox.latitudeDifference()/2,
ne.getLongitude() - bbox.longitudeDifference()/2, true));
sb.append("center=");
sb.append(c.getLatitude());
sb.append(",");
sb.append(c.getLongitude());
sb.append("&format=png");
sb.append("&zoom="+_zoomLevel);
sb.append("&size=");
sb.append(tileSize);
sb.append("x");
sb.append(tileSize);
sb.append("&sensor=");
sb.append(sensor);
if(language != null) {
sb.append("&language=");
sb.append(language);
}
if(type == SATELLITE){
sb.append("&maptype=satellite");
}else if(type == HYBRID){
sb.append("&maptype=hybrid");
}
sb.append("&key="+apiKey);
return new ProxyHttpTile(tileSize(), bbox, sb.toString());
}
示例6: maxZoomFor
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Returns the maximum zoom of a specific Tile.
* @param tile tile to check the max zoom
* @return the max zoom of the tile
*/
public int maxZoomFor(Tile tile) {
int zoom;
int height = tile.dimension().getHeight();
int width = tile.dimension().getWidth();
double latitude = tile.getBoundingBox().latitudeDifference();
double longitude = tile.getBoundingBox().longitudeDifference();
for (zoom = maxZoomLevel(); zoom > 0; zoom--) {
Coord scale = scale(zoom);
if ((scale.getLatitude() * height) > latitude && (scale.getLongitude() * width) > longitude) {
break;
}
}
return zoom;
}
示例7: scale
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Scale to the zoom level
* @param zoomLevel to scale to
*
* @return a scaled coordinate.
*/
public Coord scale(int zoomLevel) {
int divider = (1 << zoomLevel);
double longitude = (1.0 * projection().extent().longitudeDifference()) / divider / tileSize().getWidth();
double latitude = (1.0 * projection().extent().latitudeDifference()) / divider / tileSize().getHeight();
return new Coord(latitude, longitude, false);
}
示例8: bboxFor
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public BoundingBox bboxFor(Coord position, int zoomLevel) {
_zoomLevel = zoomLevel;
Coord scale = scale(zoomLevel);
Dimension tileSize = tileSize();
double x = scale.getLongitude() * tileSize.getWidth();
double y = scale.getLatitude() * tileSize.getHeight();
Coord tileScale = new Coord(y, x, false);
_tileNo = tileNo(position, projection().extent().getSouthWest(), tileScale);
Coord start = tileCoord(_tileNo, projection().extent().getSouthWest(), tileScale);
Coord end = start.translate(tileScale.getLatitude(), tileScale.getLongitude());
return new BoundingBox(start, end);
}
示例9: paint
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void paint(Graphics g, Tile screenTile) {
g.setColor(_lineColor);
g.setAntiAliased(true);
int segmentsNo = _lineSegments.size();
for (int i = 0; i < segmentsNo; i++) {
paintSegment(g, (Coord[]) _lineSegments.elementAt(i), screenTile);
}
}
示例10: addLineSegment
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Adds a Line segment to the Layer
* @param coords
*/
public void addLineSegment(Coord[] coords) {
if (coords == null || coords.length <= 1) {
return;
}
if (!coords[0].isProjected()) {
coords = getProjection().fromWGS84(coords);
}
_lineSegments.addElement(coords);
}
示例11: boundingBox
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public BoundingBox boundingBox() {
BoundingBox bbox = null;
for (int i = 0; i < _lineSegments.size(); i++) {
Coord[] coords = (Coord[]) _lineSegments.elementAt(i);
BoundingBox cBbox = BoundingBox.create(coords);
if (bbox == null) {
bbox = cBbox;
} else {
bbox = bbox.extend(cBbox);
}
}
return bbox;
}
示例12: addPoint
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Adds a point to the PointsLayer
*
* @param point a point to add
*/
public void addPoint(PointLayer point) {
Image pointIcon = point.getIcon();
if (pointIcon == null) {
point.setIcon(icon);
}
if(!point.isProjected()){
Coord c = getProjection().fromWGS84(point);
point.setLatitude(c.getLatitude());
point.setLongitude(c.getLongitude());
point.setProjected(true);
}
points.addElement(point);
}
示例13: removePoint
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Removes a point from the PointsLayer
*
* @param point to remove from the PointsLayer
*/
public void removePoint(PointLayer point) {
if(!point.isProjected()){
Coord c = getProjection().fromWGS84(point);
point.setLatitude(c.getLatitude());
point.setLongitude(c.getLongitude());
point.setProjected(true);
}
points.removeElement(point);
}
示例14: pointPosition
import com.codename1.maps.Coord; //导入依赖的package包/类
/**
* Returns the x, y point of the given coordinate relative to this tile
* @param point a coordinate to translate to x, y
* @return a Point object relative to this tile
*/
public Point pointPosition(Coord point) {
int x = position(dimension.getWidth(), point.getLongitude(),
bbox.getSouthWest().getLongitude(), bbox.getNorthEast().getLongitude());
int y = position(dimension.getHeight(), point.getLatitude(),
bbox.getSouthWest().getLatitude(), bbox.getNorthEast().getLatitude());
//
return new Point(x, dimension.getHeight() - y);
}
示例15: decodePoly
import com.codename1.maps.Coord; //导入依赖的package包/类
private ArrayList decodePoly(String encoded) {
ArrayList poly = new ArrayList();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
Coord p = new Coord(lat/1E5, lng/1E5);
poly.add(p);
}
return poly;
}