Esempio n. 1
0
  protected void onScaleChanged() {
    if (mapBackground != null && currentPoint != null) {
      final double latitude = DataProvider.LATITUDE.getValue(currentPoint) + panLatitude;
      final double longitude = DataProvider.LONGITUDE.getValue(currentPoint) + panLong;
      super.onScaleChanged(
          mapBackground.getScaleX(), mapBackground.getScaleY(latitude), longitude, latitude);
    } else {
      super.onScaleChanged();
    }

    final double widthInMeter =
        Utils.distance(
            getYAxis().minValue, getXAxis().maxValue, getYAxis().maxValue, getXAxis().maxValue);
    if (widthInMeter < 1) {
      scaleSizeInPixel = 0;
      return;
    }

    final double availableLengthInMeter = widthInMeter * 0.9;

    scaleConfiguration =
        Preferences.getInstance().getUnitsConverter().getScaleDistance(availableLengthInMeter);

    scaleSizeInPixel = (int) ((scaleConfiguration.lengthInSourceUnits / widthInMeter) * width);
  }
Esempio n. 2
0
 /*
  * This resets the map whenever reset is selected.
  */
 public void reset() {
   mapPanel.clearList();
   pane.getHorizontalScrollBar().setValue(0);
   pane.getVerticalScrollBar().setValue(0);
   list1.setSelectedIndex(0);
   list2.setSelectedIndex(0);
   mapPanel.repaint();
 }
Esempio n. 3
0
 public void setMapBackground(final MapBackground background) {
   if (mapBackground != null) {
     mapBackground.stop();
   }
   if (background != null) {
     background.setMainCanvas(mainCanvas);
     background.start();
   }
   mapBackground = background;
   onScaleChanged();
 }
Esempio n. 4
0
 /*
  * Creates the map panel to display the campus map.
  */
 public void setMapPanel() {
   mapPanel = new MapBackground();
   mapPanel.setPreferredSize(new Dimension(WIDTH - 15, HEIGHT - 100));
   // Create a scroll pane then add in mapPanel
   pane = new JScrollPane(mapPanel);
   pane.setPreferredSize(new Dimension(WIDTH - 15, HEIGHT - 100));
 }
Esempio n. 5
0
 protected void doPaintBackground(final Graphics g) {
   if (mapBackground != null) {
     mapBackground.paint(
         g,
         DataProvider.LONGITUDE.getValue(currentPoint) + panLong,
         DataProvider.LATITUDE.getValue(currentPoint) + panLatitude,
         (width - getMarginLeft() - getMarginRight()) / 2 + getMarginLeft(),
         (height - getMarginTop() - getMarginBottom()) / 2 + getMarginTop());
   }
 }
Esempio n. 6
0
  /*
   * Sets up a combo box with a list of all the UW buildings
   * The buildings are sorted alphabetically by abbreviated name
   */
  public void setList(JComboBox<String> list) {
    Map<String, String> map = mapPanel.buildingNames();

    // list = new JComboBox<String>();
    list.setPreferredSize(new Dimension(360, 30));

    Set<String> abbreviated = new TreeSet<String>(map.keySet());

    for (String str : abbreviated) {
      String name = str + ": " + map.get(str);
      list.addItem(name);
    }
  }
Esempio n. 7
0
  /*
   * When the 'find path' button is selected, this handles actually finding and
   * displaying the path for the two given buildings.
   */
  public void findPath() {
    // Get the starting location and destination from the combo boxes
    String start = String.valueOf(list1.getSelectedItem());
    String end = String.valueOf(list2.getSelectedItem());

    // Before new path is displayed, the old path must be removed
    mapPanel.clearList();

    // This handles calling the appropriate methods which will get the right
    // data and draw the paths on the map
    mapPanel.setLocations(start, end);
    mapPanel.getList();
    setHorizBar(mapPanel.horizontalPos());
    setVertBar(mapPanel.verticalPos());

    // Must repaint for the paths to show up immediately!!
    mapPanel.repaint();
  }