krysalis-jplugin/src/java/org/krysalis/swingx/laf/flat FlatButtonUI.java,NONE,1.1 FlatLookAndFeel.java,NONE,1.1 FlatScrollBarUI.java,NONE,1.1 FlatScrollButton.java,NONE,1.1 FlatScrollPaneUI.java,NONE,1.1 FlatSplitPaneDivider.java,NONE,1.1 FlatSplitPaneUI.java,NONE,1.1 FlatTabbedPaneUI.java,NONE,1.1 FlatTextFieldUI.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-jplugin/src/java/org/krysalis/swingx/laf/flat
In directory sc8-pr-cvs1:/tmp/cvs-serv24886/src/java/org/krysalis/swingx/laf/flat

Added Files:
	FlatButtonUI.java FlatLookAndFeel.java FlatScrollBarUI.java 
	FlatScrollButton.java FlatScrollPaneUI.java 
	FlatSplitPaneDivider.java FlatSplitPaneUI.java 
	FlatTabbedPaneUI.java FlatTextFieldUI.java 
Log Message:
refactoring swingx.swing.* packages to swingx.*

--- NEW FILE: FlatButtonUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

/*
 *  @(#)MetalButtonUI.java	1.22 00/02/02
 *
 *  Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
 *
 *  This software is the proprietary information of Sun Microsystems, Inc.
 *  Use is subject to license terms.
 *
 */
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;

/**
 *  MetalButtonUI implementation <p>
 *
 *  <strong>Warning:</strong> Serialized objects of this class will not be
 *  compatible with future Swing releases. The current serialization support is
 *  appropriate for short term storage or RMI between applications running the
 *  same version of Swing. A future release of Swing will provide support for
 *  long term persistence.
 *
 *@author     Tom Santos
 *@created    23 settembre 2001
 *@version    1.22 02/02/00
 */
public class FlatButtonUI extends BasicButtonUI {

    private final static FlatButtonUI flatButtonUI = new FlatButtonUI();

    /**
     *  Description of the Field
     */
    protected Color focusColor;
    /**
     *  Description of the Field
     */
    protected Color selectColor;
    /**
     *  Description of the Field
     */
    protected Color disabledTextColor;

    private boolean defaults_initialized = false;


    // ********************************
    //          Create PLAF
    // ********************************
    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     *@return    Description of the Returned Value
     */
    public static ComponentUI createUI(JComponent c) {
        return flatButtonUI;
    }


    // ********************************
    //          Install
    // ********************************
    /**
     *  Description of the Method
     *
     *@param  b  Description of Parameter
     */
    public void installDefaults(AbstractButton b) {
        super.installDefaults(b);
        Border outerBorder = BorderFactory.createLineBorder(FlatLookAndFeel.getControlShadow(), 1);
        Border innerBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2);
        b.setBorder(BorderFactory.createCompoundBorder(outerBorder, innerBorder));

        b.setRolloverEnabled(false);
        b.setFocusPainted(true);
        b.setFont(new java.awt.Font("Dialog", 0, 11));
        b.setCursor(new Cursor(Cursor.HAND_CURSOR));
        if (!defaults_initialized) {
            focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
            selectColor = UIManager.getColor(getPropertyPrefix() + "select");
            disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
            defaults_initialized = true;
        }
    }


    /**
     *  Description of the Method
     *
     *@param  b  Description of Parameter
     */
    public void uninstallDefaults(AbstractButton b) {
        super.uninstallDefaults(b);
        defaults_initialized = false;
    }


    // ********************************
    //         Default Accessors
    // ********************************
    /**
     *  Gets the selectColor attribute of the FlatButtonUI object
     *
     *@return    The selectColor value
     */
    protected Color getSelectColor() {
        return selectColor;
    }


    /**
     *  Gets the disabledTextColor attribute of the FlatButtonUI object
     *
     *@return    The disabledTextColor value
     */
    protected Color getDisabledTextColor() {
        return disabledTextColor;
    }


    /**
     *  Gets the focusColor attribute of the FlatButtonUI object
     *
     *@return    The focusColor value
     */
    protected Color getFocusColor() {
        return focusColor;
    }


    // ********************************
    //         Create Listeners
    // ********************************
    /**
     *  Description of the Method
     *
     *@param  b  Description of Parameter
     *@return    Description of the Returned Value
     */
    protected BasicButtonListener createButtonListener(AbstractButton b) {
        return new MetalButtonListener(b);
    }


    // ********************************
    //          Paint
    // ********************************
    /**
     *  Description of the Method
     *
     *@param  g  Description of Parameter
     *@param  b  Description of Parameter
     */
    protected void paintButtonPressed(Graphics g, AbstractButton b) {
        if (b.isContentAreaFilled()) {
            Dimension size = b.getSize();
            g.setColor(getSelectColor());
            g.fillRect(0, 0, size.width, size.height);
        }
    }


    /**
     *  Description of the Method
     *
     *@param  g         Description of Parameter
     *@param  b         Description of Parameter
     *@param  viewRect  Description of Parameter
     *@param  textRect  Description of Parameter
     *@param  iconRect  Description of Parameter
     */
    protected void paintFocus(Graphics g, AbstractButton b,
            Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {

        Rectangle focusRect = new Rectangle();
        String text = b.getText();
        boolean isIcon = b.getIcon() != null;

        // If there is text
        if (text != null && !text.equals("")) {
            if (!isIcon) {
                focusRect.setBounds(textRect);
            } else {
                focusRect.setBounds(iconRect.union(textRect));
            }
        }
        // If there is an icon and no text
        else if (isIcon) {
            focusRect.setBounds(iconRect);
        }

        g.setColor(getFocusColor());
        g.drawRect((focusRect.x - 1), (focusRect.y - 1),
                focusRect.width + 1, focusRect.height + 1);

    }


    /**
     *  Description of the Method
     *
     *@param  g         Description of Parameter
     *@param  c         Description of Parameter
     *@param  textRect  Description of Parameter
     *@param  text      Description of Parameter
     */
    protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
        AbstractButton b = (AbstractButton) c;
        ButtonModel model = b.getModel();
        FontMetrics fm = g.getFontMetrics();

        /*
         *  Draw the Text
         */
        if (model.isEnabled()) {

            g.setColor(b.getForeground());
            BasicGraphicsUtils.drawString(g, text, model.getMnemonic(),
                    textRect.x,
                    textRect.y + fm.getAscent());
        } else {

            g.setColor(getDisabledTextColor());
            BasicGraphicsUtils.drawString(g, text, model.getMnemonic(),
                    textRect.x, textRect.y + fm.getAscent());

        }
    }

}

/**
 *  Description of the Class
 *
 *@author     Luca Jun Barozzi
 *@created    23 settembre 2001
 */
class MetalButtonListener extends BasicButtonListener {


    /**
     *  Constructor for the MetalButtonListener object
     *
     *@param  b  Description of Parameter
     */
    public MetalButtonListener(AbstractButton b) {
        super(b);
    }


    /**
     *  Description of the Method
     *
     *@param  e  Description of Parameter
     */
    public void focusGained(FocusEvent e) {
        Component c = (Component) e.getSource();
        c.repaint();
    }
}


--- NEW FILE: FlatLookAndFeel.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import javax.swing.UIDefaults;
import javax.swing.plaf.metal.MetalLookAndFeel;

import org.krysalis.swingx.laf.metal.SimpleMetalTheme;

/**
 *@author     Nicola Ken Barozzi
 *@created    23 settembre 2001
 *@version    1.0
 */
public class FlatLookAndFeel extends MetalLookAndFeel {

  public String getID() {
    return "blyko";
  }

  public String getName() {
    return "blyko";
  }


  public String getDescription() {
    return "blyko";
  }


  public boolean isNativeLookAndFeel() {
    return false;
  }


  public boolean isSupportedLookAndFeel() {
    return true;
  }


  protected void initClassDefaults(UIDefaults table) {
    super.initClassDefaults(table);

    try {
    String flatPackageName = "org.krysalis.javax.swing.plaf.flat.Flat";

    table.put("ButtonUI", flatPackageName+"ButtonUI");
    table.put("ScrollBarUI", flatPackageName+"ScrollBarUI");
    table.put("ScrollPaneUI", flatPackageName+"ScrollPaneUI");
    table.put("SplitPaneUI", flatPackageName+"SplitPaneUI");
    table.put("TabbedPaneUI", flatPackageName+"TabbedPaneUI");
    table.put("TextFieldUI", flatPackageName+"TextFieldUI");


    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public UIDefaults getDefaults() {
    setCurrentTheme(new SimpleMetalTheme());
    return super.getDefaults();
  }

  protected void initSystemColorDefaults(UIDefaults table) {
    super.initSystemColorDefaults(table);
  }

  protected void initComponentDefaults(UIDefaults table) {
    super.initComponentDefaults(table);
    table.put("SplitPaneDivider.border", null);
    table.put("SplitPane.dividerSize", new Integer(2));
  }


}




--- NEW FILE: FlatScrollBarUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicScrollBarUI;


/**
 *  Description of the Class
 *
 *@author     Luca Jun Barozzi
 *@created    23 settembre 2001
 */
public class FlatScrollBarUI extends BasicScrollBarUI {

    /**
     *  Description of the Field
     */
    public final static String FREE_STANDING_PROP = "JScrollBar.isFreeStanding";
    private static Color shadowColor;
    private static Color highlightColor;
    private static Color darkShadowColor;
    private static Color thumbColor;
    private static Color thumbShadow;
    private static Color thumbHighlightColor;

    /**
     *  Description of the Field
     */
    protected FlatScrollButton increaseButton;
    /**
     *  Description of the Field
     */
    protected FlatScrollButton decreaseButton;

    /**
     *  Description of the Field
     */
    protected int scrollBarWidth;
    /**
     *  Description of the Field
     */
    protected boolean isFreeStanding = true;


    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     *@return    Description of the Returned Value
     */
    public static ComponentUI createUI(JComponent c) {
        return new FlatScrollBarUI();
    }


    /**
     *  Gets the preferredSize attribute of the FlatScrollBarUI object
     *
     *@param  c  Description of Parameter
     *@return    The preferredSize value
     */
    public Dimension getPreferredSize(JComponent c) {
        if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
            return new Dimension(scrollBarWidth, scrollBarWidth * 3 + 10);
        } else {
            // Horizontal

            return new Dimension(scrollBarWidth * 3 + 10, scrollBarWidth);
        }

    }


    /**
     *  Gets the minimumThumbSize attribute of the FlatScrollBarUI object
     *
     *@return    The minimumThumbSize value
     */
    protected Dimension getMinimumThumbSize() {
        return new Dimension(scrollBarWidth, scrollBarWidth);
    }


    /**
     *  Description of the Method
     */
    protected void installDefaults() {
        scrollBarWidth = ((Integer) (UIManager.get("ScrollBar.width"))).intValue();
        if (scrollbar.getBackground() == null || scrollbar.getBackground() instanceof UIResource) {
            scrollbar.setBackground(UIManager.getColor("ScrollBar.background"));
        }
        super.installDefaults();
    }


    /**
     *  Description of the Method
     */
    protected void installListeners() {
        super.installListeners();
        ((ScrollBarListener) propertyChangeListener).handlePropertyChange(scrollbar.getClientProperty(FREE_STANDING_PROP));
    }


    /**
     *  Description of the Method
     *
     *@return    Description of the Returned Value
     */
    protected PropertyChangeListener createPropertyChangeListener() {
        return new ScrollBarListener();
    }


    /**
     *  Description of the Method
     */
    protected void configureScrollBarColors() {
        shadowColor = UIManager.getColor("ScrollBar.shadow");
        highlightColor = UIManager.getColor("ScrollBar.highlight");
        darkShadowColor = UIManager.getColor("ScrollBar.darkShadow");
        thumbColor = UIManager.getColor("ScrollBar.thumb");
        thumbShadow = UIManager.getColor("ScrollBar.thumbShadow");
        thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");

    }


    /**
     *  Returns the view that represents the decrease view.
     *
     *@param  orientation  Description of Parameter
     *@return              Description of the Returned Value
     */
    protected JButton createDecreaseButton(int orientation) {
        decreaseButton = new FlatScrollButton(orientation, scrollBarWidth, isFreeStanding);
        return decreaseButton;
    }


    /**
     *  Returns the view that represents the increase view.
     *
     *@param  orientation  Description of Parameter
     *@return              Description of the Returned Value
     */
    protected JButton createIncreaseButton(int orientation) {
        increaseButton = new FlatScrollButton(orientation, scrollBarWidth, isFreeStanding);
        return increaseButton;
    }


    /**
     *  Description of the Method
     *
     *@param  g            Description of Parameter
     *@param  c            Description of Parameter
     *@param  trackBounds  Description of Parameter
     */
    protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
        g.translate(trackBounds.x, trackBounds.y);

        g.setColor(FlatLookAndFeel.getBlack());

        //g.drawRect(1,1,trackBounds.x-2,trackBounds.y-2);

        /*
         *  if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
         *  {
         *  if ( !isFreeStanding ) {
         *  trackBounds.width += 2;
         *  }
         *  if ( c.isEnabled() ) {
         *  g.setColor( darkShadowColor );
         *  g.drawLine( 0, 0, 0, trackBounds.height - 1 );
         *  g.drawLine( trackBounds.width - 2, 0, trackBounds.width - 2, trackBounds.height - 1 );
         *  g.drawLine( 2, trackBounds.height - 1, trackBounds.width - 1, trackBounds.height - 1);
         *  g.drawLine( 2, 0, trackBounds.width - 2, 0 );
         *  g.setColor( shadowColor );
         *  g.drawLine( 1, 1, 1, trackBounds.height - 2 );
         *  g.drawLine( 1, 1, trackBounds.width - 3, 1 );
         *  if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
         *  int y = thumbRect.y + thumbRect.height - trackBounds.y;
         *  g.drawLine( 1, y, trackBounds.width-1, y);
         *  }
         *  g.setColor(highlightColor);
         *  g.drawLine( trackBounds.width - 1, 0, trackBounds.width - 1, trackBounds.height - 1 );
         *  } else {
         *  /MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
         *  }
         *  if ( !isFreeStanding ) {
         *  trackBounds.width -= 2;
         *  }
         *  }
         *  else  // HORIZONTAL
         *  {
         *  if ( !isFreeStanding ) {
         *  trackBounds.height += 2;
         *  }
         *  if ( c.isEnabled() ) {
         *  g.setColor( darkShadowColor );
         *  g.drawLine( 0, 0, trackBounds.width - 1, 0 );  // top
         *  g.drawLine( 0, 2, 0, trackBounds.height - 2 ); // left
         *  g.drawLine( 0, trackBounds.height - 2, trackBounds.width - 1, trackBounds.height - 2 ); // bottom
         *  g.drawLine( trackBounds.width - 1, 2, trackBounds.width - 1, trackBounds.height - 1 ); // right
         *  g.setColor( shadowColor );
         *  /	g.setColor( Color.red);
         *  g.drawLine( 1, 1, trackBounds.width - 2, 1 );  // top
         *  g.drawLine( 1, 1, 1, trackBounds.height - 3 ); // left
         *  g.drawLine( 0, trackBounds.height - 1, trackBounds.width - 1, trackBounds.height - 1 ); // bottom
         *  if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
         *  int x = thumbRect.x + thumbRect.width - trackBounds.x;
         *  g.drawLine( x, 1, x, trackBounds.height-1);
         *  }
         *  } else {
         *  /MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
         *  }
         *  if ( !isFreeStanding ) {
         *  trackBounds.height -= 2;
         *  }
         *  }
         */
        g.translate(-trackBounds.x, -trackBounds.y);
    }


    /**
     *  Description of the Method
     *
     *@param  g            Description of Parameter
     *@param  c            Description of Parameter
     *@param  thumbBounds  Description of Parameter
     */
    protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
        if (!c.isEnabled()) {
            return;
        }

        g.translate(thumbBounds.x, thumbBounds.y);

        if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
            g.setColor(thumbColor);
            g.drawRect(2, 2, thumbBounds.width - 4, thumbBounds.height - 4);
            //g.drawRect( 1, 1, thumbBounds.width - 2, thumbBounds.height - 2 );
        } else {
            // HORIZONTAL

            g.setColor(thumbColor);
            g.drawRect(2, 2, thumbBounds.width - 5, thumbBounds.height - 4);
            //g.drawRect( 1, 1, thumbBounds.width - 3, thumbBounds.height - 2 );
        }

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


    /**
     *  This is overridden only to increase the invalid area. This ensures that
     *  the "Shadow" below the thumb is invalidated
     *
     *@author     Luca Jun Barozzi
     *@created    23 settembre 2001
     */
    /*
     *  protected void setThumbBounds(int x, int y, int width, int height)
     *  {
     *  if ((thumbRect.x == x) &&
     *  (thumbRect.y == y) &&
     *  (thumbRect.width == width) &&
     *  (thumbRect.height == height)) {
     *  return;
     *  }
     *  int minX = Math.min(x, thumbRect.x);
     *  int minY = Math.min(y, thumbRect.y);
     *  int maxX = Math.max(x + width, thumbRect.x + thumbRect.width);
     *  int maxY = Math.max(y + height, thumbRect.y + thumbRect.height);
     *  thumbRect.setBounds(x, y, width, height);
     *  scrollbar.repaint(minX, minY, (maxX - minX)+1, (maxY - minY)+1);
     *  }
     */
    class ScrollBarListener extends BasicScrollBarUI.PropertyChangeHandler {
        /**
         *  Description of the Method
         *
         *@param  e  Description of Parameter
         */
        public void propertyChange(PropertyChangeEvent e) {
            String name = e.getPropertyName();
            if (name.equals(FREE_STANDING_PROP)) {
                handlePropertyChange(e.getNewValue());
            } else {
                super.propertyChange(e);
            }
        }


        /**
         *  Description of the Method
         *
         *@param  newValue  Description of Parameter
         */
        public void handlePropertyChange(Object newValue) {
            if (newValue != null) {
                boolean temp = ((Boolean) newValue).booleanValue();
                boolean becameFlush = temp == false && isFreeStanding == true;
                boolean becameNormal = temp == true && isFreeStanding == false;

                isFreeStanding = temp;

                if (becameFlush) {
                    toFlush();
                } else if (becameNormal) {
                    toFreeStanding();
                }
            } else {

                if (!isFreeStanding) {
                    isFreeStanding = true;
                    toFreeStanding();
                }
                // This commented-out block is used for testing flush scrollbars.
                /*
                 *  if ( isFreeStanding ) {
                 *  isFreeStanding = false;
                 *  toFlush();
                 *  }
                 */
            }

            if (increaseButton != null) {
                increaseButton.setFreeStanding(isFreeStanding);
            }
            if (decreaseButton != null) {
                decreaseButton.setFreeStanding(isFreeStanding);
            }
        }


        /**
         *  Description of the Method
         */
        protected void toFlush() {
            scrollBarWidth -= 2;
        }


        /**
         *  Description of the Method
         */
        protected void toFreeStanding() {
            scrollBarWidth += 2;
        }
    }
    // end class ScrollBarListener
}




































--- NEW FILE: FlatScrollButton.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicArrowButton;

/**
 *  Description of the Class
 *
 *@author     Luca Jun Barozzi
 *@created    23 settembre 2001
 */
public class FlatScrollButton extends BasicArrowButton {
    private static Color shadowColor;
    private static Color highlightColor;
    private boolean isFreeStanding = false;

    private int buttonWidth;


    /**
     *  Constructor for the FlatScrollButton object
     *
     *@param  direction     Description of Parameter
     *@param  width         Description of Parameter
     *@param  freeStanding  Description of Parameter
     */
    public FlatScrollButton(int direction, int width, boolean freeStanding) {
        super(direction);

        shadowColor = UIManager.getColor("ScrollBar.darkShadow");
        highlightColor = UIManager.getColor("ScrollBar.highlight");

        buttonWidth = width;
        isFreeStanding = freeStanding;
    }


    /**
     *  Sets the freeStanding attribute of the FlatScrollButton object
     *
     *@param  freeStanding  The new freeStanding value
     */
    public void setFreeStanding(boolean freeStanding) {
        isFreeStanding = freeStanding;
    }


    /**
     *  Gets the preferredSize attribute of the FlatScrollButton object
     *
     *@return    The preferredSize value
     */
    public Dimension getPreferredSize() {
        if (getDirection() == NORTH) {
            return new Dimension(buttonWidth, buttonWidth - 2);
        } else if (getDirection() == SOUTH) {
            return new Dimension(buttonWidth, buttonWidth - (isFreeStanding ? 1 : 2));
        } else if (getDirection() == EAST) {
            return new Dimension(buttonWidth - (isFreeStanding ? 1 : 2), buttonWidth);
        } else if (getDirection() == WEST) {
            return new Dimension(buttonWidth - 2, buttonWidth);
        } else {
            return new Dimension(0, 0);
        }
    }


    /**
     *  Gets the minimumSize attribute of the FlatScrollButton object
     *
     *@return    The minimumSize value
     */
    public Dimension getMinimumSize() {
        return getPreferredSize();
    }


    /**
     *  Gets the maximumSize attribute of the FlatScrollButton object
     *
     *@return    The maximumSize value
     */
    public Dimension getMaximumSize() {
        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
    }


    /**
     *  Gets the buttonWidth attribute of the FlatScrollButton object
     *
     *@return    The buttonWidth value
     */
    public int getButtonWidth() {
        return buttonWidth;
    }


    /**
     *  Description of the Method
     *
     *@param  g  Description of Parameter
     */
    public void paint(Graphics g) {
        boolean isEnabled = getParent().isEnabled();

        Color arrowColor = FlatLookAndFeel.getBlack();
        boolean isPressed = getModel().isPressed();
        int width = getWidth();
        int height = getHeight();
        int w = width;
        int h = height;
        int arrowHeight = (height + 1) / 4;
        int arrowWidth = (height + 1) / 2;

        g.setColor(getBackground());
        g.fillRect(0, 0, width, height);

        if (isPressed) {
            g.setColor(FlatLookAndFeel.getControlShadow());
            g.fillRect(3, 3, width - 5, height - 5);

        }
        g.setColor(UIManager.getColor("ScrollBar.thumb"));
        g.drawRect(2, 2, width - 4, height - 4);


        if (getDirection() == NORTH) {
            if (!isFreeStanding) {
                height += 1;
                g.translate(0, -1);
                width += 2;
            }

            // Draw the arrow
            g.setColor(arrowColor);
            int startY = ((h + 1) - arrowHeight) / 2;
            int startX = (w / 2);
            //		    System.out.println( "startX :" + startX + " startY :"+startY);
            for (int line = 0; line < arrowHeight; line++) {
                g.drawLine(startX - line, startY + line, startX + line + 1, startY + line);
            }
            /*
             *  g.drawLine( 7, 6, 8, 6 );
             *  g.drawLine( 6, 7, 9, 7 );
             *  g.drawLine( 5, 8, 10, 8 );
             *  g.drawLine( 4, 9, 11, 9 );
             */
            if (isEnabled) {
                g.setColor(highlightColor);

            } else {

            }
            if (!isFreeStanding) {
                height -= 1;
                g.translate(0, 1);
                width -= 2;

            }
        } else if (getDirection() == SOUTH) {
            if (!isFreeStanding) {
                height += 1;
                width += 2;
            }

            // Draw the arrow
            g.setColor(arrowColor);

            int startY = (((h + 1) - arrowHeight) / 2) + arrowHeight - 1;
            int startX = (w / 2);

            //	    System.out.println( "startX2 :" + startX + " startY2 :"+startY);

            for (int line = 0; line < arrowHeight; line++) {
                g.drawLine(startX - line, startY - line, startX + line + 1, startY - line);
            }

            /*
             *  g.drawLine( 4, 5, 11, 5 );
             *  g.drawLine( 5, 6, 10, 6 );
             *  g.drawLine( 6, 7, 9, 7 );
             *  g.drawLine( 7, 8, 8, 8 );
             */

            if (!isFreeStanding) {
                height -= 1;
                width -= 2;
            }
        } else if (getDirection() == EAST) {
            if (!isFreeStanding) {
                height += 2;
                width += 1;
            }

            // Draw the arrow
            g.setColor(arrowColor);

            int startX = (((w + 1) - arrowHeight) / 2) + arrowHeight - 1;
            int startY = (h / 2);

            //System.out.println( "startX2 :" + startX + " startY2 :"+startY);

            for (int line = 0; line < arrowHeight; line++) {
                g.drawLine(startX - line, startY - line, startX - line, startY + line + 1);
            }

            /*
             *  g.drawLine( 5, 4, 5, 11 );
             *  g.drawLine( 6, 5, 6, 10 );
             *  g.drawLine( 7, 6, 7, 9 );
             *  g.drawLine( 8, 7, 8, 8 );
             */

            if (!isFreeStanding) {
                height -= 2;
                width -= 1;
            }
        } else if (getDirection() == WEST) {
            if (!isFreeStanding) {
                height += 2;
                width += 1;
                g.translate(-1, 0);
            }

            // Draw the arrow
            g.setColor(arrowColor);

            int startX = (((w + 1) - arrowHeight) / 2);
            int startY = (h / 2);

            for (int line = 0; line < arrowHeight; line++) {
                g.drawLine(startX + line, startY - line, startX + line, startY + line + 1);
            }

            /*
             *  g.drawLine( 6, 7, 6, 8 );
             *  g.drawLine( 7, 6, 7, 9 );
             *  g.drawLine( 8, 5, 8, 10 );
             *  g.drawLine( 9, 4, 9, 11 );
             */

            if (!isFreeStanding) {
                height -= 2;
                width -= 1;
                g.translate(1, 0);
            }
        }
    }
}

--- NEW FILE: FlatScrollPaneUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollPaneUI;
import javax.swing.plaf.metal.MetalScrollBarUI;

/**
 *  A Metal L&F implementation of ScrollPaneUI. <p>
 *
 *  <strong>Warning:</strong> Serialized objects of this class will not be
 *  compatible with future Swing releases. The current serialization support is
 *  appropriate for short term storage or RMI between applications running the
 *  same version of Swing. A future release of Swing will provide support for
 *  long term persistence.
 *
 *@author     Steve Wilson
 *@created    23 settembre 2001
 *@1.12       02/02/00
 */
public class FlatScrollPaneUI extends BasicScrollPaneUI {

    private PropertyChangeListener scrollBarSwapListener;


    /**
     *  Description of the Method
     *
     *@param  x  Description of Parameter
     *@return    Description of the Returned Value
     */
    public static ComponentUI createUI(JComponent x) {
        x.setBorder(BorderFactory.createEmptyBorder());
        return new FlatScrollPaneUI();
    }


    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     */
    public void installUI(JComponent c) {

        super.installUI(c);

        JScrollPane sp = (JScrollPane) c;
        JScrollBar hsb = sp.getHorizontalScrollBar();
        JScrollBar vsb = sp.getVerticalScrollBar();
        hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
        vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }


    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     */
    public void uninstallUI(JComponent c) {
        super.uninstallUI(c);

        JScrollPane sp = (JScrollPane) c;
        JScrollBar hsb = sp.getHorizontalScrollBar();
        JScrollBar vsb = sp.getVerticalScrollBar();
        hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
        vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
    }


    /**
     *  Description of the Method
     *
     *@param  scrollPane  Description of Parameter
     */
    public void installListeners(JScrollPane scrollPane) {
        super.installListeners(scrollPane);
        scrollBarSwapListener = createScrollBarSwapListener();
        scrollPane.addPropertyChangeListener(scrollBarSwapListener);
    }


    /**
     *  Description of the Method
     *
     *@param  scrollPane  Description of Parameter
     */
    public void uninstallListeners(JScrollPane scrollPane) {
        super.uninstallListeners(scrollPane);

        scrollPane.removePropertyChangeListener(scrollBarSwapListener);
    }


    /**
     *  Description of the Method
     *
     *@return    Description of the Returned Value
     */
    protected PropertyChangeListener createScrollBarSwapListener() {
        return
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    String propertyName = e.getPropertyName();
                    if (propertyName.equals("verticalScrollBar") ||
                            propertyName.equals("horizontalScrollBar")) {
                        ((JScrollBar) e.getOldValue()).putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP,
                                null);
                        ((JScrollBar) e.getNewValue()).putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP,
                                Boolean.FALSE);
                    }
                }
            };
    }

}

--- NEW FILE: FlatSplitPaneDivider.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JSplitPane;
import javax.swing.border.Border;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;

/**
 *  Title: Butterfly XML editor Description: Copyright: Copyright (c) Nicola Ken
 *  Barozzi Company: Bibop Research
 *
 *@author     Nicola Ken Barozzi
 *@created    23 settembre 2001
 *@version    1.0
 */

public class FlatSplitPaneDivider extends BasicSplitPaneDivider {

    private int inset = 2;

    private Color controlColor = FlatLookAndFeel.getControl();
    private Color primaryControlColor = FlatLookAndFeel.getPrimaryControl();


    /**
     *  Constructor for the FlatSplitPaneDivider object
     *
     *@param  ui  Description of Parameter
     */
    public FlatSplitPaneDivider(BasicSplitPaneUI ui) {
        super(ui);
        //setLayout(new FlatDividerLayout());
    }


    /**
     *  Description of the Method
     *
     *@param  g  Description of Parameter
     */
    public void paint(Graphics g) {
        if (splitPane.hasFocus()) {
            g.setColor(primaryControlColor);
        } else {
            g.setColor(controlColor);
        }
        Rectangle clip = g.getClipBounds();
        Insets insets = getInsets();
        g.fillRect(clip.x, clip.y, clip.width, clip.height);

        //super.paint(g);
    }


    /**
     *  Creates and return an instance of JButton that can be used to collapse
     *  the left component in the metal split pane.
     *
     *@return    Description of the Returned Value
     */
    protected JButton createLeftOneTouchButton() {
        JButton b =
            new JButton() {
                // Sprite buffer for the arrow image of the left button
                int[][] buffer = {{0, 0, 0, 0, 1, 0, 0, 0, 0},
                        {0, 0, 0, 1, 1, 1, 0, 0, 0},
                        {0, 0, 1, 1, 1, 1, 1, 0, 0},
                        {0, 1, 1, 1, 1, 1, 1, 1, 0},
                        {1, 1, 1, 1, 1, 1, 1, 1, 1}};


                public void setBorder(Border b) { }


                // Don't want the button to participate in focus traversable.
                public boolean isFocusTraversable() {
                    return false;
                }


                public void paint(Graphics g) {
                    JSplitPane splitPane = getSplitPaneFromSuper();
                    if (splitPane != null) {
                        int oneTouchSize = getOneTouchSizeFromSuper();
                        int orientation = getOrientationFromSuper();
                        int blockSize = Math.min(getDividerSize(),
                                oneTouchSize);

                        // Fill the background first ...
                        g.setColor(this.getBackground());
                        g.fillRect(0, 0, this.getWidth(),
                                this.getHeight());

                        // ... then draw the arrow.
                        /*
                         *  if (getModel().isPressed()) {
                         *  / Adjust color mapping for pressed button state
                         *  colors[1] = colors[2];
                         *  }
                         */
                        g.setColor(FlatLookAndFeel.getBlack());
                        if (orientation == JSplitPane.VERTICAL_SPLIT) {
                            // Draw the image for a vertical split
                            for (int i = 1; i <= buffer[0].length; i++) {
                                for (int j = 1; j < blockSize; j++) {
                                    if (buffer[j - 1][i - 1] == 0) {
                                        continue;
                                    }
                                    g.drawLine(i, j, i, j);
                                }
                            }
                        } else {
                            // Draw the image for a horizontal split
                            // by simply swaping the i and j axis.
                            // Except the drawLine() call this code is
                            // identical to the code block above. This was done
                            // in order to remove the additional orientation
                            // check for each pixel.
                            for (int i = 1; i <= buffer[0].length; i++) {
                                for (int j = 1; j < blockSize; j++) {
                                    if (buffer[j - 1][i - 1] == 0) {
                                        // Nothing needs
                                        // to be drawn
                                        continue;
                                    }
                                    // Draw a pixel
                                    g.drawLine(j, i, j, i);
                                }
                            }
                        }
                    }
                }
            };
        b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        b.setFocusPainted(false);
        b.setBorderPainted(false);
        return b;
    }


    /**
     *  Creates and return an instance of JButton that can be used to collapse
     *  the right component in the metal split pane.
     *
     *@return    Description of the Returned Value
     */
    protected JButton createRightOneTouchButton() {
        JButton b =
            new JButton() {
                // Sprite buffer for the arrow image of the right button
                int[][] buffer = {{1, 1, 1, 1, 1, 1, 1, 1, 1},
                        {0, 1, 1, 1, 1, 1, 1, 1, 0},
                        {0, 0, 1, 1, 1, 1, 1, 0, 0},
                        {0, 0, 0, 1, 1, 1, 0, 0, 0},
                        {0, 0, 0, 0, 1, 0, 0, 0, 0}};


                public void setBorder(Border border) { }


                // Don't want the button to participate in focus traversable.
                public boolean isFocusTraversable() {
                    return false;
                }


                public void paint(Graphics g) {
                    JSplitPane splitPane = getSplitPaneFromSuper();
                    if (splitPane != null) {
                        int oneTouchSize = getOneTouchSizeFromSuper();
                        int orientation = getOrientationFromSuper();
                        int blockSize = Math.min(getDividerSize(),
                                oneTouchSize);

                        // Fill the background first ...
                        g.setColor(this.getBackground());
                        g.fillRect(0, 0, this.getWidth(),
                                this.getHeight());

                        // ... then draw the arrow.
                        /*
                         *  if (getModel().isPressed()) {
                         *  / Adjust color mapping for pressed button state
                         *  colors[1] = colors[2];
                         *  }
                         */
                        g.setColor(FlatLookAndFeel.getBlack());
                        if (orientation == JSplitPane.VERTICAL_SPLIT) {
                            // Draw the image for a vertical split
                            for (int i = 1; i <= buffer[0].length; i++) {
                                for (int j = 1; j < blockSize; j++) {
                                    if (buffer[j - 1][i - 1] == 0) {
                                        continue;
                                    }
                                    g.drawLine(i, j, i, j);
                                }
                            }
                        } else {
                            // Draw the image for a horizontal split
                            // by simply swaping the i and j axis.
                            // Except the drawLine() call this code is
                            // identical to the code block above. This was done
                            // in order to remove the additional orientation
                            // check for each pixel.
                            for (int i = 1; i <= buffer[0].length; i++) {
                                for (int j = 1; j < blockSize; j++) {
                                    if (buffer[j - 1][i - 1] == 0) {
                                        // Nothing needs
                                        // to be drawn
                                        continue;
                                    }
                                    // Draw a pixel
                                    g.drawLine(j, i, j, i);
                                }
                            }
                        }
                    }
                }
            };
        b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        b.setFocusPainted(false);
        b.setBorderPainted(false);
        return b;
    }


    /*
     *  The following methods only exist in order to be able to access protected
     *  members in the superclass, because these are otherwise not available
     *  in any inner class.
     */
    /**
     *  Gets the oneTouchSizeFromSuper attribute of the FlatSplitPaneDivider
     *  object
     *
     *@return    The oneTouchSizeFromSuper value
     */
    int getOneTouchSizeFromSuper() {
        return super.ONE_TOUCH_SIZE;
    }


    /**
     *  Gets the oneTouchOffsetFromSuper attribute of the FlatSplitPaneDivider
     *  object
     *
     *@return    The oneTouchOffsetFromSuper value
     */
    int getOneTouchOffsetFromSuper() {
        return super.ONE_TOUCH_OFFSET;
    }


    /**
     *  Gets the orientationFromSuper attribute of the FlatSplitPaneDivider
     *  object
     *
     *@return    The orientationFromSuper value
     */
    int getOrientationFromSuper() {
        return super.orientation;
    }


    /**
     *  Gets the splitPaneFromSuper attribute of the FlatSplitPaneDivider object
     *
     *@return    The splitPaneFromSuper value
     */
    JSplitPane getSplitPaneFromSuper() {
        return super.splitPane;
    }


    /**
     *  Gets the leftButtonFromSuper attribute of the FlatSplitPaneDivider
     *  object
     *
     *@return    The leftButtonFromSuper value
     */
    JButton getLeftButtonFromSuper() {
        return super.leftButton;
    }


    /**
     *  Gets the rightButtonFromSuper attribute of the FlatSplitPaneDivider
     *  object
     *
     *@return    The rightButtonFromSuper value
     */
    JButton getRightButtonFromSuper() {
        return super.rightButton;
    }
}


--- NEW FILE: FlatSplitPaneUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
/**
 *  Title: Butterfly XML editor Description: Copyright: Copyright (c) Nicola Ken
 *  Barozzi Company: Bibop Research
 *
 *@author     Nicola Ken Barozzi
 *@created    23 settembre 2001
 *@version    1.0
 */

public class FlatSplitPaneUI extends BasicSplitPaneUI {

    /**
     *  Creates a new FlatSplitPaneUI instance
     *
     *@param  x  Description of Parameter
     *@return    Description of the Returned Value
     */
    public static ComponentUI createUI(JComponent x) {
        x.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        return new FlatSplitPaneUI();
    }


    /**
     *  Creates the default divider.
     *
     *@return    Description of the Returned Value
     */
    public BasicSplitPaneDivider createDefaultDivider() {
        return new FlatSplitPaneDivider(this);
    }
}

--- NEW FILE: FlatTabbedPaneUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

/*
 *  @(#)FlatTabbedPaneUI.java	1.93 00/02/02
 *
 *  Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
 *
 *  This software is the proprietary information of Sun Microsystems, Inc.
 *  Use is subject to license terms.
 *
 */
import javax.swing.plaf.basic.BasicHTML;
[...2763 lines suppressed...]
        }


        /**
         *  Description of the Method
         *
         *@param  e  Description of Parameter
         */
        public void componentRemoved(ContainerEvent e) {
            JTabbedPane tp = (JTabbedPane) e.getContainer();
            Component child = e.getChild();
            int index = tp.indexOfComponent(child);
            if (htmlViews != null && htmlViews.size() >= index) {
                htmlViews.removeElementAt(index);
            }
        }
    }

}


--- NEW FILE: FlatTextFieldUI.java ---
/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package  org.krysalis.swingx.laf.flat;

import java.awt.*;
import java.beans.*;

import javax.swing.*;

import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

/**
 *  Basis of a look and feel for a JTextField. <p>
 *
 *  <strong>Warning:</strong> Serialized objects of this class will not be
 *  compatible with future Swing releases. The current serialization support is
 *  appropriate for short term storage or RMI between applications running the
 *  same version of Swing. A future release of Swing will provide support for
 *  long term persistence.
 *
 *@author     Steve Wilson
 *@created    23 settembre 2001
 *@version    1.9 02/02/00
 */
public class FlatTextFieldUI extends BasicTextFieldUI {

    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     *@return    Description of the Returned Value
     */
    public static ComponentUI createUI(JComponent c) {
        return new FlatTextFieldUI();
    }


    /**
     *  Description of the Method
     *
     *@param  c  Description of Parameter
     */
    public void installUI(JComponent c) {
        super.installUI(c);
        editableChanged(c, ((JTextComponent) c).isEditable());
        c.setBorder(BorderFactory.createEmptyBorder());
    }


    /**
     *  Description of the Method
     *
     *@param  e  Description of Parameter
     */
    public void propertyChange(PropertyChangeEvent e) {
        if (e.getPropertyName().equals("editable")) {
            JComponent source = (JComponent) e.getSource();
            Color background = source.getBackground();
            boolean editable = ((Boolean) e.getNewValue()).booleanValue();
            editableChanged(source, editable);
        }
        super.propertyChange(e);
    }


    /**
     *  Description of the Method
     *
     *@param  c         Description of Parameter
     *@param  editable  Description of Parameter
     */
    private void editableChanged(JComponent c, boolean editable) {
        Color background = c.getBackground();
        if (editable == false) {
            if (background instanceof UIResource) {
                c.setBackground(UIManager.getColor("control"));
            }
        } else {
            if (background instanceof UIResource) {
                c.setBackground(UIManager.getColor("TextField.background"));
            }
        }
    }

}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.