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


Java XYItemRenderer类代码示例

本文整理汇总了Java中org.jfree.chart.renderer.xy.XYItemRenderer的典型用法代码示例。如果您正苦于以下问题:Java XYItemRenderer类的具体用法?Java XYItemRenderer怎么用?Java XYItemRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createPlot

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
private XYPlot createPlot( XYSeriesCollection dataset ) {
    XYPlot plot = new XYPlot();

    ValueAxis domainAxis = new NumberAxis( "Time" );
    domainAxis.setTickLabelsVisible( false );
    domainAxis.setRange( 0, RANGE );
    plot.setDomainAxis( domainAxis );

    ValueAxis rangeAxis = new NumberAxis( "Population" );
    rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() );
    plot.setRangeAxis( rangeAxis );
    rangeAxis.setRange( 0, 50 );

    plot.setRenderer( new StandardXYItemRenderer() );

    final int seriesIndex = 0;
    plot.setDataset( seriesIndex, dataset );
    XYItemRenderer renderer = new StandardXYItemRenderer(); // TODO: maybe use XYLineAndShapeRenderer?
    renderer.setStroke( new BasicStroke( 2f ) );
    renderer.setSeriesPaint( TOTAL_INDEX, Color.BLACK );
    renderer.setSeriesPaint( FUR_WHITE_INDEX, Color.RED );
    plot.setRenderer( seriesIndex, renderer );

    return plot;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:TestCanvas.java

示例2: applyColorSettings

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Applies the color settings from the ontology model
 */
public void applyColorSettings(){
	List colors = dataModel.getOntologyModel().getChartSettings().getYAxisColors();
	XYItemRenderer renderer = this.chartPanel.getChart().getXYPlot().getRenderer();
	for(int i=0; i < colors.size(); i++){
		String colorString = (String) colors.get(i);
		if (colorString!=null && colorString.equals("")==false) {
			Color newColor = new Color(Integer.parseInt((String) colors.get(i)));
			renderer.setSeriesPaint(i, newColor);	
		}
	}	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:15,代码来源:ChartTab.java

示例3: plotTradeBubblesOnChart

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
  {
  	final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
      final XYPlot plot = (XYPlot) main_plot;
      
  	final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
	switch(j)
	{
	case 0:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
		break;
	case 1:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
		break;
	case 2:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
		break;
	case 3:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
		break;
	}
	
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
{
          series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
      }
*/
XYDataset dataSet = new TimeSeriesCollection(series);

plot.setDataset(k, dataSet);
  	XYItemRenderer ir = new XYShapeRenderer();
  	//ir.s
  	
  	plot.setRenderer(k, ir);
  }
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:41,代码来源:ChartJDialog.java

示例4: plotSeperate

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
private void plotSeperate(XYDataset dataset, String p)
  {
  	NumberAxis rangeAxis1 = new NumberAxis(p);
rangeAxis1.setAutoRangeIncludesZero(false);     // override default
rangeAxis1.setLowerMargin(0.40);                // to leave room for volume bars
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);

final ValueAxis timeAxis = new DateAxis("Date");
timeAxis.setLowerMargin(0.02);                  // reduce the default margins
timeAxis.setUpperMargin(0.02);

XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);

XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(
    new StandardXYToolTipGenerator(
        StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
        new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")
    )
);
plot.setRenderer(0, renderer1);

final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot();
if (plot != null) cplot1.add(plot, 1);      // weight is 1.
  }
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:27,代码来源:ChartJDialog.java

示例5: addChart

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 */
private void addChart() {
    JFreeChart chart = ChartFactory.createXYBarChart(getTitle(),
            "Buckets (sec)", false, "Count",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addProgressListener(locker);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);

    groupActivatingPanel = new GroupActivatingPanel(dataset, locker);

    org.jfree.chart.ChartPanel chartPanel =
            new org.jfree.chart.ChartPanel(chart);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            groupActivatingPanel,chartPanel);
    splitPane.setDividerLocation(200);
    mainPanel().add(BorderLayout.CENTER, splitPane);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:24,代码来源:ChartPanelSingle.java

示例6: addChart

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 */
private void addChart() {
    JFreeChart chart = ChartFactory.createXYBarChart(getTitle(),
            "Elapsed Time (sec)", false, "Time" + unitSuffix(),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addProgressListener(locker);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);

    groupActivatingTable = new GroupActivatingPanel(dataset, locker);

    org.jfree.chart.ChartPanel chartPanel =
            new org.jfree.chart.ChartPanel(chart);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            groupActivatingTable, chartPanel);
    splitPane.setDividerLocation(200);
    mainPanel().add(BorderLayout.CENTER, splitPane);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:24,代码来源:ChartPanel.java

示例7: drawDomainMarkers

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is 
 * typically called from within the draw(...) method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, 
                                 Layer layer) {
                                             
    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxis(index);
    // TODO: get the axis that the renderer maps to
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:XYPlot.java

示例8: drawRangeMarkers

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Draws the range markers (if any) for a renderer and layer.  This method is 
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index,
                                Layer layer) {
                                             
    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxis(index);
    // TODO: get the axis that the renderer maps to
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:XYPlot.java

示例9: testGetRendererForDataset

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Some checks for the getRendererForDataset() method.
 */
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:XYPlotTests.java

示例10: setRenderer

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Sets a renderer and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @param index  the index.
 * @param renderer  the renderer.
 * @param notify  notify listeners?
 * 
 * @see #getRenderer(int)
 */
public void setRenderer(int index, XYItemRenderer renderer, 
                        boolean notify) {
    XYItemRenderer existing = getRenderer(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    this.renderers.set(index, renderer);
    if (renderer != null) {
        renderer.setPlot(this);
        renderer.addChangeListener(this);
    }
    configureDomainAxes();
    configureRangeAxes();
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:XYPlot.java

示例11: drawDomainMarkers

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }    
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

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

示例12: drawRangeMarkers

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Draws the range markers (if any) for a renderer and layer.  This method
 * is typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea,
                                int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:XYPlot.java

示例13: GenerateRTMapPNG

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
    new File(Workfolder + "/RT_Mapping/").mkdir();
    String pngfile = Workfolder + "/RT_Mapping/" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1)) + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1)) + "_RT.png";

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
    }
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName), "RT:" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:26,代码来源:RTAlignedPepIonMapping.java

示例14: testGetRendererForDataset2

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
@Test 
public void testGetRendererForDataset2() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset2);
   
    // by default, the renderer with index 0 is used
    assertEquals(renderer, plot.getRendererForDataset(dataset2));
    
    // add a second renderer with the same index as dataset2, now it will
    // be used
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer);
    assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:23,代码来源:XYPlotTest.java

示例15: testGetRendererForDataset

import org.jfree.chart.renderer.xy.XYItemRenderer; //导入依赖的package包/类
/**
 * Some checks for the getRendererForDataset() method.
 */
@Test
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:25,代码来源:XYPlotTest.java


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