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
Devrim Gunyel
core
Commits
4441b540
Commit
4441b540
authored
May 13, 2019
by
Piotr Gawron
Browse files
colinear points are removed when exporting to sbml
parent
3c063d71
Changes
1
Hide whitespace changes
Inline
Side-by-side
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionExporter.java
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
;
}
...
...
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