亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? percentlayout.java

?? java swing控件
?? JAVA
字號:
/**
 * L2FProd.com Common Components 6.9.1 License.
 *
 * Copyright 2005-2006 L2FProd.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.l2fprod.common.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;

/**
 * PercentLayout. <BR>Constraint based layout which allow the space to be
 * splitted using percentages. The following are allowed when adding components
 * to container:
 * <ul>
 * <li>container.add(component); <br>in this case, the component will be
 * sized to its preferred size
 * <li>container.add(component, "100"); <br>in this case, the component will
 * have a width (or height) of 100
 * <li>container.add(component, "25%"); <br>in this case, the component will
 * have a width (or height) of 25 % of the container width (or height) <br>
 * <li>container.add(component, "*"); <br>in this case, the component will
 * take the remaining space. if several components use the "*" constraint the
 * space will be divided among the components.
 * </ul>
 * 
 * @javabean.class
 *          name="PercentLayout"
 *          shortDescription="A layout supports constraints expressed in percent."
 */
public class PercentLayout implements LayoutManager2 {

  /**
   * Useful constant to layout the components horizontally (from top to
   * bottom).
   */
  public final static int HORIZONTAL = 0;

  /**
   * Useful constant to layout the components vertically (from left to right).
   */
  public final static int VERTICAL = 1;

  static class Constraint {
    protected Object value;
    private Constraint(Object value) {
      this.value = value;
    }
  }

  static class NumberConstraint extends Constraint {
    public NumberConstraint(int d) {
      this(new Integer(d));
    }
    public NumberConstraint(Integer d) {
      super(d);
    }
    public int intValue() {
      return ((Integer)value).intValue();
    }
  }

  static class PercentConstraint extends Constraint {
    public PercentConstraint(float d) {
      super(new Float(d));
    }
    public float floatValue() {
      return ((Float)value).floatValue();
    }
  }

  private final static Constraint REMAINING_SPACE = new Constraint("*");

  private final static Constraint PREFERRED_SIZE = new Constraint("");

  private int orientation;
  private int gap;

  private Hashtable m_ComponentToConstraint;

  /**
   * Creates a new HORIZONTAL PercentLayout with a gap of 0.
   */
  public PercentLayout() {
    this(HORIZONTAL, 0);
  }

  public PercentLayout(int orientation, int gap) {
    setOrientation(orientation);
    this.gap = gap;

    m_ComponentToConstraint = new Hashtable();
  }

  public void setGap(int gap) {
    this.gap = gap;   
  }
  
  /**
   * @javabean.property
   *          bound="true"
   *          preferred="true"
   */
  public int getGap() {
    return gap;
  }
  
  public void setOrientation(int orientation) {
    if (orientation != HORIZONTAL && orientation != VERTICAL) {
      throw new IllegalArgumentException("Orientation must be one of HORIZONTAL or VERTICAL");
    }
    this.orientation = orientation;
  }

  /**
   * @javabean.property
   *          bound="true"
   *          preferred="true"
   */
  public int getOrientation() {
    return orientation;
  }
  
  public Constraint getConstraint(Component component) {
    return (Constraint)m_ComponentToConstraint.get(component);
  }
  
  public void setConstraint(Component component, Object constraints) {
    if (constraints instanceof Constraint) {
      m_ComponentToConstraint.put(component, constraints);
    } else if (constraints instanceof Number) {
      setConstraint(
        component,
        new NumberConstraint(((Number)constraints).intValue()));
    } else if ("*".equals(constraints)) {
      setConstraint(component, REMAINING_SPACE);
    } else if ("".equals(constraints)) {
      setConstraint(component, PREFERRED_SIZE);
    } else if (constraints instanceof String) {
      String s = (String)constraints;
      if (s.endsWith("%")) {
        float value = Float.valueOf(s.substring(0, s.length() - 1))
          .floatValue() / 100;
        if (value > 1 || value < 0)
          throw new IllegalArgumentException("percent value must be >= 0 and <= 100");
        setConstraint(component, new PercentConstraint(value));
      } else {
        setConstraint(component, new NumberConstraint(Integer.valueOf(s)));
      }
    } else if (constraints == null) {
      // null constraint means preferred size
      setConstraint(component, PREFERRED_SIZE);
    } else {
      throw new IllegalArgumentException("Invalid Constraint");
    }    
  }
  
  public void addLayoutComponent(Component component, Object constraints) {
    setConstraint(component, constraints);    
  }

  /**
   * Returns the alignment along the x axis. This specifies how the component
   * would like to be aligned relative to other components. The value should be
   * a number between 0 and 1 where 0 represents alignment along the origin, 1
   * is aligned the furthest away from the origin, 0.5 is centered, etc.
   */
  public float getLayoutAlignmentX(Container target) {
    return 1.0f / 2.0f;
  }

  /**
   * Returns the alignment along the y axis. This specifies how the component
   * would like to be aligned relative to other components. The value should be
   * a number between 0 and 1 where 0 represents alignment along the origin, 1
   * is aligned the furthest away from the origin, 0.5 is centered, etc.
   */
  public float getLayoutAlignmentY(Container target) {
    return 1.0f / 2.0f;
  }

  /**
   * Invalidates the layout, indicating that if the layout manager has cached
   * information it should be discarded.
   */
  public void invalidateLayout(Container target) {
  }

  /**
   * Adds the specified component with the specified name to the layout.
   * 
   * @param name the component name
   * @param comp the component to be added
   */
  public void addLayoutComponent(String name, Component comp) {
  }

  /**
   * Removes the specified component from the layout.
   * 
   * @param comp the component ot be removed
   */
  public void removeLayoutComponent(Component comp) {
    m_ComponentToConstraint.remove(comp);
  }

  /**
   * Calculates the minimum size dimensions for the specified panel given the
   * components in the specified parent container.
   * 
   * @param parent the component to be laid out
   * @see #preferredLayoutSize
   */
  public Dimension minimumLayoutSize(Container parent) {
    return preferredLayoutSize(parent);
  }

  /**
   * Returns the maximum size of this component.
   * 
   * @see java.awt.Component#getMinimumSize()
   * @see java.awt.Component#getPreferredSize()
   * @see java.awt.LayoutManager
   */
  public Dimension maximumLayoutSize(Container parent) {
    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  }

  public Dimension preferredLayoutSize(Container parent) {
    Component[] components = parent.getComponents();
    Insets insets = parent.getInsets();
    int width = 0;
    int height = 0;
    Dimension componentPreferredSize;
    boolean firstVisibleComponent = true;
    for (int i = 0, c = components.length; i < c; i++) {
      if (components[i].isVisible()) {
        componentPreferredSize = components[i].getPreferredSize();
        if (orientation == HORIZONTAL) {
          height = Math.max(height, componentPreferredSize.height);
          width += componentPreferredSize.width;
          if (firstVisibleComponent) {
            firstVisibleComponent = false;
          } else {
            width += gap;
          }
        } else {
          height += componentPreferredSize.height;
          width = Math.max(width, componentPreferredSize.width);
          if (firstVisibleComponent) {
            firstVisibleComponent = false;
          } else {
            height += gap;
          }
        }
      }
    }
    return new Dimension(
      width + insets.right + insets.left,
      height + insets.top + insets.bottom);
  }

  public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    Dimension d = parent.getSize();

    // calculate the available sizes
    d.width = d.width - insets.left - insets.right;
    d.height = d.height - insets.top - insets.bottom;

    // pre-calculate the size of each components
    Component[] components = parent.getComponents();
    int[] sizes = new int[components.length];

    // calculate the available size
    int totalSize =
      (HORIZONTAL == orientation ? d.width : d.height)
        - (components.length - 1) * gap;
    int availableSize = totalSize;

    // PENDING(fred): the following code iterates 4 times on the component
    // array, need to find something more efficient!
       
    // give priority to components who want to use their preferred size or who
    // have a predefined size
    for (int i = 0, c = components.length; i < c; i++) {
      if (components[i].isVisible()) {
        Constraint constraint =
          (Constraint)m_ComponentToConstraint.get(components[i]);
        if (constraint == null || constraint == PREFERRED_SIZE) {
          sizes[i] =
            (HORIZONTAL == orientation
              ? components[i].getPreferredSize().width
              : components[i].getPreferredSize().height);
          availableSize -= sizes[i];
        } else if (constraint instanceof NumberConstraint) {
          sizes[i] = ((NumberConstraint)constraint).intValue();
          availableSize -= sizes[i];
        }
      }
    }
    
    // then work with the components who want a percentage of the remaining
    // space
    int remainingSize = availableSize;    
    for (int i = 0, c = components.length; i < c; i++) {
      if (components[i].isVisible()) {
        Constraint constraint =
          (Constraint)m_ComponentToConstraint.get(components[i]);
        if (constraint instanceof PercentConstraint) {
          sizes[i] = (int)(remainingSize * ((PercentConstraint)constraint)
            .floatValue());
          availableSize -= sizes[i];
        }
      }
    }
    
    // finally share the remaining space between the other components    
    ArrayList remaining = new ArrayList();
    for (int i = 0, c = components.length; i < c; i++) {
      if (components[i].isVisible()) {
        Constraint constraint =
          (Constraint)m_ComponentToConstraint.get(components[i]);
        if (constraint == REMAINING_SPACE) {
          remaining.add(new Integer(i));
          sizes[i] = 0;
        }
      }
    }

    if (remaining.size() > 0) {
      int rest = availableSize / remaining.size();
      for (Iterator iter = remaining.iterator(); iter.hasNext();) {
        sizes[((Integer)iter.next()).intValue()] = rest;
      }
    }

    // all calculations are done, apply the sizes
    int currentOffset = (HORIZONTAL == orientation ? insets.left : insets.top);

    for (int i = 0, c = components.length; i < c; i++) {
      if (components[i].isVisible()) {
        if (HORIZONTAL == orientation) {
          components[i].setBounds(
            currentOffset,
            insets.top,
            sizes[i],
            d.height);
        } else {
          components[i].setBounds(
            insets.left,
            currentOffset,
            d.width,
            sizes[i]);
        }
        currentOffset += gap + sizes[i];
      }
    }
  }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区在线播放| 日韩丝袜情趣美女图片| 26uuu亚洲综合色| 日韩国产欧美在线播放| 在线观看区一区二| 亚洲欧美电影院| aaa亚洲精品| 欧美成人艳星乳罩| 蜜乳av一区二区三区| 欧美午夜一区二区三区| 亚洲一区中文在线| 国产99久久久久| 欧美经典一区二区| 国产成人午夜高潮毛片| 欧美国产精品一区二区三区| 国精产品一区一区三区mba桃花| 日韩视频一区在线观看| 日韩经典一区二区| 日韩亚洲欧美成人一区| 久久精品免费看| xnxx国产精品| 丁香另类激情小说| 亚洲蜜桃精久久久久久久| 国产盗摄一区二区| 亚洲欧洲日产国码二区| 91在线播放网址| 亚洲一区在线观看网站| 这里只有精品免费| 久久99精品国产麻豆不卡| 久久综合色8888| 成a人片国产精品| 日韩伦理免费电影| 欧美日韩在线三区| 蜜桃av一区二区三区电影| 久久久噜噜噜久噜久久综合| 成人性生交大片免费看中文| 综合中文字幕亚洲| 欧美男男青年gay1069videost| 日本亚洲最大的色成网站www| 91精品办公室少妇高潮对白| 亚洲成人激情社区| 精品成a人在线观看| 成人污污视频在线观看| 亚洲一区二区三区免费视频| 精品噜噜噜噜久久久久久久久试看 | 国产精品久久久久国产精品日日| av电影在线不卡| 婷婷开心激情综合| 国产精品乱人伦| 欧美影院精品一区| 国产真实精品久久二三区| 日韩理论片一区二区| 在线综合亚洲欧美在线视频| 成人午夜私人影院| 日韩电影在线看| 国产精品久久久久久久久晋中 | 欧美久久久影院| 国产一区二区三区免费看| 伊人夜夜躁av伊人久久| 欧美在线不卡视频| 国产成人啪午夜精品网站男同| 一区二区三区在线视频观看58| 日韩欧美一区二区久久婷婷| 99精品久久免费看蜜臀剧情介绍| 日产国产高清一区二区三区 | 国产精品久久久久国产精品日日| 精品日韩av一区二区| 宅男噜噜噜66一区二区66| 欧美在线影院一区二区| 在线观看日韩毛片| 欧美无砖专区一中文字| 在线观看日韩国产| 欧美视频一区二区三区四区| 色哟哟一区二区三区| 91浏览器在线视频| 色综合久久中文综合久久97| 精品视频1区2区3区| 91福利在线看| 欧美日韩一区高清| 欧美日韩成人高清| 欧美一级二级在线观看| 日韩精品一区二区三区蜜臀 | 久久综合九色综合97婷婷女人 | 老司机免费视频一区二区| 亚洲第一久久影院| 日本系列欧美系列| 久久精品国产精品青草| 男男gaygay亚洲| 捆绑调教一区二区三区| 日本欧美大码aⅴ在线播放| 日韩av电影免费观看高清完整版| 日本午夜精品视频在线观看| 麻豆专区一区二区三区四区五区| 久久99精品久久只有精品| 国产一区二区不卡在线 | 精品在线你懂的| 国产成a人无v码亚洲福利| kk眼镜猥琐国模调教系列一区二区| av色综合久久天堂av综合| 欧美在线综合视频| 日韩一区二区三区免费观看| 久久综合色播五月| 亚洲日本免费电影| 日韩不卡一区二区| 成人一区二区三区视频| 一本一道久久a久久精品| 8v天堂国产在线一区二区| 精品999在线播放| 国产精品久久久久aaaa| 午夜精品久久久久久久久| 久久激五月天综合精品| 成人一区二区三区| 欧美乱熟臀69xxxxxx| 国产欧美va欧美不卡在线 | 午夜av一区二区| 国产麻豆精品95视频| 91官网在线观看| 亚洲精品在线一区二区| 亚洲欧美色图小说| 久久精品国产77777蜜臀| 一本久道中文字幕精品亚洲嫩| 日韩一区二区视频在线观看| 中文字幕av不卡| 欧美a级一区二区| 99精品在线观看视频| 精品女同一区二区| 亚洲精品久久久久久国产精华液| 久久aⅴ国产欧美74aaa| 色激情天天射综合网| 久久久国产一区二区三区四区小说| 一区二区三区精品| 成人一级片在线观看| 日韩精品专区在线影院重磅| 一区二区三区高清| 波多野结衣一区二区三区 | 91精品国产高清一区二区三区| 久久精品视频网| 日本女优在线视频一区二区| 91成人免费电影| 国产三级一区二区| 久久精品国产第一区二区三区| 欧美日韩中文字幕精品| 日韩久久一区二区| 成人免费精品视频| 久久久久久**毛片大全| 免费日韩伦理电影| 欧美日本视频在线| 一区二区免费在线| 91麻豆精东视频| 国产精品久久久久久福利一牛影视| 久久av资源站| 日韩欧美一区二区视频| 日日夜夜一区二区| 欧美网站一区二区| 亚洲精品高清在线观看| 91网站在线播放| 亚洲免费在线视频| 99久久99久久精品国产片果冻 | 国产综合色产在线精品| 91精品国产入口在线| 亚洲国产精品久久艾草纯爱| 在线亚洲人成电影网站色www| 亚洲欧洲精品一区二区三区不卡 | thepron国产精品| 久久久激情视频| 国产精品一区二区在线看| 精品国产91亚洲一区二区三区婷婷| 美脚の诱脚舐め脚责91| 日韩欧美一级在线播放| 美美哒免费高清在线观看视频一区二区 | 欧美sm美女调教| 精品一区二区三区久久| 精品国产一区二区三区久久影院 | 欧美一区二区高清| 天堂影院一区二区| 777色狠狠一区二区三区| 秋霞午夜鲁丝一区二区老狼| 日韩三级av在线播放| 韩国女主播成人在线观看| 久久综合九色综合欧美98| 国产一区二区免费看| 亚洲国产精品精华液2区45| 成人国产精品免费观看动漫 | 欧美三级电影一区| 香蕉久久夜色精品国产使用方法| 欧美日韩大陆一区二区| 奇米精品一区二区三区在线观看| 91精品国产综合久久久久久漫画 | 精品日本一线二线三线不卡 | 99久久精品免费看国产免费软件| 亚洲视频一二区| 欧美视频在线不卡| 久久国产视频网| 欧美激情综合网| 色综合天天做天天爱| 日韩高清国产一区在线| 欧美经典一区二区| 欧美视频在线不卡| 国产精品一级二级三级| 亚洲视频免费在线观看|