Java 类org.jfree.chart.fx.interaction.AnchorHandlerFX 实例源码

项目:jfreechart-fx    文件:ChartCanvas.java   
/**
 * Creates a new canvas to display the supplied chart in JavaFX.  If
 * {@code chart} is {@code null}, a blank canvas will be displayed.
 * 
 * @param chart  the chart. 
 */
public ChartCanvas(JFreeChart chart) {
    this.chart = chart;
    if (this.chart != null) {
        this.chart.addChangeListener(this);
    }
    this.tooltip = null;
    this.tooltipEnabled = true;
    this.chartMouseListeners = new ArrayList<>();

    widthProperty().addListener(e -> draw());
    heightProperty().addListener(e -> draw());
    // change the default font smoothing for better results
    GraphicsContext gc = getGraphicsContext2D();
    gc.setFontSmoothingType(FontSmoothingType.LCD);
    FXGraphics2D fxg2 = new FXGraphics2D(gc);
    fxg2.setRenderingHint(FXHints.KEY_USE_FX_FONT_METRICS, true);
    fxg2.setZeroStrokeWidth(0.1);
    fxg2.setRenderingHint(
                RenderingHints.KEY_FRACTIONALMETRICS, 
                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    this.g2 = fxg2;
    this.liveHandler = null;
    this.availableMouseHandlers = new ArrayList<>();

    this.availableMouseHandlers.add(new PanHandlerFX("pan", true, false, 
            false, false));

    this.auxiliaryMouseHandlers = new ArrayList<>();
    this.auxiliaryMouseHandlers.add(new TooltipHandlerFX("tooltip"));
    this.auxiliaryMouseHandlers.add(new ScrollHandlerFX("scroll"));
    this.domainZoomable = true;
    this.rangeZoomable = true;
    this.auxiliaryMouseHandlers.add(new AnchorHandlerFX("anchor"));
    this.auxiliaryMouseHandlers.add(new DispatchHandlerFX("dispatch"));

    this.overlays = FXCollections.observableArrayList();

    setOnMouseMoved(e -> handleMouseMoved(e));
    setOnMouseClicked(e -> handleMouseClicked(e));
    setOnMousePressed(e -> handleMousePressed(e));
    setOnMouseDragged(e -> handleMouseDragged(e));
    setOnMouseReleased(e -> handleMouseReleased(e));
    setOnScroll(e -> handleScroll(e));
}