Changeset 34774 in osm for applications/editors/josm
- Timestamp:
- 2018-12-08T01:29:28+01:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBuilder.java
r34429 r34774 10 10 import java.util.Map; 11 11 import java.util.concurrent.Callable; 12 import java.util.concurrent.ExecutionException; 12 13 import java.util.concurrent.ConcurrentHashMap; 13 14 import java.util.concurrent.ExecutorService; … … 16 17 17 18 import org.apache.log4j.Logger; 19 import org.openstreetmap.josm.gui.MainApplication; 20 import java.util.concurrent.ExecutionException; 18 21 import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage; 19 22 import org.openstreetmap.josm.plugins.streetside.StreetsideCubemap; … … 28 31 29 32 // JavaFX access in Java 8 30 @SuppressWarnings("restriction")31 33 public class CubemapBuilder implements ITileDownloadingTaskListener, StreetsideDataListener { 32 34 … … 40 42 41 43 private Map<String, BufferedImage> tileImages = new ConcurrentHashMap<>(); 44 private ExecutorService pool; 42 45 43 46 private int currentTileCount = 0; … … 112 115 113 116 public void downloadCubemapImages(String imageId) { 117 if(StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().getScene() != StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().getLoadingScene()) { 118 StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().setScene( 119 StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().getLoadingScene() 120 ); 121 } 114 122 115 123 final int maxThreadCount = StreetsideProperties.DOWNLOAD_CUBEFACE_TILES_TOGETHER.get()?6:6 * CubemapUtils.getMaxCols() * CubemapUtils.getMaxRows(); … … 124 132 long startTime = System.currentTimeMillis(); 125 133 134 if(CubemapBuilder.getInstance().getTileImages().keySet().size() > 0) { 135 pool.shutdownNow(); 136 CubemapBuilder.getInstance().resetTileImages(); 137 } 138 126 139 try { 127 140 128 ExecutorServicepool = Executors.newFixedThreadPool(maxThreadCount);141 pool = Executors.newFixedThreadPool(maxThreadCount); 129 142 List<Callable<List<String>>> tasks = new ArrayList<>(maxThreadCount); 130 143 … … 151 164 } 152 165 } 153 154 List<Future<List<String>>> results = pool.invokeAll(tasks); 155 for (Future<List<String>> ff : results) { 156 if (StreetsideProperties.DEBUGING_ENABLED.get() && results!=null) { 157 logger.debug( 158 MessageFormat.format( 159 "Completed tile downloading task {0} in {1} seconds.", ff.get().toString(), 160 ((System.currentTimeMillis()) - startTime)/1000) 161 ); 162 } else { 163 logger.error(MessageFormat.format("Results of downloading tasks for image id {0} are null!", imageId)); 164 } 165 } 166 167 // launch 16-tiled (high-res) downloading tasks 166 // launch 16-tiled (high-res) downloading tasks 168 167 } else if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) { 169 168 … … 181 180 } // finish preparing tasks for invocation 182 181 183 List<Future<List<String>>> results = pool.invokeAll(tasks); 184 for (Future<List<String>> ff : results) { 185 if (StreetsideProperties.DEBUGING_ENABLED.get() && results!=null) { 186 logger.debug( 187 MessageFormat.format( 188 "Completed tile downloading task {0} in {1} seconds.", ff.get().toString(), 189 ((System.currentTimeMillis()) - startTime)/1000) 190 ); 191 } else { 192 logger.error(MessageFormat.format("Results of downloading tasks for image id {0} are null!", imageId)); 182 // execute tasks 183 MainApplication.worker.submit(() -> { 184 try { 185 List<Future<List<String>>> results = pool.invokeAll(tasks); 186 187 if(StreetsideProperties.DEBUGING_ENABLED.get() && results != null) { 188 for (Future<List<String>> ff : results) { 189 try { 190 logger.debug(MessageFormat.format("Completed tile downloading task {0} in {1} seconds.",ff.get().toString(), 191 (System.currentTimeMillis() - startTime)/1000)); 192 } catch (ExecutionException e) { 193 logger.error(e); 194 } 195 } 196 } 197 } catch (InterruptedException e) { 198 logger.error(e); 193 199 } 194 } 200 }); 195 201 } catch (Exception ee) { 196 202 fails++; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/ThreeSixtyDegreeViewerPanel.java
r34416 r34774 11 11 import javafx.scene.PointLight; 12 12 import javafx.scene.Scene; 13 import javafx.scene.control.Label; 13 14 import javafx.scene.SceneAntialiasing; 14 15 import javafx.scene.control.TextArea; … … 18 19 import javafx.scene.layout.VBox; 19 20 import javafx.scene.paint.Color; 21 import javafx.scene.text.Font; 22 import javafx.scene.text.FontWeight; 20 23 21 24 @SuppressWarnings("restriction") … … 27 30 28 31 private static Scene defaultScene; 32 private static Scene loadingScene; 29 33 30 34 private static Group root; … … 80 84 subGroup.getChildren().add(cameraTransform); 81 85 86 createLoadingScene(); 87 82 88 Platform.runLater(new Runnable() { 83 89 @Override … … 199 205 } 200 206 207 private static void createLoadingScene() { 208 Label label = new Label(" Loading..."); 209 label.setFont(Font.font(null, FontWeight.BOLD, 14)); 210 VBox vbox = new VBox(label); 211 loadingScene = new Scene(vbox, 200, 100); 212 } 213 201 214 public CubemapBox getCubemapBox() { 202 215 if (cubemapBox == null) { … … 214 227 return cubemapScene; 215 228 } 229 230 public Scene getLoadingScene() { 231 return loadingScene; 232 } 216 233 }
Note:
See TracChangeset
for help on using the changeset viewer.