当前位置: 首页>>代码示例>>Java>>正文


Java Coord类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:LinesLayer.java

示例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);
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:11,代码来源:StateMachine.java

示例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;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:32,代码来源:MapsDemo.java

示例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();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:16,代码来源:MapsDemo.java

示例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());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:37,代码来源:GoogleMapsProvider.java

示例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;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:MapProvider.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:TiledProvider.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:18,代码来源:TiledProvider.java

示例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);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:12,代码来源:LinesLayer.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:14,代码来源:LinesLayer.java

示例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;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:LinesLayer.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:PointsLayer.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:15,代码来源:PointsLayer.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:14,代码来源:Tile.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:MapsDemo.java


注:本文中的com.codename1.maps.Coord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。