当前位置: 首页>>代码示例>>Java>>正文


Java XYPlot.getDomainAxis方法代码示例

本文整理汇总了Java中org.jfree.chart.plot.XYPlot.getDomainAxis方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.getDomainAxis方法的具体用法?Java XYPlot.getDomainAxis怎么用?Java XYPlot.getDomainAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.plot.XYPlot的用法示例。


在下文中一共展示了XYPlot.getDomainAxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createChart

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private JFreeChart createChart(XYDataset dataset) {

        JFreeChart chart = ChartFactory.createScatterPlot(this.title,
                this.xAxisLabel, this.yAxisLable, dataset, PlotOrientation.VERTICAL, true, true, false);

        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setNoDataMessage("NO DATA");
        XYLineAndShapeRenderer renderer
                = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setSeriesOutlinePaint(0, Color.black);
        renderer.setUseOutlinePaint(true);

        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setAutoRangeIncludesZero(false);
        return chart;

    }
 
开发者ID:Fanping,项目名称:iveely.ml,代码行数:18,代码来源:ScatterPlot.java

示例2: testXYAutoRange1

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Checks that the auto-range for the domain axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange1() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:NumberAxisTests.java

示例3: testFindDomainBounds

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    XYSeriesCollection dataset 
            = RendererXYPackageTests.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.9));
    assertTrue(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertFalse(bounds.contains(2.10));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:XYLineAndShapeRendererTests.java

示例4: testFindDomainBounds

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, 
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:StackedXYBarRendererTests.java

示例5: chartMouseMoved

import org.jfree.chart.plot.XYPlot; //导入方法依赖的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

示例6: setTimeSeriesRender

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) {

        XYPlot xyplot = (XYPlot) plot;
        xyplot.setNoDataMessage(NO_DATA_MSG);
        xyplot.setInsets(new RectangleInsets(10, 10, 5, 10));

        XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();

        xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xyRenderer.setBaseShapesVisible(false);
        if (isShowData) {
            xyRenderer.setBaseItemLabelsVisible(true);
            xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
            xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
        }
        xyRenderer.setBaseShapesVisible(isShapesVisible);

        DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
        domainAxis.setAutoTickUnitSelection(false);
        DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM"));
        domainAxis.setTickUnit(dateTickUnit);

        StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
        xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);

        setXY_XAixs(xyplot);
        setXY_YAixs(xyplot);

    }
 
开发者ID:Fanping,项目名称:iveely.ml,代码行数:30,代码来源:ChartUtils.java

示例7: shrinkSelectionOnDomain

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Decreases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is reduced by the value of {@link #getZoomInFactor()}.
 * 
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void shrinkSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
	Plot p = this.chart.getPlot();
	if (p instanceof XYPlot) {
		XYPlot plot = (XYPlot) p;
		Selection selectionObject = new Selection();
		for (int i = 0; i < plot.getDomainAxisCount(); i++) {
			ValueAxis domain = plot.getDomainAxis(i);
			double zoomFactor = getZoomInFactor();
			shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
		}
		informSelectionListener(selectionObject, selectionEvent);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:AbstractChartPanel.java

示例8: enlargeSelectionOnDomain

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Increases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is increased by the value of {@link #getZoomOutFactor()}.
 * 
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void enlargeSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
	Plot p = this.chart.getPlot();
	if (p instanceof XYPlot) {
		XYPlot plot = (XYPlot) p;
		Selection selectionObject = new Selection();
		for (int i = 0; i < plot.getDomainAxisCount(); i++) {
			ValueAxis domain = plot.getDomainAxis(i);
			double zoomFactor = getZoomOutFactor();
			shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
		}
		informSelectionListener(selectionObject, selectionEvent);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:AbstractChartPanel.java

示例9: selectCompleteDomainBounds

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Restores the auto-range calculation on the domain axis.
 */

public void selectCompleteDomainBounds() {
	Plot plot = this.chart.getPlot();
	if (plot instanceof Zoomable) {
		Zoomable z = (Zoomable) plot;
		// here we tweak the notify flag on the plot so that only
		// one notification happens even though we update multiple
		// axes...
		boolean savedNotify = plot.isNotify();
		plot.setNotify(false);
		// we need to guard against this.zoomPoint being null
		Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
		z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp);
		plot.setNotify(savedNotify);

		if (plot instanceof XYPlot) {
			XYPlot xyPlot = (XYPlot) plot;
			Selection selectionObject = new Selection();
			for (int i = 0; i < xyPlot.getDomainAxisCount(); i++) {
				ValueAxis domain = xyPlot.getDomainAxis(i);
				Range axisRange = new Range(domain.getLowerBound(), domain.getUpperBound());
				for (String axisName : axisNameResolver.resolveXAxis(i)) {
					selectionObject.addDelimiter(axisName, axisRange);
				}
			}
			informSelectionListener(selectionObject, null);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:AbstractChartPanel.java

示例10: initialise

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Initialises the renderer then returns the number of 'passes' through the
 * data that the renderer will require (usually just one).  This method 
 * will be called before the first item is rendered, giving the renderer 
 * an opportunity to initialise any state information it wants to maintain.
 * The renderer can do nothing if it chooses.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area inside the axes.
 * @param plot  the plot.
 * @param dataset  the data.
 * @param info  an optional info collection object to return data back to 
 *              the caller.
 *
 * @return The number of passes the renderer requires.
 */
public XYItemRendererState initialise(Graphics2D g2,
                                      Rectangle2D dataArea,
                                      XYPlot plot,
                                      XYDataset dataset,
                                      PlotRenderingInfo info) {
      
    // calculate the maximum allowed candle width from the axis...
    ValueAxis axis = plot.getDomainAxis();
    double x1 = axis.getLowerBound();
    double x2 = x1 + this.maxCandleWidthInMilliseconds;
    RectangleEdge edge = plot.getDomainAxisEdge();
    double xx1 = axis.valueToJava2D(x1, dataArea, edge);
    double xx2 = axis.valueToJava2D(x2, dataArea, edge);
    this.maxCandleWidth = Math.abs(xx2 - xx1); 
        // Absolute value, since the relative x 
        // positions are reversed for horizontal orientation
    
    // calculate the highest volume in the dataset... 
    if (this.drawVolume) {
        OHLCDataset highLowDataset = (OHLCDataset) dataset;
        this.maxVolume = 0.0;
        for (int series = 0; series < highLowDataset.getSeriesCount(); 
             series++) {
            for (int item = 0; item < highLowDataset.getItemCount(series); 
                 item++) {
                double volume = highLowDataset.getVolumeValue(series, item);
                if (volume > this.maxVolume) {
                    this.maxVolume = volume;
                }
                
            }    
        }
    }
    
    return new XYItemRendererState(info);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:53,代码来源:CandlestickRenderer.java

示例11: createChart

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
 * Creates a chart.
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
        "Legal & General Unit Trust Prices",  // title
        "Date",             // x-axis label
        "Price Per Unit",   // y-axis label
        dataset,            // data
        true,               // create legend?
        true,               // generate tooltips?
        false               // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    
    return chart;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:43,代码来源:SWTTimeSeriesDemo.java

示例12: plot

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static void plot(double[] predicts, double[] actuals, String name) {
	double[] index = new double[predicts.length];
	for (int i = 0; i < predicts.length; i++)
		index[i] = i;
	int min = minValue(predicts, actuals);
	int max = maxValue(predicts, actuals);
	final XYSeriesCollection dataSet = new XYSeriesCollection();
	addSeries(dataSet, index, predicts, "Predicts");
	addSeries(dataSet, index, actuals, "Actuals");
	final JFreeChart chart = ChartFactory.createXYLineChart(
			"Prediction Result", // chart title
			"Index", // x axis label
			name, // y axis label
			dataSet, // data
			PlotOrientation.VERTICAL,
			true, // include legend
			true, // tooltips
			false // urls
	);
	XYPlot xyPlot = chart.getXYPlot();
	// X-axis
	final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
	domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
	domainAxis.setTickUnit(new NumberTickUnit(20));
	domainAxis.setVerticalTickLabels(true);
	// Y-axis
	final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
	rangeAxis.setRange(min, max);
	rangeAxis.setTickUnit(new NumberTickUnit(50));
	final ChartPanel panel = new ChartPanel(chart);
	final JFrame f = new JFrame();
	f.add(panel);
	f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	f.pack();
	f.setVisible(true);
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:37,代码来源:PlotUtil.java

示例13: TimeSeriesChart

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public TimeSeriesChart() {
    XYDataset xydataset = createDataset();
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General单位信托基金价格", "日期", "价格", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    frame1 = new ChartPanel(jfreechart, true);
    dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体

}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:16,代码来源:TimeSeriesChart.java

示例14: getChartPanel

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public ChartPanel getChartPanel(List<String> industrys) {
    XYDataset xydataset = createDataset(industrys);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行业资金流入流出", "日期(日/单位)", "价格(亿/单位)", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
    dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    ChartPanel frame1 = new ChartPanel(jfreechart, true);
    return frame1;
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:16,代码来源:IndustryTimeSeriesChart.java

示例15: getChartPanel

import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public ChartPanel getChartPanel(List<String> industrys) {
    XYDataset xydataset = createDataset(industrys);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行业涨跌", "日期(日/单位)", "价格(%/单位)", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
    dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    ChartPanel frame1 = new ChartPanel(jfreechart, true);
    return frame1;
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:16,代码来源:IndustryRiseChart.java


注:本文中的org.jfree.chart.plot.XYPlot.getDomainAxis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。