Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
a9127d71
Commit
a9127d71
authored
Sep 17, 2021
by
Piotr Gawron
Browse files
StructuralState comparator updated to compare z index
parent
e457d714
Changes
1
Hide whitespace changes
Inline
Side-by-side
model/src/main/java/lcsb/mapviewer/model/map/species/field/StructuralStateComparator.java
View file @
a9127d71
...
...
@@ -6,25 +6,19 @@ import org.apache.logging.log4j.Logger;
import
lcsb.mapviewer.common.Comparator
;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.common.comparator.DoubleComparator
;
import
lcsb.mapviewer.common.comparator.IntegerComparator
;
import
lcsb.mapviewer.common.comparator.PointComparator
;
import
lcsb.mapviewer.common.comparator.StringComparator
;
import
lcsb.mapviewer.model.map.MiriamData
;
/**
* Comparator of {@link MiriamData} object.
*
* @author Piotr Gawron
*
*/
public
class
StructuralStateComparator
extends
Comparator
<
StructuralState
>
{
/**
* Epsilon value used for comparison of doubles.
*/
private
double
epsilon
;
private
static
Logger
logger
=
LogManager
.
getLogger
();
private
final
StringComparator
stringComparator
;
private
final
PointComparator
pointComparator
;
private
final
DoubleComparator
doubleComparator
;
private
final
IntegerComparator
integerComparator
;
/**
* Default constructor.
*/
...
...
@@ -34,22 +28,22 @@ public class StructuralStateComparator extends Comparator<StructuralState> {
public
StructuralStateComparator
(
final
double
epsilon
)
{
super
(
StructuralState
.
class
);
this
.
epsilon
=
epsilon
;
stringComparator
=
new
StringComparator
();
pointComparator
=
new
PointComparator
(
epsilon
);
doubleComparator
=
new
DoubleComparator
();
integerComparator
=
new
IntegerComparator
();
}
@Override
protected
int
internalCompare
(
final
StructuralState
arg0
,
final
StructuralState
arg1
)
{
StringComparator
stringComparator
=
new
StringComparator
();
if
(
stringComparator
.
compare
(
arg0
.
getValue
(),
arg1
.
getValue
())
!=
0
)
{
return
stringComparator
.
compare
(
arg0
.
getValue
(),
arg1
.
getValue
());
}
PointComparator
pointComparator
=
new
PointComparator
(
epsilon
);
if
(
pointComparator
.
compare
(
arg0
.
getPosition
(),
arg1
.
getPosition
())
!=
0
)
{
logger
.
debug
(
"position different: "
+
arg0
.
getPosition
()
+
", "
+
arg1
.
getPosition
());
return
pointComparator
.
compare
(
arg0
.
getPosition
(),
arg1
.
getPosition
());
}
DoubleComparator
doubleComparator
=
new
DoubleComparator
();
if
(
doubleComparator
.
compare
(
arg0
.
getWidth
(),
arg1
.
getWidth
())
!=
0
)
{
logger
.
debug
(
"width different: "
+
arg0
.
getWidth
()
+
", "
+
arg1
.
getWidth
());
return
doubleComparator
.
compare
(
arg0
.
getWidth
(),
arg1
.
getWidth
());
...
...
@@ -59,6 +53,11 @@ public class StructuralStateComparator extends Comparator<StructuralState> {
return
doubleComparator
.
compare
(
arg0
.
getHeight
(),
arg1
.
getHeight
());
}
if
(
integerComparator
.
compare
(
arg0
.
getZ
(),
arg1
.
getZ
())
!=
0
)
{
logger
.
debug
(
"z different: "
+
arg0
.
getZ
()
+
", "
+
arg1
.
getZ
());
return
integerComparator
.
compare
(
arg0
.
getZ
(),
arg1
.
getZ
());
}
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment