use of org.apache.pivot.wtk.RadioButton in project pivot by apache.
the class RadioButtonSkin method mouseClick.
@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
boolean consumed = super.mouseClick(component, button, x, y, count);
RadioButton radioButton = (RadioButton) getComponent();
radioButton.requestFocus();
radioButton.press();
return consumed;
}
use of org.apache.pivot.wtk.RadioButton in project pivot by apache.
the class TerraRadioButtonSkin method getBaseline.
@Override
public int getBaseline(int width, int height) {
RadioButton radioButton = (RadioButton) getComponent();
int baseline = -1;
Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
dataRenderer.render(radioButton.getButtonData(), radioButton, false);
int clientWidth = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
baseline = dataRenderer.getBaseline(clientWidth, height);
return baseline;
}
use of org.apache.pivot.wtk.RadioButton in project pivot by apache.
the class TerraRadioButtonSkin method paint.
@Override
public void paint(Graphics2D graphics) {
RadioButton radioButton = (RadioButton) getComponent();
int width = getWidth();
int height = getHeight();
// Paint the button
int offset = (height - BUTTON_DIAMETER) / 2;
graphics.translate(0, offset);
paintButton(graphics, radioButton.isEnabled(), radioButton.isSelected());
graphics.translate(0, -offset);
// Paint the content
Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
Object buttonData = radioButton.getButtonData();
dataRenderer.render(buttonData, radioButton, false);
dataRenderer.setSize(Math.max(width - (BUTTON_DIAMETER + spacing * 2), 0), height);
Graphics2D contentGraphics = (Graphics2D) graphics.create();
contentGraphics.translate(BUTTON_DIAMETER + spacing, 0);
contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
dataRenderer.paint(contentGraphics);
contentGraphics.dispose();
// Paint the focus state
if (radioButton.isFocused()) {
if (buttonData == null) {
Color focusColor = ColorUtilities.setTransparencyInColor(buttonSelectionColor, ALPHA);
graphics.setColor(focusColor);
graphics.fillOval(0, 0, BUTTON_DIAMETER - 1, BUTTON_DIAMETER - 1);
} else {
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(buttonBorderColor);
GraphicsUtilities.setAntialiasingOn(graphics);
Rectangle2D focusRectangle = new Rectangle2D.Double(BUTTON_DIAMETER + 1, 0.5, dataRenderer.getWidth() + spacing * 2 - 2, dataRenderer.getHeight() - 1);
graphics.draw(focusRectangle);
}
}
}
use of org.apache.pivot.wtk.RadioButton in project pivot by apache.
the class TerraRadioButtonSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
RadioButton radioButton = (RadioButton) getComponent();
Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
int preferredWidth = BUTTON_DIAMETER;
Object buttonData = radioButton.getButtonData();
if (buttonData != null) {
dataRenderer.render(buttonData, radioButton, false);
preferredWidth += dataRenderer.getPreferredWidth(height) + spacing * 2;
}
return preferredWidth;
}
use of org.apache.pivot.wtk.RadioButton in project pivot by apache.
the class TerraRadioButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
RadioButton radioButton = (RadioButton) getComponent();
Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
int preferredWidth = BUTTON_DIAMETER;
int preferredHeight = BUTTON_DIAMETER;
Object buttonData = radioButton.getButtonData();
if (buttonData != null) {
dataRenderer.render(buttonData, radioButton, false);
preferredWidth += dataRenderer.getPreferredWidth(-1) + spacing * 2;
preferredHeight = Math.max(preferredHeight, dataRenderer.getPreferredHeight(-1));
}
return new Dimensions(preferredWidth, preferredHeight);
}
Aggregations