private void drawBusLine(Graphics2D g2d) { if (busSelect != null) { Stroke oldStroke = g2d.getStroke(); BasicStroke lineStroke = new BasicStroke(MapConstants.lineSize, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); Hashtable<Long, Color> hLineColor = new Hashtable<Long, Color>(); List<BusLine> mapBusLine = busSelect.getBusLine(); for (int i = 0; i < mapBusLine.size(); i++) { BusLine busLine = mapBusLine.get(i); if (busLine.getMode() == Mode.DELETE) { continue; } Color hColor = null; if (mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) { if (hLineColor.containsKey(busLine.getBusId())) { hColor = hLineColor.get(busLine.getBusId()); } else { hColor = MapConstants.lineColor[(hLineColor.size() % MapConstants.lineColor.length)]; hLineColor.put(busLine.getBusId(), hColor); } } int x1 = busLine.getX1() - startX; int y1 = busLine.getY1() - startY; int x2 = busLine.getX2() - startX; int y2 = busLine.getY2() - startY; switch (busLine.getType()) { case BIDIRECT: if ((mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) && !mainFrame.containsViewType(ViewType.VIEW_TWO_WAY)) { break; } if (mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) { g2d.setColor(hColor); } else { g2d.setColor(MapConstants.lineColorBiDirect); } g2d.setStroke(lineStroke); g2d.drawLine(x1, y1, x2, y2); break; case P1_P2: if ((mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) && !mainFrame.containsViewType(ViewType.VIEW_ONE_WAY)) { break; } if (mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) { g2d.setColor(hColor); } else { g2d.setColor(MapConstants.lineColorOneWay); } g2d.setStroke(lineStroke); g2d.drawLine(x1, y1, x2, y2); drawArrow(g2d, x1, y1, x2, y2, MapConstants.lineSize); break; case P2_P1: if ((mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) && !mainFrame.containsViewType(ViewType.VIEW_ONE_WAY)) { break; } if (mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) { g2d.setColor(hColor); } else { g2d.setColor(MapConstants.lineColorOneWay); } g2d.setStroke(lineStroke); g2d.drawLine(x2, y2, x1, y1); drawArrow(g2d, x2, y2, x1, y1, MapConstants.lineSize); break; } } g2d.setStroke(oldStroke); } else if (busChoices != null && busChoices.size() > 0) { Stroke oldStroke = g2d.getStroke(); BasicStroke lineStroke = new BasicStroke(MapConstants.lineSize, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); BusChoice busChoice = busChoices.get(busChoiceIndex); List<ABus> buses = busChoice.getBuses(); for (int i = 0; i < buses.size(); i++) { ABus aBus = buses.get(i); List<BusPath> busPaths = aBus.getBusPaths(); for (int j = 0; j < busPaths.size(); j++) { BusPath busPath = busPaths.get(j); int x1 = busPath.getX1() - startX; int y1 = busPath.getY1() - startY; int x2 = busPath.getX2() - startX; int y2 = busPath.getY2() - startY; g2d.setColor(MapConstants.lineColor[i % MapConstants.lineColor.length]); g2d.setStroke(lineStroke); g2d.drawLine(x1, y1, x2, y2); drawArrow(g2d, x1, y1, x2, y2, MapConstants.lineSize); } } g2d.setStroke(oldStroke); } }