⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compoundskin.java

📁 Skin Look And Feel 1.2.10, 给你的java程序换肤, 支持大量通用皮肤文件.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ====================================================================
 *
 * Skin Look And Feel 1.2.10 License.
 *
 * Copyright (c) 2000-2004 L2FProd.com.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by L2FProd.com
 *        (http://www.L2FProd.com/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "Skin Look And Feel", "SkinLF" and "L2FProd.com" must not
 *    be used to endorse or promote products derived from this software
 *    without prior written permission. For written permission, please
 *    contact info@L2FProd.com.
 *
 * 5. Products derived from this software may not be called "SkinLF"
 *    nor may "SkinLF" appear in their names without prior written
 *    permission of L2FProd.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL L2FPROD.COM OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 */
package com.l2fprod.gui.plaf.skin;

import java.awt.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.*;

import com.l2fprod.gui.plaf.skin.impl.AbstractSkin;

/**
 * Assembles two skins to create a new one. <br>
 * This can be used to combine features from two skins.
 *
 * @author    $Author: l2fprod $
 * @created   27 avril 2002
 * @version   $Revision: 1.3 $, $Date: 2003/11/23 14:47:45 $
 */
public final class CompoundSkin extends AbstractSkin {

  private Skin skina, skinb;

  /**
   * Construct a new Skin by merging two skins.<BR>
   * If a feature is missing in the first skin, the second skin is used.
   *
   * @param a  Description of Parameter
   * @param b  Description of Parameter
   */
  public CompoundSkin(Skin a, Skin b) {
    skina = a;
    skinb = b;

    if ((a == null) || (b == null)) {
      throw new IllegalArgumentException("Skins must not be null!");
    }

    button = new CompoundButton();
    frame = new CompoundFrame();
    personality = new CompoundPersonality();
    progress = new CompoundProgress();
    scrollbar = new CompoundScrollbar();
    slider = new CompoundSlider();
    tab = new CompoundTab();
    splitpane = new CompoundSplitPane();
    separator = new CompoundSeparator();
  }

  /**
   * Gets the Colors attribute of the CompoundSkin object
   *
   * @return   The Colors value
   */
  public String[] getColors() {
    Vector v = new Vector();
    String[] result = skina.getColors();
    if (result != null) {
      addColors(result, v);
    }
    result = skinb.getColors();
    if (result != null) {
      addColors(result, v);
    }
    result = new String[v.size()];
    v.copyInto(result);
    return result;
  }

  /**
   * Gets the Resource attribute of the CompoundSkin object
   *
   * @param key  Description of Parameter
   * @return     The Resource value
   */
  public Object getResource(Object key) {
    Object value = skina.getResource(key);
    return (value != null ? value : skinb.getResource(key));
  }

  public void initComponentDefaults(UIDefaults table) {
    skina.initComponentDefaults(table);
    skinb.initComponentDefaults(table);
  }

  /**
   * Adds a feature to the Colors attribute of the CompoundSkin object
   *
   * @param colors  The feature to be added to the Colors attribute
   * @param v       The feature to be added to the Colors attribute
   */
  protected void addColors(String[] colors, Vector v) {
    for (int i = 0, c = colors.length; i < c; i = i + 2) {
      if ("".equals(colors[i + 1])) {
        continue;
      }
      v.addElement(colors[i]);
      v.addElement(colors[i + 1]);
    }
  }

  private class CompoundComponent implements SkinComponent {
    public boolean status() {
      return true;
    }
    public boolean installSkin(javax.swing.JComponent c) {
      return false;
    }
    public void uninstallSkin(javax.swing.JComponent c) {
    }
  }

  /**
   * Description of the Class
   *
   * @author    fred
   * @created   27 avril 2002
   */
  private class CompoundButton extends CompoundComponent implements SkinButton {
    /**
     * Gets the CheckBoxIconSize attribute of the CompoundButton object
     *
     * @return   The CheckBoxIconSize value
     */
    public Dimension getCheckBoxIconSize() {
      Dimension dimension = null;
      if (skina.getButton() != null) {
        dimension = skina.getButton().getCheckBoxIconSize();
      }
      if ((dimension == null) && (skinb.getButton() != null)) {
        dimension = skinb.getButton().getCheckBoxIconSize();
      }
      return dimension;
    }

    /**
     * Gets the RadioButtonIconSize attribute of the CompoundButton object
     *
     * @return   The RadioButtonIconSize value
     */
    public Dimension getRadioButtonIconSize() {
      Dimension dimension = null;
      if (skina.getButton() != null) {
        dimension = skina.getButton().getRadioButtonIconSize();
      }
      if ((dimension == null) && (skinb.getButton() != null)) {
        dimension = skinb.getButton().getRadioButtonIconSize();
      }
      return dimension;
    }

    /**
     * Gets the RadioIcon attribute of the CompoundButton object
     *
     * @param b  Description of Parameter
     * @return   The RadioIcon value
     */
    public Icon getRadioIcon(AbstractButton b) {
      Icon icon = null;
      if (skina.getButton() != null) {
        icon = skina.getButton().getRadioIcon(b);
      }
      if ((icon == null) && (skinb.getButton() != null)) {
        icon = skinb.getButton().getRadioIcon(b);
      }
      return icon;
    }

    /**
     * Description of the Method
     *
     * @return   Description of the Returned Value
     */
    public boolean status() {
      boolean result = false;
      if (skina.getButton() != null) {
        result = skina.getButton().status();
      }
      if (!result && (skinb.getButton() != null)) {
        result = skinb.getButton().status();
      }
      return result;
    }

    /**
     * Description of the Method
     *
     * @param c  Description of Parameter
     * @return   Description of the Returned Value
     */
    public boolean installSkin(JComponent c) {
      boolean result = false;
      if (skina.getButton() != null) {
        result = skina.getButton().installSkin(c);
      }
      if (!result && (skinb.getButton() != null)) {
        result = skinb.getButton().installSkin(c);
      }
      return result;
    }

    /**
     * Description of the Method
     *
     * @param g  Description of Parameter
     * @param b  Description of Parameter
     * @return   Description of the Returned Value
     */
    public boolean paintButton(Graphics g, AbstractButton b) {
      boolean result = false;
      if (skina.getButton() != null) {
        result = skina.getButton().paintButton(g, b);
      }
      if (!result && (skinb.getButton() != null)) {
        result = skinb.getButton().paintButton(g, b);
      }
      return result;
    }
  }

  /**
   * Description of the Class
   *
   * @author    fred
   * @created   27 avril 2002
   */
  private class CompoundFrame extends CompoundComponent implements SkinFrame {
    /**
     * Gets the WindowButtons attribute of the CompoundFrame object
     *
     * @param align  Description of Parameter
     * @return       The WindowButtons value
     */
    public SkinWindowButton[] getWindowButtons(int align) {
      SkinWindowButton[] buttons = null;
      if (skina.getFrame() != null) {
        buttons = skina.getFrame().getWindowButtons(align);
      }
      if ((buttons == null) && (skinb.getFrame() != null)) {
        buttons = skinb.getFrame().getWindowButtons(align);
      }
      return buttons;
    }

    /**
     * Gets the TopPreferredSize attribute of the CompoundFrame object
     *
     * @return   The TopPreferredSize value
     */
    public Dimension getTopPreferredSize() {
      Dimension dimension = null;
      if (skina.getFrame() != null) {
        dimension = skina.getFrame().getTopPreferredSize();
      }
      if ((dimension == null) && (skinb.getFrame() != null)) {
        dimension = skinb.getFrame().getTopPreferredSize();
      }
      return dimension;
    }

    /**
     * Description of the Method
     *
     * @return   Description of the Returned Value
     */
    public boolean status() {
      boolean result = false;
      if (skina.getFrame() != null) {
        result = skina.getFrame().status();
      }
      if (!result && (skinb.getFrame() != null)) {
        result = skinb.getFrame().status();
      }
      return result;
    }

    /**
     * Description of the Method
     *
     * @param c  Description of Parameter
     * @return   Description of the Returned Value
     */
    public boolean installSkin(JComponent c) {
      boolean result = false;
      if (skina.getFrame() != null) {
        result = skina.getFrame().installSkin(c);
      }
      if (!result && (skinb.getFrame() != null)) {
        result = skinb.getFrame().installSkin(c);
      }
      return result;
    }

    /**
     * Description of the Method
     *
     * @param g           Description of Parameter
     * @param c           Description of Parameter
     * @param isSelected  Description of Parameter
     * @param title       Description of Parameter
     * @return            Description of the Returned Value
     */
    public boolean paintTop(Graphics g, Component c, boolean isSelected, String title) {
      boolean result = false;
      if (skina.getFrame() != null) {
        result = skina.getFrame().paintTop(g, c, isSelected, title);
      }
      if (!result && (skinb.getFrame() != null)) {
        result = skinb.getFrame().paintTop(g, c, isSelected, title);
      }
      return result;
    }
  }

  /**
   * Description of the Class
   *
   * @author    fred
   * @created   27 avril 2002
   */
  private class CompoundPersonality extends CompoundComponent implements SkinPersonality {

    /**
     * Gets the ComboBoxInsets attribute of the CompoundPersonality object
     *
     * @return   The ComboBoxInsets value
     */
    public java.awt.Insets getComboBoxInsets() {
      Insets insets = null;
      if (skina.getPersonality() != null) {
        insets = skina.getPersonality().getComboBoxInsets();
      }
      if ((insets == null) && (skinb.getPersonality() != null)) {
        insets = skinb.getPersonality().getComboBoxInsets();
      }
      return insets;
    }

    /**
     * Gets the ComboBoxPreferredSize attribute of the CompoundPersonality
     * object
     *
     * @param c  Description of Parameter
     * @return   The ComboBoxPreferredSize value
     */
    public java.awt.Dimension getComboBoxPreferredSize(javax.swing.JComboBox c) {
      Dimension dimension = null;
      if (skina.getPersonality() != null) {
        dimension = skina.getPersonality().getComboBoxPreferredSize(c);
      }
      if ((dimension == null) && (skinb.getPersonality() != null)) {
        dimension = skinb.getPersonality().getComboBoxPreferredSize(c);
      }
      return dimension;
    }

    /**
     * Gets the TableHeaderRenderer attribute of the CompoundPersonality object
     *
     * @return   The TableHeaderRenderer value
     */
    public TableCellRenderer getTableHeaderRenderer() {
      TableCellRenderer renderer = null;
      if (skina.getPersonality() != null) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -