Skip to content
Snippets Groups Projects
Commit d32e1382 authored by Irina LEE's avatar Irina LEE
Browse files

add condition to connector (eln)

parent d71a0a3a
No related branches found
No related tags found
1 merge request!72Syscams
...@@ -45,6 +45,7 @@ import ui.window.JDialogELNConnector; ...@@ -45,6 +45,7 @@ import ui.window.JDialogELNConnector;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.*;
import javax.swing.JFrame; import javax.swing.JFrame;
import myutil.GraphicLib;
/** /**
* Class ELNConnector * Class ELNConnector
...@@ -83,50 +84,117 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { ...@@ -83,50 +84,117 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent {
return true; return true;
} }
protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { protected void drawLastSegment(Graphics gr, int x1, int y1, int x2, int y2) {
Graphics2D g = (Graphics2D) gr;
int w = g.getFontMetrics().stringWidth(value); int w = g.getFontMetrics().stringWidth(value);
Font fold = g.getFont(); Font fold = g.getFont();
Font f = fold.deriveFont(Font.ITALIC, (float) (tdp.getFontSize())); Font f = fold.deriveFont(Font.ITALIC, (float) (tdp.getFontSize()));
g.setFont(f); g.setFont(f);
if (get_p1().getFather() instanceof ELNComponent) {
if (get_p2().getFather() instanceof ELNComponent) { ELNConnectingPoint pt1 = (ELNConnectingPoint) p1;
editable = true; ELNConnectingPoint pt2 = (ELNConnectingPoint) p2;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
if (pt1.getFather() instanceof ELNComponent && pt2.getFather() instanceof ELNComponent) {
g.drawLine(x1, y1, x2, y2);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt1.getFather() instanceof ELNComponent && pt2.getFather() instanceof ELNMidPortTerminal) {
ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) pt2.getFather()).getFather();
g.drawLine(x1, y1, x2, y2);
if (connector.getValue().equals("")) {
value = searchName(connector);
} }
if (get_p2().getFather() instanceof ELNMidPortTerminal) { } else if (pt1.getFather() instanceof ELNMidPortTerminal && pt2.getFather() instanceof ELNComponent) {
ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) get_p2().getFather()).getFather(); g.drawLine(x1, y1, x2, y2);
if (!connector.getValue().equals("")) { ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) pt1.getFather()).getFather();
value = connector.getValue(); if (connector.getValue().equals("")) {
} else { value = searchName(connector);
value = searchName(connector);
}
} }
} } else if (pt1.getFather() instanceof ELNModuleTerminal && pt2.getFather() instanceof ELNModuleTerminal) {
if (get_p1().getFather() instanceof ELNMidPortTerminal) { String name1 = ((ELNModuleTerminal) pt1.getFather()).getValue();
if (get_p2().getFather() instanceof ELNComponent) { String name2 = ((ELNModuleTerminal) pt2.getFather()).getValue();
ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) get_p1().getFather()).getFather(); if (name1.equals(name2)) {
if (!connector.getValue().equals("")) { value = name1;
value = connector.getValue(); }
} else { g.drawLine(x1, y1, x2, y2);
value = searchName(connector); editable = true;
} g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt1.getFather() instanceof ELNModuleTerminal && pt2.getFather() instanceof ELNClusterTerminal) {
String name1 = ((ELNModuleTerminal) pt1.getFather()).getValue();
String name2 = ((ELNClusterTerminal) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
}
g.drawLine(x1, y1, x2, y2);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt2.getFather() instanceof ELNModuleTerminal && pt1.getFather() instanceof ELNClusterTerminal) {
String name1 = ((ELNClusterTerminal) pt1.getFather()).getValue();
String name2 = ((ELNModuleTerminal) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
}
g.drawLine(x1, y1, x2, y2);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt1.getFather() instanceof ELNModulePortDE && pt2.getFather() instanceof ELNClusterPortDE) {
String name1 = ((ELNModulePortDE) pt1.getFather()).getValue();
String name2 = ((ELNClusterPortDE) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
}
Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0);
g.setStroke(dashed);
GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt2.getFather() instanceof ELNModulePortDE && pt1.getFather() instanceof ELNClusterPortDE) {
String name1 = ((ELNClusterPortDE) pt1.getFather()).getValue();
String name2 = ((ELNModulePortDE) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
} }
Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0);
g.setStroke(dashed);
GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt1.getFather() instanceof ELNModulePortTDF && pt2.getFather() instanceof ELNClusterPortTDF) {
String name1 = ((ELNModulePortTDF) pt1.getFather()).getValue();
String name2 = ((ELNClusterPortTDF) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
}
GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else if (pt2.getFather() instanceof ELNModulePortTDF && pt1.getFather() instanceof ELNClusterPortTDF) {
String name1 = ((ELNClusterPortTDF) pt1.getFather()).getValue();
String name2 = ((ELNModulePortTDF) pt2.getFather()).getValue();
if (name1.equals(name2)) {
value = name1;
}
GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true);
editable = true;
g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2);
} else {
g.drawLine(x1, y1, x2, y2);
} }
g.setFont(fold); g.setFont(fold);
g.drawLine(x1, y1, x2, y2);
} }
private String searchName(ELNConnector c) { private String searchName(ELNConnector c) {
if (c.get_p1().getFather() instanceof ELNComponent) { if (c.p1.getFather() instanceof ELNComponent) {
if (c.get_p2().getFather() instanceof ELNComponent) { if (c.p2.getFather() instanceof ELNComponent) {
return c.getValue(); return c.getValue();
} }
if (c.get_p2().getFather() instanceof ELNComponentNodeRef || c.get_p2().getFather() instanceof ELNModuleTerminalInout) { if (c.p2.getFather() instanceof ELNComponentNodeRef || c.p2.getFather() instanceof ELNModuleTerminal) {
return ""; return "";
} }
if (c.get_p2().getFather() instanceof ELNMidPortTerminal) { if (c.p2.getFather() instanceof ELNMidPortTerminal) {
ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) c.get_p2().getFather()).getFather(); ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) c.p2.getFather()).getFather();
if (!connector.getValue().equals("")) { if (!connector.getValue().equals("")) {
return connector.getValue(); return connector.getValue();
} else { } else {
...@@ -134,15 +202,15 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent { ...@@ -134,15 +202,15 @@ public class ELNConnector extends TGConnector implements ScalableTGComponent {
} }
} }
} }
if (c.get_p1().getFather() instanceof ELNComponentNodeRef || c.get_p1().getFather() instanceof ELNModuleTerminalInout) { if (c.p1.getFather() instanceof ELNComponentNodeRef || c.p1.getFather() instanceof ELNModuleTerminal) {
return ""; return "";
} }
if (c.get_p1().getFather() instanceof ELNMidPortTerminal) { if (c.p1.getFather() instanceof ELNMidPortTerminal) {
if (c.get_p2().getFather() instanceof ELNComponentNodeRef || c.get_p2().getFather() instanceof ELNModuleTerminalInout) { if (c.p2.getFather() instanceof ELNComponentNodeRef || c.p2.getFather() instanceof ELNModuleTerminal) {
return ""; return "";
} }
if (c.get_p2().getFather() instanceof ELNComponent) { if (c.p2.getFather() instanceof ELNComponent) {
ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) c.get_p1().getFather()).getFather(); ELNConnector connector = (ELNConnector) ((ELNMidPortTerminal) c.p1.getFather()).getFather();
if (!connector.getValue().equals("")) { if (!connector.getValue().equals("")) {
return connector.getValue(); return connector.getValue();
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment