• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MapView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openstreetmap.josm.gui.MapView的典型用法代码示例。如果您正苦于以下问题:Java MapView类的具体用法?Java MapView怎么用?Java MapView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MapView类属于org.openstreetmap.josm.gui包,在下文中一共展示了MapView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: paint

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
public void paint(final Graphics2D g2D, final MapView mv, final Bounds bounds) {
    mv.setDoubleBuffered(true);
    if (tripView) {
        // draw selected road sign's trip
        paintHandler.drawTripData(g2D, mv, selRoadSigns.get(0));
    } else if (dataSet != null) {

        if (!dataSet.getRoadSigns().isEmpty()) {
            // draw road signs
            paintHandler.drawRoadSigns(g2D, mv, dataSet.getRoadSigns(), selRoadSigns);
        } else if (!dataSet.getRoadSignClusters().isEmpty()) {
            // draw road sign clusters
            paintHandler.drawRoadSignClusters(g2D, mv, dataSet.getRoadSignClusters());
        }
    }
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:18,代码来源:ScoutSignsLayer.java


示例2: arrowGeometry

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
static Pair<Pair<Point, Point>, Pair<Point, Point>> arrowGeometry(final MapView mapView, final List<LatLon> points,
        final boolean isFromSegment, final double length) {
    LatLon arrowPoint;
    double bearing;
    if (isFromSegment) {
        arrowPoint = points.size() > 2 ? points.get(points.size() / 2) : new LatLon(
                (points.get(1).lat() + points.get(0).lat()) / 2, (points.get(1).lon() + points.get(0).lon()) / 2);
        bearing = Math.toDegrees(points.get(points.size() - 1).bearing(arrowPoint));
    } else {
        arrowPoint = points.get(points.size() - 1);
        bearing = Math.toDegrees(points.get(points.size() - 1).bearing(points.get(points.size() - 2)));
    }


    final Pair<Coordinate, Coordinate> arrowEndCoordinates =
            GeometryUtil.arrowEndPoints(new Coordinate(arrowPoint.lat(), arrowPoint.lon()), bearing, length);
    final Pair<Point, Point> arrowLine1 = new Pair<>(mapView.getPoint(arrowPoint), mapView.getPoint(
            new LatLon(arrowEndCoordinates.getFirst().getLat(), arrowEndCoordinates.getFirst().getLon())));
    final Pair<Point, Point> arrowLine2 = new Pair<>(mapView.getPoint(arrowPoint), mapView.getPoint(
            new LatLon(arrowEndCoordinates.getSecond().getLat(), arrowEndCoordinates.getSecond().getLon())));
    return new Pair<>(arrowLine1, arrowLine2);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:23,代码来源:PaintUtil.java


示例3: drawItem

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
void drawItem(final Graphics2D graphics, final MapView mapView, final TurnRestriction turnRestriction,
        final boolean selected) {
    final Point point = mapView.getPoint(turnRestriction.getPoint());
    if (turnRestriction.getTurnRestrictions() != null) {
        // draw complex turn restriction

        final int radius = selected ? COMPLEX_TURN_SEL_RADIUS : COMPLEX_TURN_RADIUS;
        PaintManager.drawCircle(graphics, point, COMPLEX_TURN_COLOR, radius);
        PaintManager.drawText(graphics, Integer.toString(turnRestriction.getTurnRestrictions().size()), point,
                mapView.getFont().deriveFont(Font.BOLD, COMPLEX_TURN_FONT_SIZE), Color.white);
    } else {
        // draw simple turn restriction
        if (selected) {
            // draw turn segments
            drawTurnSegments(graphics, mapView, turnRestriction);
        }

        // draw turn restriction
        if (mapView.contains(point)) {
            final ImageIcon icon = selected ? IconConfig.getInstance().getSelectedTurnRestrictionIcon()
                    : IconConfig.getInstance().getTurnRestrictionIcon();
            PaintManager.drawIcon(graphics, icon, point);
        }
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:27,代码来源:TurnRestrictionPaintHandler.java


示例4: drawItem

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
void drawItem(final Graphics2D graphics, final MapView mapView, final Tile tile, final boolean selected) {
    final Color borderColor = tile.getStatus() == Status.OPEN ? TILE_OPEN_COLOR
            : (tile.getStatus() == Status.SOLVED ? TILE_SOLVED_COLOR : TILE_INVALID_COLOR);
    final Color tileColor = tileColor(tile);
    final Composite composite = selected ? TILE_SEL_COMPOSITE : TILE_COMPOSITE;
    final BoundingBox bbox = Util.tileToBoundingBox(tile.getX(), tile.getY());
    final Point northEast = mapView.getPoint(new LatLon(bbox.getNorth(), bbox.getEast()));
    final Point northWest = mapView.getPoint(new LatLon(bbox.getSouth(), bbox.getWest()));
    PaintManager.drawRectangle(graphics, northEast, northWest, NORMAL_COMPOSITE, composite, TILE_LINE_STROKE,
            borderColor, tileColor);

    final int radius = selected ? SEL_POINT_POS_RADIUS : POINT_POS_RADIUS;
    // draw points belonging to the tile
    if (tile.getPoints() != null && tile.getPoints().size() > 1) {
        for (final LatLon latLon : tile.getPoints()) {
            PaintManager.drawCircle(graphics, mapView.getPoint(latLon), POINT_COLOR, radius);
        }
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:21,代码来源:MissingGeometryHanlder.java


示例5: drawItem

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
void drawItem(final Graphics2D graphics, final MapView mapView, final RoadSegment segment,
        final boolean isSelected) {
    Stroke stroke;
    Color color;
    // draw segment
    if (isSelected) {
        stroke = ROAD_SEGMENT_SEL_STROKE;
        color = ROAD_SEGMENT_SEL_COLOR;
    } else {
        stroke = ROAD_SEGMENT_STROKE;
        color = ROAD_SEGMENT_COLOR;
    }
    double arrowLength = isSelected ? SEL_ARROW_LENGTH : ARROW_LENGTH;
    arrowLength = PaintUtil.arrowLength(mapView, arrowLength);
    final Pair<Pair<Point, Point>, Pair<Point, Point>> arrowGeometry =
            PaintUtil.arrowGeometry(mapView, segment.getPoints(), false, arrowLength);
    final List<Point> geometry = PaintUtil.toPoints(mapView, segment.getPoints());
    PaintManager.drawDirectedSegment(graphics, geometry, arrowGeometry, color, stroke);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:21,代码来源:DirectionOfFlowPaintHandler.java


示例6: drawDataSet

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Draws the given data set and selected items to the map.
 *
 * @param graphics a {@code Graphics2D} used to drawing to the map
 * @param mapView the current {@code MapView}
 * @param bounds the current map {@code Bounds}
 * @param dataSet the {@code DataSet} to draw to the map
 * @param items a list of selected items
 */
void drawDataSet(final Graphics2D graphics, final MapView mapView, final Bounds bounds, final DataSet<T> dataSet,
        final List<T> selectedItems) {
    final int zoom = Util.zoom(bounds);
    final Composite originalComposite = graphics.getComposite();
    final Stroke originalStroke = graphics.getStroke();
    if (zoom <= Config.getInstance().getMaxClusterZoom()) {
        if (dataSet.getClusters() != null && !dataSet.getClusters().isEmpty()) {
            drawClusters(graphics, mapView, dataSet.getClusters(), zoom, getClusterColor());
        }
    } else {
        if (dataSet.getItems() != null && !dataSet.getItems().isEmpty()) {
            drawItems(graphics, mapView, dataSet.getItems(), selectedItems);
        }
    }
    graphics.setComposite(originalComposite);
    graphics.setStroke(originalStroke);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:27,代码来源:PaintHandler.java


示例7: mapFrameInitialized

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    if (newFrame != null) {
        dialog = new NotesDialog(this);
        newFrame.addToggleDialog(dialog);
        if (newFrame.mapView != null) {
            newFrame.mapView.addComponentListener(viewChangeAdapter);
        }

        MapView.addLayerChangeListener(this);

        uploadHook = new NotesUploadHook();
        UploadAction.registerUploadHook(uploadHook);
    } else {
        MapView.removeLayerChangeListener(this);
        UploadAction.unregisterUploadHook(uploadHook);
        if (oldFrame.mapView != null) {
            oldFrame.mapView.removeComponentListener(viewChangeAdapter);
        }
        uploadHook = null;
        dialog = null;
    }
}
 
开发者ID:iandees,项目名称:josm-notes,代码行数:24,代码来源:NotesPlugin.java


示例8: grabNotes

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
private void grabNotes() {
    if (Main.map == null)
        return;
    MapView mv = Main.map.mapView;
    Bounds bbox = mv.getLatLonBounds(mv.getBounds());

    // Have the user changed view since last time
    boolean active = isActive();
    if (active && (lastBbox == null || !lastBbox.equals(bbox))) {
        if (task != null) {
            task.cancel();
        }

        // wait 500ms before downloading in case the user is in the middle
        // of a pan/zoom
        task = new DownloadNotesTask();
        timer.schedule(task, 500);
        lastBbox = bbox;
    }
}
 
开发者ID:iandees,项目名称:josm-notes,代码行数:21,代码来源:NotesPlugin.java


示例9: buildBBox

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Computes the bounding box of the currently visible {@code MapView}.
 *
 * @param mapView the currently visible map view
 * @return a {@code BoundingBox} object
 */
public static BoundingBox buildBBox(final MapView mapView) {
    final Bounds bounds =
            new Bounds(mapView.getLatLon(0, mapView.getHeight()), mapView.getLatLon(mapView.getWidth(), 0));
    return new BoundingBox(bounds.getMax().lat(), bounds.getMin().lat(), bounds.getMax().lon(),
            bounds.getMin().lon());
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:13,代码来源:Util.java


示例10: drawRoadSignClusters

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Draws the given road signs clusters to the map. A road sign cluster is represented by an icon and the road sign
 * count drawn in the middle of the icon.
 *
 * @param g2D the {@code Graphics2D} used to draw
 * @param mv the current {@code MapView}
 * @param clusterList the list of {@code RoadSignCluster}s to be drawn
 */
void drawRoadSignClusters(final Graphics2D g2D, final MapView mv, final List<RoadSignCluster> clusterList) {
    for (final RoadSignCluster cluster : clusterList) {
        final Point point = mv.getPoint(cluster.getPosition());
        final Pair<ImageIcon, Float> pair = ClusterIconConfig.getInstance().getIcon(cluster.getCount());
        g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, pair.getSecond()));
        PaintManager.drawIcon(g2D, pair.getFirst(), point);
    }
    g2D.setComposite(COMP);
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:18,代码来源:PaintHandler.java


示例11: drawRoadSign

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
private void drawRoadSign(final Graphics2D g2D, final MapView mv, final RoadSign roadSign, final boolean selected) {
    final Point point = mv.getPoint(roadSign.getSignPos().getPosition());
    if (mv.contains(point)) {
        if (selected) {
            PaintManager.drawIcon(g2D, IconConfig.getInstance().getSelRoadSignBgIcon(), point);
        }
        PaintManager.drawIcon(g2D, iconFactory.getIcon(roadSign.getType()), point);
    }
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:10,代码来源:PaintHandler.java


示例12: getArrowGeometry

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
private Pair<Pair<Point, Point>, Pair<Point, Point>> getArrowGeometry(final MapView mapView, final LatLon start,
        final LatLon end, final double length) {
    final LatLon midPoint = new LatLon((start.lat() + end.lat()) / 2, (start.lon() + end.lon()) / 2);
    final double bearing = Math.toDegrees(start.bearing(midPoint));
    final Pair<Coordinate, Coordinate> arrowEndCoordinates =
            GeometryUtil.arrowEndPoints(new Coordinate(midPoint.lat(), midPoint.lon()), bearing, -length);
    final Pair<Point, Point> arrowLine1 = new Pair<>(mapView.getPoint(midPoint), mapView.getPoint(
            new LatLon(arrowEndCoordinates.getFirst().getLat(), arrowEndCoordinates.getFirst().getLon())));
    final Pair<Point, Point> arrowLine2 = new Pair<>(mapView.getPoint(midPoint), mapView.getPoint(
            new LatLon(arrowEndCoordinates.getSecond().getLat(), arrowEndCoordinates.getSecond().getLon())));
    return new Pair<>(arrowLine1, arrowLine2);
}
 
开发者ID:Telenav,项目名称:scoutsigns,代码行数:13,代码来源:PaintHandler.java


示例13: toPoints

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Transforms geographic coordinates into screen points.
 *
 * @param mapView a {@code MapView} used for coordinate transformation
 * @param geometry a list of {@code LatLon} representing the geographic coordinates
 * @return a list of {@code Point}s
 */
static List<Point> toPoints(final MapView mapView, final List<LatLon> geometry) {
    final List<Point> points = new ArrayList<>();
    for (final LatLon latLon : geometry) {
        points.add(mapView.getPoint(latLon));
    }
    return points;
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:15,代码来源:PaintUtil.java


示例14: drawTurnSegments

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
private static void drawTurnSegments(final Graphics2D graphics, final MapView mapView,
        final TurnRestriction turnRestriction) {
    graphics.setFont(mapView.getFont().deriveFont(Font.BOLD));
    if (turnRestriction.getSegments() != null) {
        // draw segments
        for (int i = 0; i < turnRestriction.getSegments().size(); i++) {
            final Color color = i == 0 ? TURN_SEGMENT_FROM_COLOR : TURN_SEGMENT_TO_COLOR;
            final double arrowLength = PaintUtil.arrowLength(mapView, TURN_ARROW_LENGTH);
            final List<Point> geometry =
                    PaintUtil.toPoints(mapView, turnRestriction.getSegments().get(i).getPoints());
            final boolean isFromSegment = i == 0;
            final Pair<Pair<Point, Point>, Pair<Point, Point>> arrowGeometry = PaintUtil.arrowGeometry(mapView,
                    turnRestriction.getSegments().get(i).getPoints(), isFromSegment, arrowLength);
            PaintManager.drawDirectedSegment(graphics, geometry, arrowGeometry, color, TURN_SEGMENT_STROKE);
        }

        // draw labels
        final TurnSegment firstSegment = turnRestriction.getSegments().get(0);
        Point labelPoint = labelPoint(mapView, firstSegment.getPoints(), true);
        final Font font = mapView.getFont().deriveFont(Font.BOLD, TURN_SEGMENT_FONT_SIZE);
        PaintManager.drawText(graphics, Integer.toString(firstSegment.getNumberOfTrips()), labelPoint, font,
                LABEL_BACKGROUND_COLOR, Color.black, LABEL_COMPOSITE);

        final TurnSegment lastSegment = turnRestriction.getSegments().get(turnRestriction.getSegments().size() - 1);
        labelPoint = labelPoint(mapView, lastSegment.getPoints(), true);
        PaintManager.drawText(graphics, Integer.toString(turnRestriction.getNumberOfPasses()), labelPoint, font,
                LABEL_BACKGROUND_COLOR, Color.black, LABEL_COMPOSITE);
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:30,代码来源:TurnRestrictionPaintHandler.java


示例15: paint

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
public void paint(final Graphics2D graphics, final MapView mapView, final Bounds bounds) {
    mapView.setDoubleBuffered(true);
    graphics.setRenderingHints(RENDERING_MAP);
    if (dataSet != null) {
        paintHandler.drawDataSet(graphics, mapView, bounds, dataSet, selectedItems);
    }
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:9,代码来源:ImproveOsmLayer.java


示例16: drawClusters

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
private void drawClusters(final Graphics2D graphics, final MapView mapView, final List<Cluster> clusters,
        final int zoom, final Color color) {
    final SortedMap<Integer, Double> clusterRadiusMap = generateClusterRadiusMap(zoom, clusters);
    graphics.setComposite(CLUSTER_COMPOSITE);
    for (final Cluster cluster : clusters) {
        final Integer radius = clusterRadius(clusterRadiusMap, cluster.getSize()).intValue();
        PaintManager.drawCircle(graphics, mapView.getPoint(cluster.getPoint()), color,
                radius);
    }
    graphics.setComposite(NORMAL_COMPOSITE);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:12,代码来源:PaintHandler.java


示例17: cleanup

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Removes all temporary layers added to the current mapView
 */
public static void cleanup() {
    MapView mapView = MainApplication.getMap().mapView;
    mapView.removeTemporaryLayer(roadSegm);
    mapView.removeTemporaryLayer(buildingSegm);
    roadSegm = null;
    buildingSegm = null;
    MainApplication.getMap().repaint();
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:12,代码来源:ShapeMode.java


示例18: paint

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
@Override
public void paint(Graphics2D g, MapView mv, Bounds bbox) {
    if (segment != null) {
        g.setColor(color);
        g.setStroke(stroke);

        Point p1 = mv.getPoint(segment.getFirstNode());
        Point p2 = mv.getPoint(segment.getSecondNode());
        Line2D overlappingLine = new Line2D.Double(p1.getX(), p1.getY(),
                                                   p2.getX(), p2.getY());
        g.draw(overlappingLine);
    }
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:14,代码来源:DrawableSegment.java


示例19: bounds

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Determines the bounds of the current selected layer
 * @return
 */
protected Bounds bounds(){
    MapView mv = Main.map.mapView;
    return new Bounds(
        mv.getLatLon(0, mv.getHeight()),
        mv.getLatLon(mv.getWidth(), 0));
}
 
开发者ID:iandees,项目名称:josm-notes,代码行数:11,代码来源:NotesPlugin.java


示例20: findCandidateNode

import org.openstreetmap.josm.gui.MapView; //导入依赖的package包/类
/**
 * Returns the nearest node to cursor. All nodes that are “behind” segments
 * are neglected. This is to avoid way self-intersection after moving the
 * candidateNode to a new place.
 *
 * @param mv the current map view
 * @param w the way to check
 * @param p the cursor position
 * @return nearest node to cursor
 */
public static Node findCandidateNode(MapView mv, Way w, Point p) {
    if (mv == null || w == null || p == null) {
        return null;
    }

    EastNorth pEN = mv.getEastNorth(p.x, p.y);

    Double bestDistance = Double.MAX_VALUE;
    Double currentDistance;
    List<Pair<Node, Node>> wpps = w.getNodePairs(false);

    Node result = null;

    mainLoop:
    for (Node n : w.getNodes()) {
        EastNorth nEN = n.getEastNorth();

        if (nEN == null) {
            // Might happen if lat/lon for that point are not known.
            continue;
        }

        currentDistance = pEN.distance(nEN);

        if (currentDistance < bestDistance) {
            // Making sure this candidate is not behind any segment.
            for (Pair<Node, Node> wpp : wpps) {
                if (!wpp.a.equals(n)
                        && !wpp.b.equals(n)
                        && Geometry.getSegmentSegmentIntersection(
                        wpp.a.getEastNorth(), wpp.b.getEastNorth(),
                        pEN, nEN) != null) {
                    continue mainLoop;
                }
            }
            result = n;
            bestDistance = currentDistance;
        }
    }

    return result;
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:53,代码来源:ImproveWayAccuracyHelper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RtspServer类代码示例发布时间:2022-05-22
下一篇:
Java GimpyEngine类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap