Skip to main content

Slow performance

3 replies [Last post]
mambobanda
Offline
Joined: 2009-01-21

I've got a simple panel made entirely in javafx. I have a main frame also made in javafx, it is a custom node and the panel is part of the group it returns. My problem is that dragging the panel around makes it very slow. Even animation is really slow. There really isn't much on the screen for things to be this slow. The panel is also a custom node. Even with out the main frame it is still a little laggy. Are there any tutorials or tips to optimize performance for thing like this.

Here is a screen shot: http://img98.imageshack.us/img98/3484/screenshotdl0.jpg

panel source:

import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.transform.*;
import javafx.animation.transition.*;
import swagger.util.events.Draggable;

/**
* @author Mambo
*/

public class Panel extends Widget
{
public var width:Number;
public var height:Number;

public var x:Number;
public var y:Number;

public var arc:Number;
public var barHeight:Number = 10;

public var bgColor:Color = Color.BEIGE;
public var bgOpacity:Number = 1.0;

var frame = Rectangle
{
//cache:true
width: bind width
height: bind height
arcWidth: bind arc;
arcHeight:bind arc;
fill:bind bgColor;
opacity: bind bgOpacity
}

var bar = Rectangle
{
//cache:true
width: bind width;
height: arc
opacity: bind bgOpacity
}

init
{
//cache = true;
var drag = Draggable{}

drag.makeDraggable(this, bar);
translateX = x;
translateY = y;

var transTransition = TranslateTransition {
duration: 2s node: this
byX: 200 repeatCount:4 autoReverse: true
}
transTransition.play();
}

public override function create(): Node
{

return Group
{
cache:true
content: [frame, bar]
};
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
aski
Offline
Joined: 2007-06-27

Hi,

I tried to check the code in my environment
But I saw the lib containing the swagger.util.events.Draggable; class is missing.

I'm using JFX SDK 1.0 Update1, NetBeans 6.5 incl. Plugin for Java FX.
I don't have any (major) problems, preventing me developing JFX applications.

If you want to drag a Node, see the sample provided at Javafx.com. I remember well to saw such one there.

Regards,
Asghar

aski
Offline
Joined: 2007-06-27

Here the mentioned link
http://www.javafx.com/samples/DragAndDrop/index.html
It shows how easily add dragging behavior to graphics nodes (here an image) by using just a few lines of code.

mambobanda
Offline
Joined: 2009-01-21

Thanks. The problem wasn't the dragging but the gradient for the background. Once I cached it things were smooth once again. There still was some lagging, that was due to the StageStyle being transparent. With that turned of things are smooth. I still don't know the reason for that.