1 7 package javax.swing.plaf.synth; 8 9 import java.awt.*; 10 import javax.swing.*; 11 import javax.swing.border.Border ; 12 import javax.swing.plaf.UIResource ; 13 import javax.swing.text.DefaultEditorKit ; 14 import java.util.HashMap ; 15 import java.util.Map ; 16 import sun.swing.plaf.synth.SynthUI; 17 18 34 public abstract class SynthStyle { 35 38 private static Map DEFAULT_VALUES; 39 40 43 private static final SynthGraphicsUtils SYNTH_GRAPHICS = 44 new SynthGraphicsUtils (); 45 46 49 private static void populateDefaultValues() { 50 Object buttonMap = new UIDefaults.LazyInputMap(new Object [] { 51 "SPACE", "pressed", 52 "released SPACE", "released" 53 }); 54 DEFAULT_VALUES.put("Button.focusInputMap", buttonMap); 55 DEFAULT_VALUES.put("JCheckBox.focusInputMap", buttonMap); 56 DEFAULT_VALUES.put("JRadioButton.focusInputMap", buttonMap); 57 DEFAULT_VALUES.put("JToggleButton.focusInputMap", buttonMap); 58 DEFAULT_VALUES.put("SynthArrowButton.focusInputMap", buttonMap); 59 60 Object multilineInputMap = new UIDefaults.LazyInputMap(new Object [] { 61 "ctrl C", DefaultEditorKit.copyAction, 62 "ctrl V", DefaultEditorKit.pasteAction, 63 "ctrl X", DefaultEditorKit.cutAction, 64 "COPY", DefaultEditorKit.copyAction, 65 "PASTE", DefaultEditorKit.pasteAction, 66 "CUT", DefaultEditorKit.cutAction, 67 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 68 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 69 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 70 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 71 "ctrl LEFT", DefaultEditorKit.previousWordAction, 72 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 73 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 74 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 75 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 76 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 77 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 78 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 79 "ctrl A", DefaultEditorKit.selectAllAction, 80 "HOME", DefaultEditorKit.beginLineAction, 81 "END", DefaultEditorKit.endLineAction, 82 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 83 "shift END", DefaultEditorKit.selectionEndLineAction, 84 85 "UP", DefaultEditorKit.upAction, 86 "KP_UP", DefaultEditorKit.upAction, 87 "DOWN", DefaultEditorKit.downAction, 88 "KP_DOWN", DefaultEditorKit.downAction, 89 "PAGE_UP", DefaultEditorKit.pageUpAction, 90 "PAGE_DOWN", DefaultEditorKit.pageDownAction, 91 "shift PAGE_UP", "selection-page-up", 92 "shift PAGE_DOWN", "selection-page-down", 93 "ctrl shift PAGE_UP", "selection-page-left", 94 "ctrl shift PAGE_DOWN", "selection-page-right", 95 "shift UP", DefaultEditorKit.selectionUpAction, 96 "shift KP_UP", DefaultEditorKit.selectionUpAction, 97 "shift DOWN", DefaultEditorKit.selectionDownAction, 98 "shift KP_DOWN", DefaultEditorKit.selectionDownAction, 99 "ENTER", DefaultEditorKit.insertBreakAction, 100 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 101 "ctrl H", DefaultEditorKit.deletePrevCharAction, 102 "DELETE", DefaultEditorKit.deleteNextCharAction, 103 "RIGHT", DefaultEditorKit.forwardAction, 104 "LEFT", DefaultEditorKit.backwardAction, 105 "KP_RIGHT", DefaultEditorKit.forwardAction, 106 "KP_LEFT", DefaultEditorKit.backwardAction, 107 "TAB", DefaultEditorKit.insertTabAction, 108 "ctrl BACK_SLASH", "unselect", 109 "ctrl HOME", DefaultEditorKit.beginAction, 110 "ctrl END", DefaultEditorKit.endAction, 111 "ctrl shift HOME", DefaultEditorKit.selectionBeginAction, 112 "ctrl shift END", DefaultEditorKit.selectionEndAction, 113 "ctrl T", "next-link-action", 114 "ctrl shift T", "previous-link-action", 115 "ctrl SPACE", "activate-link-action", 116 "control shift O", "toggle-componentOrientation" 117 }); 118 DEFAULT_VALUES.put("EditorPane.focusInputMap", multilineInputMap); 119 DEFAULT_VALUES.put("TextArea.focusInputMap", multilineInputMap); 120 DEFAULT_VALUES.put("TextPane.focusInputMap", multilineInputMap); 121 122 Object fieldInputMap = new UIDefaults.LazyInputMap(new Object [] { 123 "ctrl C", DefaultEditorKit.copyAction, 124 "ctrl V", DefaultEditorKit.pasteAction, 125 "ctrl X", DefaultEditorKit.cutAction, 126 "COPY", DefaultEditorKit.copyAction, 127 "PASTE", DefaultEditorKit.pasteAction, 128 "CUT", DefaultEditorKit.cutAction, 129 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 130 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 131 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 132 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 133 "ctrl LEFT", DefaultEditorKit.previousWordAction, 134 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 135 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 136 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 137 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 138 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 139 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 140 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 141 "ctrl A", DefaultEditorKit.selectAllAction, 142 "HOME", DefaultEditorKit.beginLineAction, 143 "END", DefaultEditorKit.endLineAction, 144 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 145 "shift END", DefaultEditorKit.selectionEndLineAction, 146 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 147 "ctrl H", DefaultEditorKit.deletePrevCharAction, 148 "DELETE", DefaultEditorKit.deleteNextCharAction, 149 "RIGHT", DefaultEditorKit.forwardAction, 150 "LEFT", DefaultEditorKit.backwardAction, 151 "KP_RIGHT", DefaultEditorKit.forwardAction, 152 "KP_LEFT", DefaultEditorKit.backwardAction, 153 "ENTER", JTextField.notifyAction, 154 "ctrl BACK_SLASH", "unselect", 155 "control shift O", "toggle-componentOrientation" 156 }); 157 DEFAULT_VALUES.put("TextField.focusInputMap", fieldInputMap); 158 DEFAULT_VALUES.put("PasswordField.focusInputMap", fieldInputMap); 159 160 161 DEFAULT_VALUES.put("ComboBox.ancestorInputMap", 162 new UIDefaults.LazyInputMap(new Object [] { 163 "ESCAPE", "hidePopup", 164 "PAGE_UP", "pageUpPassThrough", 165 "PAGE_DOWN", "pageDownPassThrough", 166 "HOME", "homePassThrough", 167 "END", "endPassThrough", 168 "DOWN", "selectNext", 169 "KP_DOWN", "selectNext", 170 "alt DOWN", "togglePopup", 171 "alt KP_DOWN", "togglePopup", 172 "alt UP", "togglePopup", 173 "alt KP_UP", "togglePopup", 174 "SPACE", "spacePopup", 175 "ENTER", "enterPressed", 176 "UP", "selectPrevious", 177 "KP_UP", "selectPrevious" 178 })); 179 180 DEFAULT_VALUES.put("Desktop.ancestorInputMap", 181 new UIDefaults.LazyInputMap(new Object [] { 182 "ctrl F5", "restore", 183 "ctrl F4", "close", 184 "ctrl F7", "move", 185 "ctrl F8", "resize", 186 "RIGHT", "right", 187 "KP_RIGHT", "right", 188 "shift RIGHT", "shrinkRight", 189 "shift KP_RIGHT", "shrinkRight", 190 "LEFT", "left", 191 "KP_LEFT", "left", 192 "shift LEFT", "shrinkLeft", 193 "shift KP_LEFT", "shrinkLeft", 194 "UP", "up", 195 "KP_UP", "up", 196 "shift UP", "shrinkUp", 197 "shift KP_UP", "shrinkUp", 198 "DOWN", "down", 199 "KP_DOWN", "down", 200 "shift DOWN", "shrinkDown", 201 "shift KP_DOWN", "shrinkDown", 202 "ESCAPE", "escape", 203 "ctrl F9", "minimize", 204 "ctrl F10", "maximize", 205 "ctrl F6", "selectNextFrame", 206 "ctrl TAB", "selectNextFrame", 207 "ctrl alt F6", "selectNextFrame", 208 "shift ctrl alt F6", "selectPreviousFrame", 209 "ctrl F12", "navigateNext", 210 "shift ctrl F12", "navigatePrevious" 211 })); 212 213 DEFAULT_VALUES.put("FileChooser.ancestorInputMap", 214 new UIDefaults.LazyInputMap(new Object [] { 215 "ESCAPE", "cancelSelection", 216 "F2", "editFileName", 217 "F5", "refresh", 218 "BACK_SPACE", "Go Up", 219 "ENTER", "approveSelection" 220 })); 221 222 DEFAULT_VALUES.put("FormattedTextField.focusInputMap", 223 new UIDefaults.LazyInputMap(new Object [] { 224 "ctrl C", DefaultEditorKit.copyAction, 225 "ctrl V", DefaultEditorKit.pasteAction, 226 "ctrl X", DefaultEditorKit.cutAction, 227 "COPY", DefaultEditorKit.copyAction, 228 "PASTE", DefaultEditorKit.pasteAction, 229 "CUT", DefaultEditorKit.cutAction, 230 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 231 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 232 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 233 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 234 "ctrl LEFT", DefaultEditorKit.previousWordAction, 235 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 236 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 237 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 238 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 239 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 240 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 241 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 242 "ctrl A", DefaultEditorKit.selectAllAction, 243 "HOME", DefaultEditorKit.beginLineAction, 244 "END", DefaultEditorKit.endLineAction, 245 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 246 "shift END", DefaultEditorKit.selectionEndLineAction, 247 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 248 "ctrl H", DefaultEditorKit.deletePrevCharAction, 249 "DELETE", DefaultEditorKit.deleteNextCharAction, 250 "RIGHT", DefaultEditorKit.forwardAction, 251 "LEFT", DefaultEditorKit.backwardAction, 252 "KP_RIGHT", DefaultEditorKit.forwardAction, 253 "KP_LEFT", DefaultEditorKit.backwardAction, 254 "ENTER", JTextField.notifyAction, 255 "ctrl BACK_SLASH", "unselect", 256 "control shift O", "toggle-componentOrientation", 257 "ESCAPE", "reset-field-edit", 258 "UP", "increment", 259 "KP_UP", "increment", 260 "DOWN", "decrement", 261 "KP_DOWN", "decrement", 262 })); 263 264 DEFAULT_VALUES.put("InternalFrame.windowBindings", 265 new Object [] { 266 "shift ESCAPE", "showSystemMenu", 267 "ctrl SPACE", "showSystemMenu", 268 "ESCAPE", "hideSystemMenu"}); 269 270 DEFAULT_VALUES.put("List.focusInputMap", 271 new UIDefaults.LazyInputMap(new Object [] { 272 "ctrl C", "copy", 273 "ctrl V", "paste", 274 "ctrl X", "cut", 275 "COPY", "copy", 276 "PASTE", "paste", 277 "CUT", "cut", 278 "UP", "selectPreviousRow", 279 "KP_UP", "selectPreviousRow", 280 "shift UP", "selectPreviousRowExtendSelection", 281 "shift KP_UP", "selectPreviousRowExtendSelection", 282 "ctrl shift UP", "selectPreviousRowExtendSelection", 283 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 284 "ctrl UP", "selectPreviousRowChangeLead", 285 "ctrl KP_UP", "selectPreviousRowChangeLead", 286 "DOWN", "selectNextRow", 287 "KP_DOWN", "selectNextRow", 288 "shift DOWN", "selectNextRowExtendSelection", 289 "shift KP_DOWN", "selectNextRowExtendSelection", 290 "ctrl shift DOWN", "selectNextRowExtendSelection", 291 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 292 "ctrl DOWN", "selectNextRowChangeLead", 293 "ctrl KP_DOWN", "selectNextRowChangeLead", 294 "LEFT", "selectPreviousColumn", 295 "KP_LEFT", "selectPreviousColumn", 296 "shift LEFT", "selectPreviousColumnExtendSelection", 297 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 298 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 299 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 300 "ctrl LEFT", "selectPreviousColumnChangeLead", 301 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 302 "RIGHT", "selectNextColumn", 303 "KP_RIGHT", "selectNextColumn", 304 "shift RIGHT", "selectNextColumnExtendSelection", 305 "shift KP_RIGHT", "selectNextColumnExtendSelection", 306 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 307 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 308 "ctrl RIGHT", "selectNextColumnChangeLead", 309 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 310 "HOME", "selectFirstRow", 311 "shift HOME", "selectFirstRowExtendSelection", 312 "ctrl shift HOME", "selectFirstRowExtendSelection", 313 "ctrl HOME", "selectFirstRowChangeLead", 314 "END", "selectLastRow", 315 "shift END", "selectLastRowExtendSelection", 316 "ctrl shift END", "selectLastRowExtendSelection", 317 "ctrl END", "selectLastRowChangeLead", 318 "PAGE_UP", "scrollUp", 319 "shift PAGE_UP", "scrollUpExtendSelection", 320 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 321 "ctrl PAGE_UP", "scrollUpChangeLead", 322 "PAGE_DOWN", "scrollDown", 323 "shift PAGE_DOWN", "scrollDownExtendSelection", 324 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 325 "ctrl PAGE_DOWN", "scrollDownChangeLead", 326 "ctrl A", "selectAll", 327 "ctrl SLASH", "selectAll", 328 "ctrl BACK_SLASH", "clearSelection", 329 "SPACE", "addToSelection", 330 "ctrl SPACE", "toggleAndAnchor", 331 "shift SPACE", "extendTo", 332 "ctrl shift SPACE", "moveSelectionTo" 333 })); 334 335 DEFAULT_VALUES.put("List.focusInputMap.RightToLeft", 336 new UIDefaults.LazyInputMap(new Object [] { 337 "LEFT", "selectNextColumn", 338 "KP_LEFT", "selectNextColumn", 339 "shift LEFT", "selectNextColumnExtendSelection", 340 "shift KP_LEFT", "selectNextColumnExtendSelection", 341 "ctrl shift LEFT", "selectNextColumnExtendSelection", 342 "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", 343 "ctrl LEFT", "selectNextColumnChangeLead", 344 "ctrl KP_LEFT", "selectNextColumnChangeLead", 345 "RIGHT", "selectPreviousColumn", 346 "KP_RIGHT", "selectPreviousColumn", 347 "shift RIGHT", "selectPreviousColumnExtendSelection", 348 "shift KP_RIGHT", "selectPreviousColumnExtendSelection", 349 "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", 350 "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", 351 "ctrl RIGHT", "selectPreviousColumnChangeLead", 352 "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", 353 })); 354 355 DEFAULT_VALUES.put("MenuBar.windowBindings", 356 new Object [] { "F10", "takeFocus" }); 357 358 DEFAULT_VALUES.put("OptionPane.windowBindings", 359 new Object [] { "ESCAPE", "close" }); 360 361 DEFAULT_VALUES.put("RootPane.defaultButtonWindowKeyBindings", 362 new Object [] { 363 "ENTER", "press", 364 "released ENTER", "release", 365 "ctrl ENTER", "press", 366 "ctrl released ENTER", "release" 367 }); 368 369 DEFAULT_VALUES.put("ScrollBar.anecstorInputMap", 370 new UIDefaults.LazyInputMap(new Object [] { 371 "RIGHT", "positiveUnitIncrement", 372 "KP_RIGHT", "positiveUnitIncrement", 373 "DOWN", "positiveUnitIncrement", 374 "KP_DOWN", "positiveUnitIncrement", 375 "PAGE_DOWN", "positiveBlockIncrement", 376 "LEFT", "negativeUnitIncrement", 377 "KP_LEFT", "negativeUnitIncrement", 378 "UP", "negativeUnitIncrement", 379 "KP_UP", "negativeUnitIncrement", 380 "PAGE_UP", "negativeBlockIncrement", 381 "HOME", "minScroll", 382 "END", "maxScroll" 383 })); 384 385 DEFAULT_VALUES.put("ScrollBar.ancestorInputMap.RightToLeft", 386 new UIDefaults.LazyInputMap(new Object [] { 387 "RIGHT", "negativeUnitIncrement", 388 "KP_RIGHT", "negativeUnitIncrement", 389 "LEFT", "positiveUnitIncrement", 390 "KP_LEFT", "positiveUnitIncrement", 391 })); 392 393 DEFAULT_VALUES.put("ScrollPane.ancestorInputMap", 394 new UIDefaults.LazyInputMap(new Object [] { 395 "RIGHT", "unitScrollRight", 396 "KP_RIGHT", "unitScrollRight", 397 "DOWN", "unitScrollDown", 398 "KP_DOWN", "unitScrollDown", 399 "LEFT", "unitScrollLeft", 400 "KP_LEFT", "unitScrollLeft", 401 "UP", "unitScrollUp", 402 "KP_UP", "unitScrollUp", 403 "PAGE_UP", "scrollUp", 404 "PAGE_DOWN", "scrollDown", 405 "ctrl PAGE_UP", "scrollLeft", 406 "ctrl PAGE_DOWN", "scrollRight", 407 "ctrl HOME", "scrollHome", 408 "ctrl END", "scrollEnd" 409 })); 410 DEFAULT_VALUES.put("ScrollPane.ancestorInputMap.RightToLeft", 411 new UIDefaults.LazyInputMap(new Object [] { 412 "ctrl PAGE_UP", "scrollRight", 413 "ctrl PAGE_DOWN", "scrollLeft", 414 })); 415 416 DEFAULT_VALUES.put("SplitPane.ancestorInputMap", 417 new UIDefaults.LazyInputMap(new Object [] { 418 "UP", "negativeIncrement", 419 "DOWN", "positiveIncrement", 420 "LEFT", "negativeIncrement", 421 "RIGHT", "positiveIncrement", 422 "KP_UP", "negativeIncrement", 423 "KP_DOWN", "positiveIncrement", 424 "KP_LEFT", "negativeIncrement", 425 "KP_RIGHT", "positiveIncrement", 426 "HOME", "selectMin", 427 "END", "selectMax", 428 "F8", "startResize", 429 "F6", "toggleFocus", 430 "ctrl TAB", "focusOutForward", 431 "ctrl shift TAB", "focusOutBackward" 432 })); 433 434 DEFAULT_VALUES.put("Slider.focusInputMap", 435 new UIDefaults.LazyInputMap(new Object [] { 436 "RIGHT", "positiveUnitIncrement", 437 "KP_RIGHT", "positiveUnitIncrement", 438 "DOWN", "negativeUnitIncrement", 439 "KP_DOWN", "negativeUnitIncrement", 440 "PAGE_DOWN", "negativeBlockIncrement", 441 "ctrl PAGE_DOWN", "negativeBlockIncrement", 442 "LEFT", "negativeUnitIncrement", 443 "KP_LEFT", "negativeUnitIncrement", 444 "UP", "positiveUnitIncrement", 445 "KP_UP", "positiveUnitIncrement", 446 "PAGE_UP", "positiveBlockIncrement", 447 "ctrl PAGE_UP", "positiveBlockIncrement", 448 "HOME", "minScroll", 449 "END", "maxScroll" 450 })); 451 452 DEFAULT_VALUES.put("Slider.focusInputMap.RightToLeft", 453 new UIDefaults.LazyInputMap(new Object [] { 454 "RIGHT", "negativeUnitIncrement", 455 "KP_RIGHT", "negativeUnitIncrement", 456 "LEFT", "positiveUnitIncrement", 457 "KP_LEFT", "positiveUnitIncrement", 458 })); 459 460 DEFAULT_VALUES.put("TabbedPane.ancestorInputMap", 461 new UIDefaults.LazyInputMap(new Object [] { 462 "ctrl PAGE_DOWN", "navigatePageDown", 463 "ctrl PAGE_UP", "navigatePageUp", 464 "ctrl UP", "requestFocus", 465 "ctrl KP_UP", "requestFocus", 466 })); 467 468 DEFAULT_VALUES.put("TabbedPane.focusInputMap", 469 new UIDefaults.LazyInputMap(new Object [] { 470 "RIGHT", "navigateRight", 471 "KP_RIGHT", "navigateRight", 472 "LEFT", "navigateLeft", 473 "KP_LEFT", "navigateLeft", 474 "UP", "navigateUp", 475 "KP_UP", "navigateUp", 476 "DOWN", "navigateDown", 477 "KP_DOWN", "navigateDown", 478 "ctrl DOWN", "requestFocusForVisibleComponent", 479 "ctrl KP_DOWN", "requestFocusForVisibleComponent", 480 })); 481 482 DEFAULT_VALUES.put("Table.ancestorInputMap", 483 new UIDefaults.LazyInputMap(new Object [] { 484 "ctrl C", "copy", 485 "ctrl V", "paste", 486 "ctrl X", "cut", 487 "COPY", "copy", 488 "PASTE", "paste", 489 "CUT", "cut", 490 "RIGHT", "selectNextColumn", 491 "KP_RIGHT", "selectNextColumn", 492 "shift RIGHT", "selectNextColumnExtendSelection", 493 "shift KP_RIGHT", "selectNextColumnExtendSelection", 494 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 495 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 496 "ctrl RIGHT", "selectNextColumnChangeLead", 497 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 498 "LEFT", "selectPreviousColumn", 499 "KP_LEFT", "selectPreviousColumn", 500 "shift LEFT", "selectPreviousColumnExtendSelection", 501 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 502 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 503 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 504 "ctrl LEFT", "selectPreviousColumnChangeLead", 505 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 506 "DOWN", "selectNextRow", 507 "KP_DOWN", "selectNextRow", 508 "shift DOWN", "selectNextRowExtendSelection", 509 "shift KP_DOWN", "selectNextRowExtendSelection", 510 "ctrl shift DOWN", "selectNextRowExtendSelection", 511 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 512 "ctrl DOWN", "selectNextRowChangeLead", 513 "ctrl KP_DOWN", "selectNextRowChangeLead", 514 "UP", "selectPreviousRow", 515 "KP_UP", "selectPreviousRow", 516 "shift UP", "selectPreviousRowExtendSelection", 517 "shift KP_UP", "selectPreviousRowExtendSelection", 518 "ctrl shift UP", "selectPreviousRowExtendSelection", 519 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 520 "ctrl UP", "selectPreviousRowChangeLead", 521 "ctrl KP_UP", "selectPreviousRowChangeLead", 522 "HOME", "selectFirstColumn", 523 "shift HOME", "selectFirstColumnExtendSelection", 524 "ctrl shift HOME", "selectFirstRowExtendSelection", 525 "ctrl HOME", "selectFirstRow", 526 "END", "selectLastColumn", 527 "shift END", "selectLastColumnExtendSelection", 528 "ctrl shift END", "selectLastRowExtendSelection", 529 "ctrl END", "selectLastRow", 530 "PAGE_UP", "scrollUpChangeSelection", 531 "shift PAGE_UP", "scrollUpExtendSelection", 532 "ctrl shift PAGE_UP", "scrollLeftExtendSelection", 533 "ctrl PAGE_UP", "scrollLeftChangeSelection", 534 "PAGE_DOWN", "scrollDownChangeSelection", 535 "shift PAGE_DOWN", "scrollDownExtendSelection", 536 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", 537 "ctrl PAGE_DOWN", "scrollRightChangeSelection", 538 "TAB", "selectNextColumnCell", 539 "shift TAB", "selectPreviousColumnCell", 540 "ENTER", "selectNextRowCell", 541 "shift ENTER", "selectPreviousRowCell", 542 "ctrl A", "selectAll", 543 "ctrl SLASH", "selectAll", 544 "ctrl BACK_SLASH", "clearSelection", 545 "ESCAPE", "cancel", 546 "F2", "startEditing", 547 "SPACE", "addToSelection", 548 "ctrl SPACE", "toggleAndAnchor", 549 "shift SPACE", "extendTo", 550 "ctrl shift SPACE", "moveSelectionTo" 551 })); 552 553 DEFAULT_VALUES.put("Tree.ancestorInputMap", 554 new UIDefaults.LazyInputMap(new Object [] { 555 "ESCAPE", "cancel" 556 })); 557 DEFAULT_VALUES.put("Tree.focusInputMap", 558 new UIDefaults.LazyInputMap(new Object [] { 559 "ADD", "expand", 560 "SUBTRACT", "collapse", 561 "ctrl C", "copy", 562 "ctrl V", "paste", 563 "ctrl X", "cut", 564 "COPY", "copy", 565 "PASTE", "paste", 566 "CUT", "cut", 567 "UP", "selectPrevious", 568 "KP_UP", "selectPrevious", 569 "shift UP", "selectPreviousExtendSelection", 570 "shift KP_UP", "selectPreviousExtendSelection", 571 "ctrl shift UP", "selectPreviousExtendSelection", 572 "ctrl shift KP_UP", "selectPreviousExtendSelection", 573 "ctrl UP", "selectPreviousChangeLead", 574 "ctrl KP_UP", "selectPreviousChangeLead", 575 "DOWN", "selectNext", 576 "KP_DOWN", "selectNext", 577 "shift DOWN", "selectNextExtendSelection", 578 "shift KP_DOWN", "selectNextExtendSelection", 579 "ctrl shift DOWN", "selectNextExtendSelection", 580 "ctrl shift KP_DOWN", "selectNextExtendSelection", 581 "ctrl DOWN", "selectNextChangeLead", 582 "ctrl KP_DOWN", "selectNextChangeLead", 583 "RIGHT", "selectChild", 584 "KP_RIGHT", "selectChild", 585 "LEFT", "selectParent", 586 "KP_LEFT", "selectParent", 587 "PAGE_UP", "scrollUpChangeSelection", 588 "shift PAGE_UP", "scrollUpExtendSelection", 589 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 590 "ctrl PAGE_UP", "scrollUpChangeLead", 591 "PAGE_DOWN", "scrollDownChangeSelection", 592 "shift PAGE_DOWN", "scrollDownExtendSelection", 593 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 594 "ctrl PAGE_DOWN", "scrollDownChangeLead", 595 "HOME", "selectFirst", 596 "shift HOME", "selectFirstExtendSelection", 597 "ctrl shift HOME", "selectFirstExtendSelection", 598 "ctrl HOME", "selectFirstChangeLead", 599 "END", "selectLast", 600 "shift END", "selectLastExtendSelection", 601 "ctrl shift END", "selectLastExtendSelection", 602 "ctrl END", "selectLastChangeLead", 603 "F2", "startEditing", 604 "ctrl A", "selectAll", 605 "ctrl SLASH", "selectAll", 606 "ctrl BACK_SLASH", "clearSelection", 607 "ctrl LEFT", "scrollLeft", 608 "ctrl KP_LEFT", "scrollLeft", 609 "ctrl RIGHT", "scrollRight", 610 "ctrl KP_RIGHT", "scrollRight", 611 "SPACE", "addToSelection", 612 "ctrl SPACE", "toggleAndAnchor", 613 "shift SPACE", "extendTo", 614 "ctrl shift SPACE", "moveSelectionTo" 615 })); 616 DEFAULT_VALUES.put("Tree.focusInputMap.RightToLeft", 617 new UIDefaults.LazyInputMap(new Object [] { 618 "RIGHT", "selectParent", 619 "KP_RIGHT", "selectParent", 620 "LEFT", "selectChild", 621 "KP_LEFT", "selectChild", 622 })); 623 } 624 625 629 private static Object getDefaultValue(Object key) { 630 synchronized(SynthStyle .class) { 631 if (DEFAULT_VALUES == null) { 632 DEFAULT_VALUES = new HashMap (); 633 populateDefaultValues(); 634 } 635 Object value = DEFAULT_VALUES.get(key); 636 if (value instanceof UIDefaults.LazyValue) { 637 value = ((UIDefaults.LazyValue)value).createValue(null); 638 DEFAULT_VALUES.put(key, value); 639 } 640 return value; 641 } 642 } 643 644 647 public SynthStyle() { 648 } 649 650 656 public SynthGraphicsUtils getGraphicsUtils(SynthContext context) { 657 return SYNTH_GRAPHICS; 658 } 659 660 672 public Color getColor(SynthContext context, ColorType type) { 673 JComponent c = context.getComponent(); 674 Region id = context.getRegion(); 675 int cs = context.getComponentState(); 676 if (!id.isSubregion() && cs == SynthConstants.ENABLED) { 678 if (type == ColorType.BACKGROUND) { 679 return c.getBackground(); 680 } 681 else if (type == ColorType.FOREGROUND) { 682 return c.getForeground(); 683 } 684 else if (type == ColorType.TEXT_FOREGROUND) { 685 Color color = c.getForeground(); 690 if (!(color instanceof UIResource )) { 691 return color; 692 } 693 } 694 } 695 Color color = getColorForState(context, type); 697 if (color == null) { 698 if (type == ColorType.BACKGROUND || 700 type == ColorType.TEXT_BACKGROUND) { 701 return c.getBackground(); 702 } 703 else if (type == ColorType.FOREGROUND || 704 type == ColorType.TEXT_FOREGROUND) { 705 return c.getForeground(); 706 } 707 } 708 return color; 709 } 710 711 719 protected abstract Color getColorForState(SynthContext context, 720 ColorType type); 721 722 731 public Font getFont(SynthContext context) { 732 JComponent c = context.getComponent(); 733 if (context.getComponentState() == SynthConstants.ENABLED) { 734 return c.getFont(); 735 } 736 Font cFont = c.getFont(); 737 if (cFont != null && !(cFont instanceof UIResource )) { 738 return cFont; 739 } 740 return getFontForState(context); 741 } 742 743 750 protected abstract Font getFontForState(SynthContext context); 751 752 759 public Insets getInsets(SynthContext context, Insets insets) { 760 if (insets == null) { 761 insets = new Insets(0, 0, 0, 0); 762 } 763 insets.top = insets.bottom = insets.left = insets.right = 0; 764 return insets; 765 } 766 767 774 public SynthPainter getPainter(SynthContext context) { 775 return null; 776 } 777 778 784 public boolean isOpaque(SynthContext context) { 785 return true; 786 } 787 788 795 public Object get(SynthContext context, Object key) { 796 return getDefaultValue(key); 797 } 798 799 void installDefaults(SynthContext context, SynthUI ui) { 800 if (!context.isSubregion()) { 803 JComponent c = context.getComponent(); 804 Border border = c.getBorder(); 805 806 if (border == null || border instanceof UIResource ) { 807 c.setBorder(new SynthBorder (ui, getInsets(context, null))); 808 } 809 } 810 installDefaults(context); 811 } 812 813 820 public void installDefaults(SynthContext context) { 821 if (!context.isSubregion()) { 822 JComponent c = context.getComponent(); 823 Region region = context.getRegion(); 824 Font font = c.getFont(); 825 826 if (font == null || (font instanceof UIResource )) { 827 c.setFont(getFontForState(context)); 828 } 829 Color background = c.getBackground(); 830 if (background == null || (background instanceof UIResource )) { 831 c.setBackground(getColorForState(context, 832 ColorType.BACKGROUND)); 833 } 834 Color foreground = c.getForeground(); 835 if (foreground == null || (foreground instanceof UIResource )) { 836 c.setForeground(getColorForState(context, 837 ColorType.FOREGROUND)); 838 } 839 LookAndFeel.installProperty(c, "opaque", Boolean.valueOf(isOpaque(context))); 840 } 841 } 842 843 853 public void uninstallDefaults(SynthContext context) { 854 if (!context.isSubregion()) { 855 861 JComponent c = context.getComponent(); 862 Border border = c.getBorder(); 863 864 if (border instanceof UIResource ) { 865 c.setBorder(null); 866 } 867 } 868 } 869 870 882 public int getInt(SynthContext context, Object key, int defaultValue) { 883 Object value = get(context, key); 884 885 if (value instanceof Number ) { 886 return ((Number )value).intValue(); 887 } 888 return defaultValue; 889 } 890 891 901 public boolean getBoolean(SynthContext context, Object key, 902 boolean defaultValue) { 903 Object value = get(context, key); 904 905 if (value instanceof Boolean ) { 906 return ((Boolean )value).booleanValue(); 907 } 908 return defaultValue; 909 } 910 911 919 public Icon getIcon(SynthContext context, Object key) { 920 Object value = get(context, key); 921 922 if (value instanceof Icon) { 923 return (Icon)value; 924 } 925 return null; 926 } 927 928 938 public String getString(SynthContext context, Object key, 939 String defaultValue) { 940 Object value = get(context, key); 941 942 if (value instanceof String ) { 943 return (String )value; 944 } 945 return defaultValue; 946 } 947 } 948 | Popular Tags |