static {
   if (gov.nasa.worldwind.Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty(
         "com.apple.mrj.application.apple.menu.about.name", "World Wind Multi-Window Analysis");
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
  /**
   * Initiates a retrieval of the model referenced by this placemark. Once the resource is retrieved
   * and loaded, this calls <code>{@link #setColladaRoot(ColladaRoot)}</code> to specify this link's
   * new network resource, and sends an <code>
   * {@link gov.nasa.worldwind.avlist.AVKey#RETRIEVAL_STATE_SUCCESSFUL}</code> property change event
   * to this link's property change listeners.
   *
   * <p>This does nothing if this <code>KMLNetworkLink</code> has no <code>KMLLink</code>.
   *
   * @param address the address of the resource to retrieve
   */
  protected void retrieveModel(String address) throws IOException, XMLStreamException {
    Object o = this.parent.getRoot().resolveReference(address);
    if (o == null) return;

    ColladaRoot root = ColladaRoot.createAndParse(o);
    if (root == null) return;

    this.setColladaRoot(root);
    this.resourceRetrievalTime.set(System.currentTimeMillis());
    this.parent.getRoot().requestRedraw();
  }
  private void commonInitializer(File file) throws IOException {
    File parent = file.getParentFile();
    if (parent == null) parent = new File(System.getProperty("user.dir"));
    if (!parent.canWrite()) {
      String msg = Logging.getMessage("generic.FolderNoWritePermission", parent.getAbsolutePath());
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.targetFile = new RandomAccessFile(file, "rw");
    this.theChannel = this.targetFile.getChannel();
  }
  /**
   * Create a new WebView.
   *
   * @param frameSize The size of the WebView rectangle.
   * @throws UnsupportedOperationException if this class is instantiated on a non-Windows operating
   *     system.
   * @throws WWRuntimeException if creating the native web browser window fails for any reason. For
   *     example, because the process has run out of User Object handles (see documentation <a
   *     href="#limits">above</a>).
   */
  public WindowsWebView(Dimension frameSize) {
    if (frameSize == null) {
      String message = Logging.getMessage("nullValue.SizeIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (!Configuration.isWindowsOS()) {
      String message =
          Logging.getMessage(
              "NativeLib.UnsupportedOperatingSystem",
              "Windows WebView",
              System.getProperty("os.name"));
      Logging.logger().severe(message);
      throw new UnsupportedOperationException(message);
    }

    this.frameSize = frameSize;

    try {
      // Increment the instance counter
      instances.incrementAndGet();

      // Make sure that the message loop thread is running
      this.ensureMessageLoopRunning();

      // Create the web view
      this.webViewWindowPtr = WindowsWebViewJNI.newWebViewWindow(webViewMessageLoop);
      if (this.webViewWindowPtr == 0) {
        String message = Logging.getMessage("WebView.NativeExceptionInitializingWebView");
        Logging.logger().severe(message);
        throw new WWRuntimeException(message);
      }

      WindowsWebViewJNI.setFrameSize(
          this.webViewWindowPtr, this.frameSize.width, this.frameSize.height);

      this.observerPtr = WindowsWebViewJNI.newNotificationAdapter(this);

      WindowsWebViewJNI.addWindowUpdateObserver(this.webViewWindowPtr, observerPtr);
    } catch (RuntimeException e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    } catch (Error e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    }
  }
  @SuppressWarnings({"ResultOfMethodCallIgnored"})
  protected static void markFileUsed(java.io.File file) {
    if (file == null) return;

    long currentTime = System.currentTimeMillis();

    if (file.canWrite()) file.setLastModified(currentTime);

    if (file.isDirectory()) return;

    java.io.File parent = file.getParentFile();
    if (parent != null && parent.canWrite()) parent.setLastModified(currentTime);
  }
  protected static String propertyToPath(String propName) {
    if (propName == null || propName.length() == 0) return null;

    String prop = System.getProperty(propName);
    if (prop != null) return prop;

    if (propName.equalsIgnoreCase("gov.nasa.worldwind.platform.alluser.store"))
      return determineAllUserLocation();

    if (propName.equalsIgnoreCase("gov.nasa.worldwind.platform.user.store"))
      return determineSingleUserLocation();

    return null;
  }
  /**
   * {@inheritDoc} Overridden to set the link expiration time based on HTTP headers after the image
   * has been retrieved.
   */
  protected BasicWWTexture initializeTexture() {
    BasicWWTexture ret = super.initializeTexture();
    if (this.texture != null) {
      this.iconRetrievalTime = System.currentTimeMillis();

      String path = this.resolveHref();

      // Query the KMLRoot for the expiration time.
      long expiration = this.parent.getRoot().getExpiration(path);

      // Set the Icon's expiration. This has no effect if the refreshMode is not onExpire.
      this.parent.getIcon().setExpirationTime(expiration);
    }
    return ret;
  }
 protected static String determineAllUserLocation() {
   if (gov.nasa.worldwind.Configuration.isMacOS()) {
     return "/Library/Caches";
   } else if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
     String path = System.getenv("ALLUSERSPROFILE");
     if (path == null) {
       Logging.logger().severe("generic.AllUsersWindowsProfileNotKnown");
       return null;
     }
     return path + (Configuration.isWindows7OS() ? "" : "\\Application Data");
   } else if (gov.nasa.worldwind.Configuration.isLinuxOS()
       || gov.nasa.worldwind.Configuration.isUnixOS()
       || gov.nasa.worldwind.Configuration.isSolarisOS()) {
     return "/var/cache/";
   } else {
     Logging.logger().warning("generic.UnknownOperatingSystem");
     return null;
   }
 }
 protected double[] resizeArray(double[] oldArray) {
   int newSize = 2 * oldArray.length;
   double[] newArray = new double[newSize];
   System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
   return newArray;
 }
 protected int[] resizeArray(int[] oldArray) {
   int newSize = 2 * oldArray.length;
   int[] newArray = new int[newSize];
   System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
   return newArray;
 }
 protected void updateModifiedTime() {
   this.lastModifiedTime = System.currentTimeMillis();
 }
 protected static String getUserHomeDir() {
   return System.getProperty("user.home");
 }