use of org.apache.nifi.web.api.dto.PositionDTO in project kylo by Teradata.
the class AlignProcessGroupComponents method alignPorts.
private void alignPorts(Collection<PortDTO> ports, AbstractRenderer renderer) {
ports.stream().forEach(port -> {
PortDTO positionPort = new PortDTO();
positionPort.setId(port.getId());
PositionDTO lastPosition = renderer.getLastPosition();
PositionDTO newPosition = renderer.getNextPosition(lastPosition);
positionPort.setPosition(newPosition);
niFiRestClient.ports().updateInputPort(parentProcessGroupId, positionPort);
log.debug("Aligned Port {} at {},{}", port.getName(), positionPort.getPosition().getX(), positionPort.getPosition().getY());
});
}
use of org.apache.nifi.web.api.dto.PositionDTO in project kylo by Teradata.
the class ColumnRenderer method getNextPosition.
@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
Double yValue = getLastPosition() == null ? layoutGroup.getTopY() : getLastPosition().getY() + (getHeight() / itemCount);
// force the last one to go the the bottom
if (alignLastToBottom && getStoredPositionCounter() == (itemCount - 1)) {
yValue = layoutGroup.getBottomY();
}
PositionDTO newPosition = new PositionDTO();
newPosition.setX(xValue);
newPosition.setY(yValue);
storePosition(LOCATION_KEY, newPosition);
return newPosition;
}
use of org.apache.nifi.web.api.dto.PositionDTO in project kylo by Teradata.
the class SingleRowRightRenderer method getNextPosition.
@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
if (this.xSpace == null) {
this.xSpace = alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight();
}
PositionDTO newPosition = new PositionDTO();
newPosition.setX(alignmentConfig.getCenterX() - (alignmentConfig.getProcessGroupWidth() / 2));
newPosition.setY(yValue);
if (lastPosition == null) {
storePosition(newPosition);
} else {
// place right
PositionDTO rightPosition = getLastPosition();
newPosition.setX((rightPosition != null ? rightPosition.getX() : 0) + xSpace);
storePosition(newPosition);
}
return newPosition;
}
use of org.apache.nifi.web.api.dto.PositionDTO in project kylo by Teradata.
the class TopBottomRowsRenderer method getNextPosition.
private PositionDTO getNextPosition(Location location, PositionDTO lastPosition) {
Double groupPlusPadding = new Double(alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight());
Double padding = new Double(alignmentConfig.getProcessGroupPaddingLeftRight());
PositionDTO dto = new PositionDTO();
dto.setX(centerX + groupPlusPadding);
dto.setY(layoutGroup.getBottomY());
switch(location) {
case BOTTOM_RIGHT:
dto.setX(lastPosition.getX() + groupPlusPadding);
dto.setY(layoutGroup.getBottomY());
break;
case BOTTOM_LEFT:
dto.setX(lastPosition.getX() - groupPlusPadding);
dto.setY(layoutGroup.getBottomY());
break;
case TOP_RIGHT:
dto.setX(lastPosition.getX() + groupPlusPadding);
dto.setY(layoutGroup.getTopY());
break;
case TOP_LEFT:
dto.setX(lastPosition.getX() - groupPlusPadding);
dto.setY(layoutGroup.getTopY());
break;
default:
break;
}
return dto;
}
use of org.apache.nifi.web.api.dto.PositionDTO in project kylo by Teradata.
the class TopBottomRowsRenderer method getNextPosition.
@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
PositionDTO newPosition = null;
Location currentLocation = null;
Location lastLocation = getLastLocationKey() != null ? Location.valueOf(getLastLocationKey()) : null;
if (lastLocation == null) {
currentLocation = Location.TOP_LEFT;
} else {
currentLocation = lastLocation.getNext();
}
PositionDTO lastPositionAtLocation = getLastPosition(currentLocation);
if (lastPositionAtLocation != null) {
newPosition = getNextPosition(currentLocation, lastPositionAtLocation);
} else {
newPosition = getInitialPosition(currentLocation);
}
storePosition(currentLocation, newPosition);
return newPosition;
}
Aggregations