Skip to content

Instantly share code, notes, and snippets.

@GeePawHill
Created September 14, 2018 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeePawHill/bad2a07f0cb7b0c7f30becc56262b499 to your computer and use it in GitHub Desktop.
Save GeePawHill/bad2a07f0cb7b0c7f30becc56262b499 to your computer and use it in GitHub Desktop.
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