1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package test.css.controls; 26 27 import java.util.ArrayList; 28 import java.util.HashMap; 29 import java.util.HashSet; 30 import java.util.List; 31 import java.util.Map; 32 import java.util.Set; 33 import java.util.TreeSet; 34 import javafx.css.CssMetaData; 35 import javafx.css.Styleable; 36 import javafx.geometry.Bounds; 37 import javafx.geometry.HPos; 38 import javafx.geometry.Orientation; 39 import javafx.geometry.Pos; 40 import javafx.geometry.Side; 41 import javafx.geometry.VPos; 42 import javafx.scene.Node; 43 import javafx.scene.chart.BarChart; 44 import javafx.scene.chart.XYChart; 45 import javafx.scene.control.ContentDisplay; 46 import javafx.scene.control.Control; 47 import javafx.scene.control.Labeled; 48 import javafx.scene.control.OverrunStyle; 49 import javafx.scene.control.PasswordField; 50 import javafx.scene.control.ScrollBar; 51 import javafx.scene.control.ScrollPane; 52 import javafx.scene.control.ScrollPane.ScrollBarPolicy; 53 import javafx.scene.control.TextField; 54 import javafx.scene.effect.BlurType; 55 import javafx.scene.effect.DropShadow; 56 import javafx.scene.effect.InnerShadow; 57 import javafx.scene.layout.HBox; 58 import javafx.scene.layout.Pane; 59 import javafx.scene.layout.PaneBuilder; 60 import javafx.scene.layout.Region; 61 import javafx.scene.layout.VBox; 62 import javafx.scene.paint.Color; 63 import javafx.scene.shape.Rectangle; 64 import javafx.scene.text.FontSmoothingType; 65 import javafx.scene.text.Text; 66 import javafx.scene.text.TextAlignment; 67 import javafx.scene.web.WebView; 68 import test.css.controls.styles.AlignmentCssStyle; 69 import test.css.controls.styles.AxisSideAlignmentCssStyle; 70 import test.css.controls.styles.BackgroundCssStyle; 71 import test.css.controls.styles.BorderCssStyle; 72 import test.css.controls.styles.BorderedCssStyle; 73 import test.css.controls.styles.CssStyle; 74 import test.css.controls.styles.FlowAlignmentCssStyle; 75 import test.css.controls.styles.FontSmoothingCssStyle; 76 import test.css.controls.styles.LegendSideAlignmentCssStyle; 77 import test.css.controls.styles.OverrunCssStyle; 78 import test.css.controls.styles.PageInformationAlignmentCssStyle; 79 import test.css.controls.styles.Style; 80 import test.css.controls.styles.StyleArrayFactory; 81 import test.css.controls.styles.StyleSetter; 82 import test.css.controls.styles.TextAlignmentCssStyle; 83 import test.css.controls.styles.TileAlignmentCssStyle; 84 import test.css.controls.styles.TitleSideAlignmentCssStyle; 85 import test.css.utils.StyleGenerator; 86 87 /** 88 * 89 * @author andrey 90 */ 91 public class ControlsCssStylesFactory { 92 93 public static Map<String, CssStyle[]> getProps2Impls() { 94 return props2Impls; 95 } 96 97 /** 98 * 99 * @return Returns names of tested rules 100 */ 101 public static Set<String> getRules() { 102 return props2Impls.keySet(); 103 } 104 105 final private static Map<String, CssStyle[]> props2Impls = new HashMap(); 106 final private static String CSS_RED_RECTANGLE = ControlsCSSApp.class.getResource("/test/css/resources/red-rectangle.png").toExternalForm(); 107 final private static String CSS_GREEN_RECTANGLE = ControlsCSSApp.class.getResource("/test/css/resources/green-rectangle.png").toExternalForm(); 108 final private static String CSS_BORDER = ControlsCSSApp.class.getResource("/test/css/resources/border.png").toExternalForm(); 109 final private static String CSS_SMALL = ControlsCSSApp.class.getResource("/test/css/resources/small.png").toExternalForm(); 110 111 static { 112 /** 113 * styles -fx-indeterminate-bar-* - not used, they need only to css coverage. 114 * tested in JavaFXCompatibility/graphics/api/control/ProgressBar_2aTest 115 */ 116 props2Impls.put("-fx-indeterminate-bar-escape", new CssStyle[]{ 117 new CssStyle("INDETERMINATE-BAR-ESCAPE", 118 "-fx-indeterminate-bar-escape: " 119 + "false;")}); 120 props2Impls.put("-fx-indeterminate-bar-flip", new CssStyle[]{ 121 new CssStyle("INDETERMINATE-BAR-FLIP", 122 "-fx-indeterminate-bar-flip: " 123 + "false;")}); 124 props2Impls.put("-fx-indeterminate-bar-animation-time", new CssStyle[]{ 125 new CssStyle("INDETERMINATE-BAR-ANIMATION-TIME", 126 "-fx-indeterminate-bar-animation-time: " 127 + "20.0;")}); 128 props2Impls.put("-fx-indeterminate-bar-length", new CssStyle[]{ 129 new CssStyle("INDETERMINATE-BAR-LENGTH", 130 "-fx-indeterminate-bar-length: " 131 + "10;")}); 132 /** 133 * style -fx-animated not used, they need only to css coverage. 134 * tested in JavaFXCompatibility/graphics/api/control/TitledPane_aTest 135 */ 136 props2Impls.put("-fx-animated", new CssStyle[]{ 137 new CssStyle("ANIMATED", 138 "-fx-animated: " 139 + "false;")}); 140 /** 141 * style -fx-context-menu-enabled not used, they need only to css coverage. 142 * tested in WebNodeManualTests/test/com/sun/fx/webnode/tests/css/CSS/contextmenudisable 143 */ 144 props2Impls.put("-fx-context-menu-enabled", new CssStyle[]{ 145 new CssStyle("CONTEXT-MENU-ENABLED", 146 "-fx-context-menu-enabled: " 147 + "false;")}); 148 /** 149 * style -fx-display-caret not used, they need only to css coverage. 150 * tested in JavaFXCompatibility/graphics/api/control/TextBox_6aTest 151 */ 152 props2Impls.put("-fx-display-caret", new CssStyle[]{ 153 new CssStyle("DISPLAY_CARET", 154 "-fx-display-caret: " 155 + "false;")}); 156 157 props2Impls.put("-fx-effect", new CssStyle[]{ 158 new CssStyle("DROP_SHADOW", "-fx-effect: " 159 + "dropshadow( one-pass-box , green , 10 ," 160 + " 0.5 , 10 , 15);", new StyleSetter() { 161 public void setStyle(Node control) { 162 DropShadow dropShadow = new DropShadow(); 163 164 dropShadow.setBlurType(BlurType.ONE_PASS_BOX); 165 dropShadow.setColor(Color.GREEN); 166 dropShadow.setRadius(10); 167 dropShadow.setSpread(0.5); 168 dropShadow.setOffsetX(10); 169 dropShadow.setOffsetY(15); 170 control.setEffect(dropShadow); 171 } 172 }), 173 new CssStyle("INNER_SHADOW", "-fx-effect: " 174 + "innershadow( gaussian , green , 6 ," 175 + " 0.5 , 1 , 2);", new StyleSetter() { 176 public void setStyle(Node control) { 177 InnerShadow innerShadow = new InnerShadow(); 178 179 innerShadow.setBlurType(BlurType.GAUSSIAN); 180 innerShadow.setColor(Color.GREEN); 181 innerShadow.setRadius(6); 182 innerShadow.setChoke(0.5); 183 innerShadow.setOffsetX(1); 184 innerShadow.setOffsetY(2); 185 control.setEffect(innerShadow); 186 } 187 })}); 188 props2Impls.put("-fx-text-alignment", StyleArrayFactory.fromEnum(TextAlignmentCssStyle.class, "-fx-text-alignment", TextAlignment.values())); 189 props2Impls.put("-fx-content-display", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-content-display", ContentDisplay.values())); 190 props2Impls.put("-fx-valignment", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-valignment", VPos.values())); 191 props2Impls.put("-fx-halignment", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-halignment", HPos.values())); 192 props2Impls.put("-fx-node-vpos", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-node-vpos", VPos.values())); 193 props2Impls.put("-fx-node-hpos", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-node-hpos", HPos.values())); 194 props2Impls.put("-fx-hpos", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-hpos", HPos.values())); 195 props2Impls.put("-fx-vpos", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-vpos", VPos.values())); 196 props2Impls.put("-fx-alignment", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-alignment", Pos.values())); 197 props2Impls.put("-fx-text-overrun", StyleArrayFactory.fromEnum(OverrunCssStyle.class, "-fx-text-overrun", OverrunStyle.values())); 198 199 props2Impls.put("-fx-vbar-policy", getBarPoliciesStyles("-fx-vbar-policy")); 200 props2Impls.put("-fx-hbar-policy", getBarPoliciesStyles("-fx-hbar-policy")); 201 props2Impls.put("-fx-orientation", StyleArrayFactory.fromEnum(CssStyle.class, "-fx-orientation", Orientation.values())); 202 props2Impls.put("-fx-blend-mode", new CssStyle[]{new CssStyle("BLEND-MODE", "-fx-blend-mode: multiply ;-fx-content-display: center;")}); 203 props2Impls.put("-fx-translate-x", new CssStyle[]{ 204 new BorderedCssStyle("TRANSLATE-X", 205 "-fx-translate-x: " 206 + "15;", new StyleSetter() { 207 public void setStyle(Node control) { 208 control.setTranslateX(15); 209 } 210 }) { 211 @Override 212 public void decorate(Node control, Pane container) { 213 container.getChildren().add(new Rectangle(15, 15, Color.BLUE)); 214 super.decorate(control, container); 215 } 216 }}); 217 props2Impls.put("-fx-translate-y", new CssStyle[]{ 218 new BorderedCssStyle("TRANSLATE-Y", 219 "-fx-translate-y: " 220 + "15;", new StyleSetter() { 221 public void setStyle(Node control) { 222 control.setTranslateY(15); 223 } 224 }) { 225 @Override 226 public void decorate(Node control, Pane container) { 227 container.getChildren().add(new Rectangle(15, 15, Color.BLUE)); 228 super.decorate(control, container); 229 } 230 }}); 231 props2Impls.put("-fx-scale-x", new CssStyle[]{ 232 new CssStyle("SCALE-X", 233 "-fx-scale-x: " 234 + "1.2;", new StyleSetter() { 235 public void setStyle(Node control) { 236 control.setScaleX(1.2); 237 } 238 })}); 239 props2Impls.put("-fx-scale-y", new CssStyle[]{ 240 new CssStyle("SCALE-Y", 241 "-fx-scale-y: " 242 + "1.2;", new StyleSetter() { 243 public void setStyle(Node control) { 244 control.setScaleY(1.2); 245 } 246 })}); 247 props2Impls.put("-fx-graphic-text-gap", new CssStyle[]{ 248 new CssStyle("GRAPHIC-TEXT-GAP", 249 "-fx-graphic-text-gap: " 250 + "20;")}); 251 props2Impls.put("-fx-opacity", new CssStyle[]{ 252 new CssStyle("OPACITY", 253 "-fx-opacity: " 254 + "0.7;", new StyleSetter() { 255 public void setStyle(Node control) { 256 control.setOpacity(0.7); 257 } 258 }) { 259 @Override 260 public void decorate(Node control, Pane container) { 261 Bounds b = control.getBoundsInLocal(); 262 Text bottomText = new Text("See me?"); 263 bottomText.setFill(Color.RED); 264 bottomText.setLayoutY(b.getMinY() + 10); 265 bottomText.setLayoutX(b.getMaxX() + 10); 266 container.getChildren().add(bottomText); 267 } 268 }}); 269 // props2Impls.put("-fx-font", new CssStyle[]{ 270 // new CssStyle("FONT", 271 // "-fx-font: " 272 // + "italic bold 15 sans-serif;")}); 273 274 275 props2Impls.put("-fx-echo-char", new CssStyle[]{ 276 new CssStyle("ECHO-CHAR", 277 "-fx-echo-char: " 278 + "\u2622;") { 279 @Override 280 public void decorate(Node control, Pane container) { 281 if (control instanceof PasswordField) { 282 ((PasswordField) control).setText("12345"); 283 } 284 super.decorate(control, container); 285 } 286 }}); 287 props2Impls.put("-fx-padding", new CssStyle[]{ 288 new BorderedCssStyle("PADDING", 289 "-fx-padding: " 290 + "10 5 30 15;") { 291 @Override 292 public void decorate(Node control, Pane container) { 293 control.setStyle(control.getStyle() + "-fx-border-color:green;"); 294 super.decorate(control, container); 295 } 296 }}); 297 props2Impls.put("-fx-columns", new CssStyle[]{ 298 new CssStyle("COLUMNS", 299 "-fx-columns: " 300 + "5;")}); 301 props2Impls.put("-fx-pannable", new CssStyle[]{ 302 new CssStyle("PANNABLE", 303 "-fx-pannable: " 304 + "true;")}); 305 // props2Impls.put("-fx-skin", new CssStyle[]{ 306 // new CssStyle("SKIN", 307 // "-fx-skin: " 308 // + "Just text;")}); 309 // props2Impls.put("-fx-cursor", new CssStyle[]{ 310 // new CssStyle("CURSOR", 311 // "-fx-cursor: " 312 // + "crosshair;")}); 313 314 props2Impls.put("-fx-underline", new CssStyle[]{ 315 new CssStyle("UNDERLINE", 316 "-fx-underline: " 317 + "true;")}); 318 props2Impls.put("-fx-first-tab-indent", new CssStyle[]{ 319 new CssStyle("FIRST-TAB-INDENT", 320 "-fx-first-tab-indent: " 321 + "15;")}); 322 props2Impls.put("-fx-fit-to-width", new CssStyle[]{ 323 new CssStyle("FIT-TO-WIDTH", 324 "-fx-fit-to-width: " 325 + "true;")}); 326 props2Impls.put("-fx-text-fill", new CssStyle[]{ 327 new CssStyle("TEXT-FILL", 328 "-fx-text-fill: " 329 + "ladder(black, white 49%, black 50%);") { 330 @Override 331 public void decorate(Node control, Pane container) { 332 control.setStyle(control.getStyle() + "-fx-background-color: black;"); 333 super.decorate(control, container); 334 } 335 }}); 336 props2Impls.put("-fx-vgap", new CssStyle[]{ 337 new CssStyle("VGAP", 338 "-fx-vgap: " 339 + "15;")}); 340 props2Impls.put("-fx-wrap-text", new CssStyle[]{ 341 new CssStyle("WRAP-TEXT", 342 "-fx-wrap-text: " 343 + "true;") { 344 @Override 345 public void decorate(Node control, Pane container) { 346 ((Control) control).setMaxWidth(80); 347 ((Control) control).setPrefWidth(80); 348 } 349 }}); 350 props2Impls.put("-fx-tab-min-height", new CssStyle[]{ 351 new CssStyle("TAB-MIN-HEIGHT", 352 "-fx-tab-min-height: " 353 + "70;")}); 354 props2Impls.put("-fx-tab-min-width", new CssStyle[]{ 355 new CssStyle("TAB-MIN-WIDTH", 356 "-fx-tab-min-width: " 357 + "70;")}); 358 props2Impls.put("-fx-tab-max-width", new CssStyle[]{ 359 new CssStyle("TAB-MAX-WIDTH", 360 "-fx-tab-max-width: " 361 + "20;")}); 362 props2Impls.put("-fx-tab-max-height", new CssStyle[]{ 363 new CssStyle("TAB-MAX-HEIGHT", 364 "-fx-tab-max-height: " 365 + "10;")}); 366 props2Impls.put("-fx-collapsible", new CssStyle[]{ 367 new CssStyle("COLLAPSIBLE", 368 "-fx-collapsible: " 369 + "true;")}); 370 props2Impls.put("-fx-snap-to-pixel", new CssStyle[]{ 371 new CssStyle("SNAP-TO-PIXEL", 372 "-fx-snap-to-pixel: " 373 + "true;")}); 374 props2Impls.put("-fx-major-tick-unit", new CssStyle[]{ 375 new CssStyle("MAJOR-TICK-UNIT", 376 "-fx-major-tick-unit: 50;" 377 + "-fx-show-tick-marks: true;")}); 378 props2Impls.put("-fx-show-tick-marks", new CssStyle[]{ 379 new CssStyle("SHOW-TICK-MARKS", 380 "-fx-show-tick-marks: " 381 + "true;")}); 382 props2Impls.put("-fx-minor-tick-count", new CssStyle[]{ 383 new CssStyle("MINOR-TICK-COUNT", 384 "-fx-minor-tick-count: 5;" 385 + "-fx-show-tick-marks: true;") { 386 public void decorate(Node control, Pane container) { 387 if (control instanceof XYChart) { 388 ((XYChart) control).getXAxis().setStyle("-fx-minor-tick-count:3"); 389 ((XYChart) control).getYAxis().setStyle("-fx-minor-tick-count:3"); 390 } 391 super.decorate(control, container); 392 } 393 } 394 }); 395 props2Impls.put("-fx-grid-lines-visible", new CssStyle[]{ 396 new CssStyle("GRID-LINES-VISIBLE", 397 "-fx-grid-lines-visible: " 398 + "false;")}); 399 props2Impls.put("-fx-graphic", new CssStyle[]{ 400 new CssStyle("GRAPHIC", 401 "-fx-graphic: " 402 + "url(\"" + CSS_SMALL + "\");")}); 403 props2Impls.put("-fx-background-image", new CssStyle[]{ 404 new BackgroundCssStyle("BACKGROUND-IMAGE", 405 "-fx-background-image: " 406 + "url(\"" + CSS_RED_RECTANGLE + "\");")}); 407 props2Impls.put("-fx-background-position", new CssStyle[]{ 408 new BackgroundCssStyle("BACKGROUND-POSITION", 409 "-fx-background-image: " 410 + "url(\"" + CSS_RED_RECTANGLE + "\")," 411 + "url(\"" + CSS_GREEN_RECTANGLE + "\");" 412 + "-fx-background-position: right bottom, left center;" 413 + "-fx-background-repeat: space, no-repeat;") 414 }); 415 props2Impls.put("-fx-label-padding", new CssStyle[]{ 416 new CssStyle("LABEL-PADDING", 417 "-fx-label-padding: 30 20 3 10;" 418 + "-fx-background-color: red;") 419 }); 420 props2Impls.put("-fx-progress-color", new CssStyle[]{ 421 new CssStyle("PROGRESS-COLOR", 422 "-fx-progress-color: red;") 423 }); 424 props2Impls.put("-fx-use-system-menu-bar", new CssStyle[]{ 425 new CssStyle("SYSTEM-MENU", 426 "-fx-use-system-menu-bar: true;") 427 }); 428 props2Impls.put("-fx-background-repeat", new CssStyle[]{ 429 new BackgroundCssStyle("BACKGROUND-REPEAT-X-Y", 430 "-fx-background-image: " 431 + "url(\"" + CSS_RED_RECTANGLE + "\")," 432 + "url(\"" + CSS_GREEN_RECTANGLE + "\");" 433 + "-fx-background-repeat: repeat-x,repeat-y;"), 434 new BackgroundCssStyle("BACKGROUND-REPEAT-ROUND", 435 "-fx-background-image: " 436 + "url(\"" + CSS_RED_RECTANGLE + "\");" 437 + "-fx-background-repeat: round;" 438 + "-fx-background-position: bottom;"), 439 new BackgroundCssStyle("BACKGROUND-REPEAT-SPACE", 440 "-fx-background-image: " 441 + "url(\"" + CSS_RED_RECTANGLE + "\");" 442 + "-fx-background-repeat: space;" 443 + "-fx-background-position: bottom;")}); 444 props2Impls.put("-fx-background-size", new CssStyle[]{ 445 new BackgroundCssStyle("BACKGROUND-SIZE", 446 "-fx-background-image: " 447 + "url(\"" + CSS_RED_RECTANGLE + "\")," 448 + "url(\"" + CSS_GREEN_RECTANGLE + "\");" 449 + "-fx-background-size: 100% 50%, 50% 100%;" 450 + "-fx-background-repeat: no-repeat, no-repeat;"),}); 451 props2Impls.put("-fx-border-color", new CssStyle[]{ 452 new BorderCssStyle("BORDER-COLOR", 453 "-fx-border-color: " 454 + "green blue yellow red;"),}); 455 props2Impls.put("-fx-border-width", new CssStyle[]{ 456 new CssStyle("BORDER-WIDTH", 457 "-fx-border-width: " 458 + "1 2 1 2;" 459 + "-fx-border-color: red;"), 460 new CssStyle("BORDER-WIDTH-dotted", 461 "-fx-border-width: " 462 + "1 3 5 1;" 463 + "-fx-border-color: red blue green yellow;" 464 + "-fx-border-style: dotted;"), 465 new CssStyle("BORDER-WIDTH-dashed", 466 "-fx-border-width: " 467 + "1 3 5 1;" 468 + "-fx-border-color: red blue green yellow;" 469 + "-fx-border-style: dashed;")}); 470 props2Impls.put("-fx-border-style", new CssStyle[]{ 471 new BorderCssStyle("BORDER-STYLE-DASHED", "-fx-border-color: red blue green yellow;" 472 + "-fx-border-style: dashed;" 473 + "-fx-border-radius: 5;"), 474 new BorderCssStyle("BORDER-STYLE-DOTTED", "-fx-border-color: red blue green yellow;" 475 + "-fx-border-style: dotted;" 476 + "-fx-border-radius: 5;"),}); 477 props2Impls.put("-fx-border-insets", new CssStyle[]{ 478 new BorderCssStyle("BORDER-INSET", "-fx-border-color: red blue green yellow;" 479 + "-fx-border-radius: 5;" 480 + "-fx-border-insets: 5;"),}); 481 props2Impls.put("-fx-border-image-source", new CssStyle[]{ 482 new BorderCssStyle("IMAGE-BORDER", 483 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 484 + "-fx-border-image-slice: 28;" 485 + "-fx-border-image-width: 9;") 486 }); 487 props2Impls.put("-fx-border-image-insets", new CssStyle[]{ 488 new BorderCssStyle("IMAGE-BORDER-INSETS", 489 "-fx-border-image-source: url(\"" + CSS_RED_RECTANGLE + "\");" 490 + "-fx-border-image-width: 5;" 491 + "-fx-border-image-insets: 1 5 10 15;") 492 }); 493 props2Impls.put("-fx-border-image-repeat", new CssStyle[]{ 494 new BorderCssStyle("IMAGE-BORDER-REPEAT-Y", 495 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 496 + "-fx-border-image-repeat: repeat-y;" 497 + "-fx-border-image-slice: 28;" 498 + "-fx-border-image-width: 9;"), 499 new BorderCssStyle("IMAGE-BORDER-REPEAT-X", 500 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 501 + "-fx-border-image-repeat: repeat-x, repeat-y;" 502 + "-fx-border-image-slice: 28;" 503 + "-fx-border-image-width: 9;"), 504 new BorderCssStyle("IMAGE-BORDER-NO-REPEAT", 505 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 506 + "-fx-border-image-repeat: no-repeat;" 507 + "-fx-border-image-slice: 28;" 508 + "-fx-border-image-width: 9;"), 509 new BorderCssStyle("IMAGE-BORDER-SPACE", 510 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 511 + "-fx-border-image-repeat: space;" 512 + "-fx-border-image-slice: 28;" 513 + "-fx-border-image-width: 9;"), 514 new BorderCssStyle("IMAGE-BORDER-ROUND", 515 "-fx-border-image-source: url(\"" + CSS_BORDER + "\");" 516 + "-fx-border-image-repeat: round;" 517 + "-fx-border-image-slice: 28;" 518 + "-fx-border-image-width: 9;") 519 }); 520 props2Impls.put("-fx-background-color", new CssStyle[]{ 521 new CssStyle("BACKGROUND-COLOR", 522 "-fx-background-color: " 523 + "green , linear-gradient(to bottom right, yellow, red);" 524 + "-fx-background-radius: 10px, 40px;") 525 }); 526 props2Impls.put("-fx-background-insets", new CssStyle[]{ 527 new BackgroundCssStyle("BACKGROUND-INSET", 528 "-fx-background-color: " 529 + "green , linear-gradient(to bottom right, yellow, red);" 530 + "-fx-background-radius: 10px, 40px;" 531 + "-fx-background-insets: 10, 5;")}); 532 props2Impls.put("-fx-tab-spacing", new CssStyle[]{ 533 new CssStyle("TAB-SPACING", 534 "-fx-tab-spacing: " 535 + "50;")}); 536 props2Impls.put("-fx-hgap", new CssStyle[]{ 537 new CssStyle("HGAP", 538 "-fx-hgap: " 539 + "15;")}); 540 props2Impls.put("-fx-rotate", new CssStyle[]{ 541 new CssStyle("ROTATE", 542 "-fx-rotate: " 543 + "45;", new StyleSetter() { 544 public void setStyle(Node control) { 545 control.setRotate(45); 546 } 547 }) { 548 @Override 549 public void decorate(Node control, Pane container) { 550 control.setTranslateY(20); 551 } 552 }}); 553 props2Impls.put("-fx-shape", new CssStyle[]{ 554 new CssStyle("SHAPE", 555 "-fx-shape: " 556 + "\"M 50 50 L 150 50 L 100 150 Z\";-fx-background-color: yellow;") { 557 @Override 558 public void decorate(Node control, Pane container) { 559 control.getStyleClass().add("with-background"); 560 super.decorate(control, container); 561 } 562 }}); 563 props2Impls.put("-fx-scale-shape", new CssStyle[]{ 564 new CssStyle("SCALE-SHAPE", 565 "-fx-shape: " 566 + "\"M 50 50 L 150 50 L 100 150 Z\";-fx-scale-shape: false; -fx-background-color: red;") { 567 @Override 568 public void decorate(Node control, Pane container) { 569 control.getStyleClass().add("with-background"); 570 super.decorate(control, container); 571 } 572 }}); 573 props2Impls.put("-fx-position-shape", new CssStyle[]{ 574 new CssStyle("POSITION-SHAPE", 575 "-fx-shape: " 576 + "\"M 50 50 L 150 50 L 100 150 Z\";-fx-position-shape: false; -fx-background-color: blue;") { 577 @Override 578 public void decorate(Node control, Pane container) { 579 control.getStyleClass().add("with-background"); 580 super.decorate(control, container); 581 } 582 }}); 583 props2Impls.put("-fx-position-shape", new CssStyle[]{ 584 new CssStyle("POSITION-SCALE-SHAPE", 585 "-fx-shape: " 586 + "\"M 50 50 L 150 50 L 100 150 Z\";-fx-position-shape: false;-fx-scale-shape: false; -fx-background-color: blue;") { 587 @Override 588 public void decorate(Node control, Pane container) { 589 control.getStyleClass().add("with-background"); 590 super.decorate(control, container); 591 } 592 }}); 593 props2Impls.put("-fx-show-tick-labels", new CssStyle[]{ 594 new CssStyle("SHOW-TICK-LABELS", 595 "-fx-show-tick-labels: true;" 596 + "-fx-show-tick-marks: true;")}); 597 props2Impls.put("-fx-fit-to-height", new CssStyle[]{ 598 new CssStyle("FIT-TO-HEIGHT", 599 "-fx-fit-to-height: " 600 + "true;")}); 601 props2Impls.put("-fx-snap-to-ticks", new CssStyle[]{ 602 new CssStyle("SNAP-TO-TICKS", 603 "-fx-snap-to-ticks: " 604 + "true;")}); 605 props2Impls.put("-fx-bar-gap", new CssStyle[]{ 606 new CssStyle("BAR-GAP", 607 "-fx-bar-gap: " 608 + "10;")}); 609 props2Impls.put("-fx-arrows-visible", new CssStyle[]{ 610 new CssStyle("ARROWS_VISIBLE", 611 "-fx-arrows-visible: " 612 + "false;")}); 613 props2Impls.put("-fx-ellipsis-string", new CssStyle[]{ 614 new CssStyle("ELLIPSIS-STRING", 615 "-fx-ellipsis-string: " 616 + "'|||';") { 617 @Override 618 public void decorate(Node control, Pane container) { 619 if (control instanceof Labeled) { 620 ((Labeled) control).setMaxWidth(50); 621 } 622 super.decorate(control, container); 623 } 624 }}); 625 626 props2Impls.put("-fx-page-information-visible", new CssStyle[]{ 627 new CssStyle("PAGE-INFORMATION-VISIBLE", 628 "-fx-page-information-visible: " 629 + "true;")}); 630 props2Impls.put("-fx-page-information-alignment", StyleArrayFactory.fromEnum(PageInformationAlignmentCssStyle.class, "-fx-page-information-alignment", Side.values())); 631 props2Impls.put("-fx-max-page-indicator-count", new CssStyle[]{ 632 new CssStyle("MAX-PAGE-INDICATOR-COUNT", 633 "-fx-max-page-indicator-count: " 634 + "2;")}); 635 636 props2Impls.put("-fx-tooltip-visible", new CssStyle[]{ 637 new CssStyle("TOOLTIP-VISIBLE", 638 "-fx-tooltip-visible: " 639 + "false;") { 640 @Override 641 public void decorate(Node control, Pane container) { 642 super.decorate(control, container); 643 /** 644 * @todo after resolved RT-23933 645 */ 646 } 647 }}); 648 649 props2Impls.put("-fx-legend-visible", new CssStyle[]{ 650 new CssStyle("LEGEND-VISIBLE", 651 "-fx-legend-visible: " 652 + "false;")}); 653 654 props2Impls.put("-fx-legend-side", StyleArrayFactory.fromEnum(LegendSideAlignmentCssStyle.class, "-fx-legend-side", Side.values())); 655 props2Impls.put("-fx-title-side", StyleArrayFactory.fromEnum(TitleSideAlignmentCssStyle.class, "-fx-title-side", Side.values())); 656 657 props2Impls.put("-fx-vertical-zero-line-visible", new CssStyle[]{ 658 new CssStyle("VERTICAL-ZERO-LINE-VISIBLE", 659 "-fx-vertical-zero-line-visible: " 660 + "false;") { 661 @Override 662 public void decorate(Node control, Pane container) { 663 ((XYChart) control).setStyle("-fx-vertical-zero-line-visible:false;"); 664 ((XYChart) control).getYAxis().setStyle("-fx-side:right"); 665 super.decorate(control, container); 666 } 667 }}); 668 props2Impls.put("-fx-horizontal-grid-lines-visible", new CssStyle[]{ 669 new CssStyle("HORIZONTAL-GRID-LINES-VISIBLE", 670 "-fx-horizontal-grid-lines-visible: " 671 + "false;")}); 672 673 props2Impls.put("-fx-vertical-grid-lines-visible", new CssStyle[]{ 674 new CssStyle("VERTICAL-GRID-LINES-VISIBLE", 675 "-fx-vertical-grid-lines-visible: " 676 + "false;")}); 677 678 props2Impls.put("-fx-horizontal-zero-line-visible", new CssStyle[]{ 679 new CssStyle("HORIZONTAL-ZERO-LINE-VISIBLE", 680 "-fx-horizontal-zero-line-visible: " 681 + "false;") { 682 @Override 683 public void decorate(Node control, Pane container) { 684 ((XYChart) control).setStyle("-fx-horizontal-zero-line-visible:false;"); 685 ((XYChart) control).getXAxis().setStyle("-fx-side:top"); 686 super.decorate(control, container); 687 } 688 }}); 689 690 props2Impls.put("-fx-alternative-column-fill-visible", new CssStyle[]{ 691 new CssStyle("ALTERNATIVE-COLUMN-FILL-VISIBLE", 692 "-fx-alternative-column-fill-visible: " 693 + "true;")}); 694 695 props2Impls.put("-fx-alternative-row-fill-visible", new CssStyle[]{ 696 new CssStyle("ALTERNATIVE-ROW-FILL-VISIBLE", 697 "-fx-alternative-row-fill-visible: " 698 + "false;")}); 699 700 props2Impls.put("-fx-tick-label-gap", new CssStyle[]{ 701 new CssStyle("TICK-LABEL-GAP", 702 "-fx-tick-label-gap: " 703 + "40;") { 704 @Override 705 public void decorate(Node control, Pane container) { 706 ((XYChart) control).getXAxis().setStyle("-fx-tick-label-gap:1.2em;-fx-tick-labels-visible:true"); 707 super.decorate(control, container); 708 } 709 } 710 }); 711 props2Impls.put("-fx-tick-label-font", new CssStyle[]{ 712 new CssStyle("TICK-LABEL-FONT", 713 "-fx-tick-label-font:" 714 + "italic 2em sans") { 715 @Override 716 public void decorate(Node control, Pane container) { 717 ((XYChart) control).getXAxis().setStyle("-fx-tick-label-font:italic 2em sans;-fx-tick-labels-visible:true"); 718 super.decorate(control, container); 719 } 720 }}); 721 props2Impls.put("-fx-tick-length", new CssStyle[]{ 722 new CssStyle("TICK-LENGTH", 723 "-fx-tick-length: " 724 + "40;") { 725 @Override 726 public void decorate(Node control, Pane container) { 727 ((XYChart) control).getXAxis().setStyle("-fx-tick-length:40"); 728 super.decorate(control, container); 729 } 730 }}); 731 props2Impls.put("-fx-tick-labels-visible", new CssStyle[]{ 732 new CssStyle("TICK-LABELS-VISIBLE", 733 "-fx-tick-labels-visible: " 734 + "true;") { 735 @Override 736 public void decorate(Node control, Pane container) { 737 ((XYChart) control).getXAxis().setStyle("-fx-tick-labels-visible:true"); 738 super.decorate(control, container); 739 } 740 }}); 741 props2Impls.put("-fx-tick-label-fill", new CssStyle[]{ 742 new CssStyle("TICK-LABEL-FILL", 743 "-fx-tick-label-fill: " 744 + "red;-fx-tick-labels-visible:true") { 745 @Override 746 public void decorate(Node control, Pane container) { 747 ((XYChart) control).getXAxis().setStyle("-fx-tick-label-fill:red;-fx-tick-labels-visible:true"); 748 super.decorate(control, container); 749 } 750 }}); 751 props2Impls.put("-fx-side", StyleArrayFactory.fromEnum(AxisSideAlignmentCssStyle.class, "-fx-side", Side.values())); 752 props2Impls.put("-fx-tick-mark-visible", new CssStyle[]{ 753 new CssStyle("TICK-MARK-VISIBLE", 754 "-fx-tick-mark-visible: " 755 + "false;") { 756 @Override 757 public void decorate(Node control, Pane container) { 758 ((XYChart) control).getXAxis().setStyle("-fx-tick-mark-visible:false;"); 759 ((XYChart) control).getYAxis().setStyle("-fx-tick-mark-visible:false;"); 760 super.decorate(control, container); 761 } 762 }}); 763 props2Impls.put("-fx-tick-unit", new CssStyle[]{ 764 new CssStyle("TICK-UNIT", 765 "-fx-tick-unit: " 766 + "3;") { 767 @Override 768 public void decorate(Node control, Pane container) { 769 ((XYChart) control).getXAxis().setStyle("-fx-tick-unit:2"); 770 ((XYChart) control).getYAxis().setStyle("-fx-tick-unit:2"); 771 super.decorate(control, container); 772 } 773 }}); 774 props2Impls.put("-fx-minor-tick-visible", new CssStyle[]{ 775 new CssStyle("MINOR-TICK-VISIBLE", 776 "-fx-minor-tick-visible: " 777 + "false;") { 778 @Override 779 public void decorate(Node control, Pane container) { 780 ((XYChart) control).getXAxis().setStyle("-fx-minor-tick-visible:false"); 781 ((XYChart) control).getYAxis().setStyle("-fx-minor-tick-visible:false"); 782 super.decorate(control, container); 783 } 784 }}); 785 props2Impls.put("-fx-minor-tick-length", new CssStyle[]{ 786 new CssStyle("MINOR-TICK-LENGTH", 787 "-fx-minor-tick-length: " 788 + "40;") { 789 @Override 790 public void decorate(Node control, Pane container) { 791 ((XYChart) control).getXAxis().setStyle("-fx-minor-tick-length:40"); 792 ((XYChart) control).getYAxis().setStyle("-fx-minor-tick-length:40"); 793 super.decorate(control, container); 794 } 795 }}); 796 props2Impls.put("-fx-block-increment", new CssStyle[]{ 797 new CssStyle("BLOCK-INCREMENT", 798 "-fx-block-increment: " 799 + "50;")}); 800 props2Impls.put("-fx-unit-increment", new CssStyle[]{ 801 new CssStyle("UNIT-INCREMENT", 802 "-fx-unit-increment: " 803 + "50;"){ 804 805 @Override 806 public void decorate(Node control, Pane container) { 807 if (control instanceof ScrollBar) { 808 ((ScrollBar) control).setValue(1d); 809 } 810 } 811 812 }}); 813 props2Impls.put("-fx-pref-rows", new CssStyle[]{ 814 new CssStyle("PREF-ROWS", 815 "-fx-pref-rows: " 816 + "2;")}); 817 props2Impls.put("-fx-pref-tile-width", new CssStyle[]{ 818 new CssStyle("PREF-TILE-WIDTH", 819 "-fx-pref-tile-width: " 820 + "40;")}); 821 props2Impls.put("-fx-pref-columns", new CssStyle[]{ 822 new CssStyle("PREF-COLUMNS", 823 "-fx-pref-columns: " 824 + "2;")}); 825 props2Impls.put("-fx-pref-tile-height", new CssStyle[]{ 826 new CssStyle("PREF-TILE-HEIGHT", 827 "-fx-pref-tile-height: " 828 + "40;")}); 829 props2Impls.put("-fx-tile-alignment", StyleArrayFactory.fromEnum(TileAlignmentCssStyle.class, "-fx-tile-alignment", Pos.values())); 830 props2Impls.put("-fx-spacing", new CssStyle[]{ 831 new CssStyle("SPACING", 832 "-fx-spacing: " 833 + "15;")}); 834 props2Impls.put("-fx-fill-width", new CssStyle[]{ 835 new CssStyle("FILL-WIDTH", 836 "-fx-fill-width: " 837 + "true;") { 838 @Override 839 public void decorate(Node control, Pane container) { 840 super.decorate(control, container); 841 if (control instanceof VBox) { 842 VBox box = (VBox) control; 843 box.getChildren().clear(); 844 box.setStyle(box.getStyle() + "-fx-border-color:blue;"); 845 box.getChildren().add(PaneBuilder.create().children(new Rectangle(20, 20, Color.TRANSPARENT)).style("-fx-border-color:red;").build()); 846 } 847 } 848 }}); 849 850 props2Impls.put("-fx-indent", new CssStyle[]{ 851 new CssStyle("INDENT", 852 "-fx-indent: " 853 + "60;") { 854 @Override 855 public void decorate(Node control, Pane container) { 856 super.decorate(control, container); 857 control.getStyleClass().add("tree-indent"); 858 } 859 }}); 860 props2Impls.put("-fx-category-gap", new CssStyle[]{ 861 new CssStyle("CATEGORY-GAP", 862 "-fx-category-gap: " 863 + "20;")}); 864 props2Impls.put("-fx-end-margin", new CssStyle[]{ 865 new CssStyle("END-MARGIN", 866 "-fx-end-margin: " 867 + "40;") { 868 @Override 869 public void decorate(Node control, Pane container) { 870 if (control instanceof BarChart) { 871 ((BarChart) control).getXAxis().setStyle("-fx-end-margin:40"); 872 } 873 } 874 }}); 875 props2Impls.put("-fx-start-margin", new CssStyle[]{ 876 new CssStyle("START-MARGIN", 877 "-fx-start-margin: " 878 + "40;") { 879 @Override 880 public void decorate(Node control, Pane container) { 881 if (control instanceof BarChart) { 882 ((BarChart) control).getXAxis().setStyle("-fx-start-margin:40"); 883 } 884 } 885 }}); 886 props2Impls.put("-fx-gap-start-and-end", new CssStyle[]{ 887 new CssStyle("GAP-START-AND-END", 888 "-fx-gap-start-and-end: " 889 + "false;") { 890 @Override 891 public void decorate(Node control, Pane container) { 892 if (control instanceof BarChart) { 893 ((BarChart) control).getXAxis().setStyle("-fx-gap-start-and-end:false;"); 894 } 895 } 896 }}); 897 props2Impls.put("-fx-cell-size", new CssStyle[]{ 898 new CssStyle("CELL-SIZE", 899 "-fx-cell-size: " 900 + "25;") { 901 @Override 902 public void decorate(Node control, Pane container) { 903 super.decorate(control, container); 904 control.getStyleClass().add("cell-size"); 905 } 906 }}); 907 props2Impls.put("-fx-color-label-visible", new CssStyle[]{ 908 new CssStyle("COLOR-LABEL-VISIBLE", 909 "-fx-color-label-visible: " 910 + "true;")}); 911 props2Impls.put("-fx-column-halignment", StyleArrayFactory.fromEnum(FlowAlignmentCssStyle.class, "-fx-column-halignment", HPos.values())); 912 props2Impls.put("-fx-row-valignment", StyleArrayFactory.fromEnum(FlowAlignmentCssStyle.class, "-fx-row-valignment", VPos.values())); 913 props2Impls.put("-fx-clockwise", new CssStyle[]{ 914 new CssStyle("CLOCKWISE", 915 "-fx-clockwise: " 916 + "false;")}); 917 props2Impls.put("-fx-pie-label-visible", new CssStyle[]{ 918 new CssStyle("PIE-LABEL-VISIBLE", 919 "-fx-pie-label-visible: " 920 + "true;")}); 921 props2Impls.put("-fx-label-line-length", new CssStyle[]{ 922 new CssStyle("LABEL-LINE-LENGTH", 923 "-fx-label-line-length: " 924 + "40;")}); 925 props2Impls.put("-fx-start-angle", new CssStyle[]{ 926 new CssStyle("START-ANGLE", 927 "-fx-start-angle: " 928 + "180;")}); 929 props2Impls.put("-fx-font-family", new CssStyle[]{ 930 new CssStyle("FONT-FAMILY", 931 "-fx-font-family: " 932 + "Comic;")}); 933 props2Impls.put("-fx-font-size", new CssStyle[]{ 934 new CssStyle("FONT-SIZE", 935 "-fx-font-size: " 936 + "24;")}); 937 props2Impls.put("-fx-font-weight", new CssStyle[]{ 938 new CssStyle("FONT-WEIGHT", 939 "-fx-font-weight: " 940 + "bold;") { 941 @Override 942 public void decorate(Node control, Pane container) { 943 super.decorate(control, container); 944 control.setStyle(control.getStyle() + "-fx-font-family:Arial;"); 945 } 946 }}); 947 props2Impls.put("-fx-font-style", new CssStyle[]{ 948 new CssStyle("FONT-STYLE", 949 "-fx-font-style: " 950 + "italic;") { 951 @Override 952 public void decorate(Node control, Pane container) { 953 super.decorate(control, container); 954 control.setStyle(control.getStyle() + "-fx-font-family:Arial;"); 955 } 956 }}); 957 props2Impls.put("-fx-pref-height", new CssStyle[]{ 958 new CssStyle("PREF-HEIGHT", 959 "-fx-pref-height: " 960 + "40;")}); 961 props2Impls.put("-fx-min-width", new CssStyle[]{ 962 new CssStyle("MIN-WIDTH", 963 "-fx-min-width: " 964 + "200;")}); 965 props2Impls.put("-fx-min-height", new CssStyle[]{ 966 new CssStyle("MIN-HEIGHT", 967 "-fx-min-height: " 968 + "200;")}); 969 props2Impls.put("-fx-max-width", new CssStyle[]{ 970 new CssStyle("MAX-WIDTH", 971 "-fx-max-width: " 972 + "40;")}); 973 props2Impls.put("-fx-max-height", new CssStyle[]{ 974 new CssStyle("MAX-HEIGHT", 975 "-fx-max-height: " 976 + "40;")}); 977 props2Impls.put("-fx-pref-width", new CssStyle[]{ 978 new CssStyle("PREF-WIDTH", 979 "-fx-pref-width: " 980 + "40;")}); 981 props2Impls.put("-fx-prompt-text-fill", new CssStyle[]{ 982 new CssStyle("PROMPT-TEXT-FILL", 983 "-fx-prompt-text-fill: " 984 + "blue;") { 985 @Override 986 public void decorate(Node control, Pane container) { 987 super.decorate(control, container); 988 if (control instanceof TextField) { 989 ((TextField) control).setText(""); 990 ((TextField) control).setPromptText("Propm text"); 991 } 992 } 993 }}); 994 props2Impls.put("-fx-font-smoothing-type", StyleArrayFactory.fromEnum(FontSmoothingCssStyle.class, "-fx-font-smoothing-type", FontSmoothingType.values())); 995 props2Impls.put("-fx-font-scale", new CssStyle[]{ 996 new CssStyle("FONT-SCALE", 997 "-fx-font-scale: " 998 + "2;") { 999 @Override 1000 public void decorate(Node control, Pane container) { 1001 super.decorate(control, container); 1002 if (control instanceof WebView) { 1003 ((WebView) control).getEngine().load(ControlsCSSApp.class.getResource("/test/css/resources/index_1.html").toExternalForm()); 1004 } 1005 } 1006 }}); 1007 props2Impls.put("-fx-strikethrough", new CssStyle[]{ 1008 new CssStyle("STRIKETHROUGH", 1009 "-fx-strikethrough: " 1010 + "true;") { 1011 @Override 1012 public void decorate(Node control, Pane container) { 1013 super.decorate(control, container); 1014 control.setStyle(control.getStyle() + ";-fx-font-family:Verdana;"); 1015 } 1016 }}); 1017 props2Impls.put("-fx-fill-height", new CssStyle[]{ 1018 new CssStyle("FILL-HEIGHT", 1019 "-fx-fill-height: " 1020 + "true;") { 1021 @Override 1022 public void decorate(Node control, Pane container) { 1023 super.decorate(control, container); 1024 if (control instanceof HBox) { 1025 HBox box = (HBox) control; 1026 box.getChildren().clear(); 1027 box.setStyle(box.getStyle() + "-fx-border-color:blue;"); 1028 box.getChildren().add(PaneBuilder.create().children(new Rectangle(20, 20, Color.TRANSPARENT)).style("-fx-border-color:red;").build()); 1029 } 1030 } 1031 } 1032 }); 1033 props2Impls.put("-fx-size", new CssStyle[]{ 1034 new CssStyle("SIZE", 1035 "-fx-size: " 1036 + "40;") { 1037 @Override 1038 public void decorate(Node control, Pane container) { 1039 super.decorate(control, container); 1040 control.getStyleClass().add("with-fx-size"); 1041 } 1042 }}); 1043 1044 props2Impls.put("-fx-translate-z", new CssStyle[]{ 1045 new CssStyle("TRANSLATE-Z", 1046 "-fx-translate-z: " 1047 + "20;"){ 1048 1049 @Override 1050 public void decorate(Node control, Pane container) { 1051 Rectangle rec = new Rectangle(20, 50, Color.BLACK); 1052 container.getChildren().add(rec); 1053 rec.setX(5); 1054 rec.setY(50); 1055 rec.setStyle("-fx-translate-z:0"); 1056 rec.toFront(); 1057 } 1058 1059 }}); 1060 props2Impls.put("-fx-image", new CssStyle[]{ 1061 new CssStyle("IMAGE", 1062 "-fx-image: " 1063 + "url(\"" + CSS_SMALL + "\");")}); 1064 props2Impls.put("-fx-stroke-borders", new CssStyle[]{ 1065 new CssStyle("STROKE-BORDERS", 1066 "-fx-stroke-borders: " 1067 + "red 15 10 dashed 5")}); 1068 props2Impls.put("-fx-background-fills", new CssStyle[]{ 1069 new CssStyle("BACKGROUND-FILLS", 1070 "-fx-background-fills: " 1071 + "red 10 15")}); 1072 props2Impls.put("-fx-image-borders", new CssStyle[]{ 1073 new CssStyle("IMAGE-BORDERS", 1074 "-fx-image-borders: " 1075 + "url(\"" + CSS_BORDER + "\") 15 repeat-x 5 5;")}); 1076 props2Impls.put("-fx-background-images", new CssStyle[]{ 1077 new CssStyle("BACKGROUND-IMAGES", 1078 "-fx-background-images: " 1079 + "url(\"" + CSS_BORDER + "\") center repeat-x stretch;")}); 1080 props2Impls.put("-fx-text-origin", StyleArrayFactory.fromEnum(AlignmentCssStyle.class, "-fx-text-origin", VPos.values())); 1081 props2Impls.put("-fx-create-symbols", new CssStyle[]{ 1082 new CssStyle("CREATE-SYMBOLS", 1083 "-fx-create-symbols: " 1084 + "false;")}); 1085 props2Impls.put("-fx-highlight-fill", new CssStyle[]{ 1086 new CssStyle("HIGHLIGHT-FILL", 1087 "-fx-highlight-fill: " 1088 + "red;")}); 1089 props2Impls.put("-fx-highlight-text-fill", new CssStyle[]{ 1090 new CssStyle("HIGHLIGHT-TEXT-FILL", 1091 "-fx-highlight-text-fill: " 1092 + "red;")}); 1093 } 1094 1095 public static Set<Style> getStyles(ControlPage controlPage, boolean isUsingSetter) { 1096 1097 Set<Style> list = new TreeSet<Style>(); 1098 List<CssMetaData<? extends Styleable, ?>> controlKeys = getAllKeys(controlPage.keys); 1099 List<CssMetaData<? extends Styleable, ?>> regionKeys = getAllKeys(Region.getClassCssMetaData()); 1100 1101 Set<CssMetaData> uniqKeys = new HashSet<CssMetaData>(controlKeys); //makes unique keys 1102 try { 1103 if (controlPage.factory.createControl() instanceof Control) { 1104 uniqKeys.addAll(regionKeys); 1105 } 1106 } catch (Exception exc) { 1107 // ignore, this exception only web view , "Not on FX application thread" when code generate 1108 } 1109 for (CssMetaData key : uniqKeys) { 1110 CssStyle[] styles = props2Impls.get(key.getProperty()); 1111 if (styles == null) { 1112 StyleGenerator.addKey(key); //for map of styles generating 1113 } else { 1114 for (CssStyle style : styles) { 1115 if (isUsingSetter) { 1116 if (style.hasSetter()) { 1117 list.add(style); 1118 } 1119 } else { 1120 list.add(style); 1121 } 1122 } 1123 } 1124 } 1125 return list; 1126 } 1127 1128 private static CssStyle[] getBarPoliciesStyles(String keyName) { 1129 String namePref = keyName.substring("-fx-".length()).toUpperCase().replace("-", "_") + "_"; 1130 return new CssStyle[]{ 1131 new CssStyle(namePref + "NEVER", keyName + ": never;"), 1132 new CssStyle(namePref + "ALWAYS", keyName + ": always;") { 1133 @Override 1134 public void decorate(Node control, Pane container) { 1135 if (control instanceof ScrollPane) { 1136 ScrollPane scrollPane = (ScrollPane) control; 1137 scrollPane.setContent(new Rectangle(10, 10)); 1138 } 1139 super.decorate(control, container); 1140 } 1141 }, 1142 new CssStyle(namePref + "AS_NEEDED", keyName + ": as-needed;") { 1143 @Override 1144 public void decorate(Node control, Pane container) { 1145 if (control instanceof ScrollPane) { 1146 ((ScrollPane) control).setHbarPolicy(ScrollBarPolicy.NEVER); 1147 ((ScrollPane) control).setVbarPolicy(ScrollBarPolicy.NEVER); 1148 } 1149 super.decorate(control, container); 1150 } 1151 } 1152 }; 1153 } 1154 1155 private static List<CssMetaData<? extends Styleable, ?>> getAllKeys(List<CssMetaData<? extends Styleable, ?>> props) { 1156 List<CssMetaData<? extends Styleable, ?>> result = new ArrayList<CssMetaData<? extends Styleable, ?>>(props.size()); 1157 for (CssMetaData key : props) { 1158 result.addAll(getSubKeys(key)); 1159 } 1160 return result; 1161 1162 } 1163 1164 private static List<CssMetaData<? extends Styleable, ?>> getSubKeys(CssMetaData rootKey) { 1165 List<CssMetaData<? extends Styleable, ?>> keys = new ArrayList<CssMetaData<? extends Styleable, ?>>(); 1166 keys.add(rootKey); 1167 List<CssMetaData<? extends Styleable, ?>> subkeys = rootKey.getSubProperties(); 1168 if (subkeys != null) { 1169 for (CssMetaData subkey : subkeys) { 1170 keys.addAll(getSubKeys(subkey)); 1171 } 1172 } 1173 return keys; 1174 } 1175 1176 1177 public static void main(String[] a) { 1178 //for debug 1179 ControlsCSSApp.main(null); 1180 } 1181 }