Commit efd5a8d3 authored by Nico Mack's avatar Nico Mack

Added enableFading method to FadingCorona.

parent 4fddaa08
......@@ -29,6 +29,7 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
private long fadeOutTime;
private long displayTime;
private boolean fadeWithHandle;
private boolean fadingEnabled;
protected float opacity;
protected Timeline fadeInTimeline;
......@@ -57,6 +58,7 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
this.fadeOutTime = builder.fadeOutTime;
this.displayTime = builder.displayTime;
this.fadeWithHandle = builder.fadeWithHandle;
this.fadingEnabled = true;
this.opacity = 0.0f;
if (displayTime > 0) {
displayTimer = new Timer((int) displayTime, this);
......@@ -81,6 +83,7 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
this.displayTime = original.displayTime;
this.fadeWithHandle = original.fadeWithHandle;
this.opacity = original.opacity;
this.fadingEnabled = original.fadingEnabled;
if (displayTime > 0) {
displayTimer = new Timer((int) displayTime, this);
displayTimer.setRepeats(false);
......@@ -107,7 +110,27 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
// ---------------------------------------------------------------------------
public void enableFading(boolean enableIt) {
fadingEnabled = enableIt;
if (!fadingEnabled) {
if (displayTimer != null)
displayTimer.stop();
} else {
if (displayTimer != null)
displayTimer.start();
}
}
// ---------------------------------------------------------------------------
public void fadeIn() {
if (!fadingEnabled) {
this.setOpacity(1.0f);
return;
}
if ((fadeOutTimeline != null) && (!fadeOutTimeline.isDone()))
fadeOutTimeline.cancel();
......@@ -127,6 +150,12 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
// ---------------------------------------------------------------------------
public void fadeOut() {
if (!fadingEnabled) {
this.setOpacity(0.0f);
return;
}
if ((fadeOutTime > 0) && (this.opacity > 0)) {
if ((fadeInTimeline != null) && (!fadeInTimeline.isDone()))
fadeInTimeline.cancel();
......
......@@ -35,7 +35,6 @@ import java.util.List;
public abstract class SelectableCorona extends FadingCorona {
protected boolean isSelected;
protected int index;
protected boolean isLatching;
protected List<SelectionListener> listeners;
// ---------------------------------------------------------------------------
......@@ -51,7 +50,6 @@ public abstract class SelectableCorona extends FadingCorona {
public SelectableCorona(BaseSelectableCoronaBuilder<?> builder) {
super(builder);
index = builder.index;
isLatching = builder.isLatching;
listeners = new ArrayList<>();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment