Skip to content

Commit deb77bd

Browse files
authored
Add files via upload
1 parent 11492cc commit deb77bd

File tree

99 files changed

+100266
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+100266
-0
lines changed

ACLineData.java

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
* Classname : ACLineData
3+
*
4+
* Version information : 1
5+
*
6+
* Date
7+
*
8+
* Description : Contains methods for drawing
9+
* lines for the
10+
* association classes
11+
*/
12+
/******************************
13+
* Copyright (c) 2003,2019 Kevin Lano
14+
* This program and the accompanying materials are made available under the
15+
* terms of the Eclipse Public License 2.0 which is available at
16+
* http://www.eclipse.org/legal/epl-2.0
17+
*
18+
* SPDX-License-Identifier: EPL-2.0
19+
* *****************************/
20+
21+
/* Package: GUI */
22+
23+
import java.awt.*;
24+
import javax.swing.*;
25+
import java.awt.geom.*;
26+
import java.util.Vector;
27+
28+
public class ACLineData extends LineData
29+
{ // coordinates of start and end points of the line
30+
31+
RectData myclass;
32+
33+
final static BasicStroke solid = stroke;
34+
35+
public ACLineData(int xs, int ys, int xe,
36+
int ye, int linecount, int type, RectData rd)
37+
{ super(xs,ys,xe,ye,linecount,type);
38+
myclass = rd;
39+
}
40+
41+
public Object clone()
42+
{ String cnt = label.substring(1,label.length()-1);
43+
int count = 0;
44+
try { count = Integer.parseInt(cnt); }
45+
catch (Exception e)
46+
{ count = 0; }
47+
48+
ACLineData ld =
49+
new ACLineData(xstart, ystart, xend,
50+
yend, count, linetype, myclass);
51+
ld.setTransition(transition);
52+
ld.setFlow(flow);
53+
ld.setModelElement(modelElement);
54+
return ld;
55+
}
56+
57+
private void drawClass(Graphics2D g)
58+
{ // draw dashed line down from midpoint, to a class
59+
int midx = (xstart + xend)/2;
60+
int midy = (ystart + yend)/2;
61+
g.setStroke(dashed);
62+
g.drawLine(midx,midy,midx,midy+25);
63+
g.setStroke(solid);
64+
if (myclass != null)
65+
{ myclass.changePosition(0,0,midx - 10, midy+25);
66+
myclass.drawData(g);
67+
}
68+
}
69+
70+
private void drawClass(Graphics g)
71+
{ // draw dashed line down from midpoint, to a class
72+
int midx = (xstart + xend)/2;
73+
int midy = (ystart + yend)/2;
74+
// g.setStroke(dashed);
75+
g.drawLine(midx,midy,midx,midy+25);
76+
// g.setStroke(solid);
77+
if (myclass != null)
78+
{ myclass.changePosition(0,0,midx - 10, midy+25);
79+
myclass.drawData(g);
80+
}
81+
}
82+
83+
void drawData(Graphics2D g)
84+
{ if (LineLength() > 5)
85+
{ g.setColor(Color.black);
86+
if (linetype == 1)
87+
{ g.setStroke(dashed); }
88+
g.drawLine(xstart,ystart,xend,yend);
89+
g.setStroke(stroke);
90+
g.draw(new Line2D.Double(arrow1x,arrow1y,
91+
(double) xend,(double) yend));
92+
g.draw(new Line2D.Double(arrow2x,arrow2y,
93+
(double) xend,(double) yend));
94+
95+
if (modelElement != null)
96+
{ Association ast = (Association) modelElement;
97+
String role1 = ast.getRole1();
98+
String role2 = ast.getRole2();
99+
boolean ord = ast.isOrdered();
100+
if (ord) { role2 = role2 + " { ordered }"; }
101+
if (ast.isFrozen())
102+
{ role2 = role2 + " { frozen }"; }
103+
else if (ast.isAddOnly())
104+
{ role2 = role2 + " { addOnly }"; } // and derived
105+
if (ast.isDerived())
106+
{ role2 = "/" + role2; }
107+
FontMetrics fm = g.getFontMetrics();
108+
int xoffset = fm.stringWidth(role2);
109+
String c1 =
110+
ModelElement.convertCard(ast.getCard1());
111+
String c2 =
112+
ModelElement.convertCard(ast.getCard2());
113+
if (role1 != null)
114+
{ g.drawString(role1,xstart+5,ystart-5); }
115+
if (role2 != null)
116+
{ g.drawString(role2,(int) role2x - leftright*xoffset,(int) role2y); }
117+
g.drawString(c1,(int) card1x,(int) card1y);
118+
g.drawString(c2,(int) card2x,(int) card2y);
119+
g.drawString(ast.getName(), (int) (xend + xstart)/2,
120+
(int) (yend + ystart)/2);
121+
if (myclass != null)
122+
{ drawClass(g); }
123+
}
124+
}
125+
}
126+
127+
void drawData(Graphics g)
128+
{ if (LineLength() > 5)
129+
{ g.setColor(Color.black);
130+
// if (linetype == 1)
131+
// { g.setStroke(dashed); }
132+
g.drawLine(xstart,ystart,xend,yend);
133+
// g.setStroke(stroke);
134+
g.drawLine((int) arrow1x,(int) arrow1y,xend,yend);
135+
g.drawLine((int) arrow2x,(int) arrow2y,xend,yend);
136+
137+
if (modelElement != null)
138+
{ Association ast = (Association) modelElement;
139+
String role1 = ast.getRole1();
140+
String role2 = ast.getRole2();
141+
if (ast.isOrdered())
142+
{ role2 = role2 + " { ordered }"; }
143+
if (ast.isFrozen())
144+
{ role2 = role2 + " { frozen }"; }
145+
else if (ast.isAddOnly())
146+
{ role2 = role2 + " { addOnly }"; } // and derived
147+
String c1 =
148+
ModelElement.convertCard(ast.getCard1());
149+
String c2 =
150+
ModelElement.convertCard(ast.getCard2());
151+
if (role1 != null)
152+
{ g.drawString(role1,xstart+5,ystart-5); }
153+
if (role2 != null)
154+
{ g.drawString(role2,(int) role2x,(int) role2y); }
155+
g.drawString(c1,xstart+5,ystart+8);
156+
g.drawString(c2,(int) card2x,(int) card2y);
157+
if (myclass != null)
158+
{ drawClass(g); }
159+
}
160+
}
161+
}
162+
}
163+
164+

0 commit comments

Comments
 (0)