Re: Skin layoutChildren: when to get bounds of child nodes?

2014-07-27 Thread Martin Sladecek
The super.layoutChildren should size every child of the control (which 
is VBox), but not child's children. The control must finish the layout 
before children can do theirs. If you need to do layout on some child 
before that, you can call .layout() on it. It will do it's layout using 
it's current size. You should have all the bounds correct after that call.


But that would not work in your case anyway. You have both childs in a 
HBox, which takes care of resizing the children. This means you need to 
layout the HBox to get children size and in order to do that, you need 
HBox to be at it's final size, which will happen during the VBox layout. 
So your steps would be:

1) super.layoutChildren() - VBox is resized to Controls content size
2) now the VBox is resized, you can call vbox.layout()
3) now HBox is resized, so call hbox.layout()
4) children are resized. They have correct layout bounds now. But in 
order to get correct boundsInParent (but maybe you really need layout 
bounds?), you need to call .layout() on children too.


Even if you do all these steps, calling setPrefWidth() on child2 marks 
the whole tree dirty again. Because HBox needs to resize child2 using 
it's new PrefWidth. This also means, HBox prefwidth will be different, 
so it's parent (VBox) must do the same. Ditto with the control. Also, 
the HBox (VBox, control) may not have enough size to resize child2 to 
it's pref width, so child1 might be shrinked as a result, which breaks 
your invariant. You are basically changing the input for HBox's layout 
(child2.pref size) based on it's output (child1 size), which makes this 
a loop.


So in order to really make this work, you need to manage the child nodes 
directly and compute your layout by yourself. This can be done either by 
using your own subclass of Pane and overriding it's layoutChildren. Or 
if you want to do everything in Skin's layoutChildren, you can make the 
children unmanaged, but then it doesn't really matter where they are in 
the scenegraph, HBox won't be managing them.


Hope this helps!

-Martin


On 25.7.2014 18:56, Richard Bair wrote:

Hmmm. The first question I have is whether boundsInParent is really what you 
want to use, vs. layout bounds. But assuming it is what you want, why are the 
bounds zero? This is during the layout pass, which is the right place to be 
doing what you’re doing. The super layoutChildren call will size everything 
based on the contentX, contentY, contentWidth, contentHeight 
(http://hg.openjdk.java.net/openjfx/8u-dev/rt/file/4b8d06211312/modules/controls/src/main/java/javafx/scene/control/SkinBase.java).
 Is it possible that the parent itself is size 0? boundsInParent should always 
be invalidated automatically whenever the width/height/transforms/etc changes. 
If not that is definitely a bug (that you can write a simple test case for to 
prove).

But my first guess is maybe the parent is size 0 as well, due to something else 
(maybe the pref size of the control is 0 to start with or something…)

Richard

On Jul 24, 2014, at 3:34 AM, Werner Lehmann  
wrote:


Hi,

inside a control skin I have the following code pattern:

  protected void layoutChildren(...)
  {
super.layoutChildren(...);

Node child1 = ...
Bounds bip = child1.getBoundsInParent();

if (!animating) {
  Node child2 = ...
  child2.setTranslateX(bip.getMinX();
  child2.setPrefWidth(bip.getWidth());
}
  }

The skin scene graph looks roughly like this:

VBox
  HBox { ..., child1, ...}
  child2
  ...

Everything is layouted just fine but I want to adjust child2.translateX and 
prefWidth based child1 bounds. This does not work initially because 
boundsInParent returns zero components leading to incorrect initial display of 
the control.

Seems as if boundsInParent is not yet updated. I guess I could use a binding 
for that but it would conflict with an animation I also have on translateX and 
prefWidth.

Maybe there is a better time to make those adjustments on child2?

Rgds
Werner




Re: Double.MAX_VALUE in CSS -fx-max-width?

2014-07-27 Thread David Grieve

Hi Werner,

Please file a bug. I'll have to update the parser to accept 'infinity' 
as a value.


On 7/24/14, 1:11 PM, Werner Lehmann wrote:

Hi,

since FX8 we have a styleable property -fx-max-width on Region. I'd 
like to use this to replace the FXML attribute




with CSS

-fx-max-width: Infinity;

This is actually a notation to achieve the equivalent of this code:

  node.setMaxWidth(Double.MAX_VALUE);

Unfortunately it does not work like this in css. Normal values are 
accepted and seem to work but not this one. Maybe there is some 
special handing in the FXMLLoader to treat Infinity like MAX_VALUE? In 
any case, can this be done in css - maybe with a different workaround?


Rgds
Werner




Re: Regarding issue with JavaFX 8 ScrollPane

2014-07-27 Thread Jonathan Giles

Sirish,

Try with 8u20 - I just did and it works as expected - the vertical 
scrollbar is at the bottom-most position. This looks like it was a bug 
fixed between 8u5 and 8u20.


-- Jonathan

On 28/07/2014 1:15 p.m., Mong Hang Vo wrote:

Vadala,

I don't have a good answer to your question. So I am adding the 
openjfx-dev@openjdk.java.net alias.


In the future, please send your question to this alias.

Thank you very much,
Mong

Vadala, Sirish wrote:


Hello Hang,



My name is Sirish Vadala, working for Legislative Data Center, 
Sacramento, California. Right now I am working on a project 
implemented on JavaFX 8 (jdk1.8.0_05) and have a quick question on 
one of the UI related issues that my team is facing.




Coming to the issue I am not able to programmatically place the 
ScrollPane's scroll position using setVValue(double) method of 
ScrollPane. For example, if you look at the sample program below, the 
vertical scroll bar position always remains on the top what so ever 
the vValue is set to. Can you please let me know if this is an 
existing issue being worked on or if I am doing something wrong in 
implementation?




I highly appreciate your response at your convenience on this issue.



import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import java.util.logging.Level;

import java.util.logging.Logger;

import javafx.application.Application;

import javafx.embed.swing.SwingFXUtils;

import javafx.event.ActionEvent;

import javafx.event.EventHandler;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.ScrollPane;

import javafx.scene.control.ScrollPane.ScrollBarPolicy;

import javafx.scene.image.Image;

import javafx.scene.image.ImageView;

import javafx.scene.layout.VBox;

import javafx.stage.FileChooser;

import javafx.stage.Stage;

import javax.imageio.ImageIO;

public class JavaFXPixel extends Application {


private ImageView myImageView;

private ScrollPane scrollPane;


@Override

public void start(Stage primaryStage) {


Button btnLoad = new Button("Load");

btnLoad.setOnAction(btnLoadEventListener);


myImageView = new ImageView();


scrollPane = new ScrollPane();

scrollPane.setPrefSize(300, 250);

scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);

scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);

scrollPane.setContent(myImageView);


   // STILL MY VERTICAL SCROLL POSITION IS ALWAYS PLACED ON THE TOP

scrollPane.setVvalue(1.0);


VBox rootBox = new VBox();

rootBox.getChildren().addAll(btnLoad, scrollPane);


Scene scene = new Scene(rootBox, 300, 300);


primaryStage.setTitle("My Test Program");

primaryStage.setScene(scene);

primaryStage.show();


}

public static void main(String[] args) {

launch(args);

}


private final EventHandler btnLoadEventListener = 
(ActionEvent t) -> {


FileChooser fileChooser = new FileChooser();


//Set extension filter

FileChooser.ExtensionFilter extFilterJPG = new 
FileChooser.ExtensionFilter("JPG files (*.jpg)", "*.JPG");


FileChooser.ExtensionFilter extFilterPNG = new 
FileChooser.ExtensionFilter("PNG files (*.png)", "*.PNG");


fileChooser.getExtensionFilters().addAll(extFilterJPG, 
extFilterPNG);



//Show open file dialog

File file = fileChooser.showOpenDialog(null);


try {

BufferedImage bufferedImage = ImageIO.read(file);

Image image = SwingFXUtils.toFXImage(bufferedImage, null);

myImageView.setImage(image);

scrollPane.setContent(null);

scrollPane.setContent(myImageView);

scrollPane.setVvalue(1.0);

} catch (IOException ex) {

Logger.getLogger(JavaFXPixel.class.getName()).log(Level.SEVERE, null, 
ex);


}

};

}



Thanks.

Sirish Vadala

916 341 8878







Re: Regarding issue with JavaFX 8 ScrollPane

2014-07-27 Thread Mong Hang Vo

Vadala,

I don't have a good answer to your question. So I am adding the 
openjfx-dev@openjdk.java.net alias.


In the future, please send your question to this alias.

Thank you very much,
Mong

Vadala, Sirish wrote:


Hello Hang,

 

My name is Sirish Vadala, working for Legislative Data Center, 
Sacramento, California. Right now I am working on a project 
implemented on JavaFX 8 (jdk1.8.0_05) and have a quick question on one 
of the UI related issues that my team is facing.


 

Coming to the issue I am not able to programmatically place the 
ScrollPane's scroll position using setVValue(double) method of 
ScrollPane. For example, if you look at the sample program below, the 
vertical scroll bar position always remains on the top what so ever 
the vValue is set to. Can you please let me know if this is an 
existing issue being worked on or if I am doing something wrong in 
implementation?


 


I highly appreciate your response at your convenience on this issue.

 


import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import java.util.logging.Level;

import java.util.logging.Logger;

import javafx.application.Application;

import javafx.embed.swing.SwingFXUtils;

import javafx.event.ActionEvent;

import javafx.event.EventHandler;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.ScrollPane;

import javafx.scene.control.ScrollPane.ScrollBarPolicy;

import javafx.scene.image.Image;

import javafx.scene.image.ImageView;

import javafx.scene.layout.VBox;

import javafx.stage.FileChooser;

import javafx.stage.Stage;

import javax.imageio.ImageIO;

public class JavaFXPixel extends Application {




private ImageView myImageView;

private ScrollPane scrollPane;




@Override

public void start(Stage primaryStage) {




Button btnLoad = new Button("Load");

btnLoad.setOnAction(btnLoadEventListener);




myImageView = new ImageView();




scrollPane = new ScrollPane();

scrollPane.setPrefSize(300, 250);

scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);

scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);

scrollPane.setContent(myImageView);

   


   // STILL MY VERTICAL SCROLL POSITION IS ALWAYS PLACED ON THE TOP

scrollPane.setVvalue(1.0);

   


VBox rootBox = new VBox();

rootBox.getChildren().addAll(btnLoad, scrollPane);




Scene scene = new Scene(rootBox, 300, 300);




primaryStage.setTitle("My Test Program");

primaryStage.setScene(scene);

primaryStage.show();

   


}

public static void main(String[] args) {

launch(args);

}



private final EventHandler btnLoadEventListener = 
(ActionEvent t) -> {


FileChooser fileChooser = new FileChooser();

   


//Set extension filter

FileChooser.ExtensionFilter extFilterJPG = new 
FileChooser.ExtensionFilter("JPG files (*.jpg)", "*.JPG");


FileChooser.ExtensionFilter extFilterPNG = new 
FileChooser.ExtensionFilter("PNG files (*.png)", "*.PNG");


fileChooser.getExtensionFilters().addAll(extFilterJPG, 
extFilterPNG);


   


//Show open file dialog

File file = fileChooser.showOpenDialog(null);

   


try {

BufferedImage bufferedImage = ImageIO.read(file);

Image image = SwingFXUtils.toFXImage(bufferedImage, null);

myImageView.setImage(image);

scrollPane.setContent(null);

scrollPane.setContent(myImageView);

scrollPane.setVvalue(1.0);

} catch (IOException ex) {


Logger.getLogger(JavaFXPixel.class.getName()).log(Level.SEVERE, null, ex);


}

};

}

 


Thanks.

Sirish Vadala

916 341 8878





Re: 8u20 broken in OS X Yosemite?

2014-07-27 Thread Scott Palmer
Just to follow up.. things are not as dire as I initially thought.  After a
reboot my application is working much better.


On Sun, Jul 27, 2014 at 12:59 PM, Scott Palmer  wrote:

> Is anyone testing on Yosemite?  I installed the Yosemite public beta and
> am running with 8u20 b23 (also tested with 8u11, same results)
>
> Without violating my Beta Agreement with Apple, lets just say that I
> strongly suggest that someone at Oracle try it out and perhaps focus on:
> -AudioClips
> -MediaPlayer
> -Animation performance
>
> Scott
>


Re: JavaFX embedded (jre 8u6): touch problem (malformed multi touch event)

2014-07-27 Thread Daniel Blaukopf
We are in the process of moving this application into the openjfx repository.

On Jul 27, 2014, at 1:03 PM, Seeon Birger  wrote:

> You can use this one which is more suitable for testing multi-touch:
> rt-closed/toys/HelloWorld/src/helloworld/HelloMultitouch.java
> 
> Also note that if using Monocle you'll have to apply the patch referenced in 
> this JIRA:
> RT-37950 - Wrong touch coordinates for a window not at the origin (0,0)
> 
> 
> Regards,
> Seeon
> 
> 
> 
> -Original Message-
> From: Lisa Selle 
> Sent: Friday, 25 July 2014 18:43
> To: Prasant J
> Cc: openjfx-dev@openjdk.java.net
> Subject: Re: JavaFX embedded (jre 8u6): touch problem (malformed multi touch 
> event)
> 
> Daniel,
> 
> Do you have any other suggestions for apps that we know handle multitouch 
> correctly that Prasant could use to determine if his multitouch problem is in 
> the platform or in his app?
> 
> Thanks,
> 
> Lisa
> On 7/25/2014 11:42 AM, Lisa Selle wrote:
>> rt//apps/toys/Hello/ has HelloGestures which uses multitouch gestures.  
>> I'm not aware of any others, but maybe someone else on the list has 
>> some input there?  I will inquire internally also.
>> 
>> Thanks,
>> 
>> Lisa
>> On 7/25/2014 11:20 AM, Prasant J wrote:
>>> Hi Lisa,
>>> 
>>> Can you please point out to me a javafx application that can help me 
>>> test my multi touch?
>>> 
>>> I want to rule out my application out of my multi touch test, so a 
>>> standard multi touch test will be of help to me.
>>> 
>>> Regards, Prasant
>>> 
>>> 
>>> On Fri, Jul 25, 2014 at 7:47 PM, Lisa Selle 
>>> wrote:
 On 7/25/2014 10:06 AM, Prasant J wrote:
> On Wed, Jul 23, 2014 at 6:36 PM, Lisa Selle 
> wrote:
>> Hi Prasant,
>> 
>> This looks suspiciously related to 
>> https://javafx-jira.kenai.com/browse/RT-34296.  If so, this bug
>> *should*
>> be
>> fixed in Monocle but it is not (and will not be) fixed in lens.
>> 
> Thanks Lisa for pointing that out.
> First I tried to build the openjfx 8u6 (you pasted a link in 
> another
> post) with the patch someone posted in the RT-34296 jira post.
> 
> The patch had to be manually applied because it was created from a 
> different changeset. Anyway, I was able to apply the patch and 
> cross build successfully. However, only one touch was working. 
> Second touch is not working (I could not figure out). The single 
> touch is also sending two events and my application has different 
> behaviour for one event and two events. So, I abandoned this idea 
> and I;m building the latest javafx.
> 
>> I believe you are building openJFX, correct?  If you can try a 
>> recent build with the latest Monocle code (if you are building 
>> from OpenJFX, monocle is now the default) the problem should be 
>> resolved. Please let us know if that's not the case.
>> 
> I was able to build from 8u-dev/rt (tag: 8u20-b23). However my 
> application is recognizing the touch only on the main window. I 
> have multi-touch in the pop-up window where even single touch in 
> not working from some reason.
> 
> Whenever I touch to bring up the pop-up window I get the following 
> error message on console:
> 
> Exception in thread "JavaFX Application Thread"
> java.lang.InstantiationError:
> com.sun.javafx.scene.traversal.TraversalEngine
>  at
> com.sun.javafx.scene.control.skin.ScrollPaneSkin.initialize(ScrollP
> aneSkin.java:242)
> 
>  at
> com.sun.javafx.scene.control.skin.ScrollPaneSkin.(ScrollPaneS
> kin.java:130)
> 
>  at
> javafx.scene.control.ScrollPane.createDefaultSkin(ScrollPane.java:579)
>  at
> javafx.scene.control.Control.impl_processCSS(Control.java:878)
>  at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
>  at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
>  at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
>  at javafx.scene.Node.processCSS(Node.java:8858)
>  at javafx.scene.Node.processCSS(Node.java:8851)
>  at javafx.scene.Node.processCSS(Node.java:8851)
>  at javafx.scene.Scene.doCSSPass(Scene.java:525)
>  at javafx.scene.Scene.access$3400(Scene.java:144)
>  at
> javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2358)
>  at
> com.sun.javafx.tk.Toolkit.lambda$runPulse$28(Toolkit.java:314)
>  at
> com.sun.javafx.tk.Toolkit$$Lambda$354/20040469.run(Unknown
> Source)
>  at java.security.AccessController.doPrivileged(Native
> Method)
>  at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:313)
>  at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:340)
>  at
> com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:
> 451)
> 
>  at
> com.sun.java

8u20 broken in OS X Yosemite?

2014-07-27 Thread Scott Palmer
Is anyone testing on Yosemite?  I installed the Yosemite public beta and am
running with 8u20 b23 (also tested with 8u11, same results)

Without violating my Beta Agreement with Apple, lets just say that I
strongly suggest that someone at Oracle try it out and perhaps focus on:
-AudioClips
-MediaPlayer
-Animation performance

Scott


RE: JavaFX embedded (jre 8u6): touch problem (malformed multi touch event)

2014-07-27 Thread Seeon Birger
You can use this one which is more suitable for testing multi-touch:
rt-closed/toys/HelloWorld/src/helloworld/HelloMultitouch.java

Also note that if using Monocle you'll have to apply the patch referenced in 
this JIRA:
RT-37950 - Wrong touch coordinates for a window not at the origin (0,0)


Regards,
Seeon



-Original Message-
From: Lisa Selle 
Sent: Friday, 25 July 2014 18:43
To: Prasant J
Cc: openjfx-dev@openjdk.java.net
Subject: Re: JavaFX embedded (jre 8u6): touch problem (malformed multi touch 
event)

Daniel,

Do you have any other suggestions for apps that we know handle multitouch 
correctly that Prasant could use to determine if his multitouch problem is in 
the platform or in his app?

Thanks,

Lisa
On 7/25/2014 11:42 AM, Lisa Selle wrote:
> rt//apps/toys/Hello/ has HelloGestures which uses multitouch gestures.  
> I'm not aware of any others, but maybe someone else on the list has 
> some input there?  I will inquire internally also.
>
> Thanks,
>
> Lisa
> On 7/25/2014 11:20 AM, Prasant J wrote:
>> Hi Lisa,
>>
>> Can you please point out to me a javafx application that can help me 
>> test my multi touch?
>>
>> I want to rule out my application out of my multi touch test, so a 
>> standard multi touch test will be of help to me.
>>
>> Regards, Prasant
>>
>>
>> On Fri, Jul 25, 2014 at 7:47 PM, Lisa Selle 
>> wrote:
>>> On 7/25/2014 10:06 AM, Prasant J wrote:
 On Wed, Jul 23, 2014 at 6:36 PM, Lisa Selle 
 wrote:
> Hi Prasant,
>
> This looks suspiciously related to 
> https://javafx-jira.kenai.com/browse/RT-34296.  If so, this bug
> *should*
> be
> fixed in Monocle but it is not (and will not be) fixed in lens.
>
 Thanks Lisa for pointing that out.
 First I tried to build the openjfx 8u6 (you pasted a link in 
 another
 post) with the patch someone posted in the RT-34296 jira post.

 The patch had to be manually applied because it was created from a 
 different changeset. Anyway, I was able to apply the patch and 
 cross build successfully. However, only one touch was working. 
 Second touch is not working (I could not figure out). The single 
 touch is also sending two events and my application has different 
 behaviour for one event and two events. So, I abandoned this idea 
 and I;m building the latest javafx.

> I believe you are building openJFX, correct?  If you can try a 
> recent build with the latest Monocle code (if you are building 
> from OpenJFX, monocle is now the default) the problem should be 
> resolved. Please let us know if that's not the case.
>
 I was able to build from 8u-dev/rt (tag: 8u20-b23). However my 
 application is recognizing the touch only on the main window. I 
 have multi-touch in the pop-up window where even single touch in 
 not working from some reason.

 Whenever I touch to bring up the pop-up window I get the following 
 error message on console:

 Exception in thread "JavaFX Application Thread"
 java.lang.InstantiationError:
 com.sun.javafx.scene.traversal.TraversalEngine
   at
 com.sun.javafx.scene.control.skin.ScrollPaneSkin.initialize(ScrollP
 aneSkin.java:242)

   at
 com.sun.javafx.scene.control.skin.ScrollPaneSkin.(ScrollPaneS
 kin.java:130)

   at
 javafx.scene.control.ScrollPane.createDefaultSkin(ScrollPane.java:579)
   at
 javafx.scene.control.Control.impl_processCSS(Control.java:878)
   at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
   at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
   at javafx.scene.Parent.impl_processCSS(Parent.java:1267)
   at javafx.scene.Node.processCSS(Node.java:8858)
   at javafx.scene.Node.processCSS(Node.java:8851)
   at javafx.scene.Node.processCSS(Node.java:8851)
   at javafx.scene.Scene.doCSSPass(Scene.java:525)
   at javafx.scene.Scene.access$3400(Scene.java:144)
   at
 javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2358)
   at
 com.sun.javafx.tk.Toolkit.lambda$runPulse$28(Toolkit.java:314)
   at
 com.sun.javafx.tk.Toolkit$$Lambda$354/20040469.run(Unknown
 Source)
   at java.security.AccessController.doPrivileged(Native
 Method)
   at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:313)
   at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:340)
   at
 com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:
 451)

   at
 com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:
 431)

   at
 com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$363(Quan
 tumToolkit.java:298)

   at
 com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$71/28758344.run(Un
>>>