當前位置: 首頁>>代碼示例>>Java>>正文


Java ValueAxis.java2DToValue方法代碼示例

本文整理匯總了Java中org.jfree.chart.axis.ValueAxis.java2DToValue方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAxis.java2DToValue方法的具體用法?Java ValueAxis.java2DToValue怎麽用?Java ValueAxis.java2DToValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.axis.ValueAxis的用法示例。


在下文中一共展示了ValueAxis.java2DToValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateYFieldValue

import org.jfree.chart.axis.ValueAxis; //導入方法依賴的package包/類
/**
 * Updates the preselected y-value.
 */
private void updateYFieldValue() {
	// update preselected y value because range axis has been changed
	if (mousePosition != null) {
		Rectangle2D plotArea = engine.getChartPanel().getScreenDataArea();
		if (engine.getChartPanel().getChart().getPlot() instanceof XYPlot) {
			XYPlot plot = (XYPlot) engine.getChartPanel().getChart().getPlot();

			// calculate y value
			for (int i = 0; i < plot.getRangeAxisCount(); i++) {
				ValueAxis config = plot.getRangeAxis(i);
				if (config != null && config.getLabel() != null) {
					if (config.getLabel().equals(String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()))) {
						double chartY = config.java2DToValue(mousePosition.getY(), plotArea, plot.getRangeAxisEdge());
						yField.setText(String.valueOf(chartY));
					}
				}
			}
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:24,代碼來源:AddParallelLineDialog.java

示例2: chartMouseMoved

import org.jfree.chart.axis.ValueAxis; //導入方法依賴的package包/類
@Override
public void chartMouseMoved(ChartMouseEventFX event) {
    Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea();
    JFreeChart chart = event.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, 
            RectangleEdge.BOTTOM);
    // make the crosshairs disappear if the mouse is out of range
    if (!xAxis.getRange().contains(x)) { 
        x = Double.NaN;                  
    }
    double y = DatasetUtils.findYValue(plot.getDataset(), 0, x);
    this.xCrosshair.setValue(x);
    this.yCrosshair.setValue(y);
}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:17,代碼來源:CrosshairOverlayFXDemo1.java

示例3: handleClick

import org.jfree.chart.axis.ValueAxis; //導入方法依賴的package包/類
/**
 * Handles a 'click' on the plot by updating the anchor values...
 *
 * @param x  the x-coordinate, where the click occurred, in Java2D space.
 * @param y  the y-coordinate, where the click occurred, in Java2D space.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the horizontal axis...
        ValueAxis da = getDomainAxis();
        if (da != null) {
            double hvalue = da.java2DToValue(x, info.getDataArea(), getDomainAxisEdge());

            setDomainCrosshairValue(hvalue);
        }

        // set the anchor value for the vertical axis...
        ValueAxis ra = getRangeAxis();
        if (ra != null) {
            double vvalue = ra.java2DToValue(y, info.getDataArea(), getRangeAxisEdge());
            setRangeCrosshairValue(vvalue);
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:XYPlot.java

示例4: handleClick

import org.jfree.chart.axis.ValueAxis; //導入方法依賴的package包/類
/**
 * Handles a 'click' on the plot by updating the anchor values.
 *
 * @param x  the x-coordinate, where the click occurred, in Java2D space.
 * @param y  the y-coordinate, where the click occurred, in Java2D space.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the horizontal axis...
        ValueAxis da = getDomainAxis();
        if (da != null) {
            double hvalue = da.java2DToValue(x, info.getDataArea(), 
                    getDomainAxisEdge());
            setDomainCrosshairValue(hvalue);
        }

        // set the anchor value for the vertical axis...
        ValueAxis ra = getRangeAxis();
        if (ra != null) {
            double vvalue = ra.java2DToValue(y, info.getDataArea(), 
                    getRangeAxisEdge());
            setRangeCrosshairValue(vvalue);
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:XYPlot.java

示例5: _updateMainTraceInfoForCandlestick

import org.jfree.chart.axis.ValueAxis; //導入方法依賴的package包/類
private boolean _updateMainTraceInfoForCandlestick(Point2D point) {
    if (point == null) {
        return false;
    }

    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    // Top most plot.
    final XYPlot plot = this.chartJDialog.getPlot();

    final org.jfree.data.xy.DefaultHighLowDataset defaultHighLowDataset = (org.jfree.data.xy.DefaultHighLowDataset)plot.getDataset();

    // I also not sure why. This is what are being done in Mouse Listener Demo 4.
    //
    // Don't use it. It will cause us to lose precision.
    //final Point2D p2 = chartPanel.translateScreenToJava2D((Point)point);

    /* Try to get correct main chart area. */
    final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();

    final ValueAxis domainAxis = plot.getDomainAxis();
    final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
    // Don't use it. It will cause us to lose precision.
    //final double coordinateX = domainAxis.java2DToValue(p2.getX(), _plotArea,
    //        domainAxisEdge);
    final double coordinateX = domainAxis.java2DToValue(point.getX(), _plotArea,
            domainAxisEdge);
    //double coordinateY = rangeAxis.java2DToValue(mousePoint2.getY(), plotArea,
    //        rangeAxisEdge);

    int low = 0;
    int high = defaultHighLowDataset.getItemCount(0) - 1;
    Date date = new Date((long)coordinateX);
    final long time = date.getTime();
    long bestDistance = Long.MAX_VALUE;
    int bestMid = 0;

    while (low <= high) {
        int mid = (low + high) >>> 1;

        final Date d = defaultHighLowDataset.getXDate(0, mid);
        final long search = d.getTime();
        final long cmp = search - time;

        if (cmp < 0) {
            low = mid + 1;
        }
        else if (cmp > 0) {
            high = mid - 1;
        }
        else {
            bestDistance = 0;
            bestMid = mid;
            break;
        }

        final long abs_cmp = Math.abs(cmp);
        if (abs_cmp < bestDistance) {
            bestDistance = abs_cmp;
            bestMid = mid;
        }
    }

    final double xValue = defaultHighLowDataset.getXDate(0, bestMid).getTime();
    final double yValue = defaultHighLowDataset.getCloseValue(0, bestMid);
    final double xJava2D = domainAxis.valueToJava2D(xValue, _plotArea, domainAxisEdge);
    final double yJava2D = rangeAxis.valueToJava2D(yValue, _plotArea, rangeAxisEdge);

    final int tmpIndex = bestMid;
    // translateJava2DToScreen will internally convert Point2D.Double to Point.
    final Point2D tmpPoint = chartPanel.translateJava2DToScreen(new Point2D.Double(xJava2D, yJava2D));
    this.mainDrawArea.setRect(_plotArea);

    if (this.mainDrawArea.contains(tmpPoint)) {
        // 0 indicates main plot.
        this.mainTraceInfo = TraceInfo.newInstance(tmpPoint, 0, 0, tmpIndex);
        return true;
    }
    return false;
}
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:82,代碼來源:ChartLayerUI.java


注:本文中的org.jfree.chart.axis.ValueAxis.java2DToValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。