Drag event handling in JFXPanel has performance implications with expensive event handlers

We have a drag event handler that is a little expensive, takes something like 20ms. The respective code must be run in a synchronous manner however.
That is no problem in a pure JavaFX environment, as less drag events are created when CPU load is high.
However, when embedded into Swing using JFXPanel this adaptation doesn't kick in, lots of drag events are created and the application becomes sluggish.
Is there a way to mimic what JavaFX does in the JFXPanel scenario?
The code below is a self-contained example that demonstrates what I'm describing.
Some results I had:
-eventHandlerSleep=5 -noswing --> 128 drag events
-eventHandlerSleep=30 -noswing --> 46 drag events
-eventHandlerSleep=5  --> 136 drag events
-eventHandlerSleep=30  --> 135 drag events
{code}import java.util.Arrays;
import javax.swing.*;
import com.sun.glass.ui.Robot;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class DragHandlingTester {
    private static long EVENT_HANDLER_SLEEP = 30;
    public static void main(String[] args) {
        for (String arg : args) {
            if (arg.startsWith("-eventHandlerSleep=")) {
                EVENT_HANDLER_SLEEP = Long.parseLong(arg.split("=")[1]);
        if (Arrays.asList(args).contains("-noswing")) {
            Application.launch(JavaFXDragHandlingTestApp.class, args);
        } else {
            new SwingDragHandlingTestApp();
    static class SwingDragHandlingTestApp {
        SwingDragHandlingTestApp() {
            JFrame frame = new JFrame();
            final JFXPanel fxMainPanel = new JFXPanel();
            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    DragTestScene dragTestScene = new DragTestScene();
                    fxMainPanel.setScene(dragTestScene.createScene());
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.getContentPane().add(fxMainPanel);
            frame.setSize(800, 600);
            frame.setVisible(true);
    public static class JavaFXDragHandlingTestApp extends Application {
        @Override
        public void start(Stage primaryStage) {
            primaryStage.setWidth(800);
            primaryStage.setHeight(600);
            primaryStage.setX(0.0);
            primaryStage.setY(0.0);
            DragTestScene dragTestScene = new DragTestScene();
            primaryStage.setScene(dragTestScene.createScene());
            primaryStage.show();
    static class DragTestScene {
        private int drags = 0;
        public Scene createScene() {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        // after 1 second drag mouse across window
                        Thread.sleep(1000);
                        Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
                        robot.mouseMove(50, 50);
                        robot.mousePress(1);
                        for (int i = 20; i < 700; i = i + 5) {
                            robot.mouseMove(i, 50);
                            Thread.sleep(10);
                        robot.mouseRelease(1);
                    } catch (Exception e) {
                        e.printStackTrace();
            }).start();
            BorderPane borderPane = new BorderPane();
            borderPane.setOnMouseDragged(new EventHandler() {
                @Override
                public void handle(MouseEvent mouseEvent) {
                    drags++;
                    try {
                        Thread.sleep(EVENT_HANDLER_SLEEP);
                    } catch (InterruptedException ignored) {
                    System.out.println("Number of drag events: " + drags);
            return new Scene(borderPane);
{code}

Ok, I expected something like this to be the reason. We'll probably have to live with it.
My workaround right now is to use background tasks with an executor that has a single element queue handling the events in order, but rejecting any additional events as long as there is a queued event.
Still not the same performance as in JavaFX, but at least it's usable now.

Similar Messages

  • When i got firefox ready to drag to app folder, it has a circle with slash , how come???

    im ready to install the new fire fox, as i go thru process, i get to section were i have to drag firefox symbol to app folder, now the fire fox symbol has a circle with a slash thru circle on top of fire fox sybole, blocking firefox. i than drag it to folder but no luck , my finder tells me its not supported on this architecture. whats my problem?

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third party version of Firefox 4 that runs on OS X 10.4/10.5 and PPC Macs, for details see http://www.floodgap.com/software/tenfourfox
    If you prefer, you can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html

  • I don't get an option to rename a URL I drag to a folder that has a URL with the same name.

    Windows 7 asks me if I want to "Copy and Replace" or "Don't copy", but I get no option to keep both files. Is there a setting to change this?

    IE stores its favorites as separate files and folders on the hard drive and that makes it impossible to have multiple entries with the same name.<br />
    So you get the same behavior as with creating or saving files on the hard drive.
    Firefox uses an SQLite database file and that allows to store as many copies of the same URL as you want although links are used and there is only one actual entry if it is an exact copy (a click on the highlighted star on the location bar reveals this).<br />
    You can clearly see this if the URL is in the location bar, but not when you bookmark a link.
    If you want to replace or update a bookmark then you will have to edit that bookmark, either via the star in the location bar or in the Library or sidebar or bookmarks toolbar.

  • I can't be the only person who has this problem - when a month ends on a Saturday I can't drag events into the next month and instead have to cut and paste - a real pain in the butt. I thought there was something called "scroll" but I can't find that

    I can't be the only person who has this problem with iCal- when a month ends on a Saturday I can't drag events into the next month and instead have to cut and paste - a real pain in the butt. I thought there was something called "scroll" but I can't find that.

    Yeah that works, but, it involves a click on the event, a click on edit, a click on the date, keystrokes, plus, since you can't see the next month you have to have a calendar in front of you so as to put it to the right date. It's easier just to cut it and advance the month and paste it, once you are in the right month you can move it around helter skelter willy nilly no problems. Although now that you mention it I will try it, maybe it is easier than cut and paste as I don't really care about the date, as long as it gets moved into the right month I can drag it around all I want.

  • JavaFX drag events destroyed by window resize

    Hello,
    I've been having great success developing a drag-drop component for a JavaFX app, but I've run into an issue that has me completely stumped.
    Specifically, I create a component that can be dragged around inside an anchor pane.  That anchorpane is nested in a split pane, which is nested in another anchor pane (the control's root element).
    The issue can be described this way:
    Case #1:  If I start the application as a small window, I can reposition the control by dragging it around the screen as I please.
    Case #2: If I start the application and maximize the window, again, I can drag the control around the screen as I please.
    Case #3: If I start the application, drag the control around a bit, then resize the window, the drag event handling breaks as follows:
    1.  The control drag events will fire normally only within the bounds of the anchor pane's previous size.
    2.  The mouse cursor's drag icon changes as I pass in or out of those bounds
    I'm absolutely certain the anchorpane is resizing to match the parent window, otherwise Case #2 would not succeed.  I'm at a complete loss as to determine why the drag events don't fire within the bounds of the resized window after they've been fired within the bounds of it's previous size.
    Understand the mechanism I'm using to establish the drag handling:  Once the controller is instantiated and added to the scene, an event listener on the class's parentProperty fires to attach the drag event handling to the parent node.
    Previously, I was setting / clearing the drag handling on the parent node in the drag detection / drag dropped event handlers.  I had suspected that adding / removing drag events was causing the trouble and opted for this solution to ensure that the same event instance
    was being used each time.  Both methods have had the same result.
    If you want to see the UI in action, here's a youtube link (it does not demonstrate the problem I'm having):
    http://youtu.be/FJWRFN8xHFY
    Here's the code that I'm using, redacted for clarity:
    public class FileSystemNode extends AnchorPane {
        @FXML private AnchorPane fs_node_title;
        private FileSystemType mFsType;
        private Point2D mDragPoint;
        private EventHandler <MouseEvent> mNodeDragDetected;
        public FileSystemNode() {
            loadFxml();
            setId(mFsType.toString() + Double.toString(Math.random()));
        private void loadFxml() {
            FXMLLoader fxmlLoader = new FXMLLoader(
                    getClass().getResource("/FileSystemNode.fxml"));
            fxmlLoader.setRoot(this);
            fxmlLoader.setController(this);
            try {
                fxmlLoader.load();
                 parentProperty().addListener(new ChangeListener() {
                        @Override
                        public void changed(ObservableValue observable,
                                Object oldValue, Object newValue) {   
                            buildNodeDragHandlers();   
                            fs_node_title.setOnDragDetected(mNodeDragDetected);       
            } catch (IOException exception) {
                throw new RuntimeException(exception);
        public void relocateToPoint (Point2D p) {
            Point2D p2 = getParent().sceneToLocal(p);
            relocate (
                    (int) (p2.getX() - mDragPoint.getX()),
                    (int) (p2.getY() - mDragPoint.getY())
        public void buildNodeDragHandlers() {
            getParent().setOnDragOver(new EventHandler <DragEvent>() {
                //dragover to handle node dragging in the right pane view
                @Override
                public void handle(DragEvent event) {       
                    event.acceptTransferModes(TransferMode.ANY);
                    relocateToPoint(new Point2D( event.getSceneX(), event.getSceneY()));
                    event.consume();
            getParent().setOnDragDropped(new EventHandler <DragEvent> () {
                @Override
                public void handle(DragEvent event) {
                    event.setDropCompleted(true);
                    event.consume();
            //drag detection for node dragging
            mNodeDragDetected = new EventHandler <MouseEvent> () {
                @Override
                public void handle(MouseEvent event) {
                    mDragPoint = new Point2D(event.getX(), event.getY());
                            relocateToPoint(new Point2D(event.getSceneX(), event.getSceneY()));
                            ClipboardContent content = new ClipboardContent();
                            content.putString("node_drag");
                            startDragAndDrop (TransferMode.ANY).setContent(content);               
                            event.consume();                   

    Ok, I managed to reduce this even further to a single class that generates the entire application and drag events all at once.
    Copy / paste this into a new javaFX application to test it.  The case tests are:
    1.  drag/drop the "drag me!" label in the window's starting size
    2.  drag/drop the "drag me!" label only after resizing the window
    3.  Combine cases #1 and #2, dragging and dropping, resizing, then dragging and dropping again.
    In case 3, what happens for me is that the label cannot be dragged beyond the window's original bounds even though it's been resized to a larger size.
    If anyone with a better clue than I could try it and give me some thoughts, I'd certainly be appreciative.
    Thanks.
    import javafx.geometry.Point2D;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.input.ClipboardContent;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.input.TransferMode;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.Pane;
    import javafx.stage.Stage;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    public class Main extends Application {
        private AnchorPane node_root;
        private BorderPane mRoot;
        @Override
        public void start(Stage primaryStage) {
            try {
                node_root = new AnchorPane();
                mRoot = new BorderPane();
                Scene scene = new Scene(mRoot,400,400);
                primaryStage.setScene(scene);
                primaryStage.show();
            } catch(Exception e) {
                e.printStackTrace();
            addFileSystemNode ();
            mRoot.setOnDragDone (new EventHandler <DragEvent>() {
                @Override
                public void handle(DragEvent event) {
    System.out.println ("Drag done");
                    event.consume();
        public static void main(String[] args) {
            launch(args);
        public final void addFileSystemNode () {
            Label node_title = new Label();
            node_title.setText("drag me!");
            node_root.getChildren().add (node_title);
            mRoot.getChildren().add (node_root);
            buildNodeDragHandlers();    
            node_root.setLayoutX(100.0);
            node_root.setLayoutY(100.0);
        public void relocateToPoint (Point2D p) {
            Point2D p2 = mRoot.sceneToLocal(p);
            node_root.relocate (
                    (int) (p2.getX()),
                    (int) (p2.getY())
        public void buildNodeDragHandlers() {
            mRoot.setOnDragOver(new EventHandler <DragEvent>() {
                //dragover to handle node dragging in the right pane view
                @Override
                public void handle(DragEvent event) {
                    System.out.println("parent node drag over" + " "  + ((Pane) event.getSource()).getId());
                    event.acceptTransferModes(TransferMode.ANY);
                    relocateToPoint(new Point2D( event.getSceneX(), event.getSceneY()));
                    event.consume();
            mRoot.setOnDragDropped(new EventHandler <DragEvent> () {
                @Override
                public void handle(DragEvent event) {
                    System.out.println("node drag dropped");            
                    event.setDropCompleted(true);
                    event.consume();
            //drag detection for node dragging
            node_root.setOnDragDetected( new EventHandler <MouseEvent> () {
                @Override
                public void handle(MouseEvent event) {
                    System.out.println("Drag detected");            
                    //begin drag ops
                    relocateToPoint(new Point2D(event.getSceneX(), event.getSceneY()));
                    ClipboardContent content = new ClipboardContent();
                    content.putString("node_drag");
                    node_root.startDragAndDrop (TransferMode.ANY).setContent(content);            
                    event.consume();                

  • Premiere Cs4 handle CPU...performance...and idiot questions

    Ok, i tried to read as much as i could, performance threads about Premiere Cs4...but couldn't help it.
    So i upgraded to Production Premium Cs4 before 2 weeks...
    I've noticed all the problems that were mentioned...what i can't understand is the LOW PERFOMANCE in export or preview
    my system runs a QUAD 6600 with 8gbs RAM, NVIDIA 8800GT and XP64...
    after effects runs fine in almost maximum CPU (if you adjust it in preferences), but premiere (that means and ABOBE MEDIA encoder) exports in 5-20% of the CPU...if you try to encode with TMPGEnc processes go much faster and cpu is quite high...
    question 1) (yes i know i am dumb...)
    exporting speed has to do with footage, type of media that is being exporting and GPU??????
    2)is my system, just not enough???
    3)Premiere CS4 cannot handle multicore anyway...and every user here has the same problems??????
    Sometimes...i think that i will do BAD things in my PC when PREMIERE is SO SLOW and i am in such hurry...Someone...coould answer? before i start taking drugs????????????????
    A Straight answer 1) ,2) ,3) would be really nice for my emotional condition...

    Roger thank you very much!
    It is now starting to make sense. I have only run it once and not tried any other tricks yet (like trying to use the Source from the RAID array rather than from the C: drive)
    Now rather than taking 130 seconds for encoding it is down to 25 seconds versus 8 seconds for CS3. I suspect that at least some of that is because they are using the C: drive for the source.
    MPEG encoding has also a major improvement by using the rendered preview files and as matter of fact it reduced the MPEG encoding time from 75 seconds (CS3) to 57 seconds (CS4)! Maybe we will have to go back to suggesting rendering the timeline before any encoding.
    One other plus for CS4 is that the rendering is much smarter in that any duplicate segments are rendered only one time.
    Why do they hide these menus with such tiny hard to find icons? I had a similar problem finding a playback option for my second monitor.

  • How can I stop coalescing of mouse move/drag events in jdk1.6 ?

    Hello all,
    My application uses a [pen-based tablet|http://en.wikipedia.org/wiki/Graphics_tablet] to draw lines/curves. But the problem is: when I run my application, due to java’s default behavior of discarding the mouse events which occurs during the repaint call, the curves results in the set of joined straight lines.
    To overcome this problem, when searched over net, came across below link:
    [http://forums.sun.com/thread.jspa?messageID=10811388]
    I tried the option provided at the above URL i.e. overriding the below method of Component.java file:
    protected AWTEvent coalesceEvents(AWTEvent existingEvent,AWTEvent newEvent);
    But later found that, overriding this method worked fine for me for jdk1.5 but this solution did not work in case of jdk1.6. When reviewed the source of Component.java and EventQueue.java files in jdk1.6, found that this method is not having any implementation and simply returns “null” and the complete handling of coalescing of events occurs within EventQueue.java file’s local method which is mentioned below:
    private boolean coalesceEvent(AWTEvent e, int priority);
    As this method is part of EventQueue.java and also it is a private method, I am not finding any way to stop the coalescing of mouse move/drag events in jdk1.6.
    The main problem is that my application is purely based on jdk1.6 only.
    Can anybody help me out to solve this problem by providing any option of preventing the coalescing of mouse move/drag events in case of jdk1.6.
    Thank you.

    Look at the link I posted, you aren't double buffering correctly.
    I saw the other post you mistakenly made before you edited it. Not really a big deal, I was just wondering why you did that.

  • Drag events in Robot class

    I am using the Robot class in jdk1.3.1 to record and playback user input. I am getting the list of events and then traversing on it to do the appropriate action, mouse move, key events are played back fine, but I am unable to do mouse drag event.
    Here is simplified version of the code:
    for(int i = 0; i < aListEvents.size(); i++)
    AWTEvent event = (AWTEvent)aListEvents.get(i);
    Component c = (Component)event.getSource();
    int id = event.getID();
    switch(id)
    case MouseEvent.MOUSE_MOVED:
    int x = ((MouseEvent)e).getX();
    int y = ((MouseEvent)e).getY();
    m_robot.mouseMove(x,y);
    break;
    case KeyEvent.KEY_PRESSED:
    m_robot.keyPress(((KeyEvent)e).getKeyCode());
    break;
    case MouseEvent.MOUSE_DRAGGED:
         // do component drag
    break;
    Is there a way to mimic the drag event during playback and drag the object that was dragged during record?
    Any suggestions would be greatly appreciated!!
    Thanks :)

    This is an old posting, so the answer is probably too late for mamta and has also been answered elsewhere. But for whoever comes across this one, share my piece of experience:
    There's no one-to-one mapping between Java events and the system events (which is what Robot is refering to).
    After all, a MOUSE_DRAGGED is nothing but a MOUSE_MOVE after a MOUSE_PRESSED. So you can send a MOUSE_DRAGGED along to the robot as a mouseMove, because the Robot/system keeps in mind that the mouse button has been pressed before and therefor the event will appear in the Java event queue as a MOUSE_DRAGGED.
    Similar is MOUSE_CLICKED which needn't be replayed at all, because sending a MOUSE_PRESSED and a MOUSE_RELEASED to the Robot will automatically produce a MOUSE_CLICKED in the Java event queue as well.
    Same with the key strokes.

  • Performance implications of using multiple rules

    Hi:
    1.  I have a question about the performance implications of multiple rules through a rule strategy sequence.  Can you share your experience on this?
    2. Suppose that I have three rules that are accessed through a rule strategy sequence.  Would the increase in time to perform these three rules linear or some other function?
    Thanks.

    Satish,
    Depends on the rule control you are using.
    help.sap.com has given a really good example. Check this out
    http://help.sap.com/saphelp_scm41/helpdata/en/26/c2d63b18bc7e7fe10000000a114084/frameset.htm
    Let me know If you have trouble understanding or need some more help.
    Regards
    Kumar Ayyagari

  • Default implementation of mouse drag event?

    Is there any Default implementation of mouse drag event?
    Say if the developer does not override and implement mouse drag event, still when the frame is dragged, the frame gets repainted itself in the new position. It indicates some default implementation of mouse drag event, but am unable to find out where it has been implemented.
    Why bother when everything works fine? I have a requirement to move my non-modal dialog when the frame is being dragged to another location. I tried adding mousemotionlistener to the frame, to the panel inside a frame, but the event does not reach my custom implementation of mousedrag event.
    Any clues?

    Moving the frame is a different listener: ComponentListener; add one to the frame. The frame's window decorations are OS territory, so I'm not sure if there's system dependence. I seem to vaguely remember some systems sending an event only after done moving, while others send the event as the frame moves.

  • Mouse dragged event with unexpected coordinates

    I am dragging the mouse on a half circle from the middle left to the top middle. This results in mouse events with the coordinates form (10,90) ->(100,10)
    Letting the mouse go and then dragging it further to the left, the coordinates in the of the event are similar than the starting point of the first mouse drag event.
    Can anyone shed some light on this peculiar behavior?

    First of, I have to apologize for the example not being as minimalistic as it might be, but on the plus side, I know now why this happens, I just don't know how to work around it.
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    package javafxtest;
    import java.util.ArrayList;
    import javafx.application.Application;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Dimension2D;
    import javafx.geometry.Point2D;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.shape.Polygon;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.shape.Shape;
    import javafx.scene.transform.Rotate;
    import javafx.stage.Stage;
    * @author andi
    public class HandleRotation extends Application {
        private DoubleProperty currentRotation;
        private ArrayList<Double> angles;
        @Override
        public void start(Stage primaryStage) {
            currentRotation = new SimpleDoubleProperty(this, "currentRotation", 10);
            SteeringWheelGroup background = new SteeringWheelGroup(200);
            background.setManaged(false);
            Group g = new Group(background);
            final Point2D centerPoint = new Point2D(100, 100);
            angles = new ArrayList<>(3);
            angles.add(190.0);
            angles.add(270.0);
            angles.add(350.0);
            double step = (180.0 - 2 * currentRotation.doubleValue()) / (angles.size() - 1);
            int radius = 100;
            final int yTranslation = 15; // might be due to the labels
            Polygon handle = createHandle(centerPoint, radius, yTranslation);
            g.getChildren().add(handle);
            StackPane root = new StackPane();
            Scene scene = new Scene(g, 300, 250);
            primaryStage.setTitle("Handle Rotation!");
            primaryStage.setScene(scene);
            primaryStage.show();
         * Calculate the base point for the label. This is the point on the arc, matching the angle.
         * @param center point of the circle
         * @param radius radius of the circle
         * @param angle in degree in [0,180]
         * @return Point on the circle
        Point2D calculateBasePoint(Point2D center, double radius,
                double angle) {
            float newX = (float) (center.getX() + radius * Math.cos(Math.toRadians(angle)));
            float newY = (float) (center.getY() + radius * Math.sin(Math.toRadians(angle)));
            return new Point2D(newX, newY);
         * Create the polygon that represents the handle
         * @param centerPoint
         * @param radius
         * @return
        private Polygon createHandle(final Point2D centerPoint, int radius, final int yTranslation) {
            double baseAngle = 180;
            Point2D p1 = calculateBasePoint(centerPoint, radius, baseAngle - 5);
            Point2D p2 = calculateBasePoint(centerPoint, radius, baseAngle + 2);
            Point2D p3 = calculateBasePoint(centerPoint, radius*0.65, baseAngle + 2);
            Point2D p4 = calculateBasePoint(centerPoint, radius*0.65, baseAngle - 7);
            double[] points = {p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY(), p4.getX(), p4.getY()};
                      Polygon polygon = new Polygon(points);
    //        polygon.setOpacity(0);
            polygon.setTranslateY(-yTranslation);
            final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
            polygon.getTransforms().add(rotationTransform);
            polygon.setOnMouseDragged(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    if (event.getY() < centerPoint.getY()) {
    System.out.println("Event: "+event);                   
                                                       Point2D point = new Point2D((float)event.getX(), (float)event.getY());
                        double newAngle = angleBetween2Lines(centerPoint, point);
                        if (newAngle < 0) {
                            newAngle = (90 + newAngle)+ 90;
    System.out.println("Set angle on mouse drag: "+newAngle);
                        if (newAngle < 10) {
                            newAngle = 10;
                        if (newAngle > 170) {
                            newAngle = 170;
                        currentRotation.set(newAngle);
            polygon.setOnMouseReleased(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    snapToNearestAngle();
                    rotationTransform.setAngle(currentRotation.doubleValue());
            return polygon;
         * Snap to the correct angle. Correct angle is angle belonging to the nearest label.
        void snapToNearestAngle() {
            double currentAngle = currentRotation.doubleValue() + 180;
            double currentMin = 360;
            int minIndex = 0;
    System.out.println("Current rotation is "+currentAngle);
            for (int i = 0; i < angles.size(); i++) {
                double angle = angles.get(i);
                double diff = Math.abs(angle - currentAngle);
                if (diff < currentMin) {
                    currentMin = diff;
                    minIndex = i;
    System.out.println("new minDifference at "+i+": "+diff);
            Double destinationAngle = angles.get(minIndex);
    System.out.println("DestinationAngle is "+currentAngle+" -> "+(destinationAngle - 180));
            if (destinationAngle < 180 + 10 || destinationAngle > 360 - 10) {
                throw new IllegalStateException("Angle is out of range: "+currentRotation.doubleValue()+" -> "+destinationAngle);
            currentRotation.set(destinationAngle - 180);
         * Calculate the angle between the vector horizontally to the left from the center
         * and the current point.
         * @param center point
         * @param point current point
         * @return angle in degree
        double angleBetween2Lines(Point2D center, Point2D point) {
            double slope2 = calculateSlope(center, point);
            double angle = Math.atan(slope2);
            if (point.getX() > center.getX()) {
                angle += Math.PI/2;
    System.out.println("Slope: "+slope2+" angle "+Math.toDegrees(angle));
            return Math.abs(Math.toDegrees(angle));
         * Caluculate the slope of the line defined by two points.
         * The first point is the center of a circle and the second
         * point roughly lies on the circle.
         * @param center point
         * @param point on the circle
         * @return slope of the connecting line.
        double calculateSlope(Point2D center, Point2D point) {
    System.out.println("center="+center+",point="+point);       
            double absSlope = Math.abs((point.getY() - center.getY()) / (point.getX() - center.getX()));
            if (point.getY() > center.getY()) {
                if (point.getX() > center.getX()) {
                    // bottom right
                    return -absSlope;
                } else {
                    // bottom left
                    return absSlope;
            } else {
                if (point.getX() > center.getX()) {
                    // top right
                    return absSlope;
                } else {
                    // top left
                    return -absSlope;
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         * @param args the command line arguments
        public static void main(String[] args) {
            launch(args);
       private class SteeringWheelGroup extends Group {
            public SteeringWheelGroup(int destinationWidth) {
                int topPadding = 0;
                Rectangle rect = new Rectangle(getImageWidth(), getImageWidth(), Color.RED);
                double scale = destinationWidth / rect.getWidth();
                rect.setScaleX(scale);
                rect.setScaleY(scale);
                Circle circle = new Circle(getImageWidth()/2, getImageWidth()/2, getImageWidth()/2, Color.BLUE);
                circle.setScaleX(scale);
                circle.setScaleY(scale);
                Group rotationGroup = new Group(/*rect,*/ circle);
                rotationGroup.setManaged(false);
                int width = getImageWidth();
                Rectangle clipRectangle = new Rectangle(0, 0, width, width / 2);
                Circle clipCircle = new Circle(width / 2, width / 2, width / 2);
                Shape clip = Shape.intersect(clipRectangle, clipCircle);
                rotationGroup.setClip(clip);
                this.getChildren().add(rotationGroup);
                //double h = calculateHeigthOverHorizon(angle, destinationWidth/2);
                //setTranslateY(-h+topPadding);
            public final int getImageWidth() {
                return 479;
    Here is how you can reproduce my effect:
    Grab the black handle
    Drag the mouse top and right until you approach the angle -90 (have an eye out on the console log)
    Let the mouse go: the handle will snap to 90 degree
    Grab the handle a second time and move further right
    You will see that the angle printed out do not match what you expect.
    Let the mouse go, the Handle snaps back to it's original position
    As the rotation does not happen around the polygon's center, I have to use a Rotaion effect, which is applied. While I can drag the shape from the rotated location the dragging is always measured from its base position.
    So what can I do to work around this?
    final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
    polygon.getTransforms().add(rotationTransform);
    If worse comes to worst, I can use a circular handle covering everything, then I can rotate around its center, but I would like to avoid this.

  • [Solved] xcompmgr -- Drag events kill XOrg rendering (xcompmgr crash)

    To fix a problem I was having with direct draw applications glitching/ghosting https://bbs.archlinux.org/viewtopic.php … 1#p1384701 I implemented the fix I documented.
    Now, direct draw drag events kill all rendering in XOrg. It seems xcompmgr just silently dies and I have to kill and restart XOrg to get it working again. A simple example of this is dragging an image in Firefox. Input still works and the window manager is fine (I can still spawn terminals with my hotkeys). Killing xcompmgr doesn't fix the problem nor does restarting it.
    Anyone have any suggestions beyond switching to compiz/nouveau?
    Last edited by pilotkeller (2014-02-25 14:19:39)

    So I've managed to solve my problem.
    Thanks anonymous_user, you set me on the right path with the suggestion of compton. I checked its man page and it has abolished the -a flag. Didn't know why. Turns out, it's buggy and prone to these crashes.
    I'll edit my solution in my linked post noting what I've done.
    Thanks a million to you again anonymous_user, and you too headkase! You two are what make these forums amazing.

  • What would be performance implication if

    What would be performance implication if the user has assigned a permanant tablespace instead of temporary tablespace.
    Any suggestion will be so greatful.
    Thanks

    Hi,
    What version of Oracle did you make this test ?
    SQL> create user scott identified by tiger default tablespace TEMP;
    create user scott identified by tiger default tablespace TEMP
    ERROR at line 1:
    ORA-12910: cannot specify temporary tablespace as default tablespaceCheers

  • "Intervals in Hierarchy" Any Performance Implications ???

    Hi,
    Is anyone aware of any performance implications in reports when we filter on a hierarchy which has a lot of interval nodes.
    This is what we are encountering. We have a hierarchy on Account Group in which all nodes have interval ranges. We added this hierarchy in a query.
    When we do not do any filtering on the nodes of the hierarchy (Time Independent) and let it run for the complete hierarchy, the query runs fine and retuns in about 2 minutes.
    We run this query again, keeping all things exactly the same, but do "fix filter value to axis" on a node of the hierarchy. When we do this, query runs for about 45 minutes...
    We have repeatedly seen this behavior with different nodes of the hierarchy. I have not tested with a hierarchy that doesn't have hierarchy nodes...(currently working on that)
    I looked in OSS notes, didn't find anything useful, but, I might have missed something...
    Please post your comments if you have seen any behavior like this.
    Thanks alot
    Gova

    Roberto,
    Thanks for the reply. Checked out the note, doesn't seem to be addressing this issue...here are more details about the hierarchy and how we are using this in the query. May be you can smell a clue there...
    The infoobject (on which the hierarchy is built) is a NAV attribute in the query. (NAV attributes slow down the processing, but its slow only when there is an active filter.) Since this hierarchy contains ranges, it has to access additional "J Table". Another table to access, Another reason to slow it down. But again not sure why only when the filter is present.
    Could that be because of the way BW formulates the select statment? Is there a way we can mess(!) around with this? Will check to see what ST05 trace reveals, but not sure if that helps with anything.
    Thanks
    Gova

  • My firefox has stopped working with my comcast email. It is loading fine on safari but it is no longer loading my email in a timely manner. Comcast says it is a firefox problem. They suggest I uninstall and reinstall firefox. Do I just drag everything to

    My firefox has stopped working with my comcast email. It is loading fine on safari but it is no longer loading my email in a timely manner on firefox. Comcast says it is a firefox problem. They suggest I uninstall and reinstall firefox. Do I just drag everything to the trash and download a new version? in English
    == URL of affected sites ==
    http://
    == User Agent ==
    Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7

    "Clear the Cache": Firefox > Preferences > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove the Cookies" from sites that cause problems: Firefox > Preferences > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

Maybe you are looking for