コード例 #1
0
  /**
   * Save the actual configuration
   *
   * @param confToSave The configuration to save
   */
  static synchronized void saveConfiguration(PerformanceParameters confToSave)
      throws IOException, BackingStoreException {

    if (!loadConfiguration().getVMParameters().equals(confToSave.getVMParameters())) {
      confToSave.vmParameters.save();
    }

    Config configuration = EngineConfig.instance().load();
    Preferences preferences = configuration.preferences();

    Path cachePath = confToSave.getCachePath();

    if (!Files.exists(cachePath)) {
      Files.createDirectories(cachePath);
    }

    if (Files.exists(cachePath)) {
      preferences.put(
          SystemUtils.SNAP_CACHE_DIR_PROPERTY_NAME, cachePath.toAbsolutePath().toString());
    } else {
      SystemUtils.LOG.severe(
          "Directory for cache path does not exist and could not be created: "
              + cachePath.toAbsolutePath().toString());
    }

    preferences.putInt(PROPERTY_JAI_PARALLELISM, confToSave.getNbThreads());
    preferences.putInt(PROPERTY_DEFAULT_TILE_SIZE, confToSave.getDefaultTileSize());
    preferences.putInt(PROPERTY_JAI_CACHE_SIZE, confToSave.getCacheSize());
    JAI.getDefaultInstance().getTileCache().setMemoryCapacity(confToSave.getCacheSize());
    preferences.flush();
  }
コード例 #2
0
 @After
 public void tearDown() throws Exception {
   if (oldValue != null) {
     Config.instance().preferences().put(GPF.DISABLE_TILE_CACHE_PROPERTY, oldValue);
   } else {
     Config.instance().preferences().remove(GPF.DISABLE_TILE_CACHE_PROPERTY);
   }
 }
コード例 #3
0
  /**
   * Reads the parameters files and system settings to retreive the actual performance parameters.
   * It updates the "actualParameters" according to the configuration loaded.
   *
   * @return the actual performance parameters, loaded by this method
   */
  static synchronized PerformanceParameters loadConfiguration() {

    Config configuration = Config.instance().load();
    Preferences preferences = configuration.preferences();

    PerformanceParameters actualParameters = new PerformanceParameters();

    VMParameters netBeansVmParameters = VMParameters.load();
    actualParameters.setVMParameters(netBeansVmParameters.toString());
    actualParameters.setCachePath(SystemUtils.getCacheDir().toPath());

    final int defaultNbThreads = JavaSystemInfos.getInstance().getNbCPUs();
    actualParameters.setNbThreads(preferences.getInt(PROPERTY_JAI_PARALLELISM, defaultNbThreads));
    actualParameters.setDefaultTileSize(preferences.getInt(PROPERTY_DEFAULT_TILE_SIZE, 0));
    actualParameters.setCacheSize(preferences.getInt(PROPERTY_JAI_CACHE_SIZE, 0));

    return actualParameters;
  }
コード例 #4
0
 protected Path getIODir() {
   if (ioDir == null) {
     ioDir =
         Paths.get(
             Config.instance()
                 .preferences()
                 .get(PREFERENCES_KEY_IO_DIR, getColorPalettesDir().toString()));
   }
   return ioDir;
 }
コード例 #5
0
 public static void configurePreferredTileSize(Product product) {
   Dimension newSize =
       getConfiguredTileSize(
           product,
           Config.instance().preferences().get(SYSPROP_READER_TILE_WIDTH, null),
           Config.instance().preferences().get(SYSPROP_READER_TILE_HEIGHT, null));
   if (newSize != null) {
     Dimension oldSize = product.getPreferredTileSize();
     if (oldSize == null) {
       product.setPreferredTileSize(newSize);
       SystemUtils.LOG.fine(
           String.format(
               "Product '%s': tile size set to %d x %d pixels",
               product.getName(), newSize.width, newSize.height));
     } else if (!oldSize.equals(newSize)) {
       product.setPreferredTileSize(newSize);
       SystemUtils.LOG.fine(
           String.format(
               "Product '%s': tile size set to %d x %d pixels, was %d x %d pixels",
               product.getName(), newSize.width, newSize.height, oldSize.width, oldSize.height));
     }
   }
 }
コード例 #6
0
 private void setIODir(final File dir) {
   ioDir = dir.toPath();
   Config.instance().preferences().put(PREFERENCES_KEY_IO_DIR, ioDir.toString());
 }
コード例 #7
0
 /**
  * Launches the default browser to display the web site. Invoked when a command action is
  * performed.
  *
  * @param event the command event.
  */
 @Override
 public void actionPerformed(ActionEvent event) {
   DesktopHelper.browse(Config.instance().preferences().get("snap.homePageUrl", DEFAULT_PAGE_URL));
 }
コード例 #8
0
 @Test
 public void testThatTileCacheCanBeEnabled() {
   Config.instance().preferences().put(GPF.DISABLE_TILE_CACHE_PROPERTY, "false");
   assertNotNull(createOpImage().getTileCache());
 }
コード例 #9
0
 @Before
 public void setUp() throws Exception {
   oldValue = Config.instance().preferences().get(GPF.DISABLE_TILE_CACHE_PROPERTY, null);
 }