use of com.helospark.tactview.core.timeline.effect.scale.ScaleEffect in project tactview by helospark.
the class GeneralCanvasOperationStrategy method findDragData.
private DragData findDragData(GeneralCanvasOperationsMouseRequest input) {
String draggedClip = null;
DragPointType dragPointType = null;
for (var entry : input.rectangles.entrySet()) {
RegularRectangle rectangle = entry.getValue();
if (isPointClose(input.unscaledX, input.unscaledY, rectangle.getX(), rectangle.getY())) {
draggedClip = entry.getKey();
dragPointType = DragPointType.TOP_LEFT;
break;
}
if (isPointClose(input.unscaledX, input.unscaledY, rectangle.getX() + rectangle.getWidth(), rectangle.getY())) {
draggedClip = entry.getKey();
dragPointType = DragPointType.TOP_RIGHT;
break;
}
if (isPointClose(input.unscaledX, input.unscaledY, rectangle.getX(), rectangle.getY() + rectangle.getHeight())) {
draggedClip = entry.getKey();
dragPointType = DragPointType.BOTTOM_LEFT;
break;
}
if (isPointClose(input.unscaledX, input.unscaledY, rectangle.getX() + rectangle.getWidth(), rectangle.getY() + rectangle.getHeight())) {
draggedClip = entry.getKey();
dragPointType = DragPointType.BOTTOM_RIGHT;
break;
}
if (Math.abs(input.unscaledX - rectangle.getX()) < CLOSE_THRESHOLD && isYWithinRectangleRange(input.unscaledY, rectangle)) {
draggedClip = entry.getKey();
dragPointType = DragPointType.LEFT;
break;
}
if (Math.abs(input.unscaledX - (rectangle.getX() + rectangle.getWidth())) < CLOSE_THRESHOLD && isYWithinRectangleRange(input.unscaledY, rectangle)) {
draggedClip = entry.getKey();
dragPointType = DragPointType.RIGHT;
break;
}
if (Math.abs(input.unscaledY - (rectangle.getY() + rectangle.getHeight())) < CLOSE_THRESHOLD && isXWithinRectangleRange(input.unscaledX, rectangle)) {
draggedClip = entry.getKey();
dragPointType = DragPointType.BOTTOM;
break;
}
if (Math.abs(input.unscaledY - rectangle.getY()) < CLOSE_THRESHOLD && isXWithinRectangleRange(input.unscaledX, rectangle)) {
draggedClip = entry.getKey();
dragPointType = DragPointType.TOP;
break;
}
if (isPointInRectangle(input.unscaledX, input.unscaledY, rectangle)) {
draggedClip = entry.getKey();
dragPointType = DragPointType.CENTER;
break;
}
}
if (draggedClip != null && dragPointType != null) {
ValueProviderDescriptor translateElement = effectParametersRepository.findDescriptorForLabelAndClipId(draggedClip, "translate").get();
Point originalPosition = ((PointProvider) translateElement.getKeyframeableEffect()).getValueAt(uiTimelineManager.getCurrentPosition());
Point lastScale = new Point(1.0, 1.0);
ScaleEffect scaleEffect = findOptionalScale(draggedClip);
if (scaleEffect != null) {
double xScale = (double) effectParametersRepository.findDescriptorForLabelAndClipId(scaleEffect.getId(), "width scale").get().getKeyframeableEffect().getValueAt(uiTimelineManager.getCurrentPosition());
double yScale = (double) effectParametersRepository.findDescriptorForLabelAndClipId(scaleEffect.getId(), "height scale").get().getKeyframeableEffect().getValueAt(uiTimelineManager.getCurrentPosition());
lastScale = new Point(xScale, yScale);
}
return new DragData(draggedClip, dragPointType, originalPosition, lastScale, input.rectangles.get(draggedClip));
} else {
return null;
}
}
use of com.helospark.tactview.core.timeline.effect.scale.ScaleEffect in project tactview by helospark.
the class GeneralCanvasOperationStrategy method getOrAddScaleEffect.
private String getOrAddScaleEffect(String draggedClip) {
ScaleEffect optionalScale = findOptionalScale(draggedClip);
if (optionalScale != null) {
return optionalScale.getId();
}
AddEffectCommand addEffectCommand = new AddEffectCommand(draggedClip, "scale", TimelinePosition.ofZero(), timelineManagerAccessor);
return commandInterpreterService.sendWithResult(addEffectCommand).join().getAddedEffectId();
}
Aggregations