Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
minerva
core
Commits
4441b540
Commit
4441b540
authored
5 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
colinear points are removed when exporting to sbml
parent
3c063d71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!771
Resolve "wrong start and end of reaction lines"
Pipeline
#10203
passed
5 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionExporter.java
+37
-9
37 additions, 9 deletions
...r/converter/model/sbml/reaction/SbmlReactionExporter.java
with
37 additions
and
9 deletions
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionExporter.java
+
37
−
9
View file @
4441b540
...
...
@@ -21,6 +21,7 @@ import org.sbml.jsbml.SpeciesReference;
import
org.sbml.jsbml.ext.layout.AbstractReferenceGlyph
;
import
org.sbml.jsbml.ext.layout.BoundingBox
;
import
org.sbml.jsbml.ext.layout.Curve
;
import
org.sbml.jsbml.ext.layout.CurveSegment
;
import
org.sbml.jsbml.ext.layout.LineSegment
;
import
org.sbml.jsbml.ext.layout.Point
;
import
org.sbml.jsbml.ext.layout.ReactionGlyph
;
...
...
@@ -35,8 +36,10 @@ import org.w3c.dom.Node;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.common.XmlParser
;
import
lcsb.mapviewer.common.exception.InvalidXmlSchemaException
;
import
lcsb.mapviewer.converter.model.celldesigner.geometry.helper.PolylineDataFactory
;
import
lcsb.mapviewer.converter.model.sbml.SbmlBioEntityExporter
;
import
lcsb.mapviewer.converter.model.sbml.SbmlExtension
;
import
lcsb.mapviewer.model.graphics.PolylineData
;
import
lcsb.mapviewer.model.map.InconsistentModelException
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
import
lcsb.mapviewer.model.map.kinetics.SbmlKinetics
;
...
...
@@ -295,14 +298,38 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
if
(
isExtensionEnabled
(
SbmlExtension
.
RENDER
))
{
assignStyleToGlyph
(
reactionGlyph
,
createStyle
(
reaction
));
}
if
(
reactionGlyph
.
getBoundingBox
()==
null
)
{
if
(
reactionGlyph
.
getBoundingBox
()
==
null
)
{
reactionGlyph
.
setBoundingBox
(
new
BoundingBox
());
}
if
(
reactionGlyph
.
getBoundingBox
().
getPosition
()==
null
)
{
if
(
reactionGlyph
.
getBoundingBox
().
getPosition
()
==
null
)
{
reactionGlyph
.
getBoundingBox
().
setPosition
(
new
Point
());
}
reactionGlyph
.
getBoundingBox
().
getPosition
().
setZ
(
reaction
.
getZ
());
removeColinearPoints
(
reactionGlyph
);
}
private
void
removeColinearPoints
(
ReactionGlyph
glyph
)
{
PolylineData
line
=
createLine
(
glyph
.
getCurve
());
logger
.
debug
(
line
);
line
=
PolylineDataFactory
.
removeCollinearPoints
(
line
);
logger
.
debug
(
line
);
Curve
curve
=
createCurve
(
line
,
false
);
glyph
.
setCurve
(
curve
);
}
private
PolylineData
createLine
(
Curve
curve
)
{
PolylineData
result
=
new
PolylineData
();
if
(
curve
.
getCurveSegmentCount
()
>
0
)
{
CurveSegment
segment
=
curve
.
getCurveSegment
(
0
);
result
.
addPoint
(
new
Point2D
.
Double
(
segment
.
getStart
().
getX
(),
segment
.
getStart
().
getY
()));
}
for
(
int
i
=
0
;
i
<
curve
.
getCurveSegmentCount
();
i
++)
{
CurveSegment
segment
=
curve
.
getCurveSegment
(
i
);
result
.
addPoint
(
new
Point2D
.
Double
(
segment
.
getEnd
().
getX
(),
segment
.
getEnd
().
getY
()));
}
return
result
;
}
private
LocalStyle
createStyle
(
ReactionNode
node
)
{
...
...
@@ -358,16 +385,20 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
private
SpeciesReferenceGlyph
createNodeGlyph
(
ReactionGlyph
reactionGlyph
,
ReactionNode
node
)
{
SpeciesReferenceGlyph
reactantGlyph
=
reactionGlyph
.
createSpeciesReferenceGlyph
(
"node_"
+
getNextId
());
reactantGlyph
.
setSpeciesGlyph
(
speciesExporter
.
getSbmlGlyphByElementId
(
node
.
getElement
().
getElementId
()).
getId
());
reactantGlyph
.
setCurve
(
createCurve
(
node
,
node
instanceof
Reactant
));
Curve
curve
=
createCurve
(
node
.
getLine
(),
node
instanceof
Reactant
);
if
(
curve
.
getCurveSegmentCount
()
==
0
)
{
logger
.
warn
(
new
ElementUtils
().
getElementTag
(
node
)
+
" Problematic line"
);
}
reactantGlyph
.
setCurve
(
curve
);
reactantGlyph
.
setSpeciesReference
(
speciesReferenceByReactionNode
.
get
(
node
));
return
reactantGlyph
;
}
private
Curve
createCurve
(
ReactionNode
nod
e
,
boolean
reverse
)
{
private
Curve
createCurve
(
PolylineData
polylin
e
,
boolean
reverse
)
{
Curve
curve
=
new
Curve
();
List
<
Line2D
>
lines
=
node
.
getL
ine
()
.
getLines
();
List
<
Line2D
>
lines
=
polyl
ine
.
getLines
();
if
(
reverse
)
{
lines
=
node
.
getL
ine
()
.
reverse
().
getLines
();
lines
=
polyl
ine
.
reverse
().
getLines
();
}
for
(
Line2D
line
:
lines
)
{
if
(
line
.
getP1
().
distance
(
line
.
getP2
())
>
Configuration
.
EPSILON
)
{
...
...
@@ -377,9 +408,6 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
curve
.
addCurveSegment
(
segment
);
}
}
if
(
curve
.
getCurveSegmentCount
()
==
0
)
{
logger
.
warn
(
new
ElementUtils
().
getElementTag
(
node
)
+
" Problematic line"
);
}
return
curve
;
}
...
...
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