Commit f3ca1ac0 authored by David's avatar David

Lots of comment clean up

parent 59e74014
......@@ -50,7 +50,6 @@ open class TickerEntry<out T : Node>(
*/
class TickerView : View() {
private val sampleText = "What is going on? How did this get added to the pane? It shouldn't have."
private val logger = KotlinLogging.logger {}
private val marqueeView: MarqueeView by inject()
......@@ -94,7 +93,7 @@ class TickerView : View() {
}
}
val cpuTemp = object : TickerEntry<Text>(title = "CPU Temp", content = createText("88${DEGREE}C"), reschedule = true) {
val cpuTemp = object : TickerEntry<Text>(title = "CPU Temp", content = createText("88.0${DEGREE}C"), reschedule = true) {
val temperatureFile = Paths.get("/sys/class/thermal/thermal_zone0/temp").toFile()
override fun updateObservable(): Completable? {
......@@ -112,7 +111,7 @@ class TickerView : View() {
it.toDouble().div(1000)
}
.doOnNextFx {
content.text = "%.2f%sC".format(it, DEGREE)
content.text = "%.1f%sC".format(it, DEGREE)
}
.ignoreElements()
}
......@@ -126,9 +125,6 @@ class TickerView : View() {
currentTime,
TickerEntry<Node>("blorp", createText("Third!")),
TickerEntry<Node>("blerp", createText("this is the second")),
//time as TickerEntry<Node>,
//TickerEntry<Node>("test", createText(sampleText)),
//TickerEntry<Node>("more", createText("Some more words")),
TickerEntry<Node>("another", createText("This is happening")),
TickerEntry<Node>("time", createText(ZonedDateTime.now().format(DateTimeFormatter.ISO_ZONED_DATE_TIME))),
cpuTemp
......@@ -164,15 +160,18 @@ class MarqueeView : View() {
private val logger = KotlinLogging.logger {}
private val OFFSET = 5.0 //Amount of space between entries!
data class ActiveTick(val entry: TickerEntry<Node>, var cleared: Boolean = false)
private data class ActiveTick(val entry: TickerEntry<Node>, var cleared: Boolean = false)
private val activeTicks = ConcurrentLinkedQueue<ActiveTick>() //This might not need to be threadsafe, only one thing is adding/removing it
private val queuedTicks = ConcurrentLinkedQueue<TickerEntry<Node>>() //This one does, multiple threads!
private val pane: Pane = pane()
private val timeline = Timeline() //Timeline is up here in case I need to pause, play the animation
//TODO: on animation pause, should pause all the observables? maybe that doesn't matter
override val root = pane
//This is needed to make sure the pane fills up the entire space of whatever we've been put in.
fun inside(of: Pane) {
//I need this guy to autofill to max size
pane.prefWidthProperty().bind(of.widthProperty())
......@@ -183,8 +182,7 @@ class MarqueeView : View() {
val rectangle = Rectangle(25.0, 25.0)
//Need to figure out what size my clipping rectangle needs to be
//Bind the clipping to the size of the thing
rectangle.widthProperty().bind(root.widthProperty())
rectangle.heightProperty().bind(root.heightProperty())
root.clip = rectangle
......@@ -196,15 +194,9 @@ class MarqueeView : View() {
queuedTicks.add(entry)
}
//Will need to fire one of these for each thing, with some space detection, based on when one is ending.
//Fire up the animation process for the ticker
private fun startAnimation() {
//For each entry in the active ticks, animate it, until it's off th edge, and then drop it from the thing
//if there's space to add a queue'd tick, stick it in there
val timeline = Timeline()//Don't appear to need to unstart/restart this, it seems to not spinlock too bad
//TODO: this is kind of an expensive operation, should trigger only once...
//If it's already cleared, don't keep checking
fun lastOneCleared(): Boolean {
//Determine if the last entry in the activeQueue has cleared
val last = activeTicks.last()
......@@ -218,36 +210,31 @@ class MarqueeView : View() {
return last.cleared
}
//Keep track of the things we've started, so we can dispose them
val subscriptions = HashMap<TickerEntry<Node>, Disposable>()
//I want any rendering delays to slow the whole thing, not just the individual item. Also then it's less threads
//Could also update this things speed time so that stuff scrolls faster
val updateFrame = KeyFrame(Duration.millis(35.0), EventHandler<ActionEvent> {
//This appears to move too fast!
//There's possible some thread bugs in there, but only on the very first creation
if (activeTicks.isEmpty() || lastOneCleared()) {
val newTickerEntry: TickerEntry<Node>? = queuedTicks.poll()
if (newTickerEntry != null) {
//Then just put it into the active queue, so it will start processing like normal
newTickerEntry.content.layoutX = root.prefWidth //Where to start
activeTicks.add(ActiveTick(newTickerEntry))
root.add(newTickerEntry.content) //this is where it gets added
//But I never remove them!?!? UH OH They get removed later
}
}
//Something isn't working out right here.
activeTicks.forEach { active ->
val entry = active.entry
val content = entry.content
//I don't intend to bounce this
val textWidth = content.layoutBounds.width
val layoutX = content.layoutX
//instead I want to move completely from the right all the way off until it's gone
//end state of this text is the entire width of the text off the right so layoutX <= 0 - textWidth - offset
//I don't think I need to do anything about this, only know when it's been moved off the end
//Check to see if it's been animated out.
if (layoutX <= 0 - textWidth - (2 * OFFSET)) {
logger.debug("ANIMATED ${entry.title} COMPLETELY OUT THE PANEL!")
//Now I ned to figure out how to remove it
......@@ -263,15 +250,16 @@ class MarqueeView : View() {
enqueueTickEntry(entry)
}
} else {
//It's not moved out, so move it a pixel. We could move it some number of pixels
content.layoutX = content.layoutX - 1 //TODO: I should probably do animation in larger chunks perhaps, so that it can use less CPU?
//If there's an observable that we haven't started, fire it up!
val updateObservable = entry.updateObservable()
if (updateObservable != null && !subscriptions.containsKey(entry)) {
//Start up the observable that updates the UI
//Start up the observable that updates the component, whatever it is
logger.debug("Starting observable for ${entry.title}")
val disposable = updateObservable.subscribe()
subscriptions[entry] = disposable
//Need a thing to track these with
}
}
}
......
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