[jsword-svn] common/java/swing/org/crosswire/common/swing/plaf s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Aug 12 03:17:39 MST 2005


Update of /cvs/jsword/common/java/swing/org/crosswire/common/swing/plaf
In directory www.crosswire.org:/tmp/cvs-serv16817/java/swing/org/crosswire/common/swing/plaf

Added Files:
	AbstractLFCustoms.java WindowsLFCustoms.java package.html 
	OtherLFCustoms.java MetalPanelBorder.java MetalLFCustoms.java 
Log Message:
Check in LF code provided by Willie Thean.
Clean up checkstyle complaints.

--- NEW FILE: OtherLFCustoms.java ---
/**
 * Distribution License:
 * JSword is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License, version 2.1 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/lgpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: OtherLFCustoms.java,v 1.1 2005/08/12 10:17:37 dmsmith Exp $
 */
package org.crosswire.common.swing.plaf;
import javax.swing.BorderFactory;
import javax.swing.UIManager;
import javax.swing.border.Border;


/**
 * Customizations for other LF other than Windows and Metal.
 *
 * @see gnu.lgpl.License for license details. The copyright to this program is
 *      held by it's authors.
 * @author Willie Thean [williethean at yahoo dot com]
 */
public class OtherLFCustoms extends AbstractLFCustoms
{
    /**
     * Default constructor.
     */
    public OtherLFCustoms()
    {
        super();
    }

    /**
     * Install other platform specific UI defaults that we're not aware of.
     */
    protected void initPlatformUIDefaults()
    {
        Border tabbedPanePanelBorder = BorderFactory.createEtchedBorder();
        Border panelSelectBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);

        Object[] otherUIDefaults = new Object[]
        {
            "TabbedPanePanel.border", tabbedPanePanelBorder, //$NON-NLS-1$
            "SelectPanel.border", panelSelectBorder //$NON-NLS-1$
        };

        UIManager.getDefaults().putDefaults(otherUIDefaults);
    }
}

--- NEW FILE: MetalLFCustoms.java ---
/**
 * Distribution License:
 * JSword is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License, version 2.1 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/lgpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: MetalLFCustoms.java,v 1.1 2005/08/12 10:17:37 dmsmith Exp $
 */
package org.crosswire.common.swing.plaf;

import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.UIManager;
import javax.swing.border.Border;

/**
 * Provides customization to MetalLF Tabbed panes
 *
 * @see gnu.lgpl.License for license details.
 *      The copyright to this program is held by it's authors.
 * @author Willie Thean [williethean at yahoo dot com]
 */
public class MetalLFCustoms extends AbstractLFCustoms
{
    /**
     * Default constructor.
     */
    public MetalLFCustoms()
    {
        super();
    }

    /**
     * Install Metal platform specific UI defaults.
     */
    protected void initPlatformUIDefaults()
    {
        // Border panelSelectBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
        Border panelSelectBorder = BorderFactory.createCompoundBorder(
            new MetalPanelBorder(MetalPanelBorder.TOP | MetalPanelBorder.LEFT | MetalPanelBorder.RIGHT),
            BorderFactory.createEmptyBorder(5, 5, 5, 5));

        Object[] metalUIDefaults = new Object[] {
            "TabbedPane.contentBorderInsets", new Insets(1, 0, 0, 0), //$NON-NLS-1$
            "SplitPane.dividerSize", new Integer(5), //$NON-NLS-1$
            "SelectPanel.border", panelSelectBorder //$NON-NLS-1$
        };

        UIManager.getDefaults().putDefaults(metalUIDefaults);
    }
}

--- NEW FILE: package.html ---
Provides for improved Look and Feel for Tabs.

--- NEW FILE: MetalPanelBorder.java ---
/**
 * Distribution License:
 * JSword is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License, version 2.1 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/lgpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: MetalPanelBorder.java,v 1.1 2005/08/12 10:17:37 dmsmith Exp $
 */
package org.crosswire.common.swing.plaf;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;


/**
 * A class that provides a border that matches MetalBorders.ScrollPaneBorder.
 *
 * @see gnu.lgpl.License for license details.
 *      The copyright to this program is held by it's authors.
 * @author Willie Thean [williethean at yahoo dot com]
 */
public final class MetalPanelBorder extends AbstractBorder implements UIResource
{
    public static final int TOP = 1;
    public static final int LEFT = 2;
    public static final int BOTTOM = 4;
    public static final int RIGHT = 8;

    /**
     * Default constructor.
     */
    public MetalPanelBorder()
    {
        insets = new Insets(insetTop, insetLeft, insetBottom, insetRight);
    }

    /**
     * Create a MetalPanelBorder instance where the border visbility
     * (top, left, bottom and right border) is controlled by the bit mask
     * <CODE>borderFlags</CODE>.
     * @param borderFlags Match flags, a bit mask that may include TOP, LEFT, BOTTOM, and RIGHT
     */
    public MetalPanelBorder(int borderFlags)
    {
        flags = 0 | borderFlags;

        if ((flags & TOP) != TOP)
        {
            insetTop = 0;
        }

        if ((flags & LEFT) != LEFT)
        {
            insetLeft = 0;
        }

        if ((flags & BOTTOM) != BOTTOM)
        {
            insetBottom = 0;
        }

        if ((flags & RIGHT) != RIGHT)
        {
            insetRight = 0;
        }

        insets = new Insets(insetTop, insetLeft, insetBottom, insetRight);
    }

    /* (non-Javadoc)
     * @see javax.swing.border.Border#paintBorder(java.awt.Component, java.awt.Graphics, int, int, int, int)
     */
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
        g.translate(x, y);

        if ((flags & TOP) == TOP)
        {
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
            g.drawLine(0, 0, w - 2, 0);
        }

        if ((flags & LEFT) == LEFT)
        {
            g.drawLine(0, 0, 0, h - 2);
        }

        if ((flags & BOTTOM) == BOTTOM)
        {
            g.drawLine(0, h - 2, w - 2, h - 2);
            g.setColor(MetalLookAndFeel.getControlHighlight());
            g.drawLine(1, h - 1, w - 1, h - 1);
        }

        if ((flags & RIGHT) == RIGHT)
        {
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
            g.drawLine(w - 2, h - 2, w - 2, 0);
            g.setColor(MetalLookAndFeel.getControlHighlight());
            g.drawLine(w - 1, h - 1, w - 1, 1);
        }

        g.translate(-x, -y);
    }

    /* (non-Javadoc)
     * @see javax.swing.border.Border#getBorderInsets(java.awt.Component)
     */
    public Insets getBorderInsets(Component c)
    {
        return insets;
    }

    /**
     * Serialization ID
     */
    private static final long serialVersionUID = 7929433986066846750L;

    private int insetTop = 1;
    private int insetLeft = 1;
    private int insetBottom = 2;
    private int insetRight = 2;

    private int flags;

    private Insets insets;
}

--- NEW FILE: AbstractLFCustoms.java ---
/**
 * Distribution License:
 * JSword is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License, version 2.1 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/lgpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: AbstractLFCustoms.java,v 1.1 2005/08/12 10:17:37 dmsmith Exp $
 */
package org.crosswire.common.swing.plaf;

/**
 * Contains base UI defaults for all platforms.
 *
 * @see gnu.lgpl.License for license details.
 *      The copyright to this program is held by it's authors.
 * @author Willie Thean [williethean at yahoo dot com]
 */
public abstract class AbstractLFCustoms
{
    /**
     * Constructor.
     */
    public AbstractLFCustoms()
    {
    }

    /**
     * Calling this method installs base and platform specfic UI defaults.
     */
    public void initUIDefaults()
    {
        initBaseUIDefaults();
        initPlatformUIDefaults();
    }

    /**
     * Init UI Defaults value applicable to all platforms.
     */
    private void initBaseUIDefaults()
    {
        // Specify defaults applicable to all platforms here
    }

    /**
     * This method does nothing. Subclass should override this to install platform
     * specific UI defaults.
     */
    protected void initPlatformUIDefaults()
    {
    }
}

--- NEW FILE: WindowsLFCustoms.java ---
/**
 * Distribution License:
 * JSword is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License, version 2.1 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/lgpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: WindowsLFCustoms.java,v 1.1 2005/08/12 10:17:37 dmsmith Exp $
 */
package org.crosswire.common.swing.plaf;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;


/**
 * Customizations to Windows LF for tabs.
 *
 * @see gnu.lgpl.License for license details.
 *      The copyright to this program is held by it's authors.
 * @author Willie Thean [williethean at yahoo dot com]
 */
public class WindowsLFCustoms extends AbstractLFCustoms
{
    /**
     * Default constructor.
     */
    public WindowsLFCustoms()
    {
        super();
    }

    /**
     * Install Windows platform specific UI defaults.
     */
    protected void initPlatformUIDefaults()
    {
        Border tabbedPanePanelBorder = null;
        Color standardBorderColor = null;
        Object windowsScrollPaneborder = UIManager.get("ScrollPane.border"); //$NON-NLS-1$
        if (windowsScrollPaneborder != null)
        {
            standardBorderColor = ((LineBorder) windowsScrollPaneborder).getLineColor();
            tabbedPanePanelBorder = new LineBorder(standardBorderColor);
        }

        Border panelSelectBorder = BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(1, 1, 0, 1, standardBorderColor),
            BorderFactory.createEmptyBorder(5, 5, 5, 5));

        Object[] windowsUIDefaults = new Object[]
        {
            "TabbedPane.contentBorderInsets", new Insets(1, 0, 0, 0), //$NON-NLS-1$
            "TabbedPanePanel.border", tabbedPanePanelBorder, //$NON-NLS-1$
            "StandardBorder.color", standardBorderColor, //$NON-NLS-1$
            "SelectPanel.border", panelSelectBorder //$NON-NLS-1$
        };

        UIManager.getDefaults().putDefaults(windowsUIDefaults);
    }
}



More information about the jsword-svn mailing list