<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
The updateItem docs [1] already say this. I had missed that the test
program didn't do this, so thanks to Ajit for pointing it out.<br>
<br>
And yes, <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8090254">https://bugs.openjdk.org/browse/JDK-8090254</a> should be
closed as not an issue with a reference to the doc bug that
clarified this.<br>
<br>
-- Kevin<br>
<br>
[1]
<a class="moz-txt-link-freetext" href="https://download.java.net/java/early_access/javafx21/docs/api/javafx.controls/javafx/scene/control/Cell.html#updateItem(T,boolean)">https://download.java.net/java/early_access/javafx21/docs/api/javafx.controls/javafx/scene/control/Cell.html#updateItem(T,boolean)</a><br>
<br>
<div class="moz-cite-prefix">On 7/12/2023 7:50 AM, Andy Goryachev
wrote:<br>
</div>
<blockquote type="cite" cite="mid:DM5PR1001MB21722C85C7676C89EF724F59E536A@DM5PR1001MB2172.namprd10.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:Helvetica;
panose-1:0 0 0 0 0 0 0 0 0 0;}@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:"Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:"Iosevka Fixed SS16";
panose-1:2 0 5 9 3 0 0 0 0 4;}@font-face
{font-family:"Times New Roman \(Body CS\)";
panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
{font-family:"\@Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
{font-family:"Iosevka Fixed SS16 ";
panose-1:2 0 5 9 3 0 0 0 0 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}h3
{mso-style-priority:9;
mso-style-link:"Heading 3 Char";
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:13.5pt;
font-family:"Calibri",sans-serif;
font-weight:bold;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}span.apple-converted-space
{mso-style-name:apple-converted-space;}span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Iosevka Fixed SS16";
color:windowtext;}span.Heading3Char
{mso-style-name:"Heading 3 Char";
mso-style-priority:9;
mso-style-link:"Heading 3";
font-family:"Calibri",sans-serif;
font-weight:bold;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}div.WordSection1
{page:WordSection1;}</style>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16"">Ajit is right - perhaps javadoc for updateItem()
should explicitly mention this?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16"">Also, perhaps
<a href="https://bugs.openjdk.org/browse/JDK-8090254" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8090254</a>
should be closed - we recently updated javadoc to read<o:p></o:p></span></p>
<h3 style="mso-margin-top-alt:20.4pt;margin-right:0in;margin-bottom:3.0pt;margin-left:0in;background:#ECEBEC"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Warning:
Nodes should not be inserted directly into the items list<o:p></o:p></span></h3>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16"">(this is a different issue altogether)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed
SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Ajit
Ghaisas <a class="moz-txt-link-rfc2396E" href="mailto:ajit.ghaisas@oracle.com"><ajit.ghaisas@oracle.com></a><br>
<b>Date: </b>Wednesday, July 12, 2023 at 02:26<br>
<b>To: </b>John Hendrikx
<a class="moz-txt-link-rfc2396E" href="mailto:john.hendrikx@gmail.com"><john.hendrikx@gmail.com></a><br>
<b>Cc: </b><a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a>, Andy Goryachev
<a class="moz-txt-link-rfc2396E" href="mailto:andy.goryachev@oracle.com"><andy.goryachev@oracle.com></a><br>
<b>Subject: </b>Re: ListView with ImageViews for
cells very bugged?<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt">Hi John,</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt">
This looks like a user code issue and not a JavaFX
bug.</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt">
Most of the vertical scrollbar issues that you have
mentioned get fixed by adding a call to
"super.updateItem(image, empty);" as a first call in
the cell factory method "<span style="color:black;background:white">protected void
updateItem(Image image, boolean empty)</span>”</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black;background:white">I
am seeing an exception when I scroll fully down and
then scroll up by clicking empty area on the vertical
scrollbar. This looks like a separate issue though.</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black;background:white">Regards,</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black;background:white">Ajit</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt;font-family:"Courier
New";color:#080808"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On
12-Jul-2023, at 5:18 AM, Andy Goryachev
<a class="moz-txt-link-rfc2396E" href="mailto:andy.goryachev@oracle.com"><andy.goryachev@oracle.com></a> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">Thank you for the code
sample, John!</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">Had to replace loading from
https:// to a local <a class="moz-txt-link-freetext" href="file://">file://</a>, but I do see some
of the issues you've mentioned (on macOS):</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">2), 5), and 6).</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">There is also a new issue:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">7) when the top of the cell
is outside of the view area, the image is not
shown at all (but the cell is sized
correctly).</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">All this is indeed weird.
Looks like the time is right to create a bug,
unless it's this one:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<table class="MsoNormalTable" style="width:15.0in;background:white;border-collapse:collapse" width="1440" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="width:12.0pt;border:none;border-bottom:solid
#C1C7D0
1.0pt;background:#EBECF0;padding:3.75pt
7.5pt 3.75pt 7.5pt" width="16" valign="top" nowrap="nowrap">
<p class="MsoNormal" style="margin-bottom:6.0pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#172B4D"><a href="https://bugs.openjdk.org/browse/JDK-8090254" moz-do-not-send="true"><span style="color:#0052CC">JDK-8090254</span></a></span><o:p></o:p></p>
</td>
<td style="border:none;border-bottom:solid
#C1C7D0
1.0pt;background:#EBECF0;padding:3.75pt
7.5pt 3.75pt 7.5pt" valign="top">
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#172B4D"><a href="https://bugs.openjdk.org/browse/JDK-8090254" moz-do-not-send="true"><span style="color:#0052CC">[ListView]
page up/down navigation doesn't
work, when items are large
(again!)</span></a></span><o:p></o:p></p>
</div>
</td>
</tr>
</tbody>
</table>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16"">-andy</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16""> </span><o:p></o:p></p>
</div>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt">From:<span class="apple-converted-space"> </span></span></b><span style="font-size:12.0pt">openjfx-dev
<a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev-retn@openjdk.org"><openjfx-dev-retn@openjdk.org></a> on
behalf of John Hendrikx
<a class="moz-txt-link-rfc2396E" href="mailto:john.hendrikx@gmail.com"><john.hendrikx@gmail.com></a><br>
<b>Date:<span class="apple-converted-space"> </span></b>Tuesday,
July 11, 2023 at 16:34<br>
<b>To:<span class="apple-converted-space"> </span></b><a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><br>
<b>Subject:<span class="apple-converted-space"> </span></b>Re:
ListView with ImageViews for cells very
bugged?</span><o:p></o:p></p>
</div>
<p><span style="font-size:9.0pt;font-family:Helvetica">I
said I'd do it tomorrow, but here is a full
example anyway with pre-loaded images, and
without external dependencies:<o:p></o:p></span></p>
<p><span style="font-size:9.0pt;font-family:Helvetica"> <o:p></o:p></span></p>
<p><span style="font-size:9.0pt;font-family:Helvetica">package
org.int4.sdui.ui;<br>
<br>
import javafx.application.Application;<br>
import javafx.scene.Scene;<br>
import javafx.scene.control.Button;<br>
import javafx.scene.control.ListCell;<br>
import javafx.scene.control.ListView;<br>
import javafx.scene.control.TextArea;<br>
import javafx.scene.image.Image;<br>
import javafx.scene.image.ImageView;<br>
import javafx.scene.layout.HBox;<br>
import javafx.scene.layout.Priority;<br>
import javafx.scene.layout.VBox;<br>
import javafx.stage.Stage;<br>
<br>
public class Main2 {<br>
<br>
public static void main(String[] args) {<br>
Application.launch(UI.class, args);<br>
}<br>
<br>
public static class UI extends Application
{<br>
<br>
@Override<br>
public void start(Stage primaryStage)
throws InterruptedException {<br>
Image image1 = new Image(<a href="https://picsum.photos/512/512" moz-do-not-send="true">"https://picsum.photos/512/512"</a>);<br>
Image image2 = new Image(<a href="https://picsum.photos/512/512" moz-do-not-send="true">"https://picsum.photos/512/512"</a>);<br>
<br>
TextArea prompt = new TextArea("a
flower on Mars");<br>
Button button = new Button("Submit");<br>
ListView<Image> listView = new
ListView<>();<br>
<br>
while(image1.isBackgroundLoading() ||
image2.isBackgroundLoading()) {<br>
Thread.sleep(100);<br>
}<br>
<br>
listView.getItems().addAll(image1,
image2);<br>
listView.setCellFactory(lv -> {<br>
final ImageView imageView = new
ImageView();<br>
<br>
return new ListCell<>() {<br>
protected void updateItem(Image
image, boolean empty) {<br>
if(empty) {<br>
setGraphic(null);<br>
}<br>
else {<br>
imageView.setImage(image);<br>
setGraphic(imageView);<br>
}<br>
}<br>
};<br>
});<br>
<br>
HBox hbox = new HBox() {{<br>
getChildren().addAll(<br>
new VBox() {{<br>
getChildren().addAll(prompt,
button);<br>
}},<br>
listView<br>
);<br>
}};<br>
<br>
HBox.setHgrow(listView,
Priority.ALWAYS);<br>
<br>
Scene scene = new Scene(hbox);<br>
<br>
primaryStage.setScene(scene);<br>
primaryStage.show();<br>
}<br>
}<br>
}<br>
<br>
<br>
<br>
<br>
<br>
--John<o:p></o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On 12/07/2023
01:17, Andy Goryachev wrote:</span><o:p></o:p></p>
</div>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 "">I'll need to
replicate this scenario to be able to
say anything definitive.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 "">Just by looking at
the cell factory code though, I suspect
there might be some async processing
around</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">new
ImageView(new Image(new<span class="apple-converted-space"> </span><br>
>
ByteArrayInputStream(imageHandle.getImageData()))));</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 "">which might cause the
issue.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 "">Could you try
pre-loading images?</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 "">-andy</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka
Fixed SS16 ""> </span><o:p></o:p></p>
</div>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid
#B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt">From:<span class="apple-converted-space"> </span></span></b><span style="font-size:12.0pt">openjfx-dev<span class="apple-converted-space"> </span><a href="mailto:openjfx-dev-retn@openjdk.org" moz-do-not-send="true"><openjfx-dev-retn@openjdk.org></a><span class="apple-converted-space"> </span>on
behalf of Kevin Rushforth<span class="apple-converted-space"> </span><a href="mailto:kevin.rushforth@oracle.com" moz-do-not-send="true"><kevin.rushforth@oracle.com></a><br>
<b>Date:<span class="apple-converted-space"> </span></b>Tuesday,
July 11, 2023 at 15:58<br>
<b>To:<span class="apple-converted-space"> </span></b><a href="mailto:openjfx-dev@openjdk.org" moz-do-not-send="true" class="moz-txt-link-freetext">openjfx-dev@openjdk.org</a><span class="apple-converted-space"> </span><a href="mailto:openjfx-dev@openjdk.org" moz-do-not-send="true"><openjfx-dev@openjdk.org></a><br>
<b>Subject:<span class="apple-converted-space"> </span></b>Re:
ListView with ImageViews for cells
very bugged?</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">What you
have should work, but will create
redundant images and<span class="apple-converted-space"> </span><br>
ImageView ojbects. The
recommendation is to create the
nodes (ImageView<span class="apple-converted-space"> </span><br>
in this case) in the constructor of
the cell factory and call setGraphic<span class="apple-converted-space"> </span><br>
with either null or that factory's
node.<br>
<br>
Having said that, I doubt that this
is related to the visual problems<span class="apple-converted-space"> </span><br>
you are seeing. Maybe Ajit or Andy
have some ideas.<br>
<br>
-- Kevin<br>
<br>
<br>
On 7/11/2023 3:50 PM, John Hendrikx
wrote:<br>
> I tend to avoid ListView,
because for some reason it seems to
just<span class="apple-converted-space"> </span><br>
> never do what I want unless
used for its mundane rows of text
use<span class="apple-converted-space"> </span><br>
> case. I so far always just
implemented my own skin for ListView
that<span class="apple-converted-space"> </span><br>
> deals with displays that have
many images that need to scroll<span class="apple-converted-space"> </span><br>
> smoothly, but...<br>
><br>
> Recently, I've again attempted
to use ListView, this time for
showing<span class="apple-converted-space"> </span><br>
> (so far) fixed size ImageViews
with images exactly 512x512 pixels
in<span class="apple-converted-space"> </span><br>
> size:<br>
><br>
> The cell factory looks like
this, which I think is a correct<span class="apple-converted-space"> </span><br>
> implementation:<br>
><br>
>
listView.setCellFactory(lv -> {<br>
> return new
ListCell<>() {<br>
> protected void
updateItem(ImageHandle imageHandle,
boolean<span class="apple-converted-space"> </span><br>
> empty) {<br>
> if(empty) {<br>
> setGraphic(null);<br>
> }<br>
> else {<br>
> try {<br>
> setGraphic(new
ImageView(new Image(new<span class="apple-converted-space"> </span><br>
>
ByteArrayInputStream(imageHandle.getImageData()))));<br>
> }<br>
> catch(IOException
e) {<br>
>
e.printStackTrace();<br>
> }<br>
> }<br>
> }<br>
> };<br>
> });<br>
><br>
> Now, this is with JavaFX
21-ea-24 (but also happens on 19).
I spotted<span class="apple-converted-space"> </span><br>
> the following IMHO bugs:<br>
><br>
> 1) When the ImageView is so
large that a single row is only
partially<span class="apple-converted-space"> </span><br>
> visible, the scrollbar is
incorrect (it shows a full bar, even
if half<span class="apple-converted-space"> </span><br>
> of a row is displayed).<br>
><br>
> 2) The vertical scrollbar
doesn't respond to a click in the
non-thumb<span class="apple-converted-space"> </span><br>
> area at all (you'd expect to
make it scroll a page up or down
that way)<br>
><br>
> 3) When jerkily resizing the
window, I can sometimes have a
vertical +<span class="apple-converted-space"> </span><br>
> horizontal scrollbar when
there's a full row visible +
anywhere from 0<span class="apple-converted-space"> </span><br>
> to 10 extra empty pixels
(probably the potential height of a<span class="apple-converted-space"> </span><br>
> horizontal scrollbar) with the
vertical scroll bar still visible.
The<span class="apple-converted-space"> </span><br>
> algorithm to hide the scrollbar
apparently is not deterministic and<span class="apple-converted-space"> </span><br>
> depends on mouse movement
speed.<br>
><br>
> 4) When a row is less than half
visible, scrolling the window down
to<span class="apple-converted-space"> </span><br>
> another ImageView will jump the
view and hide the first cell that<span class="apple-converted-space"> </span><br>
> should still be visible for the
bottom 0-49% of its height.<br>
><br>
> 5) It's possible to get the
vertical scroll bar in such a state
that<span class="apple-converted-space"> </span><br>
> it doesn't respond to the mouse
any more at all, even by dragging
the<span class="apple-converted-space"> </span><br>
> thumb. Some keyboard action
and mouse scrolling sometimes
restores it<span class="apple-converted-space"> </span><br>
> to relatively normal
functioning.<br>
><br>
> 6) Mouse wheel scrolling acts
weird. With one large cell visible
and<span class="apple-converted-space"> </span><br>
> two rows available, scrolling
only **down** on the mouse wheel
will<span class="apple-converted-space"> </span><br>
> scroll down, then jump back up,
and scroll down again... it's<span class="apple-converted-space"> </span><br>
> impossible to scroll all the
way down to get to a point where it
stops<span class="apple-converted-space"> </span><br>
> scrolling as it keeps jumping
back.<br>
><br>
> This is with ImageView's. I
suppose they're known to have
problems...<span class="apple-converted-space"> </span><br>
> but then I switched to a
Region, which contain an ImageView
with<span class="apple-converted-space"> </span><br>
> proper min/pref/max
implementations. This improved the
situation<span class="apple-converted-space"> </span><br>
> somewhat. The scrollbar was
much more reliable, but I still saw<span class="apple-converted-space"> </span><br>
> almost all of the above issues,
but somewhat more reliable than<span class="apple-converted-space"> </span><br>
> before. Still rows would
disappear when (for the most part)<span class="apple-converted-space"> </span><br>
> invisible, those and the jumps
of the view are just totally
unacceptable.<br>
><br>
> I'm not quite sure what to make
of this, it seems the control is not<span class="apple-converted-space"> </span><br>
> meant for arbitrary graphics.<br>
><br>
> --John<br>
><br>
><br>
><br>
> package org.int4.sdui.ui;<br>
><br>
> import
hs.mediasystem.util.image.ImageHandle;<br>
> import
hs.mediasystem.util.javafx.control.Containers;<br>
><br>
> import
java.io.ByteArrayInputStream;<br>
> import java.io.IOException;<br>
> import java.util.Base64;<br>
> import java.util.List;<br>
><br>
> import
javafx.application.Application;<br>
> import javafx.scene.Scene;<br>
> import
javafx.scene.control.Button;<br>
> import
javafx.scene.control.ListCell;<br>
> import
javafx.scene.control.ListView;<br>
> import
javafx.scene.control.TextArea;<br>
> import
javafx.scene.image.Image;<br>
> import
javafx.scene.image.ImageView;<br>
> import
javafx.scene.layout.HBox;<br>
> import
javafx.scene.layout.Priority;<br>
> import javafx.stage.Stage;<br>
><br>
> import
kong.unirest.core.Unirest;<br>
><br>
> public class Main {<br>
><br>
> public static void
main(String[] args) {<br>
>
Application.launch(UI.class, args);<br>
> }<br>
><br>
> public static class UI
extends Application {<br>
><br>
> @Override<br>
> public void start(Stage
primaryStage) {<br>
> TextArea prompt = new
TextArea("a flower on Mars");<br>
> Button button = new
Button("Submit");<br>
>
ListView<ImageHandle> listView
= new ListView<>();<br>
><br>
>
listView.setCellFactory(lv -> {<br>
> return new
ListCell<>() {<br>
> protected void
updateItem(ImageHandle imageHandle,
boolean<span class="apple-converted-space"> </span><br>
> empty) {<br>
> if(empty) {<br>
> setGraphic(null);<br>
> }<br>
> else {<br>
> try {<br>
> setGraphic(new
ImageView(new Image(new<span class="apple-converted-space"> </span><br>
>
ByteArrayInputStream(imageHandle.getImageData()))));<br>
> }<br>
> catch(IOException
e) {<br>
>
e.printStackTrace();<br>
> }<br>
> }<br>
> }<br>
> };<br>
> });<br>
><br>
> button.setOnAction(e
-> {<br>
> Txt2ImgResponse
response =
textToImage(prompt.getText());<br>
><br>
> for(String image :
response.images) {<br>
>
listView.getItems().add(new<span class="apple-converted-space"> </span><br>
>
InMemoryImageHandle(Base64.getDecoder().decode(image)));<br>
> }<br>
> });<br>
><br>
> HBox hbox =
Containers.hbox(Containers.vbox(prompt,
button),<span class="apple-converted-space"> </span><br>
> listView);<br>
><br>
> HBox.setHgrow(listView,
Priority.ALWAYS);<br>
><br>
> Scene scene = new
Scene(hbox);<br>
><br>
>
primaryStage.setScene(scene);<br>
> primaryStage.show();<br>
> }<br>
><br>
> private Txt2ImgResponse
textToImage(String prompt) {<br>
> return Unirest.post("<a href="http://127.0.0.1:7860/sdapi/v1/txt2img" moz-do-not-send="true" class="moz-txt-link-freetext">http://127.0.0.1:7860/sdapi/v1/txt2img</a>")<br>
> .body(new
Txt2Img(prompt, 5))<br>
>
.contentType("application/json")<br>
>
.asObject(Txt2ImgResponse.class)<br>
> .getBody();<br>
> }<br>
> }<br>
><br>
> static class
InMemoryImageHandle implements
ImageHandle {<br>
> private final byte[] data;<br>
><br>
> public
InMemoryImageHandle(byte[] data) {<br>
> this.data = data;<br>
> }<br>
><br>
> @Override<br>
> public byte[]
getImageData() {<br>
> return data;<br>
> }<br>
><br>
> @Override<br>
> public String getKey() {<br>
> return null;<br>
> }<br>
><br>
> @Override<br>
> public boolean
isFastSource() {<br>
> return true;<br>
> }<br>
> }<br>
><br>
> record Txt2Img(String prompt,
int steps) {}<br>
> record
Txt2ImgResponse(List<String>
images) {}<br>
> }<br>
><br>
><br>
></span><o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>