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
26c965d6
Commit
26c965d6
authored
Oct 25, 2019
by
Piotr Gawron
Browse files
conversion of top and left compartment fixed
parent
e1cd9cc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParser.java
View file @
26c965d6
...
...
@@ -113,12 +113,14 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
if
(
result
instanceof
BottomSquareCompartment
)
{
result
.
setY
(
XmlParser
.
getNodeAttr
(
"y"
,
node
));
}
else
if
(
result
instanceof
LeftSquareCompartment
)
{
result
.
setX
(
XmlParser
.
getNodeAttr
(
"x"
,
node
));
result
.
setWidth
(
XmlParser
.
getNodeAttr
(
"x"
,
node
));
result
.
setX
(
0.0
);
}
else
if
(
result
instanceof
RightSquareCompartment
)
{
result
.
setX
(
XmlParser
.
getNodeAttr
(
"x"
,
node
));
result
.
setWidth
(
result
.
getWidth
()
-
result
.
getX
());
}
else
if
(
result
instanceof
TopSquareCompartment
)
{
result
.
setY
(
XmlParser
.
getNodeAttr
(
"y"
,
node
));
result
.
setHeight
(
XmlParser
.
getNodeAttr
(
"y"
,
node
));
result
.
setY
(
0.0
);
}
else
{
throw
new
InvalidXmlSchemaException
(
"Don't know what to do with celldesigner:point for class: "
+
result
.
getClass
());
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentParserTests.java
View file @
26c965d6
package
lcsb.mapviewer.converter.model.celldesigner.compartment
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.*
;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
import
lcsb.mapviewer.model.map.model.Model
;
public
class
CompartmentParserTests
extends
CellDesignerTestFunctions
{
...
...
@@ -23,6 +26,11 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
@Test
public
void
testParseCompartmensBottom
()
throws
Exception
{
Model
model
=
getModelForFile
(
"testFiles/compartment/bottom_compartment.xml"
);
Compartment
c
=
model
.
getElementByElementId
(
"ca4"
);
assertTrue
(
c
.
getY
()
>
0
);
assertTrue
(
c
.
getWidth
()
>
0
);
assertTrue
(
c
.
getHeight
()
>
0
);
assertEquals
(
0
,
c
.
getX
(),
Configuration
.
EPSILON
);
assertEquals
(
1
,
model
.
getElements
().
size
());
}
...
...
@@ -31,19 +39,33 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
public
void
testParseCompartmensTop
()
throws
Exception
{
Model
model
=
getModelForFile
(
"testFiles/compartment/top_compartment.xml"
);
Compartment
c
=
model
.
getElementByElementId
(
"ca3"
);
assertEquals
(
0
,
c
.
getX
(),
Configuration
.
EPSILON
);
assertEquals
(
0
,
c
.
getY
(),
Configuration
.
EPSILON
);
assertTrue
(
c
.
getWidth
()
>
0
);
assertTrue
(
c
.
getHeight
()
<
model
.
getHeight
());
assertEquals
(
1
,
model
.
getElements
().
size
());
}
@Test
public
void
testParseCompartmensRight
()
throws
Exception
{
Model
model
=
getModelForFile
(
"testFiles/compartment/right_compartment.xml"
);
Compartment
c
=
model
.
getElementByElementId
(
"ca2"
);
assertTrue
(
c
.
getX
()
>
0
);
assertTrue
(
c
.
getWidth
()
>
0
);
assertTrue
(
c
.
getHeight
()
>
0
);
assertEquals
(
0
,
c
.
getY
(),
Configuration
.
EPSILON
);
assertEquals
(
1
,
model
.
getElements
().
size
());
}
@Test
public
void
testParseCompartmensLeft
()
throws
Exception
{
Model
model
=
getModelForFile
(
"testFiles/compartment/left_compartment.xml"
);
Compartment
c
=
model
.
getElementByElementId
(
"ca1"
);
assertEquals
(
0
,
c
.
getX
(),
Configuration
.
EPSILON
);
assertEquals
(
0
,
c
.
getY
(),
Configuration
.
EPSILON
);
assertTrue
(
c
.
getWidth
()
<
model
.
getWidth
());
assertTrue
(
c
.
getHeight
()
>
0
);
assertEquals
(
1
,
model
.
getElements
().
size
());
}
...
...
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