title: Alternative for removed impl_isTreeVisible()
body: <p>We are reliant on Node.impl_isTreeVisible() because isVisible does not work properly (or at least the way we want it to).</p>
  
  <pre><code>/**
   * @treatAsPrivate implementation detail
   * @deprecated This is an internal API that is not intended for use and will be removed in the next version
   */
  @Deprecated
  public final boolean impl_isTreeVisible() {
      return impl_treeVisibleProperty().get();
  }
  </code></pre>
  
  <p>We have a custom Node which contains a Plot. This gets continuous data. We want to avoid to update the plot if it is not visible (still managed/rendered, but hidden).
  If the node is placed on a tab which is not selected, hence it is not visible in the window, then using isVisible still returns true. This causes the Node on the selected tab to be rendred every time the plot is updated.</p>
  
  <p>This will evaluate to true even though the node is not visible in the application window.</p>
  
  <pre><code>if (isVisible()) {
      updatePlot()
  }
  </code></pre>
  
  <p>So we have been using the following which works as we want it.</p>
  
  <pre><code>if (impl_isTreeVisible()) {
      updatePlot()
  }
  </code></pre>
  
  <p>However this will no longer work in Java 9 as such methods are removed. Is there a new approach to this in Java 9?</p>
  
  <p><strong>Update</strong>:
  Looking at Java 9 source code for javafx.scene.Node I have found the method isTreeVisible(), which looks like a replacement for impl_isTreeVisible. However looking at the Javadoc I cannot find this isTreeVisible().
  <a href="http://download.java.net/java/jdk9/docs/api/javafx/scene/Node.html" rel="nofollow noreferrer">http://download.java.net/java/jdk9/docs/api/javafx/scene/Node.html</a></p>
  
  <p>Trying with an example using isTreeVisible() will not compile with Java 9</p>
  
  <pre><code>Java9AppTest.java:50: error: cannot find symbol
                      if (text1.isTreeVisible()) {
                           ^
    symbol:   method isTreeVisible()
    location: variable text1 of type Text
  </code></pre>
  
  <p><strong>Update2</strong>: Failed to see at first that isTreeVisible() is package private.</p>
  
  <p><strong>Update3</strong>: Taken another look at Node source code, I started to check out NodeHelper if could use it to get isTreeVisible(), however the package NodeHelper is not visible. Though using --add-exports for com.sun.javafx.scene to get access to NodeHelper works.</p>
  
  <pre><code>--add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED
  </code></pre>
  
  <p>Then I can read the state of isTreeVisible() of a Node.</p>
  
  <pre><code>final boolean isTreeVisible = NodeHelper.isTreeVisible(node);
  </code></pre>
  
  <p><strong>Code Example</strong></p>
  
  <p>Contains two Tab, each with its own Text.
  Has a Task that updates each Text.
  Using isVisible() will update each text on both tabs.
  Using impl_isTreeVisible() will only update the text that is truely visible.
  It makes sense that Text should be updated, even if it is not visible. This is just to illustrate the problem. Replace Text with background process that does alot more CPU heavy work.</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.concurrent.Task;
  import javafx.scene.Scene;
  import javafx.scene.control.Tab;
  import javafx.scene.control.TabPane;
  import javafx.scene.layout.VBox;
  import javafx.scene.text.Text;
  import javafx.stage.Stage;
  
  public class Java9AppTest extends Application {
  
      private Text text1, text2;
  
      public static void main(String[] args) {
          Java9AppTest.launch(args);
      }
  
      public void start(Stage stage) throws Exception {
          TabPane root = new TabPane();
  
          VBox box1 = new VBox();
          text1 = new Text();
          text1.setText("Hello World!");
          text1.textProperty().addListener((observable, oldValue,     newValue) -&gt; {
              System.out.println("text1 changed from " + oldValue + " to " + newValue);
          });
          box1.getChildren().addAll(text1);
  
          Tab tab1 = new Tab("Tab 1");
          tab1.setContent(box1);
  
          VBox box2 = new VBox();
          text2 = new Text();
          text2.setText("Another Hello World!");
          text2.textProperty().addListener((observable, oldValue, newValue) -&gt; {
              System.out.println("text2 changed from " + oldValue + " to " + newValue);
          });
          box2.getChildren().add(text2);
  
          Tab tab2 = new Tab("Tab 2");
          tab2.setContent(box2);
  
          root.getTabs().addAll(tab1, tab2);
  
          Task&lt;Void&gt; task = new Task&lt;Void&gt;() {
              /* (non-Javadoc)
               * @see javafx.concurrent.Task#call()
               */
              @Override
              protected Void call() throws Exception {
                  final String oldText = "Hello World!";
                  final String newText = "New Hello World!";
                  while (true) {
                      if (text1.isVisible()) {
                          if (text1.getText().equals(oldText)) {
                              text1.setText(newText);
                          } else {
                              text1.setText(oldText);
                          }
                      }
  
                      if (text2.isVisible()) {
                          if (text2.getText().equals(oldText)) {
                              text2.setText(newText);
                          } else {
                              text2.setText(oldText);
                          }
                      }
  
                      Thread.sleep(2000);
                  }
              }
  
          };
  
          stage.setScene(new Scene(root));
          stage.setWidth(200);
          stage.setHeight(200);
          stage.setTitle("JavaFX 9 Application");
          stage.show();
  
          Thread thread = new Thread(task, "Task");
          thread.start();
      }
  
  }
  </code></pre>