private void drawPoint(Graphics2D g2d) { int mapPointX1 = (startX / MAP_POINT_WIDTH) + 1; int mapPointX2 = (endX / MAP_POINT_WIDTH) + 1; int mapPointY1 = (startY / MAP_POINT_HEIGHT) + 1; int mapPointY2 = (endY / MAP_POINT_HEIGHT) + 1; Stroke oldStroke = g2d.getStroke(); for (int y = mapPointY1; y <= mapPointY2; y++) { for (int x = mapPointX1; x <= mapPointX2; x++) { String mapPointKey = (x < 10 ? "0" + x : "" + x) + (y < 10 ? "0" + y : "" + y); List<PointInfo> points = null; if (mapPoint.containsKey(mapPointKey)) { points = mapPoint.get(mapPointKey); } else { points = MapDbBean.loadMapPoint(x, y); mapPoint.put(mapPointKey, points); } for (int i = 0; i < points.size(); i++) { PointInfo pointInfo = points.get(i); if (pointInfo.getMode() == Mode.DELETE) { continue; } int p_x = pointInfo.getAxisX() - startX; int p_y = pointInfo.getAxisY() - startY; if (pointInfo.getType() == PointType.LINK) { if (!((mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) && !mainFrame.containsViewType(ViewType.VIEW_POINT_LINK))) { drawPointOut(g2d, p_x, p_y, pointInfo); } } else if (pointInfo.getType() == PointType.NAME) { if (!((mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) && !mainFrame.containsViewType(ViewType.VIEW_POINT_NAME))) { drawPointOut(g2d, p_x, p_y, pointInfo); drawPointIn(g2d, p_x, p_y); } } } } } g2d.setStroke(oldStroke); }
private void removePoint(PointInfo aPoint) { List<BusLine> busLines = findBusLines(aPoint); if (busLines.size() > 0) { for (int i = 0; i < busLines.size(); i++) { BusLine busLine = busLines.get(i); removeBusLine(busLine); } } else { if (aPoint.getMode() == Mode.INSERT) { List<PointInfo> points = selectMapPoint(aPoint.getAxisX(), aPoint.getAxisY()); points.remove(aPoint); } else { aPoint.setMode(Mode.DELETE); } } }
private PointInfo findPoint(int x, int y) { List<PointInfo> points = selectMapPoint(x + startX, y + startY); for (int i = 0; i < points.size(); i++) { PointInfo pointInfo = points.get(i); if (pointInfo.getMode() == Mode.DELETE) { continue; } int p_x = pointInfo.getAxisX() - startX; int p_y = pointInfo.getAxisY() - startY; int area = MapConstants.pointSizeOut / 2; if ((p_x - area) <= x && x <= (p_x + area) && (p_y - area) <= y && y <= (p_y + area)) { return pointInfo; } } return null; }