-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
582 additions
and
93 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package graphical.basics.behaviors; | ||
|
||
import graphical.basics.gobject.struct.Gobject; | ||
import graphical.basics.presentation.Presentation; | ||
|
||
public class AlwaysOnTop { | ||
|
||
public static Runnable onTop(Gobject gobject) { | ||
return () ->{ | ||
Presentation.staticReference.remove(gobject); | ||
Presentation.staticReference.add(gobject); | ||
}; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/graphical/basics/behaviors/FollowBehavior.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package graphical.basics.behaviors; | ||
|
||
import graphical.basics.gobject.struct.Gobject; | ||
import graphical.basics.location.Location; | ||
|
||
public class FollowBehavior { | ||
public static Runnable follow(Gobject followedGobject, Gobject followerGobject) { | ||
return () -> followerGobject.setPositionTo(followedGobject.getMidPoint()); | ||
} | ||
|
||
public static Runnable followWithDelay(Gobject followedGobject, Gobject followerGobject, double delay) { | ||
return () -> { | ||
var m1 = followerGobject.getMidPoint(); | ||
var m2 = followedGobject.getMidPoint(); | ||
|
||
followerGobject.changeSetPosition((m2.getX() - m1.getX()) * delay, (m2.getY() - m1.getY()) * delay); | ||
}; | ||
} | ||
|
||
|
||
public static Runnable followWithDelay(Gobject followedGobject, Gobject followerGobject) { | ||
return followWithDelay(followedGobject, followerGobject, 0.1); | ||
} | ||
|
||
public static Runnable asSubtitle(Gobject followedGobject, Gobject followerGobject, double margin) { | ||
return () -> { | ||
var fd = followedGobject.getBorders(); | ||
var fr = followerGobject.getBorders(); | ||
var fdh2 = fd.getheight() / 2; | ||
var frh2 = fr.getheight() / 2; | ||
var fdmid = fd.midPoint(); | ||
|
||
var desirredPoint = Location.at(fd.midPoint().getX(), fd.midPoint().getY() + fdh2 + frh2 + margin); | ||
|
||
followerGobject.setPositionTo(desirredPoint); | ||
}; | ||
} | ||
|
||
public static Runnable asSubtitleWithDelay(Gobject followedGobject, Gobject followerGobject, double margin, double delay) { | ||
asSubtitle(followedGobject, followerGobject, margin).run(); | ||
return () -> { | ||
var fd = followedGobject.getBorders(); | ||
var fr = followerGobject.getBorders(); | ||
var fdh2 = fd.getheight() / 2; | ||
var frh2 = fr.getheight() / 2; | ||
var fdmid = fd.midPoint(); | ||
var frmid = fr.midPoint(); | ||
|
||
var desirredPoint = Location.at(fdmid.getX(), fdmid.getY() + fdh2 + frh2 + margin); | ||
|
||
followerGobject.changeSetPosition((desirredPoint.getX() - frmid.getX()) * delay, (desirredPoint.getY() - frmid.getY()) * delay); | ||
}; | ||
} | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package graphical.basics.behaviors; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class RunnableUtils { | ||
public static <T> Runnable wrap(T metadata, Consumer<T> consumer) { | ||
return () -> consumer.accept(metadata); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.