use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class BasicArrowButton method paint.
public void paint(Graphics g) {
Color origColor;
boolean isPressed, isEnabled;
int w, h, size;
w = getSize().width;
h = getSize().height;
origColor = g.getColor();
isPressed = getModel().isPressed();
isEnabled = isEnabled();
g.setColor(getBackground());
g.fillRect(1, 1, w - 2, h - 2);
/// Draw the proper Border
if (getBorder() != null && !(getBorder() instanceof UIResource)) {
paintBorder(g);
} else if (isPressed) {
g.setColor(shadow);
g.drawRect(0, 0, w - 1, h - 1);
} else {
// Using the background color set above
g.drawLine(0, 0, 0, h - 1);
g.drawLine(1, 0, w - 2, 0);
// inner 3D border
g.setColor(highlight);
g.drawLine(1, 1, 1, h - 3);
g.drawLine(2, 1, w - 3, 1);
// inner 3D border
g.setColor(shadow);
g.drawLine(1, h - 2, w - 2, h - 2);
g.drawLine(w - 2, 1, w - 2, h - 3);
// black drop shadow __|
g.setColor(darkShadow);
g.drawLine(0, h - 1, w - 1, h - 1);
g.drawLine(w - 1, h - 1, w - 1, 0);
}
// If there's no room to draw arrow, bail
if (h < 5 || w < 5) {
g.setColor(origColor);
return;
}
if (isPressed) {
g.translate(1, 1);
}
// Draw the arrow
size = Math.min((h - 4) / 3, (w - 4) / 3);
size = Math.max(size, 2);
paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction, isEnabled);
// Reset the Graphics back to it's original settings
if (isPressed) {
g.translate(-1, -1);
}
g.setColor(origColor);
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class NimbusIcon method paintIcon.
@Override
public void paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h) {
Painter painter = null;
if (context != null) {
painter = (Painter) context.getStyle().get(context, key);
}
if (painter == null) {
painter = (Painter) UIManager.get(prefix + "[Enabled]." + key);
}
if (painter != null && context != null) {
JComponent c = context.getComponent();
boolean rotate = false;
boolean flip = false;
//translatex and translatey are additional translations that
//must occur on the graphics context when rendering a toolbar
//icon
int translatex = 0;
int translatey = 0;
if (c instanceof JToolBar) {
JToolBar toolbar = (JToolBar) c;
rotate = toolbar.getOrientation() == JToolBar.VERTICAL;
flip = !toolbar.getComponentOrientation().isLeftToRight();
Object o = NimbusLookAndFeel.resolveToolbarConstraint(toolbar);
//that the border is probably going to be our border
if (toolbar.getBorder() instanceof UIResource) {
if (o == BorderLayout.SOUTH) {
translatey = 1;
} else if (o == BorderLayout.EAST) {
translatex = 1;
}
}
} else if (c instanceof JMenu) {
flip = !c.getComponentOrientation().isLeftToRight();
}
if (g instanceof Graphics2D) {
Graphics2D gfx = (Graphics2D) g;
gfx.translate(x, y);
gfx.translate(translatex, translatey);
if (rotate) {
gfx.rotate(Math.toRadians(90));
gfx.translate(0, -w);
painter.paint(gfx, context.getComponent(), h, w);
gfx.translate(0, w);
gfx.rotate(Math.toRadians(-90));
} else if (flip) {
gfx.scale(-1, 1);
gfx.translate(-w, 0);
painter.paint(gfx, context.getComponent(), w, h);
gfx.translate(w, 0);
gfx.scale(-1, 1);
} else {
painter.paint(gfx, context.getComponent(), w, h);
}
gfx.translate(-translatex, -translatey);
gfx.translate(-x, -y);
} else {
// use image if we are printing to a Java 1.1 PrintGraphics as
// it is not a instance of Graphics2D
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D gfx = img.createGraphics();
if (rotate) {
gfx.rotate(Math.toRadians(90));
gfx.translate(0, -w);
painter.paint(gfx, context.getComponent(), h, w);
} else if (flip) {
gfx.scale(-1, 1);
gfx.translate(-w, 0);
painter.paint(gfx, context.getComponent(), w, h);
} else {
painter.paint(gfx, context.getComponent(), w, h);
}
gfx.dispose();
g.drawImage(img, x, y, null);
img = null;
}
}
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class AquaTableHeaderBorder method paintBorder.
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
if (!doPaint)
return;
final JComponent jc = (JComponent) c;
// if the developer wants to set their own color, we should
// interpret this as "get out of the way", and don't draw aqua.
final Color componentBackground = jc.getBackground();
if (!(componentBackground instanceof UIResource)) {
doPaint = false;
jc.paint(g);
getAlternateBorder().paintBorder(jc, g, x, y, width, height);
doPaint = true;
return;
}
final State state = getState(jc);
painter.state.set(state);
painter.state.set(jc.hasFocus() ? Focused.YES : Focused.NO);
painter.state.set(height > 16 ? Widget.BUTTON_BEVEL : Widget.BUTTON_LIST_HEADER);
painter.state.set(selected ? BooleanValue.YES : BooleanValue.NO);
switch(sortOrder) {
case SORT_ASCENDING:
painter.state.set(Direction.UP);
break;
case SORT_DECENDING:
painter.state.set(Direction.DOWN);
break;
default:
painter.state.set(Direction.NONE);
break;
}
final int newX = x;
final int newY = y;
final int newWidth = width;
final int newHeight = height;
painter.paint(g, c, newX - 1, newY - 1, newWidth + 1, newHeight);
// Draw the header
g.clipRect(newX, y, newWidth, height);
g.translate(fHorizontalShift, -1);
doPaint = false;
jc.paint(g);
doPaint = true;
}
Aggregations