當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。