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
import java.awt.BorderLayout; | |
import java.awt.CardLayout; | |
import java.awt.Color; | |
import java.awt.Container; | |
import java.awt.Dimension; | |
import java.awt.EventQueue; | |
import java.awt.GridBagLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; |
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
import java.time.Duration; | |
import java.time.LocalDateTime; | |
/* | |
I seem to need to provide a lot of examples on stack overflow which are either performing a forward, backward or needs | |
to calculate the percentage of progression for a period of time. | |
Since most of this functionality can easily be distilled, I wrote myself a simple "counter" class. |
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
import java.time.Duration; | |
import java.time.Instant; | |
public class StopWatch { | |
private Instant startTime; | |
private Duration totalRunTime = Duration.ZERO; | |
public StopWatch start() { | |
startTime = Instant.now(); |
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
JFileChooser chooser = new JFileChooser(); | |
Thread t = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
SwingUtilities.invokeAndWait(new Runnable() { | |
@Override | |
public void run() { | |
chooser.showOpenDialog(null); | |
JOptionPane.showMessageDialog(null, "Bananas"); |
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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.TreeMap; | |
public class TimeLine<T> { | |
private Map<Float, KeyFrame<T>> mapEvents; |
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
import java.awt.geom.Point2D; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class SplineInterpolator { | |
private final double points[]; | |
private final List<PointUnit> normalisedCurve; |
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
import java.time.Duration; | |
import java.time.LocalDateTime; | |
public class DurationTimeLine<T> extends TimeLine<T> { | |
private Duration duration; | |
private LocalDateTime startedAt; | |
public DurationTimeLine(Duration duration, Blender<T> blender) { |
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
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.EventQueue; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.event.MouseAdapter; | |
import java.awt.event.MouseEvent; | |
import java.awt.geom.Point2D; | |
import java.time.Duration; | |
import java.time.LocalDateTime; |
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
public class Animator { | |
private Instant startTime; | |
private Duration totalRunTime = Duration.ZERO; | |
private Duration runTime; | |
private Timer timer; |
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
import Foundation | |
class AlarmClock: SimpleClock { | |
var timeout: TimeInterval = 0 | |
var hasExpired: Bool { | |
return duration >= timeout | |
} |
OlderNewer