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

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

?? graphpaperlayout.java

?? Java樣例程序集合:2D
?? JAVA
字號:
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 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();    }    /**     * @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 = (Rectangle)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 = (Rectangle)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一区二区三区免费野_久草精品视频
亚洲一区二区三区自拍| 狠狠色综合日日| 精品一区二区三区香蕉蜜桃| 高清日韩电视剧大全免费| 欧美亚洲动漫精品| 欧美国产日产图区| 麻豆91精品视频| 欧美日韩一区成人| 中文字幕综合网| 精品一区二区精品| 欧美美女直播网站| 亚洲蜜臀av乱码久久精品| 久久精品国内一区二区三区 | 最新不卡av在线| 精品午夜久久福利影院| 欧美日韩国产片| 久久久久久久久久久久电影 | 亚洲一区二区三区四区五区黄| 精彩视频一区二区三区| 欧美日韩免费在线视频| 一区二区三区中文字幕电影| 懂色av中文字幕一区二区三区| 久久这里只有精品视频网| 日韩二区在线观看| 在线播放亚洲一区| 高清不卡一二三区| 日韩精品一区二区三区swag| 日韩高清在线电影| 91 com成人网| 日韩国产高清在线| 91精品国产麻豆| 日韩av电影天堂| 7777精品久久久大香线蕉| 天堂久久一区二区三区| 欧美裸体一区二区三区| 秋霞午夜av一区二区三区| 9191久久久久久久久久久| 日韩高清在线一区| 精品三级av在线| 狠狠色狠狠色综合系列| 国产视频亚洲色图| 成人国产精品免费观看动漫| 国产精品久久久久久妇女6080| a在线播放不卡| 一区二区三区日韩欧美| 欧美日韩欧美一区二区| 免费在线观看一区二区三区| 精品国产1区2区3区| 国产主播一区二区三区| 国产精品欧美极品| 色综合久久88色综合天天6 | 中文字幕成人网| 色哟哟一区二区三区| 亚洲1区2区3区视频| 日韩欧美一级特黄在线播放| 国产盗摄精品一区二区三区在线| 国产三级欧美三级| 色婷婷综合中文久久一本| 亚洲mv在线观看| 欧美不卡视频一区| 99精品视频在线免费观看| 国产精品―色哟哟| 免费一级欧美片在线观看| 精品国产欧美一区二区| 成人av电影免费观看| 亚洲chinese男男1069| 精品国产1区2区3区| 色88888久久久久久影院野外| 亚洲第一成人在线| 久久夜色精品一区| 色吧成人激情小说| 精品一区二区三区免费| 亚洲欧美日韩久久精品| 精品日韩av一区二区| 99久久国产综合色|国产精品| 日韩国产欧美在线观看| 亚洲天堂网中文字| 精品国产乱码久久久久久久久| 99久久国产免费看| 国产一区二区三区在线观看免费 | 亚洲第一在线综合网站| 国产亚洲精品福利| 亚洲自拍偷拍九九九| 在线观看免费成人| 蜜桃av一区二区| 亚洲视频在线一区| 国产精品成人一区二区三区夜夜夜| 欧美精品粉嫩高潮一区二区| 粉嫩蜜臀av国产精品网站| 日韩av成人高清| 亚洲一区二区视频在线观看| 国产精品久久久久婷婷二区次| 337p亚洲精品色噜噜| 91欧美一区二区| 国产伦精品一区二区三区免费| 午夜av区久久| 一区二区三区**美女毛片| 国产精品丝袜在线| 久久美女艺术照精彩视频福利播放| 欧美午夜一区二区| 色婷婷久久久亚洲一区二区三区| 国产露脸91国语对白| 毛片一区二区三区| 日韩视频免费直播| 欧美性一二三区| 色狠狠色噜噜噜综合网| 色偷偷久久一区二区三区| 高清不卡在线观看| 成人av中文字幕| 本田岬高潮一区二区三区| 成人免费毛片片v| 国产精品一区免费在线观看| 亚洲一区二区三区四区五区黄| 一区二区三区四区精品在线视频| 亚洲人成网站色在线观看| 中文字幕一区二区视频| 国产精品国产三级国产aⅴ中文| 久久精品人人爽人人爽| 国产偷国产偷亚洲高清人白洁| 久久久久国产免费免费 | 亚洲bdsm女犯bdsm网站| 亚洲第一福利视频在线| 日韩主播视频在线| 奇米888四色在线精品| 日本亚洲一区二区| 狠狠色丁香久久婷婷综合丁香| 国产在线播放一区三区四| 欧美精品乱人伦久久久久久| 国产成人av福利| 成人午夜看片网址| 白白色 亚洲乱淫| 色呦呦国产精品| 欧美日韩一级大片网址| 91精品国产综合久久精品性色| 欧美日韩精品久久久| 91精品国产麻豆国产自产在线| 欧美一区二区三区视频免费播放| 欧美一区二区三区思思人| 精品粉嫩超白一线天av| 中文字幕中文字幕在线一区 | 亚洲丰满少妇videoshd| 免费一级片91| 丁香啪啪综合成人亚洲小说| 99精品欧美一区二区三区小说 | 成人av影院在线| 色狠狠色噜噜噜综合网| 日韩欧美国产综合| 成人免费一区二区三区在线观看| 一区二区三区精品视频| 蜜臀av国产精品久久久久| 国产**成人网毛片九色| 欧美日韩亚洲综合在线 | 国产精品丝袜一区| 亚洲成av人片在www色猫咪| 国产精品亚洲一区二区三区妖精 | 欧美精品一二三区| 国产日产精品1区| 日韩激情视频在线观看| 国产91精品一区二区麻豆亚洲| 欧美在线免费视屏| 久久九九久精品国产免费直播| 怡红院av一区二区三区| 国产一区二区三区在线观看免费视频 | 日韩欧美的一区二区| 1000部国产精品成人观看| 日本成人在线不卡视频| 色综合久久天天综合网| 久久婷婷一区二区三区| 亚洲高清中文字幕| 99精品视频中文字幕| 久久久久久免费网| 蜜臀久久99精品久久久画质超高清 | 国产亚洲欧美一级| 亚洲综合男人的天堂| 国产精品99久久久| 制服丝袜在线91| 伊人性伊人情综合网| 国产成人av资源| 欧美日韩美女一区二区| 中文字幕一区二区三区精华液| 国产主播一区二区三区| 制服丝袜av成人在线看| 亚洲蜜臀av乱码久久精品| 国产aⅴ综合色| 精品区一区二区| 日韩和欧美的一区| 欧美色图免费看| 亚洲精品第1页| 99re这里只有精品首页| 国产欧美一区二区精品婷婷 | 亚洲精品免费在线播放| 成人app网站| 国产精品理论片在线观看| 国产一区欧美日韩| www亚洲一区| 夜夜精品视频一区二区| 狠狠色丁香久久婷婷综| 欧美精品在线观看播放| 亚洲成人动漫在线免费观看| 在线视频你懂得一区二区三区|