Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
c566368f
Commit
c566368f
authored
Aug 13, 2020
by
Piotr Gawron
Browse files
Merge branch '1350-catalist-point-invalid' into 'devel_15.0.x'
closest point to line was inproperly computed See merge request
!1233
parents
17c0ad8b
35e4ddd4
Pipeline
#31068
passed with stage
in 19 minutes and 54 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
c566368f
...
...
@@ -14,6 +14,8 @@ minerva (15.0.3) stable; urgency=medium
another
tab
there
was
an
error
thrown
(#
1343
)
*
Bug
fix
:
chebi
and
entrez
annotations
were
incorrectly
exported
to
GPML
(#
1349
)
*
Bug
fix
:
exporting
to
GPML
sometimes
resulted
in
invalid
modification
point
end
for
catalysis
(#
1350
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Wed
,
8
Jul
2020
16
:
00
:
00
+
0200
...
...
pathvisio/src/main/java/lcsb/mapviewer/wikipathway/utils/Geo.java
View file @
c566368f
...
...
@@ -123,24 +123,35 @@ public final class Geo {
* @return point on line that is as close as possible to point
*/
public
static
Point2D
closestPointOnPolyline
(
PolylineData
mainLine
,
Point2D
point
)
{
Point2D
res
=
null
;
double
distance
=
distanceOnPolyline
(
mainLine
,
point
);
double
lenght
=
0.0
;
Point2D
res
=
mainLine
.
getBeginPoint
();
for
(
Line2D
line
:
mainLine
.
getLines
())
{
lenght
+=
lineLen
(
line
);
}
lenght
*=
distance
;
for
(
Line2D
line
:
mainLine
.
getLines
())
{
if
(
lenght
-
lineLen
(
line
)
>
0
)
{
lenght
-=
lineLen
(
line
);
}
else
{
double
tmp
=
lenght
/
lineLen
(
line
);
double
x
=
line
.
getX1
()
+
tmp
*
(
line
.
getX2
()
-
line
.
getX1
());
double
y
=
line
.
getY1
()
+
tmp
*
(
line
.
getY2
()
-
line
.
getY1
());
res
=
new
Point2D
.
Double
(
x
,
y
);
Point2D
newPoint
=
getClosestPointOnSegment
(
line
,
point
);
if
(
res
.
distanceSq
(
point
)
>
newPoint
.
distanceSq
(
point
))
{
res
=
newPoint
;
}
}
return
res
;
}
static
Point2D
getClosestPointOnSegment
(
Line2D
line
,
Point2D
point
)
{
double
xDelta
=
line
.
getX2
()
-
line
.
getX1
();
double
yDelta
=
line
.
getY2
()
-
line
.
getY1
();
if
((
xDelta
==
0
)
&&
(
yDelta
==
0
))
{
return
new
Point2D
.
Double
(
line
.
getX1
(),
line
.
getY1
());
}
double
u
=
((
point
.
getX
()
-
line
.
getX1
())
*
xDelta
+
(
point
.
getY
()
-
line
.
getY1
())
*
yDelta
)
/
(
xDelta
*
xDelta
+
yDelta
*
yDelta
);
if
(
u
<
0
)
{
return
new
Point2D
.
Double
(
line
.
getX1
(),
line
.
getY1
());
}
else
if
(
u
>
1
)
{
return
new
Point2D
.
Double
(
line
.
getX2
(),
line
.
getY2
());
}
else
{
return
new
Point2D
.
Double
((
int
)
Math
.
round
(
line
.
getX1
()
+
u
*
xDelta
),
(
int
)
Math
.
round
(
line
.
getY1
()
+
u
*
yDelta
));
}
}
}
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/AllWikipathwaysTests.java
View file @
c566368f
...
...
@@ -6,11 +6,13 @@ import org.junit.runners.Suite.SuiteClasses;
import
lcsb.mapviewer.wikipathway.XML.AllXmlTests
;
import
lcsb.mapviewer.wikipathway.model.AllModelTests
;
import
lcsb.mapviewer.wikipathway.utils.GeoTest
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
AllModelTests
.
class
,
AllXmlTests
.
class
,
ComplexReactionToModelTest
.
class
,
GeoTest
.
class
,
GPMLToModelTest
.
class
,
ReactionElbowsTest
.
class
,
ReactionGpmlInputToModelTest
.
class
,
...
...
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java
View file @
c566368f
...
...
@@ -23,7 +23,6 @@ import lcsb.mapviewer.model.map.compartment.SquareCompartment;
import
lcsb.mapviewer.model.map.model.*
;
import
lcsb.mapviewer.model.map.reaction.*
;
import
lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction
;
import
lcsb.mapviewer.model.map.reaction.type.TransportReaction
;
import
lcsb.mapviewer.model.map.species.*
;
import
lcsb.mapviewer.model.map.species.field.ModificationState
;
import
lcsb.mapviewer.model.map.species.field.Residue
;
...
...
@@ -307,7 +306,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
species
.
setX
(
1
);
species
.
setY
(
1
);
species
.
setZ
(
15
);
species
.
setNamePoint
(
species
.
getCenter
());
species
.
setNameHorizontalAlign
(
HorizontalAlign
.
CENTER
);
species
.
setNameVerticalAlign
(
VerticalAlign
.
MIDDLE
);
...
...
@@ -419,16 +418,15 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
model
.
setHeight
(
1000
);
model
.
setNotes
(
"a < b"
);
Species
p1
=
createProtein
();
p1
.
setNotes
(
"<a href='https://google.lu/'>link</a>"
);
model
.
addElement
(
p1
);
Species
p2
=
createProtein
();
model
.
addElement
(
p2
);
Reaction
r
=
createReaction
(
p1
,
p2
);
Reaction
r
=
createReaction
(
p1
,
p2
);
r
.
setNotes
(
"<xml>tag</xml>"
);
model
.
addReaction
(
r
);
...
...
@@ -439,5 +437,4 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
assertEquals
(
0
,
new
ModelComparator
().
compare
(
model
,
model2
));
}
}
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/utils/GeoTest.java
0 → 100644
View file @
c566368f
package
lcsb.mapviewer.wikipathway.utils
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.awt.geom.Line2D
;
import
java.awt.geom.Point2D
;
import
org.junit.Test
;
public
class
GeoTest
{
@Test
public
void
testClosestPointOnSegment
()
{
Point2D
result
=
Geo
.
getClosestPointOnSegment
(
new
Line2D
.
Double
(
10
,
10
,
20
,
20
),
new
Point2D
.
Double
(
20
,
10
));
assertEquals
(
result
,
new
Point2D
.
Double
(
15
,
15
));
}
@Test
public
void
testClosestPointOnSegmentEdge
()
{
Point2D
result
=
Geo
.
getClosestPointOnSegment
(
new
Line2D
.
Double
(
10
,
10
,
20
,
20
),
new
Point2D
.
Double
(
20
,
0
));
assertEquals
(
result
,
new
Point2D
.
Double
(
10
,
10
));
}
@Test
public
void
testClosestPointOnSegmentEdge2
()
{
Point2D
result
=
Geo
.
getClosestPointOnSegment
(
new
Line2D
.
Double
(
10
,
10
,
20
,
20
),
new
Point2D
.
Double
(
20
,
30
));
assertEquals
(
result
,
new
Point2D
.
Double
(
20
,
20
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment