Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Add additional rendering options (similar to GPX track rendering)
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Jan 16, 2023
1 parent 1627fb2 commit ed23a33
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,8 @@ public void destroy() {
.forEach(layer -> MainApplication.getLayerManager().removeLayer(layer));
}
MapFrame frame = MainApplication.getMap();
if (frame != null) {
toggleDialog.forEach(frame::removeToggleDialog);
}
this.mapFrameInitialized(frame, null);
destroyables.forEach(Destroyable::destroy);
toggleDialog.forEach(ToggleDialog::destroy);
}

private void clearMenues(JMenu menu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,10 @@ public class MapillaryPreferenceSetting implements SubPreferenceSetting, Mapilla
I18n.tr("When opening Mapillary image in web browser, show the blur editor instead of the image viewer"),
MapillaryProperties.IMAGE_LINK_TO_BLUR_EDITOR.get());

private final JCheckBox colorImagesByCaptureDate = new JCheckBox(
I18n.trc("Checkbox label in JOSM settings", "Color images by capture date"),
MapillaryProperties.COLOR_BY_CAPTURE_DATE.get());

private final JCheckBox useComputedLocations = new JCheckBox(
I18n.trc("Checkbox label in JOSM settings", "Use computed location information"),
MapillaryProperties.USE_COMPUTED_LOCATIONS.get());

private final JCheckBox useCustomRenderer = new JCheckBox(
I18n.trc("Checkbox label in JOSM settings", "Use the custom Mapillary renderer"),
MapillaryProperties.USE_CUSTOM_RENDERER.get());

private final SpinnerNumberModel maxDistanceForChangesetSource = new SpinnerNumberModel(
MapillaryProperties.MAXIMUM_DISTANCE_FOR_CHANGESET_SOURCE.get().doubleValue(), 0.0,
2 * WGS84Datum.INSTANCE.getEllipsoid().a, 0.5);
Expand Down Expand Up @@ -122,7 +114,6 @@ public void addGui(PreferenceTabbedPane gui) {
mainPanel.add(displayHour, GBC.eol());
mainPanel.add(moveTo, GBC.eol());
mainPanel.add(imageLinkToBlurEditor, GBC.eol());
mainPanel.add(colorImagesByCaptureDate, GBC.eol());
mainPanel.add(this.useComputedLocations, GBC.eol());
this.useComputedLocations.setToolTipText(I18n.tr("Requires JOSM restart"));

Expand Down Expand Up @@ -151,9 +142,6 @@ public void addGui(PreferenceTabbedPane gui) {
mainPanel.add(numberOfImagesToDraw, GBC.eol());
ExpertToggleAction.addVisibilitySwitcher(numberOfImagesToDraw);

mainPanel.add(this.useCustomRenderer, GBC.eol());
ExpertToggleAction.addVisibilitySwitcher(this.useCustomRenderer);

developer.addActionListener(e -> DeveloperToggleAction.getInstance().actionPerformed(null));

ExpertToggleAction.addVisibilitySwitcher(developer);
Expand All @@ -162,8 +150,8 @@ public void addGui(PreferenceTabbedPane gui) {
developer.setVisible(true);
}
MapillaryColorScheme.styleAsDefaultPanel(mainPanel, this.displayHour, this.moveTo, this.imageLinkToBlurEditor,
this.colorImagesByCaptureDate, this.useComputedLocations, this.developer, preFetchPanel,
changesetSourceDistancePanel, numberOfImagesToDraw, this.useCustomRenderer, this.requiresLogin);
this.useComputedLocations, this.developer, preFetchPanel, changesetSourceDistancePanel,
numberOfImagesToDraw, this.requiresLogin);
mainPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.BOTH));

container.add(mainPanel, BorderLayout.CENTER);
Expand Down Expand Up @@ -213,22 +201,18 @@ public void onLogout() {
loginPanel.repaint();
}

@SuppressWarnings("PMD.ShortMethodName")
@Override
public boolean ok() {
DeveloperToggleAction.getInstance().setDeveloper(developer.isSelected());
MapillaryProperties.DISPLAY_HOUR.put(displayHour.isSelected());
MapillaryProperties.MOVE_TO_IMG.put(moveTo.isSelected());
MapillaryProperties.IMAGE_LINK_TO_BLUR_EDITOR.put(imageLinkToBlurEditor.isSelected());
MapillaryProperties.PRE_FETCH_IMAGE_COUNT.put(preFetchSize.getNumber().intValue());
MapillaryProperties.COLOR_BY_CAPTURE_DATE.put(colorImagesByCaptureDate.isSelected());

MapillaryProperties.MAXIMUM_DRAW_IMAGES.put(maxForImagesToDraw.getNumber().intValue());
MapillaryProperties.MAXIMUM_DISTANCE_FOR_CHANGESET_SOURCE
.put(maxDistanceForChangesetSource.getNumber().doubleValue());

MapillaryProperties.USE_CUSTOM_RENDERER.put(this.useCustomRenderer.isSelected());

if (ExpertToggleAction.isExpert()) {
MapillaryProperties.MAXIMUM_DISTANCE_FOR_CHANGESET_SOURCE
.put(this.maxDistanceForChangesetSource.getNumber().doubleValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapillary.gui.layer;

import static org.openstreetmap.josm.tools.I18n.tr;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;

import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.Layer;
import org.openstreetmap.josm.gui.layer.gpx.CustomizeDrawingAction;
import org.openstreetmap.josm.gui.util.GuiHelper;
import org.openstreetmap.josm.plugins.mapillary.gui.preferences.display.MapillaryGPXSettingsPanel;
import org.openstreetmap.josm.tools.ImageProvider;

/**
* Customize Mapillary drawing
*/
public class MapillaryCustomizeDrawingAction extends AbstractAction
implements Layer.LayerAction, Layer.MultiLayerAction {
private transient List<Layer> layers;

/**
* Create a new {@link CustomizeDrawingAction}
*
* @param l The layers that should be customized
*/
public MapillaryCustomizeDrawingAction(List<Layer> l) {
this();
layers = l;
}

/**
* Create a new {@link CustomizeDrawingAction}
*
* @param l The layer that should be customized
*/
public MapillaryCustomizeDrawingAction(Layer l) {
this();
layers = new LinkedList<>();
layers.add(l);
}

private MapillaryCustomizeDrawingAction() {
super(tr("Customize Mapillary track drawing"));
new ImageProvider("preference").getResource().attachImageIcon(this, true);
}

@Override
public boolean supportLayers(List<Layer> layers) {
return layers.stream().allMatch(MapillaryLayer.class::isInstance);
}

@Override
public Component createMenuComponent() {
return new JMenuItem(this);
}

@Override
public Action getMultiLayerAction(List<Layer> layers) {
return new CustomizeDrawingAction(layers);
}

@Override
public void actionPerformed(ActionEvent e) {
MapillaryGPXSettingsPanel panel = new MapillaryGPXSettingsPanel(layers.stream()
.filter(MapillaryLayer.class::isInstance).map(MapillaryLayer.class::cast).collect(Collectors.toList()));
JScrollPane scrollpane = GuiHelper.embedInVerticalScrollPane(panel);
scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
int answer = JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), scrollpane,
tr("Customize track drawing"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.CLOSED_OPTION) {
return;
}
panel.savePreferences();
MainApplication.getMainPanel().repaint();
layers.forEach(Layer::invalidate);
}

}
Loading

0 comments on commit ed23a33

Please sign in to comment.