Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Meter


    @Override
    public void install(Component component) {
        super.install(component);

        Meter meter = (Meter)component;
        meter.getMeterListeners().add(this);
    }
View Full Code Here


        return false;
    }

    @Override
    public int getPreferredWidth(int height) {
        Meter meter = (Meter)getComponent();

        int preferredWidth;

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
                preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;
View Full Code Here

        return preferredWidth;
    }

    @Override
    public int getPreferredHeight(int width) {
        Meter meter = (Meter)getComponent();

        int preferredHeight;

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            preferredHeight = getPreferredWidth(width);
        } else {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
                preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
View Full Code Here

        return preferredHeight;
    }

    @Override
    public Dimensions getPreferredSize() {
        Meter meter = (Meter)getComponent();
        String text = meter.getText();

        int preferredWidth = 0;
        int preferredHeight = 0;
        if (text != null
            && text.length() > 0) {
            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
            preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;

            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
            preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
        }

        // If meter has no content, its preferred size is hard coded by the class
        preferredWidth = Math.max(preferredWidth, DEFAULT_WIDTH);
        preferredHeight = Math.max(preferredHeight, DEFAULT_HEIGHT);

        Dimensions preferredSize;
        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            preferredSize = new Dimensions(preferredWidth, preferredHeight);
        } else {
            preferredSize = new Dimensions(preferredHeight, preferredWidth);
        }
View Full Code Here

    @Override
    public int getBaseline(int width, int height) {
        int baseline = -1;

        Meter meter = (Meter)getComponent();

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
                float ascent = lm.getAscent();
View Full Code Here

        // No-op
    }

    @Override
    public void paint(Graphics2D graphics) {
        Meter meter = (Meter)getComponent();

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

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

        if (FONT_RENDER_CONTEXT.isAntiAliased()) {
            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                Platform.getTextAntialiasingHint());
        }

        if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        }

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            drawMeter(meter, graphics, width, height);
        } else {
            graphics.rotate(-Math.PI / 2d);
            graphics.translate(-height, 0);
            drawMeter(meter, graphics, height, width);
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        Meter meter = (Meter)component;
        meter.getMeterListeners().add(this);
    }
View Full Code Here

        return false;
    }

    @Override
    public int getPreferredWidth(int height) {
        Meter meter = (Meter)getComponent();

        int preferredWidth;

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
                Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
View Full Code Here

        return preferredWidth;
    }

    @Override
    public int getPreferredHeight(int width) {
        Meter meter = (Meter)getComponent();

        int preferredHeight;

        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            preferredHeight = getPreferredWidth(width);
        } else {
            String text = meter.getText();

            if (text != null
                && text.length() > 0) {
                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
                LineMetrics lm = font.getLineMetrics("", fontRenderContext);
View Full Code Here

        return preferredHeight;
    }

    @Override
    public Dimensions getPreferredSize() {
        Meter meter = (Meter)getComponent();
        String text = meter.getText();

        int preferredWidth = 0;
        int preferredHeight = 0;
        if (text != null
            && text.length() > 0) {
            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
            preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;

            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
            preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
        }

        // If meter has no content, its preferred size is hard coded by the class
        preferredWidth = Math.max(preferredWidth, DEFAULT_WIDTH);
        preferredHeight = Math.max(preferredHeight, DEFAULT_HEIGHT);

        Dimensions preferredSize;
        if (meter.getOrientation() == Orientation.HORIZONTAL) {
            preferredSize = new Dimensions(preferredWidth, preferredHeight);
        } else {
            preferredSize = new Dimensions(preferredHeight, preferredWidth);
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Meter

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.