<commit_before>package org.csstudio.opibuilder.widgets.editparts;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.csstudio.opibuilder.datadefinition.ColorMap;
import org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart;
import org.csstudio.opibuilder.editparts.ExecutionMode;
import org.csstudio.opibuilder.model.AbstractPVWidgetModel;
import org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler;
import org.csstudio.opibuilder.util.OPIColor;
import org.csstudio.opibuilder.util.OPIFont;
import org.csstudio.opibuilder.util.UIBundlingThread;
import org.csstudio.opibuilder.visualparts.BorderFactory;
import org.csstudio.opibuilder.visualparts.BorderStyle;
import org.csstudio.opibuilder.widgets.figures.IntensityGraphFigure;
import org.csstudio.opibuilder.widgets.figures.IntensityGraphFigure.IProfileDataChangeLisenter;
import org.csstudio.opibuilder.widgets.model.IntensityGraphModel;
import org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty;
import org.csstudio.platform.data.IValue;
import org.csstudio.platform.data.ValueUtil;
import org.csstudio.platform.ui.util.CustomMediaFactory;
import org.csstudio.swt.xygraph.figures.Axis;
import org.csstudio.swt.xygraph.linearscale.Range;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;

/**The widget editpart of intensity graph widget.
 * @author <NAME>
 *
 */
public class IntensityGraphEditPart extends AbstractPVWidgetEditPart {

	
	private boolean innerTrig;
	
	@Override
	protected IFigure doCreateFigure() {
		IntensityGraphModel model = getWidgetModel();
		IntensityGraphFigure graph = new IntensityGraphFigure(getExecutionMode());
		graph.setMin(model.getMinimum());
		graph.setMax(model.getMaximum());
		graph.setDataWidth(model.getDataWidth());
		graph.setDataHeight(model.getDataHeight());
		graph.setColorMap(model.getColorMap());
		graph.setShowRamp(model.isShowRamp());
		graph.setCropLeft(model.getCropLeft());
		graph.setCropRigth(model.getCropRight());
		graph.setCropTop(model.getCropTOP());
		graph.setCropBottom(model.getCropBottom());
		//init X-Axis
		for(AxisProperty axisProperty : AxisProperty.values()){
			String propID = IntensityGraphModel.makeAxisPropID(
					IntensityGraphModel.X_AXIS_ID, axisProperty.propIDPre);
			setAxisProperty(graph.getXAxis(), axisProperty, model.getPropertyValue(propID));
		}
		//init Y-Axis
		for(AxisProperty axisProperty : AxisProperty.values()){
			String propID = IntensityGraphModel.makeAxisPropID(
					IntensityGraphModel.Y_AXIS_ID, axisProperty.propIDPre);
			setAxisProperty(graph.getYAxis(), axisProperty, model.getPropertyValue(propID));
		}
		//add profile data listener
		if(getExecutionMode() == ExecutionMode.RUN_MODE && 
				(model.getHorizonProfileYPV().trim().length() >0 || 
						model.getVerticalProfileYPV().trim().length() > 0)){
			graph.addProfileDataListener(new IProfileDataChangeLisenter(){

				public void profileDataChanged(double[] xProfileData,
						double[] yProfileData, Range xAxisRange, Range yAxisRange) {
					//horizontal
					setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_Y_PV_NAME, xProfileData);
					double[] horizonXData = new double[xProfileData.length];
					double d = (xAxisRange.getUpper() - xAxisRange.getLower())/xProfileData.length;
					for(int i=0; i<xProfileData.length; i++){
						horizonXData[i] = xAxisRange.getLower() + d *i;
					}
					setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_X_PV_NAME, horizonXData);
					//vertical
					setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_Y_PV_NAME, yProfileData);
					double[] verticalXData = new double[yProfileData.length];
					d = (yAxisRange.getUpper() - yAxisRange.getLower())/yProfileData.length;
					for(int i=0; i<yProfileData.length; i++){
						verticalXData[i] = yAxisRange.getLower() + d *i;
					}
					setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_X_PV_NAME, verticalXData);					
				}	
				
			});
		}
		
		return graph;
	}
	
	@Override
	public IntensityGraphModel getWidgetModel() {
		return (IntensityGraphModel)getModel();
	}

	@Override<commit_msg>bug fix<commit_after>package org.csstudio.opibuilder.widgets.editparts;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.csstudio.opibuilder.datadefinition.ColorMap;
import org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart;
import org.csstudio.opibuilder.editparts.ExecutionMode;
import org.csstudio.opibuilder.model.AbstractPVWidgetModel;
import org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler;
import org.csstudio.opibuilder.util.OPIColor;
import org.csstudio.opibuilder.util.OPIFont;
import org.csstudio.opibuilder.util.UIBundlingThread;
import org.csstudio.opibuilder.visualparts.BorderFactory;
import org.csstudio.opibuilder.visualparts.BorderStyle;
import org.csstudio.opibuilder.widgets.figures.IntensityGraphFigure;
import org.csstudio.opibuilder.widgets.figures.IntensityGraphFigure.IProfileDataChangeLisenter;
import org.csstudio.opibuilder.widgets.model.IntensityGraphModel;
import org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty;
import org.csstudio.platform.data.IValue;
import org.csstudio.platform.data.ValueUtil;
import org.csstudio.platform.ui.util.CustomMediaFactory;
import org.csstudio.swt.xygraph.figures.Axis;
import org.csstudio.swt.xygraph.linearscale.Range;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;

/**The widget editpart of intensity graph widget.
 * @author <NAME>
 *
 */
public class IntensityGraphEditPart extends AbstractPVWidgetEditPart {

	
	private boolean innerTrig;
	
	@Override
	protected IFigure doCreateFigure() {
		IntensityGraphModel model = getWidgetModel();
		IntensityGraphFigure graph = new IntensityGraphFigure(getExecutionMode());
		graph.setMin(model.getMinimum());
		graph.setMax(model.getMaximum());
		graph.setDataWidth(model.getDataWidth());
		graph.setDataHeight(model.getDataHeight());
		graph.setColorMap(model.getColorMap());
		graph.setShowRamp(model.isShowRamp());
		graph.setCropLeft(model.getCropLeft());
		graph.setCropRigth(model.getCropRight());
		graph.setCropTop(model.getCropTOP());
		graph.setCropBottom(model.getCropBottom());
		//init X-Axis
		for(AxisProperty axisProperty : AxisProperty.values()){
			String propID = IntensityGraphModel.makeAxisPropID(
					IntensityGraphModel.X_AXIS_ID, axisProperty.propIDPre);
			setAxisProperty(graph.getXAxis(), axisProperty, model.getPropertyValue(propID));
		}
		//init Y-Axis
		for(AxisProperty axisProperty : AxisProperty.values()){
			String propID = IntensityGraphModel.makeAxisPropID(
					IntensityGraphModel.Y_AXIS_ID, axisProperty.propIDPre);
			setAxisProperty(graph.getYAxis(), axisProperty, model.getPropertyValue(propID));
		}
		//add profile data listener
		if(getExecutionMode() == ExecutionMode.RUN_MODE && 
				(model.getHorizonProfileYPV().trim().length() >0 || 
						model.getVerticalProfileYPV().trim().length() > 0)){
			graph.addProfileDataListener(new IProfileDataChangeLisenter(){

				public void profileDataChanged(double[] xProfileData,
						double[] yProfileData, Range xAxisRange, Range yAxisRange) {
					//horizontal
					setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_Y_PV_NAME, xProfileData);
					double[] horizonXData = new double[xProfileData.length];
					double d = (xAxisRange.getUpper() - xAxisRange.getLower())/(xProfileData.length-1);
					for(int i=0; i<xProfileData.length; i++){
						horizonXData[i] = xAxisRange.getLower() + d *i;
					}
					setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_X_PV_NAME, horizonXData);
					//vertical
					setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_Y_PV_NAME, yProfileData);
					double[] verticalXData = new double[yProfileData.length];
					d = (yAxisRange.getUpper() - yAxisRange.getLower())/(yProfileData.length-1);
					for(int i=0; i<yProfileData.length; i++){
						verticalXData[i] = yAxisRange.getUpper() - d*i;
					}
					setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_X_PV_NAME, verticalXData);					
				}	
				
			});
		}
		
		return graph;
	}
	
	@Override
	public IntensityGraphModel getWidgetModel() {
		return (IntensityGraphModel)getModel();
	}

	@Override
{'fraction_non_alphanumeric': 0.11158277744087326, 'fraction_numerical': 0.0016979987871437235, 'mean_word_length': 5.7040650406504065, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2022401', 'n_tokens_mistral': 2990, 'n_tokens_neox': 2693, 'n_words': 367}