use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method addShape.
public AlignAndDistributeControl addShape(final IDrawable<?> group) {
final String uuid = group.uuid();
AlignAndDistributeControl handler = m_shapes.get(uuid);
// only add if the group has not already been added
if (null == handler) {
handler = new AlignAndDistributeControlImpl((IPrimitive<?>) group, this, m_alignmentCallback, group.getBoundingBoxAttributes());
m_shapes.put(uuid, handler);
}
return handler;
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method buildVerticalDistIndex.
public void buildVerticalDistIndex(final AlignAndDistributeControl handler) {
final double top = round(handler.getTop());
final double bottom = round(handler.getBottom());
for (final AlignAndDistributeControl otherH : m_shapes.values()) {
if (skipShape(handler, otherH)) {
continue;
}
final double otherTop = round(otherH.getTop());
final double otherBottom = round(otherH.getBottom());
DistributionEntry topDist = null;
DistributionEntry vCenterDist = null;
DistributionEntry bottomDist = null;
if (otherBottom < top) {
final double dx = top - otherBottom;
final double topPoint = otherTop - dx;
final double bottomPoint = bottom + dx;
final double centerPoint = round(otherBottom + ((top - otherBottom) / 2));
topDist = new DistributionEntry(otherH, handler, topPoint, DistributionEntry.TOP_DIST);
vCenterDist = new DistributionEntry(otherH, handler, centerPoint, DistributionEntry.V_CENTER_DIST);
bottomDist = new DistributionEntry(otherH, handler, bottomPoint, DistributionEntry.BOTTOM_DIST);
} else if (otherTop > bottom) {
final double dx = otherTop - bottom;
final double topPoint = top - dx;
final double bottomPoint = otherBottom + dx;
final double centerPoint = round(bottom + ((otherTop - bottom) / 2));
topDist = new DistributionEntry(handler, otherH, topPoint, DistributionEntry.TOP_DIST);
vCenterDist = new DistributionEntry(handler, otherH, centerPoint, DistributionEntry.V_CENTER_DIST);
bottomDist = new DistributionEntry(handler, otherH, bottomPoint, DistributionEntry.BOTTOM_DIST);
}
if (topDist != null) {
addDistIndexEntry(m_topDistIndex, topDist);
addDistIndexEntry(m_vCenterDistIndex, vCenterDist);
addDistIndexEntry(m_bottomDistIndex, bottomDist);
}
}
}
use of com.ait.lienzo.client.core.shape.wires.handlers.AlignAndDistributeControl in project lienzo-core by ahome-it.
the class AlignAndDistribute method removeShape.
public void removeShape(final IDrawable<?> shape) {
final AlignAndDistributeControl handler = m_shapes.get(shape.uuid());
if (null != handler) {
indexOff(handler);
m_shapes.remove(shape.uuid());
handler.remove();
}
}
Aggregations