Java Code Examples for org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setSeriesShape()

The following examples show how to use org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setSeriesShape() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void loadMVWAPIndicator(String key) throws XPathException{
    int timeFrameMVWAP = Integer.parseInt(parameter.getParameter(key, "Time Frame VWAP"));
    int timeFrameVWAP = Integer.parseInt(parameter.getParameter(key, "Time Frame MVWAP"));

    VWAPIndicator vwap = new VWAPIndicator(series.get(),timeFrameVWAP);
    MVWAPIndicator mvwap = new MVWAPIndicator(vwap,timeFrameMVWAP);

    List<Indicator> ilVwap = new ArrayList<>();
    List<String> nlVwap = new ArrayList<>();

    XYLineAndShapeRenderer wapRenderer = createRenderer(key, "Color MVWAP", "Shape MVWAP", "Stroke MVWAP");
    Color vwapColor = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color VWAP"));
    
    StrokeType vwapStroke = StrokeType.valueOf(parameter.getParameter(key, "Stroke VWAP"));
    ShapeType vwapShape = ShapeType.valueOf(parameter.getParameter(key, "Shape VWAP"));
    wapRenderer.setSeriesPaint(1, vwapColor);
    wapRenderer.setSeriesStroke(1, vwapStroke.stroke);
    wapRenderer.setSeriesShape(1, vwapShape.shape);
    IndicatorCategory category = parameter.getCategory(key);
    ChartType chartType = parameter.getChartType(key);
    ilVwap.add(mvwap);
    ilVwap.add(vwap);
    nlVwap.add(String.format("%s [%s] (%s)",getIdentifier(key), getID(key), timeFrameMVWAP));
    nlVwap.add(String.format("%s [%s] (%s)","VWAP", getID(key), timeFrameVWAP));
    addChartIndicator(key, ilVwap, nlVwap,"MVWAP/VWAP ",wapRenderer, chartType.toBoolean(), category);
}
 
Example 2
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void loadStochasticOscillatorKIndicatorStochasticOscillatorDIndicator(String key) throws XPathExpressionException{
    int timeFrame = Integer.parseInt(parameter.getParameter(key, "Time Frame"));
    List<Indicator> indicators = new ArrayList<>();
    List<String> names = new ArrayList<>();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0,parameter.getColorOf(key, "Color D"));
    renderer.setSeriesShape(0, parameter.getShapeOf(key, "Shape D"));
    renderer.setSeriesStroke(0,parameter.getStrokeOf(key, "Stroke D"));
    renderer.setSeriesStroke(1,parameter.getStrokeOf(key, "Stroke K"));
    renderer.setSeriesShape(1, parameter.getShapeOf(key, "Shape K"));
    renderer.setSeriesPaint(1,parameter.getColorOf(key, "Color K"));
    IndicatorCategory category = parameter.getCategory(key);

    StochasticOscillatorDIndicator stochD = new StochasticOscillatorDIndicator(closePriceIndicator.get());

    indicators.add(stochD);
    indicators.add(new StochasticOscillatorKIndicator(stochD,timeFrame, new HighPriceIndicator(series.get()), new LowPriceIndicator(series.get())));
    names.add(String.format("%s [%s]", "Stoch. Oscillator D", getID(key)));
    names.add(String.format("%s [%s](Stoch. Oscillator D, %s","Stoch. Oscillator K",getID(key),timeFrame));
    addChartIndicator(key, indicators,names,String.format("Stoch. Oscillator K(%s, %s)","Stoch. Oscillator D",timeFrame),renderer,true,category);
}
 
Example 3
Source File: SparkLine.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addPointSeries(TimeSeries series, XYPlot plot) {
	logger.debug("IN");
	TimeSeries pointSerie = new TimeSeries("Point", Month.class);
	for(int i = 0; i < series.getItemCount(); i++) {
		pointSerie.add(series.getTimePeriod(i), series.getValue(i));
	}
	final TimeSeriesCollection avgDs = new TimeSeriesCollection(pointSerie); 



	XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { 
		public boolean getItemShapeVisible(int _series, int item) { 
			return (true); 
		} 
	}; 
	renderer.setSeriesPaint(2, Color.LIGHT_GRAY);
	renderer.setBaseShapesVisible(true); 
	renderer.setBaseShapesFilled(true); 
	renderer.setDrawOutlines(true); 
	renderer.setUseFillPaint(true); 
	renderer.setBaseFillPaint(Color.BLACK); 
	renderer.setBaseOutlinePaint(Color.BLACK); 
	renderer.setUseOutlinePaint(true); 
	renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, -2.0, 4.0, 4.0));

	plot.setDataset(2, avgDs);
	plot.setRenderer(2, renderer);
	logger.debug("OUT");

}
 
Example 4
Source File: ProgramStart.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method can be overwritten to get custom {@link BaseIndicatorBox} with custom {@link Indicator indicators},
 * {@link Strategy strategies} and {@link TradingRecord}. It is also possible to add a custom {@link IndicatorParameterManager}
 * to load and store the indicator parameters in custom way
 * @return a {@link BaseIndicatorBox} for the Chart that is used in the {@link #start(Stage) start(Stage) function}
 */
@Override
public BaseIndicatorBox createIndicatorBox() {

    BarSeries series = Loader.getDailyBarSeries("fb_daily.csv");

    // define indicators
    ClosePriceIndicator closePrice = new ClosePriceIndicator(series);
    MACDIndicator macd = new MACDIndicator(closePrice, 12, 26);
    EMAIndicator emaMacd = new EMAIndicator(macd, 9);

    // build a strategy
    Rule entryRule = new CrossedUpIndicatorRule(macd, emaMacd);
    Rule exitRule = new CrossedDownIndicatorRule(macd, emaMacd);
    Strategy myStragety = new  BaseStrategy(entryRule, exitRule);


    // initialize and add your indicators to the ChartIndicatorBox
    TaBarSeries taTimeSeries = new TaBarSeries(series, Currency.getInstance("USD"), GeneralTimePeriod.DAY);
    BaseIndicatorBox chartIndicatorBox = new BaseIndicatorBox(taTimeSeries);

    // two indicators in one subplot:
    XYLineAndShapeRenderer macRenderer = new XYLineAndShapeRenderer(); // specify how the lines should be rendered
    macRenderer.setSeriesShape(0, ShapeType.NONE.shape);
    macRenderer.setSeriesPaint(0,Color.RED);
    macRenderer.setSeriesShape(1,ShapeType.NONE.shape);
    macRenderer.setSeriesPaint(1,Color.GREEN);

    List<Indicator> indicatorList = Arrays.asList(macd,emaMacd);
    List<String> nameList = Arrays.asList("macd","emaMacd");
    chartIndicatorBox.addIndicator("Straregy_1",indicatorList,nameList,"My macd/emaMacd Strategy",macRenderer,true,IndicatorCategory.CUSTOM);


    // add strategies
    chartIndicatorBox.addStrategy("My ema/emaMacd Strategy", myStragety);
    return chartIndicatorBox;
}
 
Example 5
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void loadAverageDirectionalMovementUP_DOWN(String key) throws XPathExpressionException {
    Color color1 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Up"));
    StrokeType stroke1 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Up"));
    ShapeType shape1 = ShapeType.valueOf(parameter.getParameter(key,"Shape Up"));
    Color color2 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Down"));
    StrokeType stroke2 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Down"));
    ShapeType shape2 = ShapeType.valueOf(parameter.getParameter(key,"Shape Down"));
    ChartType chartType = ChartType.valueOf(parameter.getParameter(key, "Chart Type"));
    IndicatorCategory category = parameter.getCategory(key);
    int timeFrameUp = Integer.parseInt(parameter.getParameter(key, "Time Frame Up"));
    int timeFrameDown = Integer.parseInt(parameter.getParameter(key, "Time Frame Up"));
    List<Indicator> ilAdx = new ArrayList<>();
    List<String> nlAdx = new ArrayList<>();

    ilAdx.add(new ADXIndicator(series.get(), timeFrameDown));
    ilAdx.add(new ADXIndicator(series.get(), timeFrameDown));
    nlAdx.add("ADX UP "+timeFrameUp);
    nlAdx.add("ADX Down "+timeFrameUp);
    XYLineAndShapeRenderer adxRenderer = new XYLineAndShapeRenderer();
    adxRenderer.setSeriesPaint(0, color1);
    adxRenderer.setSeriesStroke(0, stroke1.stroke);
    adxRenderer.setSeriesShape(0, shape1.shape);
    adxRenderer.setSeriesPaint(1, color2);
    adxRenderer.setSeriesStroke(1, stroke2.stroke);
    adxRenderer.setSeriesShape(1, shape2.shape);
    addChartIndicator(key,
            ilAdx,
            nlAdx,
            String.format("%s [%s] (%s, %s)", getIdentifier(key), getID(key), timeFrameUp, timeFrameDown ),
            adxRenderer,
            chartType.toBoolean(),
            category);

}
 
Example 6
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void loadAroonUP_DOWN(String key) throws XPathException{
    int arronUp = Integer.parseInt(parameter.getParameter(key, "Time Frame Up"));
    int arronDown = Integer.parseInt(parameter.getParameter(key, "Time Frame Down"));
    Color colorD = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Down"));
    StrokeType strokeD = StrokeType.valueOf(parameter.getParameter(key, "Stroke Down"));
    ShapeType shapeD = ShapeType.valueOf(parameter.getParameter(key, "Shape Down"));
    ChartType chartType = parameter.getChartType(key);
    IndicatorCategory category = parameter.getCategory(key);

    List<Indicator> ilAroon = new ArrayList<>();
    List<String> nlAroon = new ArrayList<>();
    ilAroon.add(new AroonDownIndicator(series.get(), arronDown));
    ilAroon.add(new AroonUpIndicator(series.get(), arronUp));
    nlAroon.add("Aroon Down "+arronDown);
    nlAroon.add("Aroon Up "+arronUp);
    XYLineAndShapeRenderer arronUpDownRenderer = createRenderer(key, "Color Up", "Shape Up", "Stroke Up");

    arronUpDownRenderer.setSeriesPaint(1, colorD);
    arronUpDownRenderer.setSeriesStroke(1, strokeD.stroke);
    arronUpDownRenderer.setSeriesShape(1, shapeD.shape);

    addChartIndicator(key,
            ilAroon,
            nlAroon,String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key),arronUp, arronDown),
            arronUpDownRenderer,
            chartType.toBoolean(),
            category);
}
 
Example 7
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XYLineAndShapeRenderer createRenderer(Paint p, Stroke s, Shape sh, boolean isShape){
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, isShape);
    if(isShape){
        renderer.setSeriesShape(0,sh);
    }
    renderer.setSeriesPaint(0,p);
    renderer.setSeriesStroke(0,s);
    return renderer;

}
 
Example 8
Source File: ProfilePlotPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void configureRendererForCorrelativeData(XYLineAndShapeRenderer renderer) {
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesPaint(1, StatisticChartStyling.CORRELATIVE_POINT_PAINT);
    renderer.setSeriesFillPaint(1, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    renderer.setSeriesShape(1, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
}
 
Example 9
Source File: AlignmentRansacPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public AlignmentRansacPlot() {
  super(ChartFactory.createXYLineChart("", null, null, new XYSeriesCollection(),
      PlotOrientation.VERTICAL, true, true, false));

  chart = this.getChart();
  chart.setBackgroundPaint(Color.white);

  // title
  chartTitle = chart.getTitle();
  chartTitle.setMargin(5, 0, 0, 0);
  chartTitle.setFont(titleFont);

  // legend constructed by ChartFactory
  legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  // set the plot properties
  plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
  dataset = (XYSeriesCollection) plot.getDataset();

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties

  plot.setDomainCrosshairVisible(true);
  plot.setRangeCrosshairVisible(true);
  plot.setDomainCrosshairPaint(crossHairColor);
  plot.setRangeCrosshairPaint(crossHairColor);
  plot.setDomainCrosshairStroke(crossHairStroke);
  plot.setRangeCrosshairStroke(crossHairStroke);

  // set default renderer properties
  XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
  renderer.setDefaultLinesVisible(false);
  renderer.setDefaultShapesVisible(true);
  renderer.setSeriesShape(0, dataPointsShape);
  renderer.setSeriesShape(1, dataPointsShape);
  renderer.setSeriesLinesVisible(2, true);
  renderer.setSeriesShapesVisible(2, false);
  renderer.setSeriesPaint(0, Color.RED);
  renderer.setSeriesPaint(1, Color.GRAY);
  renderer.setSeriesPaint(2, Color.BLUE);
  renderer.setDefaultItemLabelPaint(labelsColor);
  renderer.setDrawSeriesLineAsPath(true);

  plot.setRenderer(renderer);

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 10
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void loadBollingerBands(String key) throws XPathException{
    List<Indicator> indicatorList = new ArrayList<>();
    List<String> namesList = new ArrayList<>();
    XYLineAndShapeRenderer bbRenderer = new XYLineAndShapeRenderer();
    int id = getID(key);

    int timeFrame = Integer.parseInt(parameter.getParameter(key,"Time Frame"));

    StandardDeviationIndicator sd = new StandardDeviationIndicator(closePriceIndicator.get(), timeFrame);
    EMAIndicator bollingerEMA = new EMAIndicator(closePriceIndicator.get(),timeFrame);
    Color color1 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Middle Band"));
    StrokeType stroke1 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Middle Band"));
    ShapeType shape1 = ShapeType.valueOf(parameter.getParameter(key,"Shape Middle Band"));
    Color color2 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Upper Band"));
    StrokeType stroke2 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Upper Band"));
    ShapeType shape2 = ShapeType.valueOf(parameter.getParameter(key,"Shape Upper Band"));
    Color color3 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Lower Band"));
    StrokeType stroke3 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Lower Band"));
    ShapeType shape3 = ShapeType.valueOf(parameter.getParameter(key,"Shape Lower Band"));
    ChartType chartType = ChartType.valueOf(parameter.getParameter(key, "Chart Type"));
    IndicatorCategory category = parameter.getCategory(key);

    BollingerBandsMiddleIndicator bbm = new BollingerBandsMiddleIndicator(bollingerEMA);
    BollingerBandsUpperIndicator bbu = new BollingerBandsUpperIndicator(bbm,sd);
    BollingerBandsLowerIndicator bbl = new BollingerBandsLowerIndicator(bbm,sd);

    indicatorList.add(bbm);
    indicatorList.add(bbu);
    indicatorList.add(bbl);

    namesList.add("Middle Band"+ timeFrame);
    namesList.add("Upper Band ");
    namesList.add("Lower Band ");

    bbRenderer.setSeriesPaint(0, color1);
    bbRenderer.setSeriesStroke(0, stroke1.stroke);
    bbRenderer.setSeriesShape(0, shape1.shape);
    bbRenderer.setSeriesPaint(1, color2);
    bbRenderer.setSeriesStroke(1,stroke2.stroke);
    bbRenderer.setSeriesShape(1, shape2.shape);
    bbRenderer.setSeriesPaint(2, color3);
    bbRenderer.setSeriesStroke(2, stroke3.stroke);
    bbRenderer.setSeriesShape(2, shape3.shape);
    addChartIndicator(key,
            indicatorList,
            namesList,
            String.format("Bollinger Bands [%s] (%s)",id,timeFrame),
            bbRenderer,chartType.toBoolean(),
            category);
}
 
Example 11
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void loadMACDIndicator(String key) throws XPathExpressionException {
    int timeFrameShort = Integer.parseInt(parameter.getParameter(key, "Time Frame Short"));
    int timeFrameLong = Integer.parseInt(parameter.getParameter(key, "Time Frame Long"));
    IndicatorCategory category = parameter.getCategory(key);
    ChartType chartType = parameter.getChartType(key);
    boolean signalLine = Boolean.valueOf(parameter.getParameter(key, "Add Signal Line"));
    XYLineAndShapeRenderer renderer = createRenderer(key, "Color", "Shape", "Stroke");
    MACDIndicator mcd = new MACDIndicator(closePriceIndicator.get(), timeFrameShort, timeFrameLong);
    if(!signalLine){
        addChartIndicator(key,
                mcd,
                String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong),
                renderer,
                chartType.toBoolean(),
                category);

    } else{
        int timeFrameSignal = Integer.parseInt(parameter.getParameter(key, "Time Frame Signal Line"));
        List<String> names = new ArrayList<>();
        List<Indicator> indicators = new ArrayList<>();
        indicators.add(mcd);
        indicators.add(new EMAIndicator(mcd, timeFrameSignal));
        names.add(String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong));
        names.add(String.format("Signal Line [%s] (%s)",getID(key),timeFrameSignal));
        Color color = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Signal Line"));
        ShapeType shape = ShapeType.valueOf(parameter.getParameter(key, "Shape Signal Line"));
        StrokeType stroke = StrokeType.valueOf(parameter.getParameter(key, "Stroke Signal Line"));
        renderer.setSeriesPaint(1,color);
        renderer.setSeriesShape(1,shape.shape);
        renderer.setSeriesStroke(1, stroke.stroke);
        addChartIndicator(key,
                indicators,
                names,
                String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong),
                renderer,
                chartType.toBoolean(),
                category);
    }



}
 
Example 12
Source File: BaseIndicatorBox.java    From TAcharting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void loadKeltner(String key) throws XPathException{

        int timeFrame = Integer.parseInt(parameter.getParameter(key, "Time Frame"));
        double ratio = Double.valueOf(parameter.getParameter(key, "Ratio"));
        int atr = Integer.parseInt(parameter.getParameter(key, "Time Frame ATR"));
        Color colorU = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Upper"));
        StrokeType strokeU = StrokeType.valueOf(parameter.getParameter(key, "Stroke Upper"));
        ShapeType shapeU = ShapeType.valueOf(parameter.getParameter(key,"Shape Upper"));
        Color colorL = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Lower"));
        StrokeType strokeL = StrokeType.valueOf(parameter.getParameter(key, "Stroke Lower"));
        ShapeType shapeL = ShapeType.valueOf(parameter.getParameter(key,"Shape Lower"));
        ChartType chartType = ChartType.valueOf(parameter.getParameter(key, "Chart Type"));
        IndicatorCategory category = parameter.getCategory(key);

        XYLineAndShapeRenderer renderer = createRenderer(key, "Color Middle", "Shape Middle", "Stroke Middle");
        renderer.setSeriesStroke(1, strokeU.stroke);
        renderer.setSeriesStroke(2, strokeL.stroke);
        renderer.setSeriesShape(1, shapeU.shape);
        renderer.setSeriesShape(2, shapeL.shape);
        renderer.setSeriesPaint(1, colorU);
        renderer.setSeriesPaint(2, colorL);

        KeltnerChannelMiddleIndicator kcM = new KeltnerChannelMiddleIndicator(series.get(), timeFrame);
        KeltnerChannelUpperIndicator kcU = new KeltnerChannelUpperIndicator(kcM,ratio,atr);
        KeltnerChannelLowerIndicator kcL = new KeltnerChannelLowerIndicator(kcM,ratio,atr);

        List<Indicator> ilKelt = new ArrayList<>();
        List<String> nlKelt = new ArrayList<>();
        ilKelt.add(kcM);
        ilKelt.add(kcU);
        ilKelt.add(kcL);
        nlKelt.add("Keltner Middle");
        nlKelt.add("Keltner Upper");
        nlKelt.add("Keltner Lower");
        addChartIndicator(key,
                ilKelt,
                nlKelt,
                String.format("%s [%s] (%s, %s, %S)", getIdentifier(key), getID(key), timeFrame, ratio, atr),
                renderer,
                chartType.toBoolean(),
                category);
    }
 
Example 13
Source File: ChartRendererFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private static void configureXYLineAndShapeRenderer(XYLineAndShapeRenderer renderer, ValueSource valueSource,
		PlotInstance plotInstance) {
	renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
	SeriesFormat seriesFormat = valueSource.getSeriesFormat();
	DimensionConfig domainConfig = valueSource.getDomainConfig();
	DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
			PlotDimension.COLOR);
	DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
			PlotDimension.SHAPE);
	ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);

	int seriesCount = valueSourceData.getSeriesDataForAllGroupCells().groupCellCount();

	// Loop all series and set series format.
	// Format based on dimension configs will be set later on in initFormatDelegate().
	for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
		// configure linestyle
		if (seriesFormat.getLineStyle() == LineStyle.NONE) {
			renderer.setSeriesLinesVisible(seriesIdx, false);
		} else {
			renderer.setSeriesLinesVisible(seriesIdx, true);
			renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
		}

		// configure series shape if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
			if (seriesFormat.getItemShape() != ItemShape.NONE) {
				renderer.setSeriesShapesVisible(seriesIdx, true);
				renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
			} else {
				renderer.setSeriesShapesVisible(seriesIdx, false);
			}
		}

		// configure series color if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
			Color itemColor = seriesFormat.getItemColor();
			renderer.setSeriesPaint(seriesIdx, itemColor);
			renderer.setSeriesFillPaint(seriesIdx, itemColor);
		}
		renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
		renderer.setUseOutlinePaint(true);
	}
}
 
Example 14
Source File: AlignmentRansacPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public AlignmentRansacPlot() {
  super(null, true);

  dataset = new XYSeriesCollection();
  chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true,
      true, false);

  chart.setBackgroundPaint(Color.white);
  setChart(chart);

  // title
  chartTitle = chart.getTitle();
  chartTitle.setMargin(5, 0, 0, 0);
  chartTitle.setFont(titleFont);

  // legend constructed by ChartFactory
  legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  // set the plot properties
  plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties

  plot.setDomainCrosshairVisible(true);
  plot.setRangeCrosshairVisible(true);
  plot.setDomainCrosshairPaint(crossHairColor);
  plot.setRangeCrosshairPaint(crossHairColor);
  plot.setDomainCrosshairStroke(crossHairStroke);
  plot.setRangeCrosshairStroke(crossHairStroke);

  // set default renderer properties
  XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
  renderer.setDefaultLinesVisible(false);
  renderer.setDefaultShapesVisible(true);
  renderer.setSeriesShape(0, dataPointsShape);
  renderer.setSeriesShape(1, dataPointsShape);
  renderer.setSeriesLinesVisible(2, true);
  renderer.setSeriesShapesVisible(2, false);
  renderer.setSeriesPaint(0, Color.RED);
  renderer.setSeriesPaint(1, Color.GRAY);
  renderer.setSeriesPaint(2, Color.BLUE);
  renderer.setDefaultItemLabelPaint(labelsColor);
  renderer.setDrawSeriesLineAsPath(true);

  plot.setRenderer(renderer);


  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 15
Source File: Scatter.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public JFreeChart getChart() {
    if (chart == null) {
        chart = ChartFactory.createXYLineChart(title, // chart title
                xLabel,
                // domain axis label
                yLabel,
                // range axis label
                dataset,
                // data
                PlotOrientation.VERTICAL,
                // orientation
                true,
                // include legend
                true,
                // tooltips?
                false
        // URLs?
        );

        XYPlot plot = (XYPlot) chart.getPlot();
        if (xLog) {
            LogAxis xAxis = new LogAxis("");
            xAxis.setBase(10);
            plot.setDomainAxis(xAxis);
        }
        if (yLog) {
            LogAxis yAxis = new LogAxis("");
            yAxis.setBase(10);
            plot.setRangeAxis(yAxis);
        }

        if (colors == null) {
            colors = ColorBrewer.getPairedColors(dataset.getSeriesCount());
        }
        for( int i = 0; i < colors.length; i++ ) {
            plot.getRenderer().setSeriesPaint(i, colors[i]);
        }

        ValueAxis rangeAxis = plot.getRangeAxis();
        if (rangeAxis instanceof NumberAxis) {
            NumberAxis axis = (NumberAxis) rangeAxis;
            axis.setAutoRangeIncludesZero(false);
        }

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        double x = 1.5;
        double w = x * 2;
        renderer.setSeriesShape(0, new Ellipse2D.Double(-x, x, w, w));
        setShapeLinesVisibility(plot);
    }
    return chart;
}