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
002f1824
Commit
002f1824
authored
6 years ago
by
Ludovic Apvrille
Browse files
Options
Downloads
Patches
Plain Diff
Update on zoom aspects
parent
4f3cfc40
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/TGCScalableWithInternalComponent.java
+14
-0
14 additions, 0 deletions
src/main/java/ui/TGCScalableWithInternalComponent.java
ttool/src/test/java/ui/TestTDiagramPanel.java
+78
-81
78 additions, 81 deletions
ttool/src/test/java/ui/TestTDiagramPanel.java
with
92 additions
and
81 deletions
src/main/java/ui/TGCScalableWithInternalComponent.java
+
14
−
0
View file @
002f1824
...
...
@@ -98,6 +98,13 @@ public abstract class TGCScalableWithInternalComponent extends TGCWithInternalCo
maxX
*=
factor
;
maxY
*=
factor
;
if
(
father
==
null
)
{
minX
=
tdp
.
getMinX
();
maxX
=
tdp
.
getMaxX
();
minY
=
tdp
.
getMinY
();
maxY
=
tdp
.
getMinY
();
}
//TraceManager.addDev("x=" + x + " y=" + y + " width=" + width + " height=" + height);
oldScaleFactor
=
scaleFactor
;
...
...
@@ -143,6 +150,13 @@ public abstract class TGCScalableWithInternalComponent extends TGCWithInternalCo
dMaxWidth
=
dMaxWidth
-
maxWidth
;
dMaxHeight
=
dMaxHeight
-
maxHeight
;
if
(
father
==
null
)
{
minX
=
tdp
.
getMinX
();
maxX
=
tdp
.
getMaxX
();
minY
=
tdp
.
getMinY
();
maxY
=
tdp
.
getMinY
();
}
rescaled
=
true
;
}
}
This diff is collapsed.
Click to expand it.
ttool/src/test/java/ui/TestTDiagramPanel.java
+
78
−
81
View file @
002f1824
package
ui
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.awt.Point
;
import
org.junit.Before
;
import
org.junit.Test
;
import
ui.avatarad.AvatarADStopState
;
import
ui.tmlcompd.TMLCCompositeComponent
;
import
ui.tmldd.TMLArchiDiagramPanel
;
import
ui.tmldd.TMLArchiDiagramToolBar
;
import
java.awt.*
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestTDiagramPanel
extends
AbstractUITest
{
static
TDiagramPanel
diagramPanel
;
static
TGCScalableWithoutInternalComponent
atomicComponent
;
static
TGCScalableWithInternalComponent
compositeComponent
;
static
TDiagramPanel
diagramPanel
;
static
TGCScalableWithoutInternalComponent
atomicComponent
;
static
TGCScalableWithInternalComponent
compositeComponent
;
public
TestTDiagramPanel
()
{
super
();
}
public
TestTDiagramPanel
()
{
super
();
}
@Before
public
void
setUp
()
throws
Exception
{
final
TToolBar
toolBar
=
new
TMLArchiDiagramToolBar
(
mainGUI
);
diagramPanel
=
new
TMLArchiDiagramPanel
(
mainGUI
,
toolBar
);
atomicComponent
=
new
AvatarADStopState
(
500
,
500
,
0
,
1400
,
0
,
1900
,
true
,
null
,
diagramPanel
);
diagramPanel
.
addBuiltComponent
(
atomicComponent
);
@Before
public
void
setUp
()
throws
Exception
{
final
TToolBar
toolBar
=
new
TMLArchiDiagramToolBar
(
mainGUI
);
diagramPanel
=
new
TMLArchiDiagramPanel
(
mainGUI
,
toolBar
);
atomicComponent
=
new
AvatarADStopState
(
500
,
500
,
0
,
1400
,
0
,
1900
,
true
,
null
,
diagramPanel
);
diagramPanel
.
addBuiltComponent
(
atomicComponent
);
compositeComponent
=
new
TMLCCompositeComponent
(
500
,
500
,
0
,
1400
,
0
,
1900
,
true
,
null
,
diagramPanel
);
diagramPanel
.
addBuiltComponent
(
compositeComponent
);
compositeComponent
=
new
TMLCCompositeComponent
(
500
,
500
,
0
,
1400
,
0
,
1900
,
true
,
null
,
diagramPanel
);
diagramPanel
.
addBuiltComponent
(
compositeComponent
);
diagramPanel
.
setComponentPointed
(
null
);
}
diagramPanel
.
setComponentPointed
(
null
);
}
@Test
public
void
testMoveUp
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
(),
atomicComponent
.
getY
()
-
TDiagramPanel
.
MOVE_SPEED
);
@Test
public
void
testMoveUp
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
(),
atomicComponent
.
getY
()
-
TDiagramPanel
.
MOVE_SPEED
);
diagramPanel
.
upComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
upComponent
();
diagramPanel
.
upComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
upComponent
();
checkResults
(
expectedPos
,
atomicComponent
);
checkResults
(
expectedPos
,
atomicComponent
);
// assertTrue(atomicComponent.getY() == 499);
// assertTrue(atomicComponent.getX() == 500);
}
}
@Test
public
void
testMoveDown
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
(),
atomicComponent
.
getY
()
+
TDiagramPanel
.
MOVE_SPEED
);
@Test
public
void
testMoveDown
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
(),
atomicComponent
.
getY
()
+
TDiagramPanel
.
MOVE_SPEED
);
diagramPanel
.
downComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
downComponent
();
diagramPanel
.
downComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
downComponent
();
checkResults
(
expectedPos
,
atomicComponent
);
checkResults
(
expectedPos
,
atomicComponent
);
// assertTrue(atomicComponent.getY() == 501);
// assertTrue(atomicComponent.getX() == 500);
}
}
@Test
public
void
testMoveRight
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
()
+
TDiagramPanel
.
MOVE_SPEED
,
atomicComponent
.
getY
()
);
@Test
public
void
testMoveRight
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
()
+
TDiagramPanel
.
MOVE_SPEED
,
atomicComponent
.
getY
());
diagramPanel
.
rightComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
rightComponent
();
diagramPanel
.
rightComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
rightComponent
();
checkResults
(
expectedPos
,
atomicComponent
);
checkResults
(
expectedPos
,
atomicComponent
);
// assertTrue(atomicComponent.getX() == 501);
// assertTrue(atomicComponent.getY() == 500);
}
}
@Test
public
void
testMoveLeft
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
()
-
TDiagramPanel
.
MOVE_SPEED
,
atomicComponent
.
getY
()
);
diagramPanel
.
leftComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
leftComponent
();
@Test
public
void
testMoveLeft
()
{
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
()
-
TDiagramPanel
.
MOVE_SPEED
,
atomicComponent
.
getY
());
checkResults
(
expectedPos
,
atomicComponent
);
diagramPanel
.
leftComponent
();
diagramPanel
.
setComponentPointed
(
atomicComponent
);
diagramPanel
.
leftComponent
();
checkResults
(
expectedPos
,
atomicComponent
);
// assertTrue(atomicComponent.getX() == 499);
// assertTrue(atomicComponent.getY() == 500);
}
}
/**
* Issue #81
*/
/*@Test
public void testMoveAtomicComponentAfterZoom() {
diagramPanel.setZoom(3.0);
/**
* Issue #81
*/
@Test
public
void
testMoveAtomicComponentAfterZoom
()
{
diagramPanel
.
setZoom
(
3.0
);
diagramPanel.setComponentPointed(atomicComponent);
diagramPanel
.
setComponentPointed
(
atomicComponent
);
final Point expectedPos = new Point(atomicComponent.getX() + TDiagramPanel.MOVE_SPEED,
atomicComponent
.getY()
);
final
Point
expectedPos
=
new
Point
(
atomicComponent
.
getX
()
+
TDiagramPanel
.
MOVE_SPEED
,
atomic
Component
.
getY
()
);
diagramPanel.right
Component
(
);
diagramPanel
.
rightComponent
();
checkResults(expectedPos, atomicComponent);
}*/
checkResults
(
expectedPos
,
atomicComponent
);
}
/**
* Issue #81
*/
@Test
public
void
testMoveCompositeComponentAfterZoom
()
{
diagramPanel
.
setZoom
(
3.0
);
/*
@Test
public void testMoveCompositeComponentAfterZoom() {
diagramPanel.setZoom(3.0);
diagramPanel
.
setComponentPointed
(
compositeComponent
);
diagramPanel.setComponentPointed(compositeComponent);
final
Point
expectedPos
=
new
Point
(
compositeComponent
.
getX
()
+
TDiagramPanel
.
MOVE_SPEED
,
compositeComponent
.
getY
()
);
final Point expectedPos = new Point(compositeComponent.getX() + TDiagramPanel.MOVE_SPEED, compositeComponent.getY());
diagramPanel
.
rightComponent
();
diagramPanel.rightComponent();
checkResults
(
expectedPos
,
compositeComponent
);
}
checkResults(expectedPos, compositeComponent);
} */
private
void
checkResults
(
final
Point
expectedPos
,
final
TGComponent
component
)
{
assertTrue
(
"X position is "
+
component
.
getX
()
+
" instead of "
+
expectedPos
.
x
+
"."
,
component
.
getX
()
==
expectedPos
.
x
);
assertTrue
(
"Y position is "
+
component
.
getY
()
+
" instead of "
+
expectedPos
.
y
+
"."
,
component
.
getY
()
==
expectedPos
.
y
);
}
private
void
checkResults
(
final
Point
expectedPos
,
final
TGComponent
component
)
{
assertTrue
(
"X position is "
+
component
.
getX
()
+
" instead of "
+
expectedPos
.
x
+
"."
,
component
.
getX
()
==
expectedPos
.
x
);
assertTrue
(
"Y position is "
+
component
.
getY
()
+
" instead of "
+
expectedPos
.
y
+
"."
,
component
.
getY
()
==
expectedPos
.
y
);
}
}
This diff is collapsed.
Click to expand it.
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