<commit_before><?xml version="1.0" encoding="utf-8"?>
<mx:VBox  xmlns:mx="http://www.adobe.com/2006/mxml"
		  xmlns:ui="weave.ui.*"
		  xmlns="weave.editors.*"
		  label="{lang('ScatterPlot')}"
		  implements="weave.api.ui.ILinkableObjectEditor">
	<mx:Script>
		<![CDATA[
			import mx.events.SliderEvent;
			
			import weave.api.core.ILinkableObject;
			import weave.api.getCallbackCollection;
			import weave.api.linkBindableProperty;
			import weave.api.unlinkBindableProperty;
			import weave.compiler.StandardLib;
			import weave.data.AttributeColumns.ColorColumn;
			import weave.utils.PlotterUtils;
			import weave.visualization.plotters.ScatterPlotPlotter;
			
			[Bindable]private var _plotter:ScatterPlotPlotter = null;
			
			
			public function setTarget(object:ILinkableObject):void
			{
				if(_plotter)
				{
					_plotter.fill.color.removeCallback(handleColorColumnChange);
					unlinkBindableProperty(_plotter.fill.alpha.defaultValue, alphaSlider, "value");
					unlinkBindableProperty(_plotter.enabledSizeBy, sizeByCheck, "selected");
					getCallbackCollection(_plotter).removeCallback(handlePlotterChange);
					_plotter.fill.color.removeCallback(handlePlotterFillColor);
					unlinkBindableProperty(_plotter.colorNegative, colorNegativePicker, 'selectedColor');
					unlinkBindableProperty(_plotter.colorPositive, colorPositivePicker, 'selectedColor');
					unlinkBindableProperty(_plotter.colorBySize, colorBySizeCheckBox, 'selected');
					
					dataXCol.dynamicObject = null;
					dataYCol.dynamicObject = null;
					colorCol.dynamicObject = null;
					sizeSelector.dynamicObject = null;
				}
				
				_plotter = object as ScatterPlotPlotter;
				
				if(_plotter)
				{
					if (!initialized)
						initialize();
					_plotter.fill.color.addImmediateCallback(this, handleColorColumnChange, true);
					linkBindableProperty(_plotter.fill.alpha.defaultValue, alphaSlider, "value");
					linkBindableProperty(_plotter.enabledSizeBy, sizeByCheck, "selected");
					getCallbackCollection(_plotter).addGroupedCallback(this, handlePlotterChange, true);
					_plotter.fill.color.addGroupedCallback(this, handlePlotterFillColor);
					linkBindableProperty(_plotter.colorNegative, colorNegativePicker, 'selectedColor');
					linkBindableProperty(_plotter.colorPositive, colorPositivePicker, 'selectedColor');
					linkBindableProperty(_plotter.colorBySize, colorBySizeCheckBox, 'selected');
					
					dataXCol.dynamicObject = _plotter.dataX;
					dataYCol.dynamicObject = _plotter.dataY;
					colorCol.columnWrapper = _plotter.fill.color;
					sizeSelector.dynamicObject = _plotter.screenRadius;
				}
			}
			
			public function hasPendingChanges():Boolean { return false; }
			public function applyChanges():void { }
			
			private var _prevGlobalColorColumnName:String = null;
			private function handleColorColumnChange():void
			{
				var newName:String = _plotter.fill.color.internalDynamicColumn.globalName;
				if (newName)
					_prevGlobalColorColumnName = newName;
			}
			
			private function handlePlotterChange():void
			{
				// when the plotter settings change, update the slider interface
				if (_plotter.colorBySize.value)
				{
					sizeBySlider.thumbCount = 1;
					sizeBySlider.value = _plotter.maxScreenRadius.value;
				}
				else if (_plotter.enabledSizeBy.value)
				{
					sizeBySlider.thumbCount = 2;
					sizeBySlider.values = [_plotter.minScreenRadius.value, _plotter.maxScreenRadius.value];
				}
				else
				{
					sizeBySlider.thumbCount = 1;
					sizeBySlider.value = _plotter.defaultScreenRadius.value;
				}
			}
			private function handleSizeSliderChange(event:SliderEvent):void
			{
				// when user interacts with slider, update session state
				if (_plotter.colorBySize.value)
				{
					_plotter.maxScreenRadius.value = event.value;
				}
				else if (_plotter.enabledSizeBy.value)
				{
					if(event.thumbIndex == 0)
					{
						_plotter.minScreenRadius.value = event.value;
					}
					else
					{
						_plotter.maxScreenRadius.value = event.value;
					}
				}
				else
				{
					_plotter.defaultScreenRadius.value = event.value;
				}
			}
			private function handlePlotterFillColor():void
			{
				overrideColorCheckBox.mx_internal::setSelected(!_plotter.fill.color.getInternalColumn());
				var color:Number = StandardLib.asNumber(_plotter.fill.color.defaultValue.value);
				if (isFinite(color))
					overrideColorPicker.selectedColor = color;
			}
			private function handleOverrideColor():void
			{
				if (overrideColorCheckBox.selected)
				{
					colorBySizeCheckBox.selected = false;
					_plotter.fill.color.defaultValue.value = overrideColorPicker.selectedColor;
					_plotter.fill.color.internalDynamicColumn.removeObject();
				}
				else
				{
					_plotter.fill.color.defaultValue.value = NaN;
					_plotter.fill.color.internalDynamicColumn.requestGlobalObject(_prevGlobalColorColumnName, ColorColumn, false);
				}
			}
		]]>
	</mx:Script>
	<ui:DynamicColumnComponent id="dataXCol" label="{lang('X')}"/>
	<ui:DynamicColumnComponent id="dataYCol" label="{lang('Y')}"/>
	<ui:DynamicColumnComponent id="colorCol" label="{lang('Color')}" showLinkControl="false"/>
	<ui:CustomCheckBox id="sizeByCheck" label="{lang('Size')}" textAlign="right"/>
	<ui:DynamicColumnComponent id="sizeSelector">
		<ui:creationComplete>
			<![CDATA[
			sizeSelector.addChildAt(sizeByCheck, 0);
			sizeSelector.useFirstChildAsLabel = true;
			]]>
		</ui:creationComplete>
	</ui:DynamicColumnComponent>
	<ui:Indent label="{lang('Point size')}">
		<mx:HSlider id="sizeBySlider"
					liveDragging="true"
					width="100%"
					thumbCount="2"
					snapInterval="1"
					minimum="1" 
					maximum="60"
					tickValues="[5,10,15,20,25,30,35,40,45,50,55,60]"
					change="handleSizeSliderChange(event)"
					mouseDown="event.stopImmediatePropagation();"/>
	</ui:Indent>
	<ui:Indent label="{lang('Point opacity')}">
		<mx:HSlider id="alphaSlider" 
					width="100%" 
					snapInterval="0.05"
					tickInterval=".25"
					dataTipFormatFunction="{PlotterUtils.alphaSliderFormatFunction}"
					minimum="0" maximum="1"
					liveDragging="true"/>
	</ui:Indent>
	
	<mx:HBox>
		<mx:CheckBox id="overrideColorCheckBox"
					 label="{lang('Override global color')}"
					 change="handleOverrideColor()"/>
		<ui:CustomColorPicker id="overrideColorPicker"
							  enabled="{overrideColorCheckBox.selected}"
							  selectedColor="0xE0E0E0"
							  change="handleOverrideColor()"/><commit_msg>fixed bugs where scatterplot initial state would be changed by editor.<commit_after><?xml version="1.0" encoding="utf-8"?>
<mx:VBox  xmlns:mx="http://www.adobe.com/2006/mxml"
		  xmlns:ui="weave.ui.*"
		  xmlns="weave.editors.*"
		  label="{lang('ScatterPlot')}"
		  implements="weave.api.ui.ILinkableObjectEditor">
	<mx:Script>
		<![CDATA[
			import mx.core.UIComponent;
			import mx.events.SliderEvent;
			
			import weave.api.core.ILinkableObject;
			import weave.api.getCallbackCollection;
			import weave.api.linkBindableProperty;
			import weave.api.unlinkBindableProperty;
			import weave.compiler.StandardLib;
			import weave.core.UIUtils;
			import weave.data.AttributeColumns.ColorColumn;
			import weave.utils.PlotterUtils;
			import weave.visualization.plotters.ScatterPlotPlotter;
			
			[Bindable]private var _plotter:ScatterPlotPlotter = null;
			
			
			public function setTarget(object:ILinkableObject):void
			{
				if(_plotter)
				{
					unlinkBindableProperty(_plotter.fill.alpha.defaultValue, alphaSlider, "value");
					unlinkBindableProperty(_plotter.enabledSizeBy, sizeByCheck, "selected");
					unlinkBindableProperty(_plotter.colorNegative, colorNegativePicker, 'selectedColor');
					unlinkBindableProperty(_plotter.colorPositive, colorPositivePicker, 'selectedColor');
					unlinkBindableProperty(_plotter.colorBySize, colorBySizeCheckBox, 'selected');
					_plotter.fill.color.removeCallback(handleColorColumnChange);
					_plotter.fill.color.removeCallback(handlePlotterFillColor);
					getCallbackCollection(_plotter).removeCallback(handlePlotterChange);
					
					dataXCol.dynamicObject = null;
					dataYCol.dynamicObject = null;
					colorCol.columnWrapper = null;
					sizeCol.dynamicObject = null;
				}
				
				_plotter = object as ScatterPlotPlotter;
				
				if(_plotter)
				{
					if (!initialized)
						initialize();
					linkBindableProperty(_plotter.fill.alpha.defaultValue, alphaSlider, "value");
					linkBindableProperty(_plotter.enabledSizeBy, sizeByCheck, "selected");
					linkBindableProperty(_plotter.colorNegative, colorNegativePicker, 'selectedColor');
					linkBindableProperty(_plotter.colorPositive, colorPositivePicker, 'selectedColor');
					linkBindableProperty(_plotter.colorBySize, colorBySizeCheckBox, 'selected');
					_plotter.fill.color.addImmediateCallback(this, handleColorColumnChange, true);
					_plotter.fill.color.addGroupedCallback(this, handlePlotterFillColor);
					getCallbackCollection(_plotter).addGroupedCallback(this, handlePlotterChange, true);
					
					dataXCol.dynamicObject = _plotter.dataX;
					dataYCol.dynamicObject = _plotter.dataY;
					colorCol.columnWrapper = _plotter.fill.color;
					sizeCol.dynamicObject = _plotter.screenRadius;
				}
			}
			
			public function hasPendingChanges():Boolean { return false; }
			public function applyChanges():void { }
			
			private var _prevGlobalColorColumnName:String = null;
			private function handleColorColumnChange():void
			{
				var newName:String = _plotter.fill.color.internalDynamicColumn.globalName;
				if (newName)
					_prevGlobalColorColumnName = newName;
			}
			
			private function handlePlotterChange():void
			{
				// when the plotter settings change, update the slider interface
				if (_plotter.colorBySize.value)
				{
					sizeBySlider.thumbCount = 1;
					sizeBySlider.value = _plotter.maxScreenRadius.value;
				}
				else if (_plotter.enabledSizeBy.value)
				{
					sizeBySlider.thumbCount = 2;
					sizeBySlider.values = [_plotter.minScreenRadius.value, _plotter.maxScreenRadius.value];
				}
				else
				{
					sizeBySlider.thumbCount = 1;
					sizeBySlider.value = _plotter.defaultScreenRadius.value;
				}
			}
			private function handleSizeSliderChange(event:SliderEvent):void
			{
				if (!UIUtils.hasFocus(event.target as UIComponent))
					return;
				
				// when user interacts with slider, update session state
				if (_plotter.colorBySize.value)
				{
					_plotter.maxScreenRadius.value = event.value;
				}
				else if (_plotter.enabledSizeBy.value)
				{
					if(event.thumbIndex == 0)
					{
						_plotter.minScreenRadius.value = event.value;
					}
					else
					{
						_plotter.maxScreenRadius.value = event.value;
					}
				}
				else
				{
					_plotter.defaultScreenRadius.value = event.value;
				}
			}
			private function handlePlotterFillColor():void
			{
				overrideColorCheckBox.mx_internal::setSelected(!_plotter.fill.color.getInternalColumn());
				var color:Number = StandardLib.asNumber(_plotter.fill.color.defaultValue.value);
				if (isFinite(color))
					overrideColorPicker.selectedColor = color;
			}
			private function handleOverrideColor(event:Event):void
			{
				if (!UIUtils.hasFocus(event.target as UIComponent))
					return;
				if (overrideColorCheckBox.selected)
				{
					colorBySizeCheckBox.selected = false;
					_plotter.fill.color.defaultValue.value = overrideColorPicker.selectedColor;
					_plotter.fill.color.internalDynamicColumn.removeObject();
				}
				else
				{
					_plotter.fill.color.defaultValue.value = NaN;
					_plotter.fill.color.internalDynamicColumn.requestGlobalObject(_prevGlobalColorColumnName, ColorColumn, false);
				}
			}
		]]>
	</mx:Script>
	<ui:DynamicColumnComponent id="dataXCol" label="{lang('X')}"/>
	<ui:DynamicColumnComponent id="dataYCol" label="{lang('Y')}"/>
	<ui:DynamicColumnComponent id="colorCol" label="{lang('Color')}" showLinkControl="false"/>
	<ui:CustomCheckBox id="sizeByCheck" label="{lang('Size')}" textAlign="right"/>
	<ui:DynamicColumnComponent id="sizeCol">
		<ui:creationComplete>
			<![CDATA[
			sizeCol.addChildAt(sizeByCheck, 0);
			sizeCol.useFirstChildAsLabel = true;
			]]>
		</ui:creationComplete>
	</ui:DynamicColumnComponent>
	<ui:Indent label="{lang('Point size')}">
		<mx:HSlider id="sizeBySlider"
					liveDragging="true"
					width="100%"
					thumbCount="2"
					snapInterval="1"
					minimum="1" 
					maximum="60"
					tickValues="[5,10,15,20,25,30,35,40,45,50,55,60]"
					change="handleSizeSliderChange(event)"
					mouseDown="event.stopImmediatePropagation();"/>
	</ui:Indent>
	<ui:Indent label="{lang('Point opacity')}">
		<mx:HSlider id="alphaSlider" 
					width="100%" 
					snapInterval="0.05"
					tickInterval=".25"
					dataTipFormatFunction="{PlotterUtils.alphaSliderFormatFunction}"
					minimum="0" maximum="1"
					liveDragging="true"/>
	</ui:Indent>
	
	<mx:HBox>
		<mx:CheckBox id="overrideColorCheckBox"
					 label="{lang('Override global color')}"
					 change="handleOverrideColor(event)"/>
		<ui:CustomColorPicker id="overrideColorPicker"
							  enabled="{overrideColorCheckBox.selected}"
							  selectedColor="0xE0E0E0"
							  change="handleOverrideColor(event)"/>
{'fraction_non_alphanumeric': 0.11769189724826587, 'fraction_numerical': 0.008689686713926366, 'mean_word_length': 4.171462357114702, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 2, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, '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': '5522095', 'n_tokens_mistral': 5228, 'n_tokens_neox': 4045, 'n_words': 573}