Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
d1522956
Commit
d1522956
authored
4 years ago
by
Ludovic Apvrille
Browse files
Options
Downloads
Patches
Plain Diff
Adding multiplicities
parent
3f0044cf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/ui/TGConnectorWithMultiplicity.java
+40
-2
40 additions, 2 deletions
src/main/java/ui/TGConnectorWithMultiplicity.java
src/main/java/ui/avatarcd/AvatarCDBlock.java
+2
-2
2 additions, 2 deletions
src/main/java/ui/avatarcd/AvatarCDBlock.java
with
42 additions
and
4 deletions
src/main/java/ui/TGConnectorWithMultiplicity.java
+
40
−
2
View file @
d1522956
...
@@ -60,6 +60,11 @@ import java.util.Vector;
...
@@ -60,6 +60,11 @@ import java.util.Vector;
* @author Ludovic APVRILLE
* @author Ludovic APVRILLE
*/
*/
public
abstract
class
TGConnectorWithMultiplicity
extends
TGConnectorWithCommentConnectionPoints
{
public
abstract
class
TGConnectorWithMultiplicity
extends
TGConnectorWithCommentConnectionPoints
{
public
final
static
int
MULTIPLICITY_X
=
5
;
public
final
static
int
MULTIPLICITY_Y
=
5
;
protected
String
originMultiplicity
,
destinationMultiplicity
;
protected
String
originMultiplicity
,
destinationMultiplicity
;
public
TGConnectorWithMultiplicity
(
int
_x
,
int
_y
,
int
_minX
,
int
_minY
,
int
_maxX
,
int
_maxY
,
boolean
_pos
,
TGComponent
_father
,
TDiagramPanel
_tdp
,
TGConnectingPoint
_p1
,
TGConnectingPoint
_p2
,
Vector
<
Point
>
_listPoint
)
{
public
TGConnectorWithMultiplicity
(
int
_x
,
int
_y
,
int
_minX
,
int
_minY
,
int
_maxX
,
int
_maxY
,
boolean
_pos
,
TGComponent
_father
,
TDiagramPanel
_tdp
,
TGConnectingPoint
_p1
,
TGConnectingPoint
_p2
,
Vector
<
Point
>
_listPoint
)
{
...
@@ -85,13 +90,16 @@ public abstract class TGConnectorWithMultiplicity extends TGConnectorWithComment
...
@@ -85,13 +90,16 @@ public abstract class TGConnectorWithMultiplicity extends TGConnectorWithComment
@Override
@Override
public
boolean
editOndoubleClick
(
JFrame
frame
)
{
public
boolean
editOndoubleClick
(
JFrame
frame
)
{
String
[]
labels
=
{
"origin"
,
"destination"
}
;
String
[]
labels
=
new
String
[
2
]
;
String
[]
values
=
new
String
[
2
];
String
[]
values
=
new
String
[
2
];
labels
[
0
]
=
"origin ("
+
getTGComponent1
().
getName
()
+
")"
;
labels
[
1
]
=
"destination ("
+
getTGComponent2
().
getName
()
+
")"
;
values
[
0
]
=
originMultiplicity
;
values
[
0
]
=
originMultiplicity
;
values
[
1
]
=
destinationMultiplicity
;
values
[
1
]
=
destinationMultiplicity
;
JDialogMultiString
jdms
=
new
JDialogMultiString
(
frame
,
"Multiplicity"
,
2
,
labels
,
values
);
JDialogMultiString
jdms
=
new
JDialogMultiString
(
frame
,
"Multiplicity"
,
2
,
labels
,
values
);
GraphicLib
.
centerOnParent
(
jdms
,
5
00
,
3
00
);
GraphicLib
.
centerOnParent
(
jdms
,
3
00
,
2
00
);
jdms
.
setVisible
(
true
);
// blocked until dialog has been closed
jdms
.
setVisible
(
true
);
// blocked until dialog has been closed
if
(
jdms
.
hasBeenSet
())
{
if
(
jdms
.
hasBeenSet
())
{
...
@@ -145,4 +153,34 @@ public abstract class TGConnectorWithMultiplicity extends TGConnectorWithComment
...
@@ -145,4 +153,34 @@ public abstract class TGConnectorWithMultiplicity extends TGConnectorWithComment
}
}
}
}
protected
void
internalDrawing
(
Graphics
g
)
{
super
.
internalDrawing
(
g
);
int
length
=
g
.
getFontMetrics
().
stringWidth
(
originMultiplicity
);
int
modifierX
=
getModifierX
(
getTGComponent1
(),
getTGConnectingPointP1
(),
length
);
int
modifierY
=
getModifierY
(
getTGComponent1
(),
getTGConnectingPointP1
(),
g
.
getFont
().
getSize
());
g
.
drawString
(
originMultiplicity
,
getTGConnectingPointP1
().
getX
()
+
modifierX
,
getTGConnectingPointP1
().
getY
()
+
modifierY
);
length
=
g
.
getFontMetrics
().
stringWidth
(
destinationMultiplicity
);
modifierX
=
getModifierX
(
getTGComponent2
(),
getTGConnectingPointP2
(),
length
);
modifierY
=
getModifierY
(
getTGComponent2
(),
getTGConnectingPointP2
(),
g
.
getFont
().
getSize
());
g
.
drawString
(
destinationMultiplicity
,
getTGConnectingPointP2
().
getX
()
+
modifierX
,
getTGConnectingPointP2
().
getY
()
+
modifierY
);
}
protected
int
getModifierX
(
TGComponent
tgc
,
TGConnectingPoint
p
,
int
length
)
{
if
(
p
.
getX
()
<=
tgc
.
getX
()+
width
/
2
)
{
return
-
MULTIPLICITY_X
-
length
;
}
return
MULTIPLICITY_X
;
}
protected
int
getModifierY
(
TGComponent
tgc
,
TGConnectingPoint
p
,
int
fontSize
)
{
if
(
p
.
getY
()
<=
tgc
.
getY
()+
height
/
2
)
{
return
-
MULTIPLICITY_Y
-
fontSize
;
}
return
MULTIPLICITY_Y
+
fontSize
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/ui/avatarcd/AvatarCDBlock.java
+
2
−
2
View file @
d1522956
...
@@ -161,7 +161,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S
...
@@ -161,7 +161,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S
Font
f
=
g
.
getFont
();
Font
f
=
g
.
getFont
();
int
currentHeight
=
f
.
getSize
()
*
2
;
int
currentHeight
=
f
.
getSize
()
*
2
;
g
.
setColor
(
new
Color
(
avat
.
getRed
(),
avat
.
getGreen
(),
Math
.
min
(
255
,
avat
.
getBlue
()
+
(
getMyDepth
()
*
10
))));
g
.
setColor
(
new
Color
(
avat
.
getRed
(),
avat
.
getGreen
(),
Math
.
min
(
255
,
avat
.
getBlue
()
+
(
getMyDepth
()
*
10
))));
g
.
fill3DRect
(
x
+
1
,
y
+
1
,
width
-
1
,
Math
.
min
(
currentHeight
,
height
)
-
1
,
true
);
g
.
fill3DRect
(
x
+
1
,
y
+
1
,
width
-
1
,
Math
.
min
(
currentHeight
,
height
),
true
);
g
.
setColor
(
c
);
g
.
setColor
(
c
);
//Strings
//Strings
...
@@ -180,7 +180,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S
...
@@ -180,7 +180,7 @@ public class AvatarCDBlock extends TGCScalableWithInternalComponent implements S
if
(
currentHeight
<
height
)
{
if
(
currentHeight
<
height
)
{
//g.drawLine(x, y+h, x+width, y+h);
//g.drawLine(x, y+h, x+width, y+h);
g
.
setColor
(
new
Color
(
avat
.
getRed
(),
avat
.
getGreen
(),
Math
.
min
(
255
,
avat
.
getBlue
()
+
(
getMyDepth
()
*
10
))));
g
.
setColor
(
new
Color
(
avat
.
getRed
(),
avat
.
getGreen
(),
Math
.
min
(
255
,
avat
.
getBlue
()
+
(
getMyDepth
()
*
10
))));
g
.
fill3DRect
(
x
+
1
,
y
+
currentHeight
+
2
,
width
-
1
,
height
-
1
-
currentHeight
,
true
);
g
.
fill3DRect
(
x
+
1
,
y
+
currentHeight
+
1
,
width
-
1
,
height
-
1
-
currentHeight
,
true
);
g
.
setColor
(
c
);
g
.
setColor
(
c
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Ludovic Apvrille
@ludovic.apvrille
mentioned in issue
#284 (closed)
·
4 years ago
mentioned in issue
#284 (closed)
mentioned in issue #284
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment