use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TerraColorChooserButtonSkin method paint.
@Override
public void paint(Graphics2D graphics) {
ColorChooserButton colorChooserButton = (ColorChooserButton) getComponent();
int width = getWidth();
int height = getHeight();
Color backgroundColorLocal = null;
Color bevelColorLocal = null;
Color borderColorLocal = null;
if (colorChooserButton.isEnabled()) {
backgroundColorLocal = this.backgroundColor;
bevelColorLocal = (pressed || (colorChooserPopup.isOpen() && !colorChooserPopup.isClosing())) ? pressedBevelColor : this.bevelColor;
borderColorLocal = this.borderColor;
} else {
backgroundColorLocal = disabledBackgroundColor;
bevelColorLocal = disabledBevelColor;
borderColorLocal = disabledBorderColor;
}
// Paint the background
GraphicsUtilities.setAntialiasingOn(graphics);
if (!themeIsFlat()) {
graphics.setPaint(new GradientPaint(width / 2f, 0, bevelColorLocal, width / 2f, height / 2f, backgroundColorLocal));
} else {
graphics.setPaint(backgroundColorLocal);
}
graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height - 1, CORNER_RADIUS, CORNER_RADIUS));
// Paint the content
GraphicsUtilities.setAntialiasingOff(graphics);
Bounds contentBounds = new Bounds(0, 0, Math.max(width - TRIGGER_WIDTH - 1, 0), Math.max(height - 1, 0));
Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
dataRenderer.setSize(Math.max(contentBounds.width - (padding.getWidth() + 2) + 1, 0), Math.max(contentBounds.height - (padding.getHeight() + 2) + 1, 0));
Graphics2D contentGraphics = (Graphics2D) graphics.create();
contentGraphics.translate(padding.left + 1, padding.top + 1);
contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
dataRenderer.paint(contentGraphics);
contentGraphics.dispose();
GraphicsUtilities.setAntialiasingOn(graphics);
if (!themeIsFlat()) {
// Paint the border
if (borderColorLocal != null) {
graphics.setPaint(borderColorLocal);
graphics.setStroke(new BasicStroke(1));
graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height - 1, CORNER_RADIUS, CORNER_RADIUS));
}
}
// Paint the focus state
if (colorChooserButton.isFocused()) {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 2.0f }, 0.0f);
graphics.setStroke(dashStroke);
graphics.setColor(this.borderColor);
graphics.draw(new RoundRectangle2D.Double(2.5, 2.5, Math.max(width - 5, 0), Math.max(height - 5, 0), CORNER_RADIUS / 2, CORNER_RADIUS / 2));
}
GraphicsUtilities.setAntialiasingOff(graphics);
// Paint the trigger
GeneralPath triggerIconShape = new GeneralPath(Path2D.WIND_EVEN_ODD);
triggerIconShape.moveTo(0, 0);
triggerIconShape.lineTo(3, 3);
triggerIconShape.lineTo(6, 0);
triggerIconShape.closePath();
Graphics2D triggerGraphics = (Graphics2D) graphics.create();
triggerGraphics.setStroke(new BasicStroke(0));
triggerGraphics.setPaint(color);
Bounds triggerBounds = new Bounds(Math.max(width - (padding.right + TRIGGER_WIDTH), 0), 0, TRIGGER_WIDTH, Math.max(height - padding.getHeight(), 0));
int tx = triggerBounds.x + (triggerBounds.width - triggerIconShape.getBounds().width) / 2;
int ty = triggerBounds.y + (triggerBounds.height - triggerIconShape.getBounds().height) / 2;
triggerGraphics.translate(tx, ty);
triggerGraphics.draw(triggerIconShape);
triggerGraphics.fill(triggerIconShape);
triggerGraphics.dispose();
}
use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class FakeWindowSkin method paint.
@Override
public void paint(Graphics2D graphics) {
// Call the base class to paint the background
super.paint(graphics);
int width = getWidth();
int height = getHeight();
int titleBarHeight = titleBarTablePane.getHeight();
// Draw the title area
Color titleBarBackgroundColorLocal = this.titleBarBackgroundColor;
Color titleBarBorderColorLocal = this.titleBarBorderColor;
Color titleBarBevelColorLocal = this.titleBarBevelColor;
graphics.setPaint(new GradientPaint(width / 2f, 0, titleBarBevelColorLocal, width / 2f, titleBarHeight + 1, titleBarBackgroundColorLocal));
graphics.fillRect(0, 0, width, titleBarHeight + 1);
// Draw the border
graphics.setPaint(titleBarBorderColorLocal);
GraphicsUtilities.drawRect(graphics, 0, 0, width, titleBarHeight + 2);
// Draw the content area
Bounds contentAreaRectangle = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
graphics.setPaint(contentBorderColor);
GraphicsUtilities.drawRect(graphics, contentAreaRectangle.x, contentAreaRectangle.y, contentAreaRectangle.width, contentAreaRectangle.height);
// graphics.setPaint(contentBevelColor);
GraphicsUtilities.drawLine(graphics, contentAreaRectangle.x + 1, contentAreaRectangle.y + 1, contentAreaRectangle.width - 2, Orientation.HORIZONTAL);
}
Aggregations