📄 erddependanciespanel.java
字号:
dependency.setYPosn_1(rec1.y); dependency.setYPosn_2((rec2.y + rec2.height) + ((rec1.y - (rec2.y + rec2.height)) / 2)); dependency.setYPosn_3(rec2.y + rec2.height); } else if ( ( (rec1.y + rec1.height + 20) < rec2.y ) && ( rec1.x < (rec2.x + (rec2.width / 2)) ) ) { dependency.setPosition(ErdTableDependency.POSITION_2); dependency.setXPosn_1(table1.getNextJoin(ErdTable.BOTTOM_JOIN) + rec1.x); dependency.setXPosn_3(table2.getNextJoin(ErdTable.TOP_JOIN) + rec2.x); dependency.setYPosn_1(rec1.y + rec1.height); dependency.setYPosn_2(dependency.getYPosn_1() + ((rec2.y - dependency.getYPosn_1()) / 2)); dependency.setYPosn_3(rec2.y); } else if (rec1.y > rec2.y + (0.75 * rec2.height) + 20) { dependency.setPosition(ErdTableDependency.POSITION_3); dependency.setXPosn_2(table2.getNextJoin(ErdTable.BOTTOM_JOIN) + rec2.x); if (rec1.x > rec2.x) { dependency.setYPosn_1(table1.getNextJoin(ErdTable.LEFT_JOIN) + rec1.y); dependency.setXPosn_1(rec1.x); } else { dependency.setYPosn_1(table1.getNextJoin(ErdTable.RIGHT_JOIN) + rec1.y); dependency.setXPosn_1(rec1.x + rec1.width); } dependency.setYPosn_2(rec2.y + rec2.height); } else if (rec2.y > rec1.y + (0.75 * rec1.height) + 20) { dependency.setPosition(ErdTableDependency.POSITION_4); dependency.setXPosn_1(table1.getNextJoin(ErdTable.BOTTOM_JOIN) + rec1.x); if (rec1.x > rec2.x) { dependency.setYPosn_2(table2.getNextJoin(ErdTable.RIGHT_JOIN) + rec2.y); dependency.setXPosn_2(rec2.x + rec2.width); } else { dependency.setYPosn_2(table2.getNextJoin(ErdTable.LEFT_JOIN) + rec2.y); dependency.setXPosn_2(rec2.x); } dependency.setYPosn_1(rec1.y + rec1.height); } else if (rec2.x < rec1.x) { dependency.setPosition(ErdTableDependency.POSITION_5); dependency.setYPosn_1(table2.getNextJoin(ErdTable.RIGHT_JOIN) + rec2.y); dependency.setYPosn_2(table1.getNextJoin(ErdTable.LEFT_JOIN) + rec1.y); dependency.setXPosn_1(rec2.x + rec2.width); dependency.setXPosn_2(dependency.getXPosn_1() + ((rec1.x - dependency.getXPosn_1()) / 2)); dependency.setXPosn_3(rec1.x); } else { dependency.setPosition(ErdTableDependency.POSITION_6); dependency.setYPosn_2(table1.getNextJoin(ErdTable.RIGHT_JOIN) + rec1.y); dependency.setYPosn_1(table2.getNextJoin(ErdTable.LEFT_JOIN) + rec2.y); dependency.setXPosn_1(rec2.x); dependency.setXPosn_2(rec1.x + rec1.width + ((rec2.x - (rec1.x + rec1.width)) / 2)); dependency.setXPosn_3(rec1.x + rec1.width); dependency.setYPosn_3(rec1.y); } } private void drawLines(Graphics2D g, ErdTableDependency dependency, int xOffset, int yOffset) { int xPosn_1 = dependency.getXPosn_1() + xOffset; int xPosn_2 = dependency.getXPosn_2() + xOffset; int xPosn_3 = dependency.getXPosn_3() + xOffset; int yPosn_1 = dependency.getYPosn_1() + yOffset; int yPosn_2 = dependency.getYPosn_2() + yOffset; int yPosn_3 = dependency.getYPosn_3() + yOffset; if (isDashed) { g.setStroke(dashedStroke); } else { g.setStroke(solidStroke); } if (dependency.getPosition() == ErdTableDependency.POSITION_1) { g.drawLine(xPosn_1, yPosn_1, xPosn_1, yPosn_2); g.drawLine(xPosn_1, yPosn_2, xPosn_3, yPosn_2); g.drawLine(xPosn_3, yPosn_2, xPosn_3, yPosn_3); int[] polyXs = {xPosn_3 + 5, xPosn_3, xPosn_3 - 5}; int[] polyYs = {yPosn_3 + 10, yPosn_3, yPosn_3 + 10}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } else if (dependency.getPosition() == ErdTableDependency.POSITION_2) { g.drawLine(xPosn_1, yPosn_1, xPosn_1, yPosn_2); g.drawLine(xPosn_1, yPosn_2, xPosn_3, yPosn_2); g.drawLine(xPosn_3, yPosn_2, xPosn_3, yPosn_3); int[] polyXs = {xPosn_3 - 5, xPosn_3, xPosn_3 + 5}; int[] polyYs = {yPosn_3 - 10, yPosn_3, yPosn_3 - 10}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } else if (dependency.getPosition() == ErdTableDependency.POSITION_3) { g.drawLine(xPosn_1, yPosn_1, xPosn_2, yPosn_1); g.drawLine(xPosn_2, yPosn_1, xPosn_2, yPosn_2); int[] polyXs = {xPosn_2 + 5, xPosn_2, xPosn_2 - 5}; int[] polyYs = {yPosn_2 + 10, yPosn_2, yPosn_2 + 10}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } else if (dependency.getPosition() == ErdTableDependency.POSITION_4) { Rectangle rec1 = dependency.getTable_1().getBounds(); Rectangle rec2 = dependency.getTable_2().getBounds(); int[] polyXs = new int[3]; if (rec1.x > rec2.x) { polyXs[0] = xPosn_2 + 10; polyXs[2] = xPosn_2 + 10; } else { polyXs[0] = xPosn_2 - 10; polyXs[2] = xPosn_2 - 10; } polyXs[1] = xPosn_2; g.drawLine(xPosn_1, yPosn_1, xPosn_1, yPosn_2); g.drawLine(xPosn_1, yPosn_2, xPosn_2, yPosn_2); int[] polyYs = {yPosn_2 - 5, yPosn_2, yPosn_2 + 5}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } else if (dependency.getPosition() == ErdTableDependency.POSITION_5) { g.drawLine(xPosn_1, yPosn_1, xPosn_2, yPosn_1); g.drawLine(xPosn_2, yPosn_1, xPosn_2, yPosn_2); g.drawLine(xPosn_2, yPosn_2, xPosn_3, yPosn_2); int[] polyXs = {xPosn_1 + 10, xPosn_1, xPosn_1 + 10}; int[] polyYs = {yPosn_1 - 5, yPosn_1, yPosn_1 + 5}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } else if (dependency.getPosition() == ErdTableDependency.POSITION_6) { g.drawLine(xPosn_1, yPosn_1, xPosn_2, yPosn_1); g.drawLine(xPosn_2, yPosn_1, xPosn_2, yPosn_2); g.drawLine(xPosn_2, yPosn_2, xPosn_3, yPosn_2); int[] polyXs = {xPosn_1 - 10, xPosn_1, xPosn_1 - 10}; int[] polyYs = {yPosn_1 - 5, yPosn_1, yPosn_1 + 5}; if (isDashed) g.setStroke(solidStroke); if (filledArrow) g.fillPolygon(polyXs, polyYs, 3); else g.drawPolyline(polyXs, polyYs, 3); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -