Instantly share code, notes, and snippets.

Embed
What would you like to do?
package org.geepawhill.contentment.fragments;
import org.geepawhill.contentment.core.*;
import javafx.scene.Group;
/**
* Makes a group and adds it to the destination, making it available via get for later
* manipulators.
*
* @author GeePaw
*
*/
public class Entrance implements Fragment, GroupSource
{
private Group group;
private Group destination;
public Entrance(Group destination, Group group)
{
this.destination = destination;
this.group = group;
}
@Override
public void prepare(Context context)
{
group.setOpacity(1);
if(destination!=null) destination.getChildren().add(group);
else context.canvas.getChildren().add(group);
}
@Override
public boolean interpolate(Context context, double fraction)
{
return false;
}
@Override
public Group group()
{
return group;
}
}
package org.geepawhill.contentment.fragments;
import javafx.scene.Group;
import org.geepawhill.contentment.core.Context;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EntranceTest
{
private Context context;
@BeforeEach
public void before()
{
context = new Context();
}
@Test
public void addsNewGroup()
{
Entrance entrance = new Entrance(context.canvas, new Group() );
entrance.prepare(context);
entrance.interpolate(context, 1);
assertThat(context.canvas.getChildren().contains(entrance.group())).isTrue();
}
@Test
public void isInstant()
{
Entrance entrance = new Entrance(context.canvas, new Group());
entrance.prepare(context);
assertThat(entrance.interpolate(context, .1)).isFalse();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment