Package com.seaglasslookandfeel

Examples of com.seaglasslookandfeel.SeaGlassContext


    protected void installDefaults(JSlider slider) {
        updateStyle(slider);
    }

    protected void uninstallDefaults() {
        SeaGlassContext context = getContext(slider, ENABLED);
        style.uninstallDefaults(context);
        context.dispose();
        style = null;

        context = getContext(slider, Region.SLIDER_TRACK, ENABLED);
        sliderTrackStyle.uninstallDefaults(context);
        context.dispose();
        sliderTrackStyle = null;

        context = getContext(slider, Region.SLIDER_THUMB, ENABLED);
        sliderThumbStyle.uninstallDefaults(context);
        context.dispose();
        sliderThumbStyle = null;
    }
View Full Code Here


        slider.removePropertyChangeListener(this);
        super.uninstallListeners(slider);
    }

    private void updateStyle(JSlider c) {
        SeaGlassContext context = getContext(c, ENABLED);
        SynthStyle oldStyle = style;
        style = SeaGlassLookAndFeel.updateStyle(context, this);

        if (style != oldStyle) {
            thumbWidth = style.getInt(context, "Slider.thumbWidth", 30);

            thumbHeight = style.getInt(context, "Slider.thumbHeight", 14);
           
            trackHeightHack = style.getInt(context, "Slider.trackHeight", 5);

            // handle scaling for sizeVarients for special case components. The
            // key "JComponent.sizeVariant" scales for large/small/mini
            // components are based on Apples LAF
            String scaleKey = SeaGlassStyle.getSizeVariant(slider);
            if (scaleKey != null) {
                if (SeaGlassStyle.LARGE_KEY.equals(scaleKey)) {
                    thumbWidth *= 1.15;
                    thumbHeight *= 1.15;
                    trackHeightHack = 7;
                } else if (SeaGlassStyle.SMALL_KEY.equals(scaleKey)) {
                    thumbWidth *= 0.857;
                    thumbHeight *= 0.857;
                    trackHeightHack = 3;
                } else if (SeaGlassStyle.MINI_KEY.equals(scaleKey)) {
                    thumbWidth *= 0.784;
                    thumbHeight *= 0.784;
                    trackHeightHack = 3;
                }
            }

            trackBorder = style.getInt(context, "Slider.trackBorder", 1);

            trackHeight = thumbHeight + trackBorder * 2;

            paintValue = style.getBoolean(context, "Slider.paintValue", true);
            if (oldStyle != null) {
                uninstallKeyboardActions(c);
                installKeyboardActions(c);
            }
        }
        context.dispose();

        context = getContext(c, Region.SLIDER_TRACK, ENABLED);
        sliderTrackStyle = SeaGlassLookAndFeel.updateStyle(context, this);
        context.dispose();

        context = getContext(c, Region.SLIDER_THUMB, ENABLED);
        sliderThumbStyle = SeaGlassLookAndFeel.updateStyle(context, this);
        context.dispose();
    }
View Full Code Here

            throw new IllegalArgumentException("Width and height must be >= 0");
        }
        if (slider.getPaintLabels() && labelsHaveSameBaselines()) {
            // Get the insets for the track.
            Insets trackInsets = new Insets(0, 0, 0, 0);
            SeaGlassContext trackContext = getContext(slider, Region.SLIDER_TRACK);
            style.getInsets(trackContext, trackInsets);
            trackContext.dispose();
            if (slider.getOrientation() == JSlider.HORIZONTAL) {
                int valueHeight = 0;
                if (paintValue) {
                    SeaGlassContext context = getContext(slider);
                    valueHeight = context.getStyle().getGraphicsUtils(context).getMaximumCharHeight(context);
                    context.dispose();
                }
                int tickHeight = 0;
                if (slider.getPaintTicks()) {
                    tickHeight = getTickLength();
                }
                int labelHeight = getHeightOfTallestLabel();
                int contentHeight = valueHeight + trackHeight + trackInsets.top + trackInsets.bottom + tickHeight + labelHeight + 4;
                int centerY = height / 2 - contentHeight / 2;
                centerY += valueHeight + 2;
                centerY += trackHeight + trackInsets.top + trackInsets.bottom;
                centerY += tickHeight + 2;
                Component label = (Component) slider.getLabelTable().elements().nextElement();
                Dimension pref = label.getPreferredSize();
                return centerY + label.getBaseline(pref.width, pref.height);
            } else { // VERTICAL
                Integer value = slider.getInverted() ? getLowestValue() : getHighestValue();
                if (value != null) {
                    int valueY = insetCache.top;
                    int valueHeight = 0;
                    if (paintValue) {
                        SeaGlassContext context = getContext(slider);
                        valueHeight = context.getStyle().getGraphicsUtils(context).getMaximumCharHeight(context);
                        context.dispose();
                    }
                    int contentHeight = height - insetCache.top - insetCache.bottom;
                    int trackY = valueY + valueHeight;
                    int trackHeight = contentHeight - valueHeight;
                    int yPosition = yPositionForValue(value.intValue(), trackY, trackHeight);
View Full Code Here

        layout();
        calculateThumbLocation();
    }

    protected void layout() {
        SeaGlassContext context = getContext(slider);
        SynthGraphicsUtils synthGraphics = style.getGraphicsUtils(context);

        // Set the thumb size.
        Dimension size = getThumbSize();
        thumbRect.setSize(size.width, size.height);

        // Get the insets for the track.
        Insets trackInsets = new Insets(0, 0, 0, 0);
        SeaGlassContext trackContext = getContext(slider, Region.SLIDER_TRACK);
        style.getInsets(trackContext, trackInsets);
        trackContext.dispose();

        if (slider.getOrientation() == JSlider.HORIZONTAL) {
            // Calculate the height of all the subcomponents so we can center
            // them.
            valueRect.height = 0;
View Full Code Here

        }
        return size;
    }

    protected void recalculateIfInsetsChanged() {
        SeaGlassContext context = getContext(slider);
        Insets newInsets = style.getInsets(context, null);
        if (!newInsets.equals(insetCache)) {
            insetCache = newInsets;
            calculateGeometry();
        }
        context.dispose();
    }
View Full Code Here

        }
        return SeaGlassLookAndFeel.getComponentState(c);
    }

    public void update(Graphics g, JComponent c) {
        SeaGlassContext context = getContext(c);
        SeaGlassLookAndFeel.update(context, g);
        context.getPainter().paintSliderBackground(context, g, 0, 0, c.getWidth(), c.getHeight(), slider.getOrientation());
        paint(context, g);
        context.dispose();
    }
View Full Code Here

        paint(context, g);
        context.dispose();
    }

    public void paint(Graphics g, JComponent c) {
        SeaGlassContext context = getContext(c);
        paint(context, g);
        context.dispose();
    }
View Full Code Here

            g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
            context.getStyle().getGraphicsUtils(context).paintText(context, g, "" + slider.getValue(), valueRect.x, valueRect.y, -1);
        }

        SeaGlassContext subcontext = getContext(slider, Region.SLIDER_TRACK);
        paintTrack(subcontext, g, trackRect);
        subcontext.dispose();

        subcontext = getContext(slider, Region.SLIDER_THUMB);
        paintThumb(subcontext, g, thumbRect);
        subcontext.dispose();

        if (slider.getPaintTicks() && clip.intersects(tickRect)) {
            paintTicks(g);
        }
View Full Code Here

    /**
     * @see javax.swing.plaf.basic.BasicTabbedPaneUI#uninstallDefaults()
     */
    protected void uninstallDefaults() {
        SeaGlassContext context = getContext(tabPane, ENABLED);

        style.uninstallDefaults(context);
        context.dispose();
        style = null;

        tabStyle.uninstallDefaults(tabContext);
        tabContext.dispose();
        tabContext = null;
View Full Code Here

    /**
     * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, javax.swing.JComponent)
     */
    public void update(Graphics g, JComponent c) {
        SeaGlassContext context = getContext(c);

        SeaGlassLookAndFeel.update(context, g);
        context.getPainter().paintTabbedPaneBackground(context, g, tabAreaRect.x, tabAreaRect.y, tabAreaRect.width, tabAreaRect.height);
        paint(context, g);
        context.dispose();
    }
View Full Code Here

TOP

Related Classes of com.seaglasslookandfeel.SeaGlassContext

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.