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