Package pivot.wtk

Examples of pivot.wtk.PushButton


        return new Dimensions(preferredWidth, preferredHeight);
    }

    public void paint(Graphics2D graphics) {
        PushButton pushButton = (PushButton)getComponent();

        Color borderColor = null;
        Color gradientStartColor = null;
        Color gradientEndColor = null;

        if (pushButton.isEnabled()) {
            if (pressed
                || pushButton.isSelected()) {
                borderColor = pressedBorderColor;
                gradientStartColor = pressedGradientStartColor;
                gradientEndColor = pressedGradientEndColor;
            } else {
                if (highlighted) {
                    borderColor = highlightedBorderColor;
                    gradientStartColor = highlightedGradientStartColor;
                    gradientEndColor = highlightedGradientEndColor;
                } else {
                    borderColor = this.borderColor;
                    gradientStartColor = this.gradientStartColor;
                    gradientEndColor = this.gradientEndColor;
                }
            }
        }
        else {
            borderColor = disabledBorderColor;
            gradientStartColor = disabledGradientStartColor;
            gradientEndColor = disabledGradientEndColor;
        }

        int width = getWidth();
        int height = getHeight();

        Graphics2D contentGraphics = (Graphics2D)graphics.create();

        // Paint the background
        RoundRectangle2D buttonRectangle = new RoundRectangle2D.Double(0, 0,
            width - 1, height - 1, cornerRadius, cornerRadius);

        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

        graphics.setPaint(new GradientPaint(width / 2, 0, gradientStartColor,
            width / 2, height, gradientEndColor));
        graphics.fill(buttonRectangle);

        // Paint the border
        graphics.setPaint(borderColor);
        graphics.setStroke(new BasicStroke());
        graphics.draw(buttonRectangle);

        // Paint the content
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
        dataRenderer.render(pushButton.getButtonData(), pushButton, false);
        dataRenderer.setSize(Math.max(width - (padding.left + padding.right + 2), 0),
            Math.max(getHeight() - (padding.top + padding.bottom + 2), 0));

        contentGraphics.translate(padding.left + 1, padding.top + 1);
        contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
        dataRenderer.paint(contentGraphics);

        // Paint the focus state
        if (pushButton.isFocused()) {
            BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] {1.0f, 1.0f}, 0.0f);

            graphics.setColor(highlightedGradientStartColor);
            graphics.setStroke(dashStroke);
View Full Code Here


        FlowPane buttonFlowPane = wtkxSerializer.getObjectByID("buttonFlowPane");

        for (int i = 0, n = alert.getOptionCount(); i < n; i++) {
            Object option = alert.getOption(i);

            PushButton optionButton = new PushButton(option);
            HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
            optionButtonStyles.put("color", theme.getColor(4));
            optionButtonStyles.put("backgroundColor", theme.getColor(16));
            optionButtonStyles.put("borderColor", theme.getColor(13));

            optionButton.setStyles(optionButtonStyles);
            optionButton.getStyles().put("preferredAspectRatio", 3);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Alert alert = (Alert)getComponent();
View Full Code Here

TOP

Related Classes of pivot.wtk.PushButton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.