396 } |
396 } |
397 |
397 |
398 @Override |
398 @Override |
399 public Object createValue(UIDefaults table) { |
399 public Object createValue(UIDefaults table) { |
400 try { |
400 try { |
401 Class c; |
401 Class<?> c; |
402 Object cl; |
402 Object cl; |
403 // See if we should use a separate ClassLoader |
403 // See if we should use a separate ClassLoader |
404 if (table == null || !((cl = table.get("ClassLoader")) |
404 if (table == null || !((cl = table.get("ClassLoader")) |
405 instanceof ClassLoader)) { |
405 instanceof ClassLoader)) { |
406 cl = Thread.currentThread(). |
406 cl = Thread.currentThread(). |
410 cl = ClassLoader.getSystemClassLoader(); |
410 cl = ClassLoader.getSystemClassLoader(); |
411 } |
411 } |
412 } |
412 } |
413 |
413 |
414 c = Class.forName(className, true, (ClassLoader)cl); |
414 c = Class.forName(className, true, (ClassLoader)cl); |
415 Constructor constructor = c.getConstructor( |
415 Constructor<?> constructor = c.getConstructor( |
416 AbstractRegionPainter.PaintContext.class, int.class); |
416 AbstractRegionPainter.PaintContext.class, int.class); |
417 if (constructor == null) { |
417 if (constructor == null) { |
418 throw new NullPointerException( |
418 throw new NullPointerException( |
419 "Failed to find the constructor for the class: " + |
419 "Failed to find the constructor for the class: " + |
420 className); |
420 className); |
562 return matches(c.getParent(), partIndex - 1); |
562 return matches(c.getParent(), partIndex - 1); |
563 } else if (!parts[partIndex].named) { |
563 } else if (!parts[partIndex].named) { |
564 //if c is not named, and parts[partIndex] has an expected class |
564 //if c is not named, and parts[partIndex] has an expected class |
565 //type registered, then check to make sure c is of the |
565 //type registered, then check to make sure c is of the |
566 //right type; |
566 //right type; |
567 Class clazz = parts[partIndex].c; |
567 Class<?> clazz = parts[partIndex].c; |
568 if (clazz != null && clazz.isAssignableFrom(c.getClass())) { |
568 if (clazz != null && clazz.isAssignableFrom(c.getClass())) { |
569 //so far so good, recurse |
569 //so far so good, recurse |
570 return matches(c.getParent(), partIndex - 1); |
570 return matches(c.getParent(), partIndex - 1); |
571 } else if (clazz == null && |
571 } else if (clazz == null && |
572 registeredRegions.containsKey(parts[partIndex].s)) { |
572 registeredRegions.containsKey(parts[partIndex].s)) { |
634 |
634 |
635 private final class Part { |
635 private final class Part { |
636 private String s; |
636 private String s; |
637 //true if this part represents a component name |
637 //true if this part represents a component name |
638 private boolean named; |
638 private boolean named; |
639 private Class c; |
639 private Class<?> c; |
640 |
640 |
641 Part(String s) { |
641 Part(String s) { |
642 named = s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"'; |
642 named = s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"'; |
643 if (named) { |
643 if (named) { |
644 this.s = s.substring(1, s.length() - 1); |
644 this.s = s.substring(1, s.length() - 1); |
814 } |
814 } |
815 } |
815 } |
816 |
816 |
817 private static final class PainterBorder implements Border, UIResource { |
817 private static final class PainterBorder implements Border, UIResource { |
818 private Insets insets; |
818 private Insets insets; |
819 private Painter painter; |
819 private Painter<Component> painter; |
820 private String painterKey; |
820 private String painterKey; |
821 |
821 |
822 PainterBorder(String painterKey, Insets insets) { |
822 PainterBorder(String painterKey, Insets insets) { |
823 this.insets = insets; |
823 this.insets = insets; |
824 this.painterKey = painterKey; |
824 this.painterKey = painterKey; |
825 } |
825 } |
826 |
826 |
827 @Override |
827 @Override |
828 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { |
828 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { |
829 if (painter == null) { |
829 if (painter == null) { |
830 painter = (Painter)UIManager.get(painterKey); |
830 @SuppressWarnings("unchecked") |
|
831 Painter<Component> temp = (Painter<Component>)UIManager.get(painterKey); |
|
832 painter = temp; |
831 if (painter == null) return; |
833 if (painter == null) return; |
832 } |
834 } |
833 |
835 |
834 g.translate(x, y); |
836 g.translate(x, y); |
835 if (g instanceof Graphics2D) |
837 if (g instanceof Graphics2D) |