Created
September 14, 2018 12:34
-
-
Save GeePawHill/bad2a07f0cb7b0c7f30becc56262b499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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