예제 #1
0
  public void mouseMoved(MouseEvent e) {
    MapStatusBar.setCoordinate(
        StringUtil.toNumString(e.getX()) + " : " + StringUtil.toNumString(e.getY()));

    dragX = MapConstants.NULL;
    dragY = MapConstants.NULL;
    updateStatusMessage();
  }
예제 #2
0
  private void movingMap(int x, int y) {
    MapStatusBar.setCoordinate(StringUtil.toNumString(x) + " : " + StringUtil.toNumString(y));

    if (mainFrame.getMapMode() == MapMode.VIEW
        || mainFrame.getMapMode() == MapMode.TEST_ROUTE
        || mainFrame.getMapMode() == MapMode.ADD_BUS
        || mainFrame.getMapMode() == MapMode.EDIT_BUS
        || mainFrame.getMapMode() == MapMode.COPY_BUS
        || mainFrame.getMapMode() == MapMode.EDIT_POINT) {
      if (dragX != MapConstants.NULL && dragY != MapConstants.NULL) {
        int diffX = x - dragX;
        int diffY = y - dragY;
        dragX = x;
        dragY = y;

        startX -= diffX;
        startY -= diffY;
        repaint();
      }
    }
    if (mainFrame.getMapMode() == MapMode.ADD_BUS
        || mainFrame.getMapMode() == MapMode.EDIT_BUS
        || mainFrame.getMapMode() == MapMode.COPY_BUS
        || mainFrame.getMapMode() == MapMode.EDIT_POINT) {
      if (dragPoint != null) {
        List<PointInfo> oldMapPoint = selectMapPoint(dragPoint.getAxisX(), dragPoint.getAxisY());

        dragPoint.setAxisX(x + startX);
        dragPoint.setAxisY(y + startY);
        dragPoint.setEdited();
        if (dragPoint.equals(pointSelect)) {
          mainFrame.onSelectPoint(pointSelect);
        }

        List<PointInfo> newMapPoint = selectMapPoint(dragPoint.getAxisX(), dragPoint.getAxisY());
        if (!oldMapPoint.equals(newMapPoint)) {
          oldMapPoint.remove(dragPoint);
          newMapPoint.add(dragPoint);
        }

        List<BusLine> busLines = findBusLines(dragPoint);
        for (int i = 0; i < busLines.size(); i++) {
          BusLine busLine = busLines.get(i);
          if (busLine.getP1Id() == dragPoint.getPId()) {
            busLine.setX1(dragPoint.getAxisX());
            busLine.setY1(dragPoint.getAxisY());
          } else if (busLine.getP2Id() == dragPoint.getPId()) {
            busLine.setX2(dragPoint.getAxisX());
            busLine.setY2(dragPoint.getAxisY());
          }
        }
        repaint();
      }
    }
  }
예제 #3
0
 private BusLine addBusLine(PointInfo p1, PointInfo p2) {
   if (p1.equals(p2)) {
     return null;
   }
   BusLine aBusLine = findBusLine(p1, p2);
   if (aBusLine == null) {
     aBusLine =
         new BusLine(
             p1.getPId(),
             p2.getPId(),
             p1.getAxisX(),
             p1.getAxisY(),
             p2.getAxisX(),
             p2.getAxisY(),
             StringUtil.distance(p1.getAxisX(), p1.getAxisY(), p2.getAxisX(), p2.getAxisY()),
             busSelect.getBusId(),
             busSelect.getBusNoTh(),
             busSelect.getBusNoEn(),
             busSelect.getBusPrice(),
             mainFrame.getLineType(),
             "",
             "",
             "",
             "");
     busSelect.getBusLine().add(aBusLine);
     busSelect.setEdited();
     mainFrame.onSelectBus(busSelect);
   }
   return aBusLine;
 }
예제 #4
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));
      }
    }
  }
예제 #5
0
 private void updateStatusMessage() {
   String msg = "";
   if (dragX != MapConstants.NULL && dragY != MapConstants.NULL) {
     msg =
         "Moving the map to ("
             + StringUtil.toNumString(startX)
             + " : "
             + StringUtil.toNumString(startY)
             + " - "
             + StringUtil.toNumString(endX)
             + " : "
             + StringUtil.toNumString(endY)
             + ") of ("
             + StringUtil.toNumString(MAP_MAX_WIDTH)
             + " : "
             + StringUtil.toNumString(MAP_MAX_HEIGHT)
             + ")";
   } else if (dragPoint != null) {
     msg =
         "Moving the point to ("
             + StringUtil.toNumString(dragPoint.getAxisX())
             + " : "
             + StringUtil.toNumString(dragPoint.getAxisY())
             + ")";
   } else if (pointSelect != null) {
     if (pointSelect.getType() == PointType.LINK) {
       msg =
           "Linked Point ("
               + StringUtil.toNumString(pointSelect.getAxisX())
               + " : "
               + StringUtil.toNumString(pointSelect.getAxisY())
               + ")";
     } else if (pointSelect.getType() == PointType.NAME) {
       msg =
           "Named Point ("
               + StringUtil.toNumString(pointSelect.getAxisX())
               + " : "
               + StringUtil.toNumString(pointSelect.getAxisY())
               + ")";
     }
   } else {
     msg =
         "Now showing ("
             + StringUtil.toNumString(startX)
             + " : "
             + StringUtil.toNumString(startY)
             + " - "
             + StringUtil.toNumString(endX)
             + " : "
             + StringUtil.toNumString(endY)
             + ") of ("
             + StringUtil.toNumString(MAP_MAX_WIDTH)
             + " : "
             + StringUtil.toNumString(MAP_MAX_HEIGHT)
             + ")";
   }
   MapStatusBar.setMessage(msg);
 }