src/macosx/classes/com/apple/laf/AquaPainter.java
Print this page
@@ -64,11 +64,11 @@
static <T extends JRSUIState> AquaPainter<T> create(final T state, final NineSliceMetricsProvider metricsProvider) {
return new AquaNineSlicingImagePainter<T>(state, metricsProvider);
}
- abstract void paint(final SunGraphics2D g, final T stateToPaint, final Component c);
+ abstract void paint(final Graphics2D g, final T stateToPaint, final Component c);
final Rectangle boundsRect = new Rectangle();
final JRSUIControl control;
T state;
public AquaPainter(final JRSUIControl control, final T state) {
@@ -83,11 +83,11 @@
void paint(final Graphics g, final Component c, final int x, final int y, final int w, final int h) {
boundsRect.setBounds(x, y, w, h);
final T nextState = (T)state.derive();
- final SunGraphics2D g2d = getGraphics2D(g);
+ final Graphics2D g2d = getGraphics2D(g);
if (g2d != null) paint(g2d, nextState, c);
state = nextState;
}
static class AquaNineSlicingImagePainter<T extends JRSUIState> extends AquaPainter<T> {
@@ -103,11 +103,11 @@
this.metricsProvider = metricsProvider;
slicedControlImages = new HashMap<T, RecyclableJRSUISlicedImageControl>();
}
@Override
- void paint(final SunGraphics2D g, final T stateToPaint, final Component c) {
+ void paint(final Graphics2D g, final T stateToPaint, final Component c) {
if (metricsProvider == null) {
AquaSingleImagePainter.paintFromSingleCachedImage(g, control, stateToPaint, c, boundsRect);
return;
}
@@ -130,15 +130,15 @@
public AquaSingleImagePainter(final T state) {
super(new JRSUIControl(false), state);
}
@Override
- void paint(SunGraphics2D g, T stateToPaint, Component c) {
+ void paint(Graphics2D g, T stateToPaint, Component c) {
paintFromSingleCachedImage(g, control, stateToPaint, c, boundsRect);
}
- static void paintFromSingleCachedImage(final SunGraphics2D g, final JRSUIControl control, final JRSUIState controlState, final Component c, final Rectangle boundsRect) {
+ static void paintFromSingleCachedImage(final Graphics2D g, final JRSUIControl control, final JRSUIState controlState, final Component c, final Rectangle boundsRect) {
Rectangle clipRect = g.getClipBounds();
Rectangle intersection = boundsRect.intersection(clipRect);
if (intersection.width <= 0 || intersection.height <= 0) return;
int imgX1 = intersection.x - boundsRect.x;
@@ -193,21 +193,23 @@
return image;
}
}
- protected SunGraphics2D getGraphics2D(final Graphics g) {
+ protected Graphics2D getGraphics2D(final Graphics g) {
try {
return (SunGraphics2D)g; // doing a blind try is faster than checking instanceof
} catch (Exception e) {
if (g instanceof PeekGraphics) {
// if it is a peek just dirty the region
g.fillRect(boundsRect.x, boundsRect.y, boundsRect.width, boundsRect.height);
} else if (g instanceof ProxyGraphics2D) {
final ProxyGraphics2D pg = (ProxyGraphics2D)g;
final Graphics2D g2d = pg.getDelegate();
if (g2d instanceof SunGraphics2D) { return (SunGraphics2D)g2d; }
+ } else if (g instanceof Graphics2D) {
+ return (Graphics2D) g;
}
}
return null;
}