Search in sources :

Example 6 with RadioButton

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;
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton)

Example 7 with RadioButton

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;
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) RadioButton(org.apache.pivot.wtk.RadioButton) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Example 8 with RadioButton

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);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) Color(java.awt.Color) Rectangle2D(java.awt.geom.Rectangle2D) RadioButton(org.apache.pivot.wtk.RadioButton) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint) Graphics2D(java.awt.Graphics2D)

Example 9 with RadioButton

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;
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) RadioButton(org.apache.pivot.wtk.RadioButton) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Example 10 with RadioButton

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);
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) Dimensions(org.apache.pivot.wtk.Dimensions) RadioButton(org.apache.pivot.wtk.RadioButton) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Aggregations

RadioButton (org.apache.pivot.wtk.RadioButton)13 Button (org.apache.pivot.wtk.Button)10 Paint (java.awt.Paint)5 RadialGradientPaint (java.awt.RadialGradientPaint)5 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)5 LinkButton (org.apache.pivot.wtk.LinkButton)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 URL (java.net.URL)1 Vote (org.apache.pivot.util.Vote)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 CardPane (org.apache.pivot.wtk.CardPane)1 CardPaneListener (org.apache.pivot.wtk.CardPaneListener)1 Checkbox (org.apache.pivot.wtk.Checkbox)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 ImageView (org.apache.pivot.wtk.ImageView)1 Label (org.apache.pivot.wtk.Label)1 PushButton (org.apache.pivot.wtk.PushButton)1