mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
fix side as first level nodes are drawn
This commit is contained in:
parent
c4a4424364
commit
696ac88330
@ -230,6 +230,8 @@ public class FreemindImporter
|
|||||||
TopicType currentWiseTopic = wiseParent;
|
TopicType currentWiseTopic = wiseParent;
|
||||||
|
|
||||||
int order = 0;
|
int order = 0;
|
||||||
|
int firstLevelRightOrder = 0;
|
||||||
|
int firstLevelLeftOrder = 1;
|
||||||
for (Object element : freeChilden) {
|
for (Object element : freeChilden) {
|
||||||
|
|
||||||
if (element instanceof Node) {
|
if (element instanceof Node) {
|
||||||
@ -247,7 +249,13 @@ public class FreemindImporter
|
|||||||
if (depth != 1) {
|
if (depth != 1) {
|
||||||
norder = order++;
|
norder = order++;
|
||||||
} else {
|
} else {
|
||||||
norder = calcFirstLevelOrder(freeChilden, freeChild);
|
if (freeChild.getPOSITION().equals(POSITION_LEFT)) {
|
||||||
|
norder = firstLevelLeftOrder;
|
||||||
|
firstLevelLeftOrder = firstLevelLeftOrder + 2;
|
||||||
|
} else {
|
||||||
|
norder = firstLevelRightOrder;
|
||||||
|
firstLevelRightOrder = firstLevelRightOrder + 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wiseChild.setOrder(norder);
|
wiseChild.setOrder(norder);
|
||||||
|
|
||||||
@ -343,53 +351,6 @@ public class FreemindImporter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sort the freemind node following this pattern:
|
|
||||||
* <p/>
|
|
||||||
* 0 -> 3
|
|
||||||
* 1 -> 1
|
|
||||||
* 2 -> 0
|
|
||||||
* 3 -> 2
|
|
||||||
* 4 -> 4
|
|
||||||
*/
|
|
||||||
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @Nullable Node freeChild) {
|
|
||||||
final List<Node> nodes = new ArrayList<Node>();
|
|
||||||
int result;
|
|
||||||
|
|
||||||
// Collect all the nodes of the same side ...
|
|
||||||
for (Object child : freeChilden) {
|
|
||||||
if (child instanceof Node) {
|
|
||||||
Node node = (Node) child;
|
|
||||||
|
|
||||||
final String side = node.getPOSITION();
|
|
||||||
if (side == freeChild.getPOSITION() || freeChild.getPOSITION().equals(side)) {
|
|
||||||
nodes.add(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// What is the index of the current node ?
|
|
||||||
int nodeIndex = 0;
|
|
||||||
for (Node node : nodes) {
|
|
||||||
if (node == freeChild) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nodeIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = nodes.size();
|
|
||||||
int center = (size - 1) / 2;
|
|
||||||
result = nodeIndex - center;
|
|
||||||
|
|
||||||
if (result < 0) {
|
|
||||||
result = (result * ORDER_SEPARATION_FACTOR * -2) - 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = result * ORDER_SEPARATION_FACTOR * 2;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Position is (x,y).
|
* Position is (x,y).
|
||||||
* x values greater than 0 are right axis
|
* x values greater than 0 are right axis
|
||||||
@ -420,16 +381,14 @@ public class FreemindImporter
|
|||||||
int y;
|
int y;
|
||||||
if (depth == 1) {
|
if (depth == 1) {
|
||||||
|
|
||||||
// Follow the following algorithm ...
|
// pair order numbers represent nodes at the right
|
||||||
// Order: 3 = -100 1
|
// odd order numbers represent nodes at the left
|
||||||
// Order: 1 = -50 2
|
|
||||||
// Order: 0 = 0 3
|
|
||||||
// Order: 2 = 50 4
|
|
||||||
// Order: 4 = 100 5
|
|
||||||
if (order % 2 == 0) {
|
if (order % 2 == 0) {
|
||||||
y = ROOT_LEVEL_TOPIC_HEIGHT * order;
|
int multiplier = (int) ((order - Math.floor((childrenCount - 1) / 2)) * 2);
|
||||||
|
y = multiplier * ROOT_LEVEL_TOPIC_HEIGHT;
|
||||||
} else {
|
} else {
|
||||||
y = -ROOT_LEVEL_TOPIC_HEIGHT * (order + 1);
|
int multiplier = (int) ((order - Math.floor(childrenCount / 2)) * 2);
|
||||||
|
y = multiplier * ROOT_LEVEL_TOPIC_HEIGHT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user