API REVIEW for TabPane tab content loading and fixed content size

Paru Somashekar parvathi.somashekar at oracle.com
Wed Jul 3 14:03:56 PDT 2013


JIRA : https://javafx-jira.kenai.com/browse/RT-24105 &
https://javafx-jira.kenai.com/browse/RT-30648

The following is API to control how tab content gets loaded for a 
TabPane in order to improve startup time and runtime performance for a 
TabPane.

Jonathan has already reviewed the following API and I have incorporated 
his feedback. Thanks Jonathan.

  TabContentSceneGraphPolicy is a static enum within TabPane
------------------------------------------------------------
public static enum TabContentSceneGraphPolicy {
          //The content all the tabs get loaded up front with no 
optimization. If there are a lot of tabs and content is large - this 
could potentially cause slow start up time. This is the default behavior.
         ALL_TABS,
          //Only the content of the selected tab will be loaded on 
startup and other tabs get loaded on selection. When a new tab is 
selected, its content is loaded into the scenegraph and the content of 
the previously selected tab is unloaded from the scenegraph.
         SELECTED_TAB,
          //Only the content of the selected tab will be loaded at 
startup and content of other tabs get loaded lazily in the background. 
Hence there is no loading and unloading of tab content when different 
tabs are selected as in the case of SELECTED_TAB option.
         SELECTED_TAB_WITH_LAZY_LOADING
     }
--------------------------------------------------------------
  API to specify fixed Width/Height/Size for tab content.

private DoubleProperty fixedWidth
public final void setFixedWidth(double value)
public final double getFixedWidth()
public final DoubleProperty fixedWidthProperty()

private DoubleProperty fixedHeight
public final void setFixedHeight(double value)
public final double getFixedHeight()
public final DoubleProperty fixedHeightProperty()

public final void setFixedSize(double width, double height)
----------------------------------------------------------------
Notes on performance considerations

The TabPane offers some performance optimizations in the area of tab 
content loading. Basically the default policy is to load the contents of 
all specified tabs. If the TabPane consists of a large number of big 
content tabs, then this could lead to a potential slow start up time, as 
it will have to spend some time in loading all the content up front 
before starting up.

In such situations, the TabPane allows specification of the 
TabContentSceneGraphPolicy which determines how the tab contents are 
loaded : all tabs, selected tab only, or selected tab and lazy loading 
of the rest of the tabs. The selected tab only option also ensures the 
content of the previously selected tab is removed from the scenegraph. 
This gives the added benefit of ensuring that no scenegraph related 
activities are performed on any of the tab contents that is not 
currently selected. However this could potentially cause the tab switch 
operation to be a bit slow. In order to achieve faster tab switch 
operation, the third option is provided where the content of the rest of 
the tabs are loaded lazily in the background. However the lazy loading 
option could result in a slower runtime performance.

Another area of optimization is provided for specifying a fixed width / 
height / size of the tab content area. If a fixed value is specified, 
measurement of the tab content sizes for the purpose of setting the 
available space is eliminated, thus providing faster resize operations 
on windows that contain a TabPane in them.
---------------------------------------------------------------

There might be a situation where the TabContentSceneGraphPolicy is set 
to SELECTED_TAB in which case only the content of the selected tab is 
loaded and user does not set fixed size. In such a case, we can either 
do one of the following,
1) hardcode a fixed size if it is not already set
2) measure the selected tab only and grow in size only if the size of 
the next selected tab is bigger than the previous one.
3) throw an exception if SELECTED_TAB is chosen and fixed size is not set.
I prefer option either 1 or 2, that way we do not force the developer to 
set a fixed size for the tab content.
Thoughts suggestions welcome, I shall go with option 1 if I don't hear any.


More information about the openjfx-dev mailing list