Skip to content

IllegalArgumentException seen when using LogAxis and clicking anywhere outside data plot area #8

Closed
@chaddaniels

Description

@chaddaniels

I ran into a scenario where clicking outside the data plot area (in the legend area, axis labels area, etc) while using a LogAxis can result in an IllegalArgumentException. After this occurs the chart is then essentially non-interactive and does not respond to user input such as drag to zoom.

Stack Trace:

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: A positive range length is required: Range[0.05449587578346141,0.05449587578346141]
	at org.jfree.chart.axis.ValueAxis.setRange(ValueAxis.java:1278)
	at org.jfree.chart.axis.ValueAxis.setRange(ValueAxis.java:1256)
	at org.jfree.chart.axis.LogAxis.zoomRange(LogAxis.java:953)
	at org.jfree.chart.plot.XYPlot.zoomDomainAxes(XYPlot.java:5119)
	at org.jfree.chart.fx.interaction.ZoomHandlerFX.handleMouseReleased(ZoomHandlerFX.java:234)
	at org.jfree.chart.fx.ChartCanvas.handleMouseReleased(ChartCanvas.java:648)
	at org.jfree.chart.fx.ChartCanvas.lambda$new$6(ChartCanvas.java:196)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
	at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
	at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
	at com.sun.glass.ui.View.notifyMouse(View.java:937)

Complete self contained example:

/**
 * Click in the axis label area to see IllegalArgumentException followed by erratic behavior
 */
public class IllegalArgumentBug extends Application
{
    public static void main(String[] args)
    {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage)
    {
        XYSeriesCollection primarySeriesCollection = new XYSeriesCollection();

        JFreeChart chart = ChartFactory.createXYLineChart(
            "",
            "",
            "",
            primarySeriesCollection,
            PlotOrientation.VERTICAL,
            true,
            false,
            false);

        XYPlot plot = chart.getXYPlot();
        plot.setDomainAxis(new LogAxis("X"));
        plot.setRangeAxis(new LogAxis("Y"));

        ChartViewer chartViewer = new ChartViewer(chart);
        primaryStage.setScene(new Scene(chartViewer));

        primaryStage.show();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions