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

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

?? graphpaperlayout.java

?? java tutotrials or beginners
?? JAVA
字號:
/* * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * *   - Redistributions of source code must retain the above copyright *     notice, this list of conditions and the following disclaimer. * *   - 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. * *   - Neither the name of Sun Microsystems nor the names of its *     contributors may be used to endorse or promote products derived *     from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS 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 THE COPYRIGHT OWNER OR * 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 layout;import java.awt.*;import java.util.Hashtable;/** * The <code>GraphPaperLayout</code> class is a layout manager that * lays out a container's components in a rectangular grid, similar * to GridLayout.  Unlike GridLayout, however, components can take * up multiple rows and/or columns.  The layout manager acts as a * sheet of graph paper.  When a component is added to the layout * manager, the location and relative size of the component are * simply supplied by the constraints as a Rectangle. * <p><code><pre> * import java.awt.*; * import java.applet.Applet; * public class ButtonGrid extends Applet { *     public void init() { *         setLayout(new GraphPaperLayout(new Dimension(5,5))); *         // Add a 1x1 Rect at (0,0) *         add(new Button("1"), new Rectangle(0,0,1,1)); *         // Add a 2x1 Rect at (2,0) *         add(new Button("2"), new Rectangle(2,0,2,1)); *         // Add a 1x2 Rect at (1,1) *         add(new Button("3"), new Rectangle(1,1,1,2)); *         // Add a 2x2 Rect at (3,2) *         add(new Button("4"), new Rectangle(3,2,2,2)); *         // Add a 1x1 Rect at (0,4) *         add(new Button("5"), new Rectangle(0,4,1,1)); *         // Add a 1x2 Rect at (2,3) *         add(new Button("6"), new Rectangle(2,3,1,2)); *     } * } * </pre></code> * * @author      Michael Martak */public class GraphPaperLayout implements LayoutManager2 {    int hgap;            //horizontal gap    int vgap;            //vertical gap    Dimension gridSize;  //grid size in logical units (n x m)    Hashtable<Component, Rectangle> compTable; //constraints (Rectangles)    /**     * Creates a graph paper layout with a default of a 1 x 1 graph, with no     * vertical or horizontal padding.     */    public GraphPaperLayout() {        this(new Dimension(1,1));    }    /**     * Creates a graph paper layout with the given grid size, with no vertical     * or horizontal padding.     */    public GraphPaperLayout(Dimension gridSize) {        this(gridSize, 0, 0);    }    /**     * Creates a graph paper layout with the given grid size and padding.     * @param gridSize size of the graph paper in logical units (n x m)     * @param hgap horizontal padding     * @param vgap vertical padding     */    public GraphPaperLayout(Dimension gridSize, int hgap, int vgap) {        if ((gridSize.width <= 0) || (gridSize.height <= 0)) {            throw new IllegalArgumentException(                "dimensions must be greater than zero");        }        this.gridSize = new Dimension(gridSize);        this.hgap = hgap;        this.vgap = vgap;        compTable = new Hashtable<Component, Rectangle>();    }    /**     * @return the size of the graph paper in logical units (n x m)     */    public Dimension getGridSize() {        return new Dimension( gridSize );    }    /**     * Set the size of the graph paper in logical units (n x m)     */    public void setGridSize( Dimension d ) {        setGridSize( d.width, d.height );    }    /**     * Set the size of the graph paper in logical units (n x m)     */    public void setGridSize( int width, int height ) {        gridSize = new Dimension( width, height );    }    public void setConstraints(Component comp, Rectangle constraints) {        compTable.put(comp, new Rectangle(constraints));    }    /**     * Adds the specified component with the specified name to     * the layout.  This does nothing in GraphPaperLayout, since constraints     * are required.     */    public void addLayoutComponent(String name, Component comp) {    }    /**     * Removes the specified component from the layout.     * @param comp the component to be removed     */    public void removeLayoutComponent(Component comp) {        compTable.remove(comp);    }    /**     * Calculates the preferred size dimensions for the specified     * panel given the components in the specified parent container.     * @param parent the component to be laid out     *     * @see #minimumLayoutSize     */    public Dimension preferredLayoutSize(Container parent) {        return getLayoutSize(parent, true);    }    /**     * 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 getLayoutSize(parent, false);    }    /**     * Algorithm for calculating layout size (minimum or preferred).     * <p>     * The width of a graph paper layout is the largest cell width     * (calculated in <code>getLargestCellSize()</code> times the number of     * columns, plus the horizontal padding times the number of columns     * plus one, plus the left and right insets of the target container.     * <p>     * The height of a graph paper layout is the largest cell height     * (calculated in <code>getLargestCellSize()</code> times the number of     * rows, plus the vertical padding times the number of rows     * plus one, plus the top and bottom insets of the target container.     *     * @param parent the container in which to do the layout.     * @param isPreferred true for calculating preferred size, false for     *                    calculating minimum size.     * @return the dimensions to lay out the subcomponents of the specified     *         container.     * @see java.awt.GraphPaperLayout#getLargestCellSize     */    protected Dimension getLayoutSize(Container parent, boolean isPreferred) {        Dimension largestSize = getLargestCellSize(parent, isPreferred);        Insets insets = parent.getInsets();        largestSize.width = ( largestSize.width * gridSize.width ) +            ( hgap * ( gridSize.width + 1 ) ) + insets.left + insets.right;        largestSize.height = ( largestSize.height * gridSize.height ) +            ( vgap * ( gridSize.height + 1 ) ) + insets.top + insets.bottom;        return largestSize;    }    /**     * Algorithm for calculating the largest minimum or preferred cell size.     * <p>     * Largest cell size is calculated by getting the applicable size of each     * component and keeping the maximum value, dividing the component's width     * by the number of columns it is specified to occupy and dividing the     * component's height by the number of rows it is specified to occupy.     *     * @param parent the container in which to do the layout.     * @param isPreferred true for calculating preferred size, false for     *                    calculating minimum size.     * @return the largest cell size required.     */    protected Dimension getLargestCellSize(Container parent,                                           boolean isPreferred) {        int ncomponents = parent.getComponentCount();        Dimension maxCellSize = new Dimension(0,0);        for ( int i = 0; i < ncomponents; i++ ) {            Component c = parent.getComponent(i);            Rectangle rect = compTable.get(c);            if ( c != null && rect != null ) {                Dimension componentSize;                if ( isPreferred ) {                    componentSize = c.getPreferredSize();                } else {                    componentSize = c.getMinimumSize();                }                // Note: rect dimensions are already asserted to be > 0 when the                // component is added with constraints                maxCellSize.width = Math.max(maxCellSize.width,                    componentSize.width / rect.width);                maxCellSize.height = Math.max(maxCellSize.height,                    componentSize.height / rect.height);            }        }        return maxCellSize;    }    /**     * Lays out the container in the specified container.     * @param parent the component which needs to be laid out     */    public void layoutContainer(Container parent) {        synchronized (parent.getTreeLock()) {            Insets insets = parent.getInsets();            int ncomponents = parent.getComponentCount();            if (ncomponents == 0) {                return;            }            // Total parent dimensions            Dimension size = parent.getSize();            int totalW = size.width - (insets.left + insets.right);            int totalH = size.height - (insets.top + insets.bottom);            // Cell dimensions, including padding            int totalCellW = totalW / gridSize.width;            int totalCellH = totalH / gridSize.height;            // Cell dimensions, without padding            int cellW = (totalW - ( (gridSize.width + 1) * hgap) )                    / gridSize.width;            int cellH = (totalH - ( (gridSize.height + 1) * vgap) )                    / gridSize.height;            for ( int i = 0; i < ncomponents; i++ ) {                Component c = parent.getComponent(i);                Rectangle rect = compTable.get(c);                if ( rect != null ) {                    int x = insets.left + ( totalCellW * rect.x ) + hgap;                    int y = insets.top + ( totalCellH * rect.y ) + vgap;                    int w = ( cellW * rect.width ) - hgap;                    int h = ( cellH * rect.height ) - vgap;                    c.setBounds(x, y, w, h);                }            }        }    }    // LayoutManager2 /////////////////////////////////////////////////////////    /**     * Adds the specified component to the layout, using the specified     * constraint object.     * @param comp the component to be added     * @param constraints  where/how the component is added to the layout.     */    public void addLayoutComponent(Component comp, Object constraints) {        if (constraints instanceof Rectangle) {            Rectangle rect = (Rectangle)constraints;            if ( rect.width <= 0 || rect.height <= 0 ) {                throw new IllegalArgumentException(                    "cannot add to layout: rectangle must have positive width and height");            }            if ( rect.x < 0 || rect.y < 0 ) {                throw new IllegalArgumentException(                    "cannot add to layout: rectangle x and y must be >= 0");            }            setConstraints(comp, rect);        } else if (constraints != null) {            throw new IllegalArgumentException(                "cannot add to layout: constraint must be a Rectangle");        }    }    /**     * Returns the maximum size of this component.     * @see java.awt.Component#getMinimumSize()     * @see java.awt.Component#getPreferredSize()     * @see LayoutManager     */    public Dimension maximumLayoutSize(Container target) {        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);    }    /**     * 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 0.5f;    }    /**     * 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 0.5f;    }    /**     * Invalidates the layout, indicating that if the layout manager     * has cached information it should be discarded.     */    public void invalidateLayout(Container target) {        // Do nothing    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品免费在线| 亚洲男帅同性gay1069| 一本色道久久综合亚洲精品按摩| 久久成人羞羞网站| 蜜桃av噜噜一区二区三区小说| 午夜天堂影视香蕉久久| 亚洲第一二三四区| 日日夜夜一区二区| 日韩极品在线观看| 久久国产精品第一页| 国产乱人伦偷精品视频不卡| 国产自产2019最新不卡| 高清国产一区二区| 在线国产亚洲欧美| 国产欧美日韩一区二区三区在线观看| 国产精品久久久久久久蜜臀 | 日韩精品午夜视频| 久久精品噜噜噜成人88aⅴ| 九九**精品视频免费播放| 国产激情一区二区三区| 97超碰欧美中文字幕| 欧美午夜不卡视频| 日韩欧美视频在线| 亚洲国产精品成人综合| 一区二区三区欧美激情| 麻豆成人久久精品二区三区红| 国产精品1024久久| 日本精品裸体写真集在线观看| 欧美另类一区二区三区| 久久你懂得1024| 亚洲精品国产无天堂网2021| 免费成人美女在线观看.| 成人高清免费观看| 欧美日韩一级二级三级| 久久久91精品国产一区二区精品| 亚洲男人的天堂在线aⅴ视频| 蜜臀av性久久久久蜜臀aⅴ| 成人激情图片网| 欧美一区二区视频在线观看2022| 中文字幕欧美区| 午夜精品在线看| 成人精品视频.| 日韩一区二区不卡| 亚洲国产另类精品专区| 国产盗摄视频一区二区三区| 欧美午夜一区二区三区| 国产精品乱码久久久久久| 美腿丝袜在线亚洲一区 | 一区二区三区在线免费视频| 美女一区二区三区| 欧美曰成人黄网| 国产精品成人在线观看| 国产一区二区三区美女| 51午夜精品国产| 亚洲综合av网| 91在线视频18| 国产精品剧情在线亚洲| 国产成人免费视频精品含羞草妖精| 欧美一级二级在线观看| 亚洲一区在线免费观看| 97se亚洲国产综合自在线| 久久精品一区二区三区av| 美女一区二区视频| 日韩一区二区三免费高清| 午夜久久久久久久久| 欧美日韩一级大片网址| 一区二区三区鲁丝不卡| 91片黄在线观看| 国产精品人妖ts系列视频| 国v精品久久久网| 久久久久久麻豆| 国产原创一区二区| 精品国产乱码久久久久久浪潮 | 国产精品美女视频| 成人黄色小视频| 国产精品久久久久天堂| 99re这里只有精品视频首页| 日本不卡视频在线| 日韩欧美国产一二三区| 久久99精品久久久久| 精品成人a区在线观看| 国产精品18久久久| 国产精品电影院| 色屁屁一区二区| 一区二区三区蜜桃网| 欧美日本韩国一区| 看国产成人h片视频| 日韩美一区二区三区| 国产传媒一区在线| 亚洲免费av高清| 欧美日本一区二区三区四区| 免费高清在线一区| 久久久精品免费网站| 99综合电影在线视频| 亚洲人成网站影音先锋播放| 欧美视频精品在线观看| 美国av一区二区| 国产日产欧美精品一区二区三区| av电影一区二区| 五月天久久比比资源色| 亚洲精品一区二区三区影院| av欧美精品.com| 天天综合色天天综合| 久久久精品蜜桃| 欧美色综合久久| 国产制服丝袜一区| 亚洲卡通动漫在线| 精品欧美一区二区在线观看| 99久久综合99久久综合网站| 日韩精品五月天| 国产精品国产自产拍高清av| 欧美一级国产精品| 色综合久久久久久久| 久久精品国产77777蜜臀| 亚洲另类色综合网站| 久久免费视频色| 欧美日韩精品免费观看视频| 成人国产精品免费观看| 日本色综合中文字幕| 亚洲精品一二三区| 国产日韩欧美精品一区| 4438x亚洲最大成人网| 一本一本大道香蕉久在线精品| 久久精品国产秦先生| 亚洲一区二区四区蜜桃| 国产精品网友自拍| 久久综合九色综合97婷婷女人 | 日韩亚洲欧美一区二区三区| 91美女在线看| 成人激情图片网| 久久69国产一区二区蜜臀| 一二三四社区欧美黄| 国产精品色哟哟网站| 日韩精品在线一区| 欧美一区二视频| 欧美视频在线不卡| 欧洲激情一区二区| 99在线热播精品免费| 成人激情图片网| 国产一区二区三区不卡在线观看| 日本欧美韩国一区三区| 视频精品一区二区| 亚洲一区二区在线观看视频| 中文字幕一区二区视频| 国产精品女同一区二区三区| 久久久精品免费观看| 久久久久久影视| 久久久久久99精品| 欧美激情综合五月色丁香小说| 精品久久久久久无| 亚洲午夜激情av| 一级女性全黄久久生活片免费| 亚洲精品第一国产综合野| 亚洲综合一二区| 洋洋av久久久久久久一区| 一区二区三区中文字幕电影| 一区二区三区四区国产精品| 亚洲最新视频在线观看| 午夜精品福利视频网站| 日日夜夜免费精品视频| 精品一区二区三区视频在线观看 | 亚洲大片免费看| 亚洲高清久久久| 天天影视网天天综合色在线播放| 手机精品视频在线观看| 蜜臀av在线播放一区二区三区| 另类调教123区| 国产一区二区三区蝌蚪| caoporen国产精品视频| 91国产免费看| 欧美一区二区网站| 久久精品亚洲乱码伦伦中文| 国产精品久久影院| 亚洲图片有声小说| 麻豆一区二区在线| 成人黄色av电影| 欧美性色黄大片手机版| 日韩精品一区二区三区三区免费| 久久综合久久综合久久综合| 国产精品久99| 婷婷丁香久久五月婷婷| 国产在线乱码一区二区三区| 97久久人人超碰| 777午夜精品视频在线播放| 久久久夜色精品亚洲| 亚洲图片欧美综合| 国产精品一品视频| 欧美无人高清视频在线观看| 精品三级av在线| 亚洲男同性视频| 国产一区二区伦理片| 欧美亚洲高清一区| 中文字幕精品一区二区三区精品| 亚洲国产视频一区| 成人av一区二区三区| 欧美日韩国产大片| 亚洲三级小视频| 国产黑丝在线一区二区三区| 欧美美女一区二区| 综合久久久久久久|