use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistributeControlImpl method removeChildrenIfIndexed.
public void removeChildrenIfIndexed(final IPrimitive<?> prim, final List<ShapePair> pairs) {
for (final IPrimitive<?> child : prim.asGroup().getChildNodes()) {
final AlignAndDistributeControl handler = m_alignAndDistribute.getControlForShape(child.uuid());
if (handler != null) {
final ShapePair pair = new ShapePair(prim.asGroup(), child, handler);
pairs.add(pair);
prim.asGroup().remove(child);
}
if (child instanceof Group) {
removeChildrenIfIndexed(child.asGroup(), pairs);
}
}
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method removeHorizontalDistIndex.
public void removeHorizontalDistIndex(final AlignAndDistributeControl handler) {
for (final DistributionEntry dist : handler.getHorizontalDistributionEntries()) {
final AlignAndDistributeControl h1 = dist.getShape1();
final AlignAndDistributeControl h2 = dist.getShape2();
// make sure we don't remove from handler, or it will remove from the collection currently being iterated.
if (handler == h1) {
h2.getHorizontalDistributionEntries().remove(dist);
} else {
h1.getHorizontalDistributionEntries().remove(dist);
}
switch(dist.getDistributionType()) {
case DistributionEntry.LEFT_DIST:
removeDistIndexEntry(m_leftDistIndex, dist);
break;
case DistributionEntry.H_CENTER_DIST:
removeDistIndexEntry(m_hCenterDistIndex, dist);
break;
case DistributionEntry.RIGHT_DIST:
removeDistIndexEntry(m_rightDistIndex, dist);
break;
}
}
handler.getHorizontalDistributionEntries().clear();
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method removeVerticalDistIndex.
public void removeVerticalDistIndex(final AlignAndDistributeControl handler) {
for (final DistributionEntry dist : handler.getVerticalDistributionEntries()) {
final AlignAndDistributeControl h1 = dist.getShape1();
final AlignAndDistributeControl h2 = dist.getShape2();
// make sure we don't remove from handler, or it will remove from the collection currently being iterated.
if (handler == h1) {
h2.getVerticalDistributionEntries().remove(dist);
} else {
h1.getVerticalDistributionEntries().remove(dist);
}
switch(dist.getDistributionType()) {
case DistributionEntry.TOP_DIST:
removeDistIndexEntry(m_topDistIndex, dist);
break;
case DistributionEntry.V_CENTER_DIST:
removeDistIndexEntry(m_vCenterDistIndex, dist);
break;
case DistributionEntry.BOTTOM_DIST:
removeDistIndexEntry(m_bottomDistIndex, dist);
break;
}
}
handler.getVerticalDistributionEntries().clear();
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistributeControlImpl method indexOn.
private void indexOn(final IPrimitive<?> shape) {
final AlignAndDistributeControl handler = m_alignAndDistribute.getControlForShape(shape.uuid());
indexOn(handler);
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method buildHorizontalDistIndex.
public void buildHorizontalDistIndex(final AlignAndDistributeControl handler) {
final double left = round(handler.getLeft());
final double right = round(handler.getRight());
for (final AlignAndDistributeControl otherH : m_shapes.values()) {
if (skipShape(handler, otherH)) {
continue;
}
final double otherLeft = round(otherH.getLeft());
final double otherRight = round(otherH.getRight());
DistributionEntry leftDist = null;
DistributionEntry hCenterDist = null;
DistributionEntry rightDist = null;
if (otherRight < left) {
final double dx = left - otherRight;
final double leftPoint = otherLeft - dx;
final double rightPoint = right + dx;
final double centerPoint = round(otherRight + ((left - otherRight) / 2));
leftDist = new DistributionEntry(otherH, handler, leftPoint, DistributionEntry.LEFT_DIST);
hCenterDist = new DistributionEntry(otherH, handler, centerPoint, DistributionEntry.H_CENTER_DIST);
rightDist = new DistributionEntry(otherH, handler, rightPoint, DistributionEntry.RIGHT_DIST);
} else if (otherLeft > right) {
final double dx = otherLeft - right;
final double leftPoint = left - dx;
final double rightPoint = otherRight + dx;
final double centerPoint = round(otherLeft + ((right - otherLeft) / 2));
leftDist = new DistributionEntry(handler, otherH, leftPoint, DistributionEntry.LEFT_DIST);
hCenterDist = new DistributionEntry(handler, otherH, centerPoint, DistributionEntry.H_CENTER_DIST);
rightDist = new DistributionEntry(handler, otherH, rightPoint, DistributionEntry.RIGHT_DIST);
}
if (leftDist != null) {
addDistIndexEntry(m_leftDistIndex, leftDist);
addDistIndexEntry(m_hCenterDistIndex, hCenterDist);
addDistIndexEntry(m_rightDistIndex, rightDist);
}
}
}
Aggregations