257 /*************************************************************************** 258 * * 259 * Public API * 260 * * 261 **************************************************************************/ 262 263 /** {@inheritDoc} */ 264 @Override public void dispose() { 265 super.dispose(); 266 267 if (behavior != null) { 268 behavior.dispose(); 269 } 270 } 271 272 /** {@inheritDoc} */ 273 @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { 274 // The TabPane can only be as wide as it widest content width. 275 double maxw = 0.0; 276 for (TabContentRegion contentRegion: tabContentRegions) { 277 maxw = Math.max(maxw, snapSize(contentRegion.prefWidth(-1))); 278 } 279 280 final boolean isHorizontal = isHorizontal(); 281 final double tabHeaderAreaSize = snapSize(isHorizontal ? 282 tabHeaderArea.prefWidth(-1) : tabHeaderArea.prefHeight(-1)); 283 284 double prefWidth = isHorizontal ? 285 Math.max(maxw, tabHeaderAreaSize) : maxw + tabHeaderAreaSize; 286 return snapSize(prefWidth) + rightInset + leftInset; 287 } 288 289 /** {@inheritDoc} */ 290 @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { 291 // The TabPane can only be as high as it highest content height. 292 double maxh = 0.0; 293 for (TabContentRegion contentRegion: tabContentRegions) { 294 maxh = Math.max(maxh, snapSize(contentRegion.prefHeight(-1))); 295 } 296 297 final boolean isHorizontal = isHorizontal(); 298 final double tabHeaderAreaSize = snapSize(isHorizontal ? 299 tabHeaderArea.prefHeight(-1) : tabHeaderArea.prefWidth(-1)); 300 301 double prefHeight = isHorizontal ? 302 maxh + snapSize(tabHeaderAreaSize) : Math.max(maxh, tabHeaderAreaSize); 303 return snapSize(prefHeight) + topInset + bottomInset; 304 } 305 306 /** {@inheritDoc} */ 307 @Override public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset) { 308 Side tabPosition = getSkinnable().getSide(); 309 if (tabPosition == Side.TOP) { 310 return tabHeaderArea.getBaselineOffset() + topInset; 311 } 312 return 0; 313 } 314 315 /** {@inheritDoc} */ 316 @Override protected void layoutChildren(final double x, final double y, 317 final double w, final double h) { 318 TabPane tabPane = getSkinnable(); 319 Side tabPosition = tabPane.getSide(); 320 321 double headerHeight = snapSize(tabHeaderArea.prefHeight(-1)); 322 double tabsStartX = tabPosition.equals(Side.RIGHT)? x + w - headerHeight : x; 323 double tabsStartY = tabPosition.equals(Side.BOTTOM)? y + h - headerHeight : y; 324 325 final double leftInset = snappedLeftInset(); 326 final double topInset = snappedTopInset(); 327 final double rightInset = snappedRightInset(); 328 329 if (tabPosition == Side.TOP) { 330 tabHeaderArea.resize(w, headerHeight); 331 tabHeaderArea.relocate(tabsStartX, tabsStartY); 332 tabHeaderArea.getTransforms().clear(); 333 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.TOP))); 334 } else if (tabPosition == Side.BOTTOM) { 335 tabHeaderArea.resize(w, headerHeight); 336 tabHeaderArea.relocate(w + leftInset, tabsStartY - headerHeight); 337 tabHeaderArea.getTransforms().clear(); 338 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.BOTTOM), 0, headerHeight)); 339 } else if (tabPosition == Side.LEFT) { 340 tabHeaderArea.resize(h, headerHeight); 341 tabHeaderArea.relocate(tabsStartX + headerHeight, h - headerHeight + topInset); 342 tabHeaderArea.getTransforms().clear(); 343 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.LEFT), 0, headerHeight)); 344 } else if (tabPosition == Side.RIGHT) { 345 tabHeaderArea.resize(h, headerHeight); 346 tabHeaderArea.relocate(tabsStartX, y - headerHeight); 347 tabHeaderArea.getTransforms().clear(); | 257 /*************************************************************************** 258 * * 259 * Public API * 260 * * 261 **************************************************************************/ 262 263 /** {@inheritDoc} */ 264 @Override public void dispose() { 265 super.dispose(); 266 267 if (behavior != null) { 268 behavior.dispose(); 269 } 270 } 271 272 /** {@inheritDoc} */ 273 @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { 274 // The TabPane can only be as wide as it widest content width. 275 double maxw = 0.0; 276 for (TabContentRegion contentRegion: tabContentRegions) { 277 maxw = Math.max(maxw, snapSizeX(contentRegion.prefWidth(-1))); 278 } 279 280 final boolean isHorizontal = isHorizontal(); 281 final double tabHeaderAreaSize = isHorizontal 282 ? snapSizeX(tabHeaderArea.prefWidth(-1)) 283 : snapSizeY(tabHeaderArea.prefHeight(-1)); 284 285 double prefWidth = isHorizontal ? 286 Math.max(maxw, tabHeaderAreaSize) : maxw + tabHeaderAreaSize; 287 return snapSizeX(prefWidth) + rightInset + leftInset; 288 } 289 290 /** {@inheritDoc} */ 291 @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { 292 // The TabPane can only be as high as it highest content height. 293 double maxh = 0.0; 294 for (TabContentRegion contentRegion: tabContentRegions) { 295 maxh = Math.max(maxh, snapSizeY(contentRegion.prefHeight(-1))); 296 } 297 298 final boolean isHorizontal = isHorizontal(); 299 final double tabHeaderAreaSize = isHorizontal 300 ? snapSizeY(tabHeaderArea.prefHeight(-1)) 301 : snapSizeX(tabHeaderArea.prefWidth(-1)); 302 303 double prefHeight = isHorizontal ? 304 maxh + snapSizeY(tabHeaderAreaSize) : Math.max(maxh, tabHeaderAreaSize); 305 return snapSizeY(prefHeight) + topInset + bottomInset; 306 } 307 308 /** {@inheritDoc} */ 309 @Override public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset) { 310 Side tabPosition = getSkinnable().getSide(); 311 if (tabPosition == Side.TOP) { 312 return tabHeaderArea.getBaselineOffset() + topInset; 313 } 314 return 0; 315 } 316 317 /** {@inheritDoc} */ 318 @Override protected void layoutChildren(final double x, final double y, 319 final double w, final double h) { 320 TabPane tabPane = getSkinnable(); 321 Side tabPosition = tabPane.getSide(); 322 323 double headerHeight = tabPosition.isHorizontal() 324 ? snapSizeY(tabHeaderArea.prefHeight(-1)) 325 : snapSizeX(tabHeaderArea.prefHeight(-1)); 326 double tabsStartX = tabPosition.equals(Side.RIGHT)? x + w - headerHeight : x; 327 double tabsStartY = tabPosition.equals(Side.BOTTOM)? y + h - headerHeight : y; 328 329 final double leftInset = snappedLeftInset(); 330 final double topInset = snappedTopInset(); 331 332 if (tabPosition == Side.TOP) { 333 tabHeaderArea.resize(w, headerHeight); 334 tabHeaderArea.relocate(tabsStartX, tabsStartY); 335 tabHeaderArea.getTransforms().clear(); 336 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.TOP))); 337 } else if (tabPosition == Side.BOTTOM) { 338 tabHeaderArea.resize(w, headerHeight); 339 tabHeaderArea.relocate(w + leftInset, tabsStartY - headerHeight); 340 tabHeaderArea.getTransforms().clear(); 341 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.BOTTOM), 0, headerHeight)); 342 } else if (tabPosition == Side.LEFT) { 343 tabHeaderArea.resize(h, headerHeight); 344 tabHeaderArea.relocate(tabsStartX + headerHeight, h - headerHeight + topInset); 345 tabHeaderArea.getTransforms().clear(); 346 tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.LEFT), 0, headerHeight)); 347 } else if (tabPosition == Side.RIGHT) { 348 tabHeaderArea.resize(h, headerHeight); 349 tabHeaderArea.relocate(tabsStartX, y - headerHeight); 350 tabHeaderArea.getTransforms().clear(); |