예제 #1
0
  private void drawBusChoices(Graphics2D g2d) {
    if (busChoices != null && busChoices.size() > 0) {
      g2d.setFont(new Font("Tahoma", Font.BOLD, 12));

      int marginX = 20;
      int marginY = 25;
      int x = marginX;
      int y = marginY;
      for (int i = 0; i < busChoices.size(); i++) {
        BusChoice busChoice = busChoices.get(i);

        String concat = "";
        String busInfo = (i + 1) + ". [";
        List<ABus> buses = busChoice.getBuses();
        for (int j = 0; j < buses.size(); j++) {
          ABus aBus = buses.get(j);
          String busNo = aBus.getBusNo();
          String busPrice = StringUtil.toAmountString(aBus.getBusPrice());

          busInfo = busInfo + concat + busNo + "(" + busPrice + ")";
          concat = " -> ";
        }
        busInfo = busInfo + "]";

        int w = g2d.getFontMetrics().stringWidth(busInfo);
        int h = (int) g2d.getFontMetrics().getLineMetrics(busInfo, g2d).getHeight();

        Color bg = MapConstants.labelBusBG;
        Color fg = MapConstants.labelBusFG;
        if (i == busChoiceIndex) {
          bg = MapConstants.labelBusBGHL;
          fg = MapConstants.labelBusFGHL;
        }

        g2d.setColor(bg);
        g2d.fillRect(x - 2, y - h + 1, w + 4, h + 5);

        g2d.setColor(fg);
        g2d.drawString(busInfo, x, y);

        y = marginY + ((i + 1) * (h + 10));
      }
    }
  }
예제 #2
0
  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);
    }
  }