/**
   * Called after Main.mapFrame is initialized. (After the first data is loaded). You can use this
   * callback to tweak the newFrame to your needs, as example install an alternative Painter.
   */
  @Override
  public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    super.mapFrameInitialized(oldFrame, newFrame);

    if (newFrame != null) {
      ElevationMapMode eleMode = new ElevationMapMode("Elevation profile", newFrame);
      newFrame.addMapMode(new IconToggleButton(eleMode));
      ElevationProfileDialog eleProfileDlg = new ElevationProfileDialog();
      eleProfileDlg.addModelListener(eleMode);
      eleProfileDlg.setProfileLayer(getCurrentLayer());
      newFrame.addToggleDialog(eleProfileDlg);
    }
  }
Пример #2
0
  /**
   * Constructs a new {@code MapFrame}.
   *
   * @param contentPane The content pane used to register shortcuts in its {@link
   *     javax.swing.InputMap} and {@link javax.swing.ActionMap}
   * @param viewportData the initial viewport of the map. Can be null, then the viewport is derived
   *     from the layer data.
   */
  public MapFrame(JPanel contentPane, ViewportData viewportData) {
    setSize(400, 400);
    setLayout(new BorderLayout());

    mapView = new MapView(contentPane, viewportData);
    new FileDrop(mapView);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);

    leftPanel = new JPanel();
    leftPanel.setLayout(new GridBagLayout());
    leftPanel.add(mapView, GBC.std().fill());
    splitPane.setLeftComponent(leftPanel);

    dialogsPanel = new DialogsPanel(splitPane);
    splitPane.setRightComponent(dialogsPanel);

    /** All additional space goes to the mapView */
    splitPane.setResizeWeight(1.0);

    /** Some beautifications. */
    splitPane.setDividerSize(5);
    splitPane.setBorder(null);
    splitPane.setUI(
        new BasicSplitPaneUI() {
          @Override
          public BasicSplitPaneDivider createDefaultDivider() {
            return new BasicSplitPaneDivider(this) {
              @Override
              public void setBorder(Border b) {}
            };
          }
        });

    // JSplitPane supports F6 and F8 shortcuts by default, but we need them for Audio actions
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), new Object());
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), new Object());

    add(splitPane, BorderLayout.CENTER);

    dialogsPanel.setLayout(new BoxLayout(dialogsPanel, BoxLayout.Y_AXIS));
    dialogsPanel.setPreferredSize(
        new Dimension(Main.pref.getInteger("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH), 0));
    dialogsPanel.setMinimumSize(new Dimension(24, 0));
    mapView.setMinimumSize(new Dimension(10, 0));

    // toolBarActions, map mode buttons
    addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
    addMapMode(new IconToggleButton(new LassoModeAction(), true));
    addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
    addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
    addMapMode(new IconToggleButton(new DeleteAction(this), true));
    addMapMode(new IconToggleButton(new ParallelWayAction(this), true));
    addMapMode(new IconToggleButton(new ExtrudeAction(this), true));
    addMapMode(new IconToggleButton(new ImproveWayAccuracyAction(Main.map), false));
    toolBarActionsGroup.setSelected(allMapModeButtons.get(0).getModel(), true);
    toolBarActions.setFloatable(false);

    // toolBarToggles, toggle dialog buttons
    LayerListDialog.createInstance(this);
    addToggleDialog(LayerListDialog.getInstance());
    addToggleDialog(propertiesDialog = new PropertiesDialog());
    addToggleDialog(selectionListDialog = new SelectionListDialog());
    addToggleDialog(relationListDialog = new RelationListDialog());
    addToggleDialog(new CommandStackDialog());
    addToggleDialog(new UserListDialog());
    addToggleDialog(new HistoryDialog(), true);
    addToggleDialog(conflictDialog = new ConflictDialog());
    addToggleDialog(validatorDialog = new ValidatorDialog());
    addToggleDialog(filterDialog = new FilterDialog());
    addToggleDialog(new ChangesetDialog(), true);
    addToggleDialog(new MapPaintDialog());
    toolBarToggle.setFloatable(false);

    // status line below the map
    statusLine = new MapStatus(this);
    MapView.addLayerChangeListener(this);

    boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;
    if (unregisterTab) {
      for (JComponent c : allDialogButtons) c.setFocusTraversalKeysEnabled(false);
      for (JComponent c : allMapModeButtons) c.setFocusTraversalKeysEnabled(false);
    }
  }