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

📄 erddependanciespanel.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ErdDependanciesPanel.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.gui.erd;import java.awt.BasicStroke;import java.awt.Color;import java.awt.Dimension;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Rectangle;import java.awt.RenderingHints;import java.util.Vector;import javax.swing.JComponent;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.4 $ * @date     $Date: 2006/05/14 06:56:52 $ */public class ErdDependanciesPanel extends JComponent {        /** The controller for the ERD viewer */    private ErdViewerPanel parent;    /** The table dependencies to draw */    private ErdTableDependency[] dependencies;        /** The line colour */    private Color lineColour;    /** The dashed stroke */    private static BasicStroke dashedStroke;    /** Solid line stroke */    private static BasicStroke solidStroke;        /** Whether a dashed line stroke is selected */    private boolean isDashed;    /** The line weight */    private float lineWeight;    /** Whether the arrow connection is filled */    private boolean filledArrow;    /** The line style */    private int lineStyle;    /** The colour index */    private int colourIndex;        /** A solid line */    public static final int LINE_STYLE_ONE = 0;    /** Dashed style 1 */    public static final int LINE_STYLE_TWO = 1;    /** Dashed style 2 */    public static final int LINE_STYLE_THREE = 2;        /** <p>Constructs a new instance with the specified     *  <code>ErdViewerPanel</code> as the parent or controller     *  object.     *     *  @param the parent controller object     */    public ErdDependanciesPanel(ErdViewerPanel parent) {        super();                lineColour = Color.BLACK;        colourIndex = 0;        lineStyle = 0;        lineWeight = 1.0f;        isDashed = false;        filledArrow = true;        solidStroke = new BasicStroke(lineWeight);                setDoubleBuffered(true);        this.parent = parent;            }        /** <p>Constructs a new instance with the specified     *  <code>ErdViewerPanel</code> as the parent or controller     *  object.     *     *  @param the parent controller object     */    public ErdDependanciesPanel(ErdViewerPanel parent, Vector t_dependencies) {        this(parent);                if (t_dependencies != null)            setTableDependencies(t_dependencies);            }        public ErdTableDependency[] getTableDependencies() {        return dependencies;    }        public void setArrowStyle(boolean filledArrow) {        this.filledArrow = filledArrow;    }        public int getArrowStyleIndex() {        return filledArrow ? 0 : 1;    }        public void setLineWeight(float lineWeight) {        this.lineWeight = lineWeight;    }        public float getLineWeight() {        return lineWeight;    }        public int getColourIndex() {        return colourIndex;    }        public int getLineStyleIndex() {        return lineStyle;    }        public void setLineStyle(int style) {        lineStyle = style;        solidStroke = new BasicStroke(lineWeight);                switch (style) {            case LINE_STYLE_ONE:                isDashed = false;                break;            case LINE_STYLE_TWO:                isDashed = true;                float dash1[] = {2.0f};                dashedStroke = new BasicStroke(lineWeight, 0, 0, 10f, dash1, 0.0f);                break;            case LINE_STYLE_THREE:                isDashed = true;                float dash2[] = {5f, 2.0f};                dashedStroke = new BasicStroke(lineWeight, 0, 0, 10f, dash2, 0.0f);                break;        }            }        public void setLineColour(Color lineColour) {        this.lineColour = lineColour;    }        public Color getLineColour() {        return lineColour;    }        protected void setTableDependencies(Vector v) {        int v_size = v.size();        dependencies = new ErdTableDependency[v_size];                for (int i = 0; i < v_size; i++) {            dependencies[i] = (ErdTableDependency)v.elementAt(i);        }            }        public Dimension getSize() {        return getPreferredSize();    }        /** <p>Overrides to return <code>false</code>.     *     *  @return <code>false</code>     */    public boolean isOpaque() {        return false;    }        /** <p>Overrides this class's <code>paintComponent</code>     *  method to draw the relationship lines between tables.     *     *  @param the <code>Graphics</code> object     */    protected void paintComponent(Graphics g) {        parent.resetAllTableJoins();        Graphics2D g2d = (Graphics2D)g;        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                RenderingHints.VALUE_ANTIALIAS_ON);        drawDependencies(g2d);    }        protected void drawDependencies(Graphics2D g2d) {        drawDependencies(g2d, 0, 0);    }    protected void drawDependencies(Graphics2D g2d, int xOffset, int yOffset) {                if (dependencies == null) {            return;        }        g2d.setColor(lineColour);                for (int i = 0; i < dependencies.length; i++) {            determinePositions(dependencies[i]);            drawLines(g2d, dependencies[i], xOffset, yOffset);        }    }        private void determinePositions(ErdTableDependency dependency) {                dependency.reset();                ErdTable table1 = dependency.getTable_1();        ErdTable table2 = dependency.getTable_2();                Rectangle rec1 = table1.getBounds();        Rectangle rec2 = table2.getBounds();                if ( ( (rec2.y + rec2.height + 20) < rec1.y ) &&                ( rec2.x < (rec1.x + (rec1.width / 2)) ) ) {                        dependency.setPosition(ErdTableDependency.POSITION_1);                        dependency.setXPosn_3(table2.getNextJoin(ErdTable.BOTTOM_JOIN) + rec2.x);            dependency.setXPosn_1(table1.getNextJoin(ErdTable.TOP_JOIN) + rec1.x);

⌨️ 快捷键说明

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