| 1 |
package com.jidesoft.plaf.basic; |
| 2 |
|
| 3 |
import com.jidesoft.jdk.JdkSpecificClass; |
| 4 |
import com.jidesoft.plaf.LookAndFeelFactory; |
| 5 |
import com.jidesoft.plaf.UIDefaultsLookup; |
| 6 |
import com.jidesoft.plaf.XPUtils; |
| 7 |
import com.jidesoft.swing.*; |
| 8 |
import com.jidesoft.utils.ColorUtils; |
| 9 |
import com.jidesoft.utils.SecurityUtils; |
| 10 |
import com.jidesoft.utils.SystemInfo; |
| 11 |
|
| 12 |
import javax.swing.*; |
| 13 |
import javax.swing.plaf.ColorUIResource; |
| 14 |
import javax.swing.plaf.UIResource; |
| 15 |
import java.awt.*; |
| 16 |
|
| 17 |
/** |
| 18 |
* Painter for JIDE styles. |
| 19 |
* <p/> |
| 20 |
* Please note, this class is an internal class which is meant to be used by other JIDE classes only. Future version |
| 21 |
* might break your build if you use it. |
| 22 |
*/ |
| 23 |
public class BasicPainter implements SwingConstants, ThemePainter { |
| 24 |
private static BasicPainter _instance; |
| 25 |
|
| 26 |
public static ThemePainter getInstance() { |
| 27 |
if (_instance == null) { |
| 28 |
_instance = new BasicPainter(); |
| 29 |
} |
| 30 |
return _instance; |
| 31 |
} |
| 32 |
|
| 33 |
protected Color _bk0; |
| 34 |
protected Color _bk1; |
| 35 |
protected Color _bk2; |
| 36 |
protected Color _bk3; |
| 37 |
protected Color _borderColor; |
| 38 |
|
| 39 |
public BasicPainter() { |
| 40 |
} |
| 41 |
|
| 42 |
public void installDefaults() { |
| 43 |
if (_bk0 == null) { |
| 44 |
_bk0 = UIDefaultsLookup.getColor("JideButton.background"); |
| 45 |
} |
| 46 |
if (_bk1 == null) { |
| 47 |
_bk1 = UIDefaultsLookup.getColor("JideButton.focusedBackground"); |
| 48 |
} |
| 49 |
if (_bk2 == null) { |
| 50 |
_bk2 = UIDefaultsLookup.getColor("JideButton.selectedBackground"); |
| 51 |
} |
| 52 |
if (_bk3 == null) { |
| 53 |
_bk3 = UIDefaultsLookup.getColor("JideButton.selectedAndFocusedBackground"); |
| 54 |
} |
| 55 |
if (_borderColor == null) { |
| 56 |
_borderColor = UIDefaultsLookup.getColor("JideButton.borderColor"); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
public void uninstallDefaults() { |
| 61 |
_borderColor = null; |
| 62 |
_bk0 = null; |
| 63 |
_bk1 = null; |
| 64 |
_bk2 = null; |
| 65 |
_bk3 = null; |
| 66 |
} |
| 67 |
|
| 68 |
public Color getGripperForeground() { |
| 69 |
return UIDefaultsLookup.getColor("Gripper.foreground"); |
| 70 |
} |
| 71 |
|
| 72 |
public Color getGripperForegroundLt() { |
| 73 |
return UIDefaultsLookup.getColor("JideButton.highlight"); |
| 74 |
} |
| 75 |
|
| 76 |
public Color getSeparatorForeground() { |
| 77 |
return UIDefaultsLookup.getColor("JideButton.shadow"); |
| 78 |
} |
| 79 |
|
| 80 |
public Color getSeparatorForegroundLt() { |
| 81 |
return UIDefaultsLookup.getColor("JideButton.highlight"); |
| 82 |
} |
| 83 |
|
| 84 |
public Color getCollapsiblePaneContentBackground() { |
| 85 |
return UIDefaultsLookup.getColor("CollapsiblePane.contentBackground"); |
| 86 |
} |
| 87 |
|
| 88 |
public Color getCollapsiblePaneTitleForeground() { |
| 89 |
return UIDefaultsLookup.getColor("CollapsiblePane.foreground"); |
| 90 |
} |
| 91 |
|
| 92 |
public Color getCollapsiblePaneTitleForegroundEmphasized() { |
| 93 |
return UIDefaultsLookup.getColor("CollapsiblePane.emphasizedForeground"); |
| 94 |
} |
| 95 |
|
| 96 |
public Color getCollapsiblePaneFocusTitleForegroundEmphasized() { |
| 97 |
return UIDefaultsLookup.getColor("CollapsiblePane.emphasizedForeground"); |
| 98 |
} |
| 99 |
|
| 100 |
public Color getCollapsiblePaneFocusTitleForeground() { |
| 101 |
return UIDefaultsLookup.getColor("CollapsiblePane.foreground"); |
| 102 |
} |
| 103 |
|
| 104 |
public ImageIcon getCollapsiblePaneUpIcon() { |
| 105 |
return (ImageIcon) UIDefaultsLookup.getIcon("CollapsiblePane.upIcon"); |
| 106 |
} |
| 107 |
|
| 108 |
public ImageIcon getCollapsiblePaneDownIcon() { |
| 109 |
return (ImageIcon) UIDefaultsLookup.getIcon("CollapsiblePane.downIcon"); |
| 110 |
} |
| 111 |
|
| 112 |
public ImageIcon getCollapsiblePaneUpIconEmphasized() { |
| 113 |
return getCollapsiblePaneUpIcon(); |
| 114 |
} |
| 115 |
|
| 116 |
public ImageIcon getCollapsiblePaneDownIconEmphasized() { |
| 117 |
return getCollapsiblePaneDownIcon(); |
| 118 |
} |
| 119 |
|
| 120 |
public ImageIcon getCollapsiblePaneTitleButtonBackground() { |
| 121 |
return (ImageIcon) UIDefaultsLookup.getIcon("CollapsiblePane.titleButtonBackground"); |
| 122 |
} |
| 123 |
|
| 124 |
public ImageIcon getCollapsiblePaneTitleButtonBackgroundEmphasized() { |
| 125 |
return (ImageIcon) UIDefaultsLookup.getIcon("CollapsiblePane.titleButtonBackground.emphasized"); |
| 126 |
} |
| 127 |
|
| 128 |
public ImageIcon getCollapsiblePaneUpMask() { |
| 129 |
return getCollapsiblePaneUpIcon(); |
| 130 |
} |
| 131 |
|
| 132 |
public ImageIcon getCollapsiblePaneDownMask() { |
| 133 |
return getCollapsiblePaneDownIcon(); |
| 134 |
} |
| 135 |
|
| 136 |
public Color getBackgroundDk() { |
| 137 |
return UIDefaultsLookup.getColor("JideButton.background"); |
| 138 |
} |
| 139 |
|
| 140 |
public Color getBackgroundLt() { |
| 141 |
return UIDefaultsLookup.getColor("JideButton.background"); |
| 142 |
} |
| 143 |
|
| 144 |
public Color getSelectionSelectedDk() { |
| 145 |
return _bk2; |
| 146 |
} |
| 147 |
|
| 148 |
public Color getSelectionSelectedLt() { |
| 149 |
return _bk2; |
| 150 |
} |
| 151 |
|
| 152 |
public Color getMenuItemBorderColor() { |
| 153 |
return UIDefaultsLookup.getColor("MenuItem.selectionBorderColor"); |
| 154 |
} |
| 155 |
|
| 156 |
public Color getMenuItemBackground() { |
| 157 |
return UIDefaultsLookup.getColor("MenuItem.background"); |
| 158 |
} |
| 159 |
|
| 160 |
public Color getCommandBarTitleBarBackground() { |
| 161 |
return UIDefaultsLookup.getColor("CommandBar.titleBarBackground"); |
| 162 |
} |
| 163 |
|
| 164 |
public Color getControl() { |
| 165 |
return UIDefaultsLookup.getColor("JideButton.background"); |
| 166 |
} |
| 167 |
|
| 168 |
public Color getControlLt() { |
| 169 |
return getControlShadow(); |
| 170 |
} |
| 171 |
|
| 172 |
public Color getControlDk() { |
| 173 |
return getControlShadow(); |
| 174 |
} |
| 175 |
|
| 176 |
public Color getControlShadow() { |
| 177 |
return UIDefaultsLookup.getColor("JideButton.shadow"); |
| 178 |
} |
| 179 |
|
| 180 |
public Color getTitleBarBackground() { |
| 181 |
return UIDefaultsLookup.getColor("DockableFrame.activeTitleBackground"); |
| 182 |
} |
| 183 |
|
| 184 |
public Color getDockableFrameTitleBarActiveForeground() { |
| 185 |
return UIDefaultsLookup.getColor("DockableFrame.activeTitleForeground"); |
| 186 |
} |
| 187 |
|
| 188 |
public Color getDockableFrameTitleBarInactiveForeground() { |
| 189 |
return UIDefaultsLookup.getColor("DockableFrame.inactiveTitleForeground"); |
| 190 |
} |
| 191 |
|
| 192 |
public Color getTabbedPaneSelectDk() { |
| 193 |
return UIDefaultsLookup.getColor("JideTabbedPane.selectedTabBackgroundDk"); |
| 194 |
} |
| 195 |
|
| 196 |
public Color getTabbedPaneSelectLt() { |
| 197 |
return UIDefaultsLookup.getColor("JideTabbedPane.selectedTabBackgroundlt"); |
| 198 |
} |
| 199 |
|
| 200 |
public Color getTabAreaBackgroundDk() { |
| 201 |
return UIDefaultsLookup.getColor("JideTabbedPane.tabAreaBackgroundDk"); |
| 202 |
} |
| 203 |
|
| 204 |
public Color getTabAreaBackgroundLt() { |
| 205 |
return UIDefaultsLookup.getColor("JideTabbedPane.tabAreaBackgroundLt"); |
| 206 |
} |
| 207 |
|
| 208 |
public Color getOptionPaneBannerForeground() { |
| 209 |
return new ColorUIResource(255, 255, 255); |
| 210 |
} |
| 211 |
|
| 212 |
public Color getOptionPaneBannerDk() { |
| 213 |
return new ColorUIResource(45, 96, 249); |
| 214 |
} |
| 215 |
|
| 216 |
public Color getOptionPaneBannerLt() { |
| 217 |
return new ColorUIResource(0, 52, 206); |
| 218 |
} |
| 219 |
|
| 220 |
public void paintSelectedMenu(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 221 |
Color oldColor = g.getColor(); |
| 222 |
g.setColor(UIDefaultsLookup.getColor("JideButton.darkShadow")); |
| 223 |
g.drawLine(rect.x, rect.y + rect.height, rect.x, rect.y + 1); |
| 224 |
g.drawLine(rect.x + rect.width - 2, rect.y, rect.x + rect.width - 2, rect.y + rect.height); |
| 225 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 226 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 3, rect.y); |
| 227 |
} |
| 228 |
else { |
| 229 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 3, rect.y + rect.height - 1); |
| 230 |
} |
| 231 |
g.setColor(oldColor); |
| 232 |
} |
| 233 |
|
| 234 |
public void paintMenuItemBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 235 |
paintMenuItemBackground(c, g, rect, orientation, state, true); |
| 236 |
} |
| 237 |
|
| 238 |
public void paintMenuItemBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state, boolean showBorder) { |
| 239 |
paintButtonBackground(c, g, rect, orientation, state, showBorder); |
| 240 |
} |
| 241 |
|
| 242 |
public void paintButtonBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 243 |
paintButtonBackground(c, g, rect, orientation, state, true); |
| 244 |
} |
| 245 |
|
| 246 |
public void paintButtonBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state, boolean showBorder) { |
| 247 |
installDefaults(); |
| 248 |
Color background = null; |
| 249 |
|
| 250 |
Boolean highContrast = UIManager.getBoolean("Theme.highContrast"); |
| 251 |
if (highContrast) { |
| 252 |
background = c.getBackground(); |
| 253 |
paintBackground(c, g, rect, state == STATE_DEFAULT || state == STATE_DISABLE ? null : _borderColor, |
| 254 |
state == STATE_PRESSED || state == STATE_SELECTED || state == STATE_ROLLOVER ? UIDefaultsLookup.getColor("JideButton.selectedBackground") : background, orientation); |
| 255 |
return; |
| 256 |
} |
| 257 |
|
| 258 |
switch (state) { |
| 259 |
case STATE_DEFAULT: |
| 260 |
background = c.getBackground(); |
| 261 |
if (background == null || background instanceof UIResource) { |
| 262 |
background = _bk0; |
| 263 |
} |
| 264 |
paintBackground(c, g, rect, showBorder ? _borderColor : null, background, orientation); |
| 265 |
break; |
| 266 |
case STATE_ROLLOVER: |
| 267 |
if (c instanceof ComponentStateSupport) { |
| 268 |
background = ((ComponentStateSupport) c).getBackgroundOfState(STATE_ROLLOVER); |
| 269 |
} |
| 270 |
if (background == null || background instanceof UIResource) { |
| 271 |
background = _bk1; |
| 272 |
} |
| 273 |
paintBackground(c, g, rect, showBorder ? _borderColor : null, background, orientation); |
| 274 |
break; |
| 275 |
case STATE_SELECTED: |
| 276 |
if (c instanceof ComponentStateSupport) { |
| 277 |
background = ((ComponentStateSupport) c).getBackgroundOfState(STATE_SELECTED); |
| 278 |
} |
| 279 |
if (background == null || background instanceof UIResource) { |
| 280 |
background = _bk2; |
| 281 |
} |
| 282 |
paintBackground(c, g, rect, showBorder ? _borderColor : null, background, orientation); |
| 283 |
break; |
| 284 |
case STATE_DISABLE_SELECTED: |
| 285 |
if (c instanceof ComponentStateSupport) { |
| 286 |
background = ((ComponentStateSupport) c).getBackgroundOfState(STATE_SELECTED); |
| 287 |
} |
| 288 |
if (background == null || background instanceof UIResource) { |
| 289 |
background = _bk2; |
| 290 |
} |
| 291 |
paintBackground(c, g, rect, showBorder ? ColorUtils.toGrayscale(_borderColor) : null, ColorUtils.toGrayscale(background), orientation); |
| 292 |
break; |
| 293 |
case STATE_PRESSED: |
| 294 |
if (c instanceof ComponentStateSupport) { |
| 295 |
background = ((ComponentStateSupport) c).getBackgroundOfState(STATE_PRESSED); |
| 296 |
} |
| 297 |
if (background == null || background instanceof UIResource) { |
| 298 |
background = _bk3; |
| 299 |
} |
| 300 |
paintBackground(c, g, rect, showBorder ? _borderColor : null, background, orientation); |
| 301 |
break; |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
protected void paintBackground(JComponent c, Graphics g, Rectangle rect, Color borderColor, Color background, int orientation) { |
| 306 |
Color oldColor = g.getColor(); |
| 307 |
if (borderColor != null) { |
| 308 |
boolean paintDefaultBorder = true; |
| 309 |
Object o = c.getClientProperty("JideButton.paintDefaultBorder"); |
| 310 |
if (o instanceof Boolean) { |
| 311 |
paintDefaultBorder = (Boolean) o; |
| 312 |
} |
| 313 |
if (paintDefaultBorder) { |
| 314 |
g.setColor(borderColor); |
| 315 |
Object position = c.getClientProperty(JideButton.CLIENT_PROPERTY_SEGMENT_POSITION); |
| 316 |
if (position == null || JideButton.SEGMENT_POSITION_ONLY.equals(position)) { |
| 317 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1); |
| 318 |
} |
| 319 |
else if (JideButton.SEGMENT_POSITION_FIRST.equals(position)) { |
| 320 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 321 |
g.drawRect(rect.x, rect.y, rect.width, rect.height - 1); |
| 322 |
} |
| 323 |
else { |
| 324 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height); |
| 325 |
} |
| 326 |
} |
| 327 |
else if (JideButton.SEGMENT_POSITION_MIDDLE.equals(position)) { |
| 328 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 329 |
g.drawRect(rect.x, rect.y, rect.width, rect.height - 1); |
| 330 |
} |
| 331 |
else { |
| 332 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height); |
| 333 |
} |
| 334 |
} |
| 335 |
else if (JideButton.SEGMENT_POSITION_LAST.equals(position)) { |
| 336 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 337 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1); |
| 338 |
} |
| 339 |
else { |
| 340 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1); |
| 341 |
} |
| 342 |
} |
| 343 |
} |
| 344 |
g.setColor(background); |
| 345 |
g.fillRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); |
| 346 |
} |
| 347 |
else { |
| 348 |
g.setColor(background); |
| 349 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 350 |
} |
| 351 |
g.setColor(oldColor); |
| 352 |
} |
| 353 |
|
| 354 |
public void paintChevronBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 355 |
if (state != STATE_DEFAULT) { |
| 356 |
paintButtonBackground(c, g, rect, orientation, state); |
| 357 |
} |
| 358 |
} |
| 359 |
|
| 360 |
public void paintDividerBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 361 |
Color oldColor = g.getColor(); |
| 362 |
g.setColor(UIDefaultsLookup.getColor("SplitPane.background")); |
| 363 |
g.fillRect(0, 0, rect.width, rect.height); |
| 364 |
g.setColor(oldColor); |
| 365 |
} |
| 366 |
|
| 367 |
public void paintCommandBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 368 |
g.setColor(UIDefaultsLookup.getColor("CommandBar.background")); |
| 369 |
g.fillRoundRect(rect.x, rect.y, rect.width, rect.height, 2, 2); |
| 370 |
} |
| 371 |
|
| 372 |
public void paintFloatingCommandBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 373 |
g.setColor(UIDefaultsLookup.getColor("CommandBar.background")); |
| 374 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 375 |
} |
| 376 |
|
| 377 |
public void paintMenuShadow(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 378 |
Color oldColor = g.getColor(); |
| 379 |
g.setColor(UIDefaultsLookup.getColor("MenuItem.shadowColor")); |
| 380 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 381 |
g.setColor(oldColor); |
| 382 |
} |
| 383 |
|
| 384 |
public void paintContentBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 385 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 386 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 387 |
} |
| 388 |
|
| 389 |
public void paintStatusBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 390 |
if (c.isOpaque()) { |
| 391 |
paintContentBackground(c, g, rect, orientation, state); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
public void paintCommandBarTitlePane(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 396 |
g.setColor(getCommandBarTitleBarBackground()); |
| 397 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 398 |
} |
| 399 |
|
| 400 |
public void paintGripper(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 401 |
// int w = Math.min(30, rect.width); |
| 402 |
// int h = rect.height; |
| 403 |
|
| 404 |
// basic painter always use horizontal line to paint grippers. It's just they are short and more lines when paints vertical gripper |
| 405 |
// and long and fewer lines when paints horizontally. |
| 406 |
g.setColor(getGripperForeground()); |
| 407 |
|
| 408 |
// shrink the rect size |
| 409 |
if (rect.width > rect.height) { |
| 410 |
rect.x = rect.x + rect.width / 2 - 10; |
| 411 |
rect.width = 22; |
| 412 |
} |
| 413 |
else { |
| 414 |
rect.y = rect.y + rect.height / 2 - 10; |
| 415 |
rect.height = 22; |
| 416 |
} |
| 417 |
|
| 418 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 419 |
if (rect.width <= 30) { |
| 420 |
final int MARGIN = 3; |
| 421 |
for (int i = 0; i < (rect.height - 2 * MARGIN) / 2; i++) { |
| 422 |
g.drawLine(rect.x + 3, rect.y + MARGIN + i * 2, rect.x + rect.width - MARGIN, rect.y + MARGIN + i * 2); |
| 423 |
} |
| 424 |
} |
| 425 |
else { // for gripper in popup |
| 426 |
final int MARGIN = 2; |
| 427 |
for (int i = 0; i < (rect.height - 2 * MARGIN) / 2; i++) { |
| 428 |
g.drawLine((rect.width - rect.width) / 2, rect.y + MARGIN + i * 2, (rect.width + rect.width) / 2, rect.y + MARGIN + i * 2); |
| 429 |
} |
| 430 |
} |
| 431 |
} |
| 432 |
else { |
| 433 |
final int MARGIN = 3; |
| 434 |
int count = (rect.width - 2 * MARGIN) / 2; |
| 435 |
for (int i = 0; i < count; i++) { |
| 436 |
int x = rect.x + rect.width / 2 - count + i * 2; |
| 437 |
g.drawLine(x, rect.y + MARGIN, x, rect.y + rect.height - MARGIN); |
| 438 |
} |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
public void paintChevronMore(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 443 |
g.setColor(UIDefaultsLookup.getColor("CommandBar.darkShadow")); |
| 444 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 445 |
if (!c.getComponentOrientation().isLeftToRight()) { |
| 446 |
int y = rect.y + 4; |
| 447 |
for (int i = -2; i <= 2; i++) { |
| 448 |
int offset = Math.abs(i); |
| 449 |
g.drawLine(rect.x + 2 + offset, y, rect.x + 3 + offset, y); |
| 450 |
g.drawLine(rect.x + 6 + offset, y, rect.x + 7 + offset, y); |
| 451 |
y++; |
| 452 |
} |
| 453 |
} |
| 454 |
else { |
| 455 |
int y = rect.y + 4; |
| 456 |
for (int i = -2; i <= 2; i++) { |
| 457 |
int offset = -Math.abs(i); |
| 458 |
g.drawLine(rect.x + 4 + offset, y, rect.x + 5 + offset, y); |
| 459 |
g.drawLine(rect.x + 8 + offset, y, rect.x + 9 + offset, y); |
| 460 |
y++; |
| 461 |
} |
| 462 |
} |
| 463 |
} |
| 464 |
else if (orientation == SwingConstants.VERTICAL) { |
| 465 |
int x = rect.x + 4; |
| 466 |
for (int i = -2; i <= 2; i++) { |
| 467 |
int offset = -Math.abs(i); |
| 468 |
g.drawLine(x, rect.y + 4 + offset, x, rect.y + 5 + offset); |
| 469 |
g.drawLine(x, rect.y + 8 + offset, x, rect.y + 9 + offset); |
| 470 |
x++; |
| 471 |
} |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
public void paintChevronOption(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 476 |
int startX; |
| 477 |
int startY; |
| 478 |
if (orientation == SwingConstants.HORIZONTAL || !c.getComponentOrientation().isLeftToRight()) { |
| 479 |
startX = rect.x + 3; |
| 480 |
startY = rect.y + rect.height - 7; |
| 481 |
} |
| 482 |
else { |
| 483 |
startX = rect.x + rect.width - 7; |
| 484 |
startY = rect.y + 3; |
| 485 |
} |
| 486 |
if (orientation == SwingConstants.HORIZONTAL || !c.getComponentOrientation().isLeftToRight()) { |
| 487 |
JideSwingUtilities.paintArrow(g, UIDefaultsLookup.getColor("CommandBar.darkShadow"), startX, startY, 5, SwingConstants.HORIZONTAL); |
| 488 |
} |
| 489 |
else { |
| 490 |
JideSwingUtilities.paintArrow(g, UIDefaultsLookup.getColor("CommandBar.darkShadow"), startX, startY, 5, orientation); |
| 491 |
} |
| 492 |
} |
| 493 |
|
| 494 |
public void paintFloatingChevronOption(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 495 |
int startX = rect.width / 2 - 4; |
| 496 |
int startY = rect.height / 2 - 2; |
| 497 |
if (state == STATE_ROLLOVER) { |
| 498 |
JideSwingUtilities.paintArrow(g, Color.BLACK, startX, startY, 9, orientation); |
| 499 |
} |
| 500 |
else { |
| 501 |
JideSwingUtilities.paintArrow(g, Color.WHITE, startX, startY, 9, orientation); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
public void paintDockableFrameBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 506 |
if (!c.isOpaque()) { |
| 507 |
return; |
| 508 |
} |
| 509 |
g.setColor(UIDefaultsLookup.getColor("DockableFrame.background")); |
| 510 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 511 |
} |
| 512 |
|
| 513 |
public void paintDockableFrameTitlePane(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 514 |
int x = rect.x; |
| 515 |
int y = rect.y; |
| 516 |
int w = rect.width - 1; |
| 517 |
int h = rect.height; |
| 518 |
if (c.getBorder() != null) { |
| 519 |
Insets insets = c.getBorder().getBorderInsets(c); |
| 520 |
x += insets.left; |
| 521 |
y += insets.top; |
| 522 |
w -= insets.right + insets.left; |
| 523 |
h -= insets.top + insets.bottom; |
| 524 |
} |
| 525 |
rect = new Rectangle(x + 1, y + 1, w - 1, h - 1); |
| 526 |
|
| 527 |
Boolean highContrast = UIManager.getBoolean("Theme.highContrast"); |
| 528 |
if (state == STATE_SELECTED) { |
| 529 |
g.setColor(UIDefaultsLookup.getColor("DockableFrame.activeTitleBorderColor")); |
| 530 |
if ("true".equals(SecurityUtils.getProperty("shadingtheme", "false"))) { |
| 531 |
g.drawRoundRect(x, y, w, h, 2, 2); |
| 532 |
} |
| 533 |
else { |
| 534 |
g.drawRect(x, y, w, h); |
| 535 |
} |
| 536 |
g.setColor(highContrast ? UIDefaultsLookup.getColor("JideButton.selectedBackground") : UIDefaultsLookup.getColor("DockableFrame.activeTitleBackground")); |
| 537 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 538 |
} |
| 539 |
else { |
| 540 |
g.setColor(UIDefaultsLookup.getColor("DockableFrame.inactiveTitleBorderColor")); |
| 541 |
g.drawRoundRect(x, y, w, h, 2, 2); |
| 542 |
g.setColor(UIDefaultsLookup.getColor("DockableFrame.inactiveTitleBackground")); |
| 543 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 544 |
} |
| 545 |
if ("true".equals(SecurityUtils.getProperty("shadingtheme", "false"))) { |
| 546 |
JideSwingUtilities.fillGradient(g, rect, SwingConstants.HORIZONTAL); |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
public void paintCollapsiblePaneTitlePaneBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 551 |
Boolean highContrast = UIManager.getBoolean("Theme.highContrast"); |
| 552 |
if (!(c.getBackground() instanceof UIResource)) { |
| 553 |
g.setColor(c.getBackground()); |
| 554 |
} |
| 555 |
else { |
| 556 |
g.setColor(UIDefaultsLookup.getColor(highContrast ? "JideButton.background" : "CollapsiblePane.background")); |
| 557 |
} |
| 558 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 559 |
if (highContrast) { |
| 560 |
g.setColor(UIDefaultsLookup.getColor("CollapsiblePane.background")); |
| 561 |
g.drawRect(rect.x, rect.y, rect.width - 1, rect.height); |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
public void paintCollapsiblePaneTitlePaneBackgroundEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 566 |
if (!(c.getBackground() instanceof UIResource)) { |
| 567 |
g.setColor(c.getBackground()); |
| 568 |
} |
| 569 |
else { |
| 570 |
g.setColor(UIDefaultsLookup.getColor("CollapsiblePane.emphasizedBackground")); |
| 571 |
} |
| 572 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 573 |
} |
| 574 |
|
| 575 |
public void paintCollapsiblePanesBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 576 |
if (!c.isOpaque()) { |
| 577 |
return; |
| 578 |
} |
| 579 |
|
| 580 |
if (!(c.getBackground() instanceof UIResource)) { |
| 581 |
g.setColor(c.getBackground()); |
| 582 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 583 |
} |
| 584 |
else { |
| 585 |
g.setColor(UIDefaultsLookup.getColor("TextField.background")); |
| 586 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
public void paintCollapsiblePaneTitlePaneBackgroundPlainEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 591 |
g.setColor(UIDefaultsLookup.getColor("CollapsiblePane.emphasizedBackground")); |
| 592 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); |
| 593 |
} |
| 594 |
|
| 595 |
public void paintCollapsiblePaneTitlePaneBackgroundPlain(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 596 |
if (!(c.getBackground() instanceof UIResource)) { |
| 597 |
g.setColor(c.getBackground()); |
| 598 |
} |
| 599 |
else { |
| 600 |
g.setColor(UIDefaultsLookup.getColor("CollapsiblePane.background")); |
| 601 |
} |
| 602 |
switch (orientation) { |
| 603 |
case SwingConstants.EAST: |
| 604 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 605 |
break; |
| 606 |
case SwingConstants.WEST: |
| 607 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 608 |
break; |
| 609 |
case SwingConstants.NORTH: |
| 610 |
g.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y); |
| 611 |
case SwingConstants.SOUTH: |
| 612 |
default: |
| 613 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); |
| 614 |
break; |
| 615 |
} |
| 616 |
} |
| 617 |
|
| 618 |
public void paintCollapsiblePaneTitlePaneBackgroundSeparatorEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 619 |
g.setColor(UIManager.getColor("CollapsiblePane.emphasizedBackground")); |
| 620 |
g.fillRect(rect.x, rect.y, rect.x + rect.width, rect.height); |
| 621 |
} |
| 622 |
|
| 623 |
public void paintCollapsiblePaneTitlePaneBackgroundSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 624 |
g.setColor(UIManager.getColor("CollapsiblePane.background")); |
| 625 |
g.fillRect(rect.x, rect.y, rect.x + rect.width, rect.height); |
| 626 |
} |
| 627 |
|
| 628 |
public Color getColor(Object key) { |
| 629 |
return UIDefaultsLookup.getColor(key); |
| 630 |
} |
| 631 |
|
| 632 |
public void paintTabAreaBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 633 |
if (c.isOpaque() && c instanceof JideTabbedPane) { |
| 634 |
JideTabbedPane tabbedPane = (JideTabbedPane) c; |
| 635 |
int tabShape = tabbedPane.getTabShape(); |
| 636 |
int colorTheme = tabbedPane.getColorTheme(); |
| 637 |
if (tabShape == JideTabbedPane.SHAPE_BOX) { |
| 638 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 639 |
} |
| 640 |
else { |
| 641 |
if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) { |
| 642 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 643 |
|
| 644 |
} |
| 645 |
else if (colorTheme == JideTabbedPane.COLOR_THEME_VSNET) { |
| 646 |
g.setColor(UIDefaultsLookup.getColor("JideTabbedPane.tabAreaBackground")); |
| 647 |
} |
| 648 |
else { |
| 649 |
g.setColor(UIDefaultsLookup.getColor("control")); |
| 650 |
} |
| 651 |
} |
| 652 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
public void paintTabBackground(JComponent c, Graphics g, Shape region, Color[] colors, int orientation, int state) { |
| 657 |
Graphics2D g2d = (Graphics2D) g.create(); |
| 658 |
Color backgroundStart = colors[0]; |
| 659 |
Color backgroundEnd = colors[1]; |
| 660 |
if (backgroundEnd != null && backgroundStart != null) { |
| 661 |
int tabPlacement = JideTabbedPane.TOP; |
| 662 |
if (c instanceof JideTabbedPane) { |
| 663 |
tabPlacement = ((JideTabbedPane) c).getTabPlacement(); |
| 664 |
} |
| 665 |
switch (tabPlacement) { |
| 666 |
case JideTabbedPane.LEFT: |
| 667 |
JideSwingUtilities.fillGradient(g2d, region, backgroundStart, backgroundEnd, false); |
| 668 |
break; |
| 669 |
case JideTabbedPane.RIGHT: |
| 670 |
JideSwingUtilities.fillGradient(g2d, region, backgroundEnd, backgroundStart, false); |
| 671 |
break; |
| 672 |
case JideTabbedPane.BOTTOM: |
| 673 |
JideSwingUtilities.fillGradient(g2d, region, backgroundEnd, backgroundStart, true); |
| 674 |
break; |
| 675 |
case JideTabbedPane.TOP: |
| 676 |
default: |
| 677 |
JideSwingUtilities.fillGradient(g2d, region, backgroundStart, backgroundEnd, true); |
| 678 |
break; |
| 679 |
} |
| 680 |
} |
| 681 |
g2d.dispose(); |
| 682 |
} |
| 683 |
|
| 684 |
public void paintTabContentBorder(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 685 |
|
| 686 |
} |
| 687 |
|
| 688 |
public void paintSidePaneItemBackground(JComponent c, Graphics g, Rectangle rect, Color[] colors, int orientation, int state) { |
| 689 |
Color startColor = colors != null && colors.length > 0 ? colors[0] : c.getBackground(); |
| 690 |
Color endColor = colors != null && colors.length > 1 ? colors[1] : startColor; |
| 691 |
switch (orientation) { |
| 692 |
case SwingConstants.WEST: |
| 693 |
JideSwingUtilities.fillGradient((Graphics2D) g, rect, |
| 694 |
startColor, endColor, false); |
| 695 |
break; |
| 696 |
case SwingConstants.EAST: |
| 697 |
JideSwingUtilities.fillGradient((Graphics2D) g, rect, |
| 698 |
endColor, startColor, false); |
| 699 |
break; |
| 700 |
case SwingConstants.NORTH: |
| 701 |
JideSwingUtilities.fillGradient((Graphics2D) g, rect, |
| 702 |
startColor, endColor, true); |
| 703 |
break; |
| 704 |
case SwingConstants.SOUTH: |
| 705 |
JideSwingUtilities.fillGradient((Graphics2D) g, rect, |
| 706 |
endColor, startColor, true); |
| 707 |
break; |
| 708 |
} |
| 709 |
} |
| 710 |
|
| 711 |
public void paintHeaderBoxBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 712 |
boolean isCellEditor = Boolean.TRUE.equals(c.getClientProperty(HeaderBox.CLIENT_PROPERTY_TABLE_CELL_EDITOR)); |
| 713 |
|
| 714 |
Color baseColor = c.getBackground(); |
| 715 |
if (baseColor instanceof UIResource) { |
| 716 |
baseColor = UIDefaultsLookup.getColor("HeaderBox.background"); |
| 717 |
if (baseColor == null) { |
| 718 |
baseColor = UIDefaultsLookup.getColor("control"); |
| 719 |
} |
| 720 |
} |
| 721 |
if (state == STATE_PRESSED || state == STATE_SELECTED || state == STATE_ROLLOVER) { |
| 722 |
Color color = ColorUtils.getDerivedColor(baseColor, 0.48f); |
| 723 |
if (isCellEditor) { |
| 724 |
g.setColor(color); |
| 725 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 726 |
} |
| 727 |
else { |
| 728 |
g.setColor(color); |
| 729 |
g.fillRoundRect(rect.x, rect.y, rect.width - 1, rect.height - 1, 4, 4); |
| 730 |
|
| 731 |
g.setColor(ColorUtils.getDerivedColor(baseColor, 0.40f)); |
| 732 |
g.drawRoundRect(rect.x, rect.y, rect.width - 1, rect.height - 1, 6, 6); |
| 733 |
} |
| 734 |
|
| 735 |
g.setColor(ColorUtils.getDerivedColor(baseColor, 0.45f)); |
| 736 |
g.drawLine(rect.x + 1, rect.y + rect.height - 3, rect.x + rect.width - 2, rect.y + rect.height - 3); |
| 737 |
|
| 738 |
g.setColor(ColorUtils.getDerivedColor(baseColor, 0.43f)); |
| 739 |
g.drawLine(rect.x + 2, rect.y + rect.height - 2, rect.x + rect.width - 3, rect.y + rect.height - 2); |
| 740 |
|
| 741 |
g.setColor(ColorUtils.getDerivedColor(baseColor, 0.40f)); |
| 742 |
g.drawLine(rect.x + 3, rect.y + rect.height - 1, rect.x + rect.width - 4, rect.y + rect.height - 1); |
| 743 |
} |
| 744 |
else { |
| 745 |
if (isCellEditor) { |
| 746 |
g.setColor(baseColor); |
| 747 |
g.fillRect(rect.x, rect.y, rect.width - 1, rect.height - 1); |
| 748 |
} |
| 749 |
else { |
| 750 |
g.setColor(baseColor); |
| 751 |
g.fillRoundRect(rect.x, rect.y, rect.width - 1, rect.height - 1, 2, 2); |
| 752 |
|
| 753 |
g.setColor(ColorUtils.getDerivedColor(baseColor, .42f)); |
| 754 |
g.drawRoundRect(rect.x, rect.y, rect.width - 1, rect.height - 1, 2, 4); |
| 755 |
} |
| 756 |
|
| 757 |
g.setColor(ColorUtils.getDerivedColor(baseColor, .48f)); |
| 758 |
g.drawLine(rect.x + 1, rect.y + rect.height - 3, rect.x + rect.width - 2, rect.y + rect.height - 3); |
| 759 |
g.setColor(ColorUtils.getDerivedColor(baseColor, .47f)); |
| 760 |
g.drawLine(rect.x + 1, rect.y + rect.height - 2, rect.x + rect.width - 2, rect.y + rect.height - 2); |
| 761 |
|
| 762 |
if (isCellEditor) { |
| 763 |
g.setColor(new Color(198, 197, 178)); |
| 764 |
g.drawLine(rect.x + rect.width - 3, rect.y + 4, rect.x + rect.width - 3, rect.y + rect.height - 7); |
| 765 |
g.setColor(Color.WHITE); |
| 766 |
g.drawLine(rect.x + rect.width - 2, rect.y + 4, rect.x + rect.width - 2, rect.y + rect.height - 7); |
| 767 |
} |
| 768 |
} |
| 769 |
} |
| 770 |
|
| 771 |
public void paintToolBarSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 772 |
if (c.isOpaque()) { |
| 773 |
g.setColor(c.getBackground()); |
| 774 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 775 |
} |
| 776 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 777 |
g.setColor(c.getForeground()); |
| 778 |
g.drawLine(rect.x + rect.width / 2, rect.y + 1, rect.x + rect.width / 2, rect.y + rect.height - 2); |
| 779 |
} |
| 780 |
else { // HORIZONTAL |
| 781 |
g.setColor(c.getForeground()); |
| 782 |
g.drawLine(rect.x + 1, rect.y + rect.height / 2, rect.x + rect.width - 2, rect.y + rect.height / 2); |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
public void paintPopupMenuSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 787 |
int defaultShadowWidth = UIDefaultsLookup.getInt("MenuItem.shadowWidth"); |
| 788 |
int defaultTextIconGap = UIDefaultsLookup.getInt("MenuItem.textIconGap"); |
| 789 |
Color shadowColor = UIDefaultsLookup.getColor("MenuItem.shadowColor"); |
| 790 |
Color foreground = UIDefaultsLookup.getColor("PopupMenuSeparator.foreground"); |
| 791 |
Color background = UIDefaultsLookup.getColor("PopupMenuSeparator.background"); |
| 792 |
|
| 793 |
g.setColor(shadowColor); |
| 794 |
if (c.getComponentOrientation().isLeftToRight()) { |
| 795 |
g.fillRect(0, 0, defaultShadowWidth, rect.height); |
| 796 |
if ("true".equals(SecurityUtils.getProperty("shadingtheme", "false"))) { |
| 797 |
JideSwingUtilities.fillSingleGradient(g, new Rectangle(rect.x, rect.y, defaultShadowWidth, rect.height), SwingConstants.EAST, 255); |
| 798 |
} |
| 799 |
|
| 800 |
g.setColor(background); |
| 801 |
g.fillRect(rect.x + defaultShadowWidth, rect.y, rect.width - defaultShadowWidth, rect.height); |
| 802 |
|
| 803 |
g.setColor(foreground); |
| 804 |
g.drawLine(rect.x + defaultShadowWidth + defaultTextIconGap, rect.y + 1, rect.x + rect.width, rect.y + 1); |
| 805 |
} |
| 806 |
else { |
| 807 |
g.fillRect(rect.x + rect.width, rect.y, defaultShadowWidth, rect.height); |
| 808 |
if ("true".equals(SecurityUtils.getProperty("shadingtheme", "false"))) { |
| 809 |
JideSwingUtilities.fillSingleGradient(g, new Rectangle(rect.x + rect.width - defaultTextIconGap, rect.y, defaultShadowWidth, 2), SwingConstants.WEST, 255); |
| 810 |
} |
| 811 |
|
| 812 |
g.setColor(background); |
| 813 |
g.fillRect(rect.x, rect.y, rect.width - defaultShadowWidth, rect.height); |
| 814 |
|
| 815 |
g.setColor(foreground); |
| 816 |
g.drawLine(rect.x, rect.y + 1, rect.x + rect.width - defaultShadowWidth - defaultTextIconGap, rect.y + 1); |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
public void paintStatusBarSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 821 |
|
| 822 |
} |
| 823 |
|
| 824 |
/** |
| 825 |
* The distant from top edge of the table header to the top edge of the sort arrow. |
| 826 |
*/ |
| 827 |
public static int V_GAP = 0; |
| 828 |
|
| 829 |
/** |
| 830 |
* The distant from the right edge of the table header to left edge of sort arrow. |
| 831 |
*/ |
| 832 |
public static int H_GAP = 5; |
| 833 |
|
| 834 |
/** |
| 835 |
* The gap between the sort arrow and index text. |
| 836 |
*/ |
| 837 |
public static int ARROW_TEXT_GAP = 0; |
| 838 |
|
| 839 |
/** |
| 840 |
* Should the arrow be displayed on the top of the header. |
| 841 |
* |
| 842 |
* @return true to display the sort arrow on top. Otherwise false. |
| 843 |
*/ |
| 844 |
protected boolean shouldDisplayOnTop() { |
| 845 |
return SystemInfo.isWindowsVistaAbove() && |
| 846 |
(LookAndFeelFactory.isWindowsLookAndFeel(UIManager.getLookAndFeel()) && !LookAndFeelFactory.isWindowsClassicLookAndFeel(UIManager.getLookAndFeel())) && XPUtils.isXPStyleOn(); |
| 847 |
} |
| 848 |
|
| 849 |
public void fillBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state, Color color) { |
| 850 |
Color oldColor = g.getColor(); |
| 851 |
g.setColor(color); |
| 852 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
| 853 |
g.setColor(oldColor); |
| 854 |
} |
| 855 |
|
| 856 |
public Insets getSortableTableHeaderColumnCellDecoratorInsets(JComponent c, Graphics g, Rectangle rect, int orientation, int state, int sortOrder, Icon sortIcon, int orderIndex, Color indexColor, boolean paintIndex) { |
| 857 |
if (shouldDisplayOnTop()) { |
| 858 |
return null; |
| 859 |
} |
| 860 |
int iconWidth = sortIcon == null ? 0 : sortIcon.getIconWidth(); |
| 861 |
int textWidthAndGap = 0; |
| 862 |
if (paintIndex && orderIndex != -1) { |
| 863 |
Font font; |
| 864 |
if (g != null) { |
| 865 |
Font oldFont = g.getFont(); |
| 866 |
font = g.getFont().deriveFont(Font.PLAIN, oldFont.getSize() - 3); |
| 867 |
} |
| 868 |
else if (c.getFont() != null) { |
| 869 |
font = c.getFont().deriveFont(Font.PLAIN, c.getFont().getSize() - 3); |
| 870 |
} |
| 871 |
else { |
| 872 |
font = Font.getFont("Arial"); |
| 873 |
} |
| 874 |
String str = "" + (orderIndex + 1); |
| 875 |
int textWidth = SwingUtilities.computeStringWidth(c.getFontMetrics(font), str); |
| 876 |
textWidthAndGap = ARROW_TEXT_GAP + textWidth + H_GAP; |
| 877 |
} |
| 878 |
else { |
| 879 |
textWidthAndGap = H_GAP; |
| 880 |
} |
| 881 |
if (textWidthAndGap + iconWidth == 0) { |
| 882 |
return null; |
| 883 |
} |
| 884 |
return new Insets(0, 0, 0, textWidthAndGap + iconWidth); |
| 885 |
} |
| 886 |
|
| 887 |
public void paintSortableTableHeaderColumn(JComponent c, Graphics g, Rectangle rect, int orientation, int state, int sortOrder, Icon sortIcon, int orderIndex, Color indexColor, boolean paintIndex) { |
| 888 |
int iconHeight = sortIcon == null ? 0 : sortIcon.getIconHeight(); |
| 889 |
int iconWidth = sortIcon == null ? 0 : sortIcon.getIconWidth(); |
| 890 |
int yOffset = sortIcon == null ? 0 : (rect.height - iconHeight) / 2 - V_GAP; |
| 891 |
|
| 892 |
boolean leftToRight = c.getComponentOrientation().isLeftToRight(); |
| 893 |
if (paintIndex && orderIndex != -1) { |
| 894 |
Font oldFont = g.getFont(); |
| 895 |
Font font = g.getFont().deriveFont(Font.PLAIN, oldFont.getSize() - 3); |
| 896 |
String str = "" + (orderIndex + 1); |
| 897 |
int textWidth = SwingUtilities.computeStringWidth(c.getFontMetrics(font), str); |
| 898 |
g.setFont(font); |
| 899 |
Color oldColor = g.getColor(); |
| 900 |
g.setColor(indexColor); |
| 901 |
int x = rect.x + rect.width / 2 - (iconWidth + ARROW_TEXT_GAP + textWidth) / 2; |
| 902 |
int y = rect.y + V_GAP; |
| 903 |
if (shouldDisplayOnTop()) { |
| 904 |
JideSwingUtilities.drawString(c, g, str, x + ARROW_TEXT_GAP + iconWidth, rect.y + V_GAP + c.getFontMetrics(font).getAscent() - 2); |
| 905 |
} |
| 906 |
else if (leftToRight) { |
| 907 |
JideSwingUtilities.drawString(c, g, str, rect.x + rect.width - textWidth - H_GAP, rect.y + yOffset + iconHeight / 2 + 1); |
| 908 |
} |
| 909 |
else { |
| 910 |
JideSwingUtilities.drawString(c, g, str, rect.x + H_GAP, rect.y + yOffset + iconHeight / 2 + 1); |
| 911 |
} |
| 912 |
g.setColor(oldColor); |
| 913 |
g.setFont(oldFont); |
| 914 |
if (sortIcon != null) { |
| 915 |
if (!shouldDisplayOnTop()) { |
| 916 |
if (leftToRight) { |
| 917 |
x = rect.x + rect.width - iconWidth - textWidth - H_GAP - ARROW_TEXT_GAP; |
| 918 |
} |
| 919 |
else { |
| 920 |
x = rect.x + textWidth + H_GAP + ARROW_TEXT_GAP; |
| 921 |
} |
| 922 |
} |
| 923 |
if(JdkSpecificClass.isSynthIcon(sortIcon)) { |
| 924 |
JdkSpecificClass.paintTableHeaderIcon(c, sortIcon, g, x, y); |
| 925 |
} |
| 926 |
else sortIcon.paintIcon(c, g, x, y); |
| 927 |
} |
| 928 |
} |
| 929 |
else { |
| 930 |
if (sortIcon != null) { |
| 931 |
int x = rect.x + rect.width / 2 - iconWidth / 2; |
| 932 |
int y = rect.y + V_GAP; |
| 933 |
|
| 934 |
if (!shouldDisplayOnTop()) { |
| 935 |
if (leftToRight) { |
| 936 |
x = rect.x + rect.width - iconWidth - H_GAP; |
| 937 |
y = rect.y + yOffset; |
| 938 |
} |
| 939 |
else { |
| 940 |
x = rect.x + H_GAP; |
| 941 |
y = rect.y + yOffset; |
| 942 |
} |
| 943 |
} |
| 944 |
if(JdkSpecificClass.isSynthIcon(sortIcon)) { |
| 945 |
JdkSpecificClass.paintTableHeaderIcon(c, sortIcon, g, x, y); |
| 946 |
} |
| 947 |
else sortIcon.paintIcon(c, g, x, y); |
| 948 |
} |
| 949 |
} |
| 950 |
} |
| 951 |
} |