<commit_before>/**
 * 
 */
package org.epics.pvmanager.graphene;

import java.awt.image.BufferedImage;
import java.util.List;

import org.epics.graphene.Point2DDataset;
import org.epics.graphene.ScatterGraph2DRenderer;
import org.epics.graphene.ScatterGraph2DRendererUpdate;
import org.epics.pvmanager.QueueCollector;
import org.epics.pvmanager.ReadFunction;
import org.epics.vtype.VImage;
import org.epics.vtype.VNumberArray;
import org.epics.vtype.ValueUtil;

/**
 * @author shroffk
 * 
 */
public class ScatterGraphFunction implements ReadFunction<Plot2DResult> {

    private ReadFunction<? extends VNumberArray> yArray;
    private ReadFunction<? extends VNumberArray> xArray;

    private ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300,
	    200);

    private VImage previousImage;

    private final QueueCollector<ScatterGraph2DRendererUpdate> rendererUpdateQueue = new QueueCollector<>(
	    100);

    public ScatterGraphFunction(ReadFunction<? extends VNumberArray> yArray,
	    ReadFunction<? extends VNumberArray> xArray) {
	this.yArray = yArray;
	this.xArray = xArray;
    }

    public QueueCollector<ScatterGraph2DRendererUpdate> getRendererUpdateQueue() {
	return rendererUpdateQueue;
    }

    @Override
    public Plot2DResult readValue() {
	VNumberArray newYData = yArray.readValue();
	VNumberArray newXData = xArray.readValue();

	Point2DDataset dataset = null;
	dataset = org.epics.graphene.Point2DDatasets.lineData(
		newXData.getData(), newYData.getData());

	List<ScatterGraph2DRendererUpdate> updates = rendererUpdateQueue
		.readValue();
	for (ScatterGraph2DRendererUpdate scatterGraph2DRendererUpdate : updates) {
	    renderer.update(scatterGraph2DRendererUpdate);
	}

	if (renderer.getImageHeight() == 0 && renderer.getImageWidth() == 0) {
	    return null;<commit_msg>..pvmanager.graphene: adding null checks for ScatterPlotFunction<commit_after>/**
 * 
 */
package org.epics.pvmanager.graphene;

import java.awt.image.BufferedImage;
import java.util.List;

import org.epics.graphene.Point2DDataset;
import org.epics.graphene.ScatterGraph2DRenderer;
import org.epics.graphene.ScatterGraph2DRendererUpdate;
import org.epics.pvmanager.QueueCollector;
import org.epics.pvmanager.ReadFunction;
import org.epics.vtype.VImage;
import org.epics.vtype.VNumberArray;
import org.epics.vtype.ValueUtil;

/**
 * @author shroffk
 * 
 */
public class ScatterGraphFunction implements ReadFunction<Plot2DResult> {

    private ReadFunction<? extends VNumberArray> yArray;
    private ReadFunction<? extends VNumberArray> xArray;

    private ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300,
	    200);

    private VImage previousImage;

    private final QueueCollector<ScatterGraph2DRendererUpdate> rendererUpdateQueue = new QueueCollector<>(
	    100);

    public ScatterGraphFunction(ReadFunction<? extends VNumberArray> yArray,
	    ReadFunction<? extends VNumberArray> xArray) {
	this.yArray = yArray;
	this.xArray = xArray;
    }

    public QueueCollector<ScatterGraph2DRendererUpdate> getRendererUpdateQueue() {
	return rendererUpdateQueue;
    }

    @Override
    public Plot2DResult readValue() {
	VNumberArray newYData = yArray.readValue();
	VNumberArray newXData = xArray.readValue();

	// both x and y array data should be avaliable
	if (newYData == null || newYData.getData() == null)
	    return null;
	if (newXData == null || newXData.getData() == null)
	    return null;
	
	Point2DDataset dataset = null;
	dataset = org.epics.graphene.Point2DDatasets.lineData(
		newXData.getData(), newYData.getData());

	List<ScatterGraph2DRendererUpdate> updates = rendererUpdateQueue
		.readValue();
	for (ScatterGraph2DRendererUpdate scatterGraph2DRendererUpdate : updates) {
	    renderer.update(scatterGraph2DRendererUpdate);
	}

	if (renderer.getImageHeight() == 0 && renderer.getImageWidth() == 0) {
	    return null;
{'fraction_non_alphanumeric': 0.09636691574336512, 'fraction_numerical': 0.013398608606029374, 'mean_word_length': 5.1230283911671926, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6547244', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1223, 'n_words': 241}