public void mouseMoved(MouseEvent e) { MapStatusBar.setCoordinate( StringUtil.toNumString(e.getX()) + " : " + StringUtil.toNumString(e.getY())); dragX = MapConstants.NULL; dragY = MapConstants.NULL; updateStatusMessage(); }
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); }
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(); } } }
public void mouseReleased(MouseEvent e) { if (this.contains(e.getPoint()) == false) { MapStatusBar.setCoordinate(""); } if (e.getButton() == MapConstants.MOUSE_BUTTON_LEFT && e.getClickCount() == 1) { if (mainFrame.getMapMode() == MapMode.VIEW || mainFrame.getMapMode() == MapMode.TEST_ROUTE) { dragX = MapConstants.NULL; dragY = MapConstants.NULL; updateStatusMessage(); } else if (mainFrame.getMapMode() == MapMode.ADD_BUS || mainFrame.getMapMode() == MapMode.EDIT_BUS || mainFrame.getMapMode() == MapMode.COPY_BUS || mainFrame.getMapMode() == MapMode.EDIT_POINT) { dragX = MapConstants.NULL; dragY = MapConstants.NULL; dragPoint = null; updateStatusMessage(); } } }
public void mouseExited(MouseEvent e) { MapStatusBar.setCoordinate(""); }