-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#150: adds an experimental implementation to replace BlockViewPane
ChunkListView exploits ListView features and enables LogoRRR to handle bigger log files as well
- Loading branch information
1 parent
8a3dc79
commit 1911310
Showing
11 changed files
with
430 additions
and
167 deletions.
There are no files selected for viewing
98 changes: 20 additions & 78 deletions
98
app/src/main/scala/app/logorrr/views/block/BlockImage.scala
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 |
---|---|---|
@@ -1,102 +1,44 @@ | ||
package app.logorrr.views.block | ||
|
||
import app.logorrr.model.LogEntry | ||
import app.logorrr.util.{CanLog, ColorUtil, JfxUtils} | ||
import app.logorrr.util.{CanLog, ColorUtil} | ||
import app.logorrr.views.search.Filter | ||
import javafx.beans.property.{SimpleIntegerProperty, SimpleListProperty, SimpleObjectProperty} | ||
import javafx.beans.value.ChangeListener | ||
import javafx.beans.{InvalidationListener, Observable} | ||
import javafx.beans.property.{ReadOnlyDoubleProperty, SimpleIntegerProperty, SimpleListProperty, SimpleObjectProperty} | ||
import javafx.scene.image.WritableImage | ||
import javafx.scene.paint.Color | ||
|
||
import scala.jdk.CollectionConverters.CollectionHasAsScala | ||
|
||
object BlockImage { | ||
|
||
/** width is constrained by the maximum texture width which is set to 4096 */ | ||
val MaxWidth = 4096 | ||
|
||
/** max height of a single SQView, constrained by maximum texture height (4096) */ | ||
val MaxHeight = 4096 | ||
val MaxHeight = 100 | ||
val Height = 100 | ||
|
||
} | ||
|
||
|
||
class BlockImage(name: String | ||
, widthProperty: SimpleIntegerProperty | ||
, widthProperty: ReadOnlyDoubleProperty | ||
, blockSizeProperty: SimpleIntegerProperty | ||
, entriesProperty: java.util.List[LogEntry] | ||
, entries: java.util.List[LogEntry] | ||
, filtersProperty: SimpleListProperty[Filter] | ||
, selectedElemProperty: SimpleObjectProperty[LogEntry]) extends CanLog { | ||
|
||
private var lpb: LPixelBuffer = _ | ||
/** | ||
* height property is calculated on the fly depending on the blockwidth/blockheight, | ||
* width of BlockImage, number of elements and max size of possible of texture (4096). | ||
* */ | ||
val heightProperty: SimpleIntegerProperty = new SimpleIntegerProperty() | ||
|
||
val imageProperty = new SimpleObjectProperty[WritableImage]() | ||
|
||
private val heightListener: ChangeListener[Number] = JfxUtils.onNew[Number](height => { | ||
// logTrace("heightListener " + height) | ||
setImage(getWidth, height.intValue) | ||
}) | ||
|
||
private val blockSizeListener: InvalidationListener = (_: Observable) => { | ||
repaint("blockSizeListener") | ||
, selectedElemProperty: SimpleObjectProperty[LogEntry] | ||
, heightProperty: SimpleIntegerProperty) | ||
extends WritableImage(LPixelBuffer(name | ||
, widthProperty.get().toInt | ||
, heightProperty.get() | ||
, blockSizeProperty | ||
, entries | ||
, filtersProperty | ||
, selectedElemProperty | ||
, Array.fill((widthProperty.get() * heightProperty.get()).toInt)(ColorUtil.toARGB(Color.WHITE)))) with CanLog { | ||
|
||
def draw(i: Int, color: Color): Unit = { | ||
logError("implement me") | ||
} | ||
|
||
val widthListener: ChangeListener[Number] = JfxUtils.onNew[Number](_ => { | ||
repaint("widthListener") | ||
}) | ||
|
||
init() | ||
|
||
def init(): Unit = { | ||
addListener() | ||
} | ||
|
||
|
||
def shutdown(): Unit = { | ||
lpb = null | ||
// just wipe out everything (?!) | ||
imageProperty.set(null) | ||
removeListener() | ||
} | ||
|
||
|
||
def addListener(): Unit = { | ||
heightProperty.addListener(heightListener) | ||
widthProperty.addListener(widthListener) | ||
blockSizeProperty.addListener(blockSizeListener) | ||
} | ||
|
||
def removeListener(): Unit = { | ||
heightProperty.removeListener(heightListener) | ||
widthProperty.removeListener(widthListener) | ||
blockSizeProperty.removeListener(blockSizeListener) | ||
logError("implement me") | ||
} | ||
|
||
|
||
private def setImage(width: Int, height: Int): Unit = { | ||
lpb = LPixelBuffer(width | ||
, height | ||
, blockSizeProperty | ||
, entriesProperty | ||
, filtersProperty | ||
, selectedElemProperty | ||
, Array.fill(width * height)(ColorUtil.toARGB(Color.WHITE))) | ||
this.imageProperty.set(new WritableImage(lpb)) | ||
} | ||
|
||
// todo check visibility | ||
def repaint(ctx: String): Unit = Option(lpb).foreach(_.repaint(ctx, filtersProperty.asScala.toSeq, selectedElemProperty.get())) | ||
|
||
def setHeight(height: Int): Unit = heightProperty.set(height) | ||
|
||
def getWidth: Int = widthProperty.get() | ||
|
||
def draw(i: Int, color: Color): Unit = lpb.draw(i, color) | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package app.logorrr.views.block | ||
|
||
import app.logorrr.model.LogEntry | ||
|
||
import scala.collection.mutable.ListBuffer | ||
|
||
object Chunk { | ||
|
||
/** creates a list of LogEntries with the given size */ | ||
def mkTestLogEntries(size: Int): java.util.List[LogEntry] = { | ||
val entries = { | ||
(0 until size).foldLeft(new java.util.ArrayList[LogEntry]())((acc, e) => { | ||
acc.add(LogEntry(e, s"t $e", None)) | ||
acc | ||
}) | ||
} | ||
entries | ||
} | ||
|
||
def mkTestChunks(nrEntries: Int | ||
, width: Int | ||
, height: Int | ||
, blocksize: Int): Seq[Chunk] = { | ||
val entries = mkTestLogEntries(nrEntries) | ||
mkChunks(entries, width, height, blocksize) | ||
} | ||
|
||
def mkChunks(entries: java.util.List[LogEntry] | ||
, width: Double | ||
, height: Double | ||
, blocksize: Int): Seq[Chunk] = { | ||
if (width != 0 && blocksize != 0) { | ||
// nr of chunks is calculated as follows: | ||
// how many entries fit into a chunk? | ||
// given their size and the width and height of a chunk it is easy to calculate. | ||
val cols = (width / blocksize).toInt | ||
val rows = (height / blocksize).toInt | ||
val nrElements = rows * cols | ||
|
||
val entriesSize = entries.size() | ||
var curIndex = 0 | ||
val lb = new ListBuffer[Chunk] | ||
|
||
while (curIndex < entriesSize) { | ||
val end = if (curIndex + nrElements < entriesSize) { | ||
curIndex + nrElements | ||
} else { | ||
entriesSize | ||
} | ||
val blockViewEntries = entries.subList(curIndex, end) | ||
if (blockViewEntries.size() > 0) { | ||
lb.addOne(Chunk(blockViewEntries)) | ||
} | ||
curIndex = curIndex + nrElements | ||
} | ||
lb.toSeq | ||
} else { | ||
Seq() | ||
} | ||
|
||
} | ||
} | ||
|
||
case class Chunk(entries: java.util.List[LogEntry]) { | ||
require(!entries.isEmpty, "entries was empty") | ||
lazy val name = s"chunk:${entries.get(0).lineNumber}_${entries.get(entries.size() - 1).lineNumber}" | ||
} |
Oops, something went wrong.