Package com.seaglasslookandfeel.painter

Examples of com.seaglasslookandfeel.painter.SeaGlassPainter


     *         none could be found.
     */
    public SeaGlassPainter getBackgroundPainter(SynthContext ctx) {
        Values  v      = getValues(ctx);
        int     xstate = getExtendedState(ctx, v);
        SeaGlassPainter p      = null;

        // check the cache
        tmpKey.init("backgroundPainter$$instance", xstate);
        p = (SeaGlassPainter) v.cache.get(tmpKey);

View Full Code Here


     *         none could be found.
     */
    public SeaGlassPainter getForegroundPainter(SynthContext ctx) {
        Values  v      = getValues(ctx);
        int     xstate = getExtendedState(ctx, v);
        SeaGlassPainter p      = null;

        // check the cache
        tmpKey.init("foregroundPainter$$instance", xstate);
        p = (SeaGlassPainter) v.cache.get(tmpKey);

View Full Code Here

     *         none could be found.
     */
    public SeaGlassPainter getBorderPainter(SynthContext ctx) {
        Values  v      = getValues(ctx);
        int     xstate = getExtendedState(ctx, v);
        SeaGlassPainter p      = null;

        // check the cache
        tmpKey.init("borderPainter$$instance", xstate);
        p = (SeaGlassPainter) v.cache.get(tmpKey);

View Full Code Here

     * @param h       Height of the region to paint to, may be 0.
     */
    @SuppressWarnings("unchecked")
    @Override
    public void paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h) {
        SeaGlassPainter painter = null;

        if (context != null) {
            painter = (SeaGlassPainter) context.getStyle().get(context, key);
        }

        if (painter == null) {
            painter = (SeaGlassPainter) UIManager.get(prefix + "[Enabled]." + key);
        }

        if (painter == null) {
            painter = (SeaGlassPainter) UIManager.get(prefix + "." + key);
        }

        if (painter != null && context != null) {
            JComponent c      = context.getComponent();
            boolean    rotate = false;
            boolean    flip   = false;

            // translatex and translatey are additional translations that
            // must occur on the graphics context when rendering a toolbar
            // icon
            int translatex = 0;
            int translatey = 0;

            if (c instanceof JToolBar) {
                JToolBar toolbar = (JToolBar) c;

                rotate = toolbar.getOrientation() == JToolBar.VERTICAL;
                flip   = !toolbar.getComponentOrientation().isLeftToRight();
                Object o = SeaGlassLookAndFeel.resolveToolbarConstraint(toolbar);

                // we only do the +1 hack for UIResource borders, assuming
                // that the border is probably going to be our border
                if (toolbar.getBorder() instanceof UIResource) {

                    if (o == BorderLayout.SOUTH) {
                        translatey = 1;
                    } else if (o == BorderLayout.EAST) {
                        translatex = 1;
                    }
                }
            }

            if (g instanceof Graphics2D) {
                Graphics2D gfx = (Graphics2D) g;

                gfx.translate(x, y);
                gfx.translate(translatex, translatey);

                if (rotate) {
                    gfx.rotate(Math.toRadians(90));
                    gfx.translate(0, -w);
                    painter.paint(gfx, context.getComponent(), h, w);
                    gfx.translate(0, w);
                    gfx.rotate(Math.toRadians(-90));
                } else if (flip) {
                    gfx.scale(-1, 1);
                    gfx.translate(-w, 0);
                    painter.paint(gfx, context.getComponent(), w, h);
                    gfx.translate(w, 0);
                    gfx.scale(-1, 1);
                } else {
                    painter.paint(gfx, context.getComponent(), w, h);
                }

                gfx.translate(-translatex, -translatey);
                gfx.translate(-x, -y);
            } else {

                // use image if we are printing to a Java 1.1 PrintGraphics as
                // it is not a instance of Graphics2D
                BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                Graphics2D    gfx = img.createGraphics();

                if (rotate) {
                    gfx.rotate(Math.toRadians(90));
                    gfx.translate(0, -w);
                    painter.paint(gfx, context.getComponent(), h, w);
                } else if (flip) {
                    gfx.scale(-1, 1);
                    gfx.translate(-w, 0);
                    painter.paint(gfx, context.getComponent(), w, h);
                } else {
                    painter.paint(gfx, context.getComponent(), w, h);
                }

                gfx.dispose();
                g.drawImage(img, x, y, null);
                img = null;
View Full Code Here

     * @param y the y coordinate of the upper-left corner of the icon.
     */
    @SuppressWarnings("unchecked")
    @Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        SeaGlassPainter painter = (SeaGlassPainter) UIManager.get(prefix + "[Enabled]." + key);

        if (painter != null) {
            JComponent jc  = (c instanceof JComponent) ? (JComponent) c : null;
            Graphics2D gfx = (Graphics2D) g;

            gfx.translate(x, y);
            painter.paint(gfx, jc, width, height);
            gfx.translate(-x, -y);
        }
    }
View Full Code Here

     *
     * @param g the Graphics context to paint with.
     */
    @Override
    protected void paintComponent(Graphics g) {
        SeaGlassPainter painter = (SeaGlassPainter) UIManager.get("TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");

        if (painter != null) {

            Graphics2D g2d = (Graphics2D) g;

            painter.paint(g2d, this, getWidth() + 1, getHeight());
        }
    }
View Full Code Here

        // basic components are all non-opaque by default.
        Component c  = ctx.getComponent();
        Color     bg = (c != null) ? c.getBackground() : null;

        if (bg == null || bg.getAlpha() > 0) {
            SeaGlassPainter backgroundPainter = style.getBackgroundPainter(ctx);

            if (backgroundPainter != null) {
                paint(backgroundPainter, ctx, g, x, y, w, h, transform);
            }
        }
View Full Code Here

     * @param h         the height to paint.
     * @param transform the affine transform to apply, or {@code null} if none
     *                  is to be applied.
     */
    private void paintForeground(SynthContext ctx, Graphics g, int x, int y, int w, int h, AffineTransform transform) {
        SeaGlassPainter foregroundPainter = style.getForegroundPainter(ctx);

        if (foregroundPainter != null) {
            paint(foregroundPainter, ctx, g, x, y, w, h, transform);
        }
    }
View Full Code Here

     * @param h         the height to paint.
     * @param transform the affine transform to apply, or {@code null} if none
     *                  is to be applied.
     */
    private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w, int h, AffineTransform transform) {
        SeaGlassPainter borderPainter = style.getBorderPainter(ctx);

        if (borderPainter != null) {
            paint(borderPainter, ctx, g, x, y, w, h, transform);
        }
    }
View Full Code Here

TOP

Related Classes of com.seaglasslookandfeel.painter.SeaGlassPainter

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.