package rainbowPackage;

import javafx.scene.paint.Color;

public class DeterminerForBasisImageHit
{
	private ColorTooSimilar colorTooSimilarFunction = new ColorTooSimilar();
	private Color fxColor = Color.BEIGE, tempColor = Color.OLIVE, basisPRColor = Color.INDIANRED;
	private TransparencySlider transparencySlider = new TransparencySlider( Color.BLACK );
	private ColorDecide colorDecide = new ColorDecide();
	private IndependentTextBackgroundColorPasser independentTextBackgroundColorPasser = new IndependentTextBackgroundColorPasser();
	private boolean returnImmediatly = false;

	public DeterminerForBasisImageHit()	{	}

	public Color ToFXColor()
	{
		return transparencySlider.ToFXColor();
	}

	public boolean ReturnImmediatly()
	{
		return returnImmediatly;
	}

	public Color PixelColorDetermine( Color BasisPRColor, Color BackgroundBasisPRColor, Color BrowserPRColor, Color InitialColorContrastingChoice, Color ColorTooSimilarReplacementColor, double ColorDifference, boolean InvertBasisFromBackground, boolean AuxiliarySwitch, boolean InvertBasisPicture, boolean InvertBoth, boolean NextStepColorTooSimilarEffect, boolean TextOutlineBlendingToBasisInvert, Color TextColorToOverlay, Color BackgroundColorToOverlay, Color BasisOverlaySperateTextColor, Color BasisOverlaySperateBackgroundColor, boolean TextColorOverlay, boolean BackgroundColorOverlay, boolean ShowBasisOverlayForText, boolean ShowBasisOverlayForBackground, boolean BasisOverlaySeperateTextFade, boolean BasisOverlaySeperateBackgroundFade, boolean BasisImageStandOutHit, boolean SomeTargetColorHit, boolean BrowserTextHit, double TextTransitionFactor, boolean SomeTargetColorHitFromDisplayType, boolean LaterReversed, boolean TypeOfDisplayIsBackgroundToBasisFullDisplay, boolean UseFadeAtAll, Color ColorFromSplash2D )
	{
		returnImmediatly = true;
		basisPRColor = BasisPRColor;
		fxColor = ColorFromSplash2D;
		transparencySlider.set( ColorFromSplash2D );
		if ( BasisImageStandOutHit && ( InvertBoth || InvertBasisPicture ) )
			//if ( ( !BrowserTextHit && !ShowBasisOverlayForText ) || ( BrowserTextHit && !ShowBasisOverlayForBackground ) )
		{
			//basisPRColor.invert();
			tempColor = basisPRColor;
			basisPRColor = tempColor.invert();
			/*if ( !UseFadeAtAll )
				if ( !BrowserTextHit && ShowBasisOverlayForBackground )
				{
					transparencySlider.set( basisPRColor );
					return transparencySlider.ToFXColor();
				}
				else if ( BrowserTextHit && ShowBasisOverlayForText && TextTransitionFactor < 0.01 )
				{
					transparencySlider.set( BasisPRColor );
					return transparencySlider.ToFXColor();
				}// */
		}
		if ( AuxiliarySwitch && !UseFadeAtAll )//if ( !UseFadeAtAll )
		{
			if ( !( BasisImageStandOutHit && SomeTargetColorHit && BrowserTextHit ) )
				if ( !BasisImageStandOutHit )
					return fxColor;
				else
					return basisPRColor;
			else if ( BasisImageStandOutHit && SomeTargetColorHit && !TextOutlineBlendingToBasisInvert && !ShowBasisOverlayForText && BrowserTextHit )
			{
				//if ( !SomeTargetColorHit )
				//	tempColor = fxColor;
				//else
				//tempColor = basisPRColor;
				//if ( colorTooSimilarFunction.ColorTooSimilarFunction( fxColor, basisPRColor, ColorDifference) )
				//{
				//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor.invert(), tempColor );
					//return transparencySlider.ToFXColor();
				//}
				//else
				//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, tempColor );
				returnImmediatly = false;
				//return colorDecide.NextColorDecide( transparencySlider.ToFXColor(), transparencySlider.ToFXColor(), transparencySlider.ToFXColor(), BrowserPRColor, transparencySlider.ToFXColor(), transparencySlider.ToFXColor(), 9999, true, false, false, false );
				//return transparencySlider.ToFXColor();
				//if ( TextTransitionFactor > 0.99 )
				//	transparencySlider.set( basisPRColor );
				//else if ( TextTransitionFactor < 0.01 )
				//	transparencySlider.set( fxColor );
				//else
				//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
				//fxColor = colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, SomeTargetColorHit, !BrowserTextHit, NextStepColorTooSimilarEffect, InvertBasisFromBackground, TypeOfDisplayIsBackgroundToBasisFullDisplay );
				//if ( TextTransitionFactor > 0.999 )
				//	transparencySlider.set( basisPRColor );
				//else if ( TextTransitionFactor < 0.001 )
				//	transparencySlider.set( fxColor );
				//else
				//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
				//return transparencySlider.ToFXColor();
			}
			else if ( !ShowBasisOverlayForText && SomeTargetColorHit )
			{
				returnImmediatly = false;
				//returnImmediatly = BasisImageStandOutHit && BrowserTextHit && !TextOutlineBlendingToBasisInvert && TextTransitionFactor > 0.04 && TextTransitionFactor < 0.96;
				//return transparencySlider.ToFXColor();//colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, LaterReversed == Reversed, NextStepColorTooSimilarEffect, InvertBasisFromBackground );
			}
			else if ( BasisImageStandOutHit )
			{
				if ( !BrowserTextHit && SomeTargetColorHit && ShowBasisOverlayForBackground )
				{
					transparencySlider.set( basisPRColor );
					return transparencySlider.ToFXColor();
				}
				else if ( !BrowserTextHit && SomeTargetColorHit )
				{
					//if ( ShowBasisOverlayForBackground == false && colorTooSimilarFunction.ColorTooSimilarFunction( fxColor, basisPRColor, ColorDifference ) )
					//	transparencySlider.set( fxColor.invert() );
					return transparencySlider.ToFXColor();
				}
				else if ( BrowserTextHit && SomeTargetColorHit && ShowBasisOverlayForText )
				{
					returnImmediatly = false;
					tempColor = basisPRColor;
					fxColor = tempColor.invert();
					transparencySlider.set( fxColor );
					//if ( ShowBasisOverlayForText && TextTransitionFactor < 0.01 )
					//{
					//	transparencySlider.set( fxColor );
					//	return transparencySlider.ToFXColor();
					//}
				}
				//else if ( BrowserTextHit && ShowBasisOverlayForText && !SomeTargetColorHit )
				//{
					//returnImmediatly = false;
				//	tempColor = transparencySlider.ToFXColor();
				//	fxColor = tempColor.invert();
				//	return fxColor;
				//}
				//if ( returnImmediatly )
				//{
				//	return transparencySlider.ToFXColor();
				//}
				///fxColor = colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, SomeTargetColorHit, !BrowserTextHit, NextStepColorTooSimilarEffect, InvertBasisFromBackground, TypeOfDisplayIsBackgroundToBasisFullDisplay );
				///if ( TextTransitionFactor > 0.99 )
				///	transparencySlider.set( basisPRColor );
				///else if ( TextTransitionFactor < 0.01 )
				///	transparencySlider.set( fxColor );
				///else
				///	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
				///return transparencySlider.ToFXColor();
				//if ( TextTransitionFactor < 0.01 )
				//	transparencySlider.set( fxColor );
				//else if ( TextTransitionFactor > 0.99 )
				//	transparencySlider.set( basisPRColor );
				//else
				//{
				//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
				//	returnImmediatly = BrowserTextHit && !TextOutlineBlendingToBasisInvert;
				//}
				//if ( returnImmediatly )//if ( !SomeTargetColorHit && BrowserTextHit && !TextOutlineBlendingToBasisInvert )
				//	return transparencySlider.ToFXColor();// #/
			}
			if ( !SomeTargetColorHit )
			{
				if ( ( InvertBasisPicture && !BrowserTextHit ) || ( !InvertBasisPicture && BrowserTextHit ) )
				{
					returnImmediatly = false;
					fxColor = basisPRColor.invert();
				}
				else if ( BrowserTextHit )
					fxColor = basisPRColor;
				transparencySlider.set( fxColor );
				return transparencySlider.ToFXColor();
				//returnImmediatly = false;
				//if ( ( InvertBasisPicture && !BrowserTextHit ) || ( !InvertBasisPicture && BrowserTextHit ) )
				//	fxColor = basisPRColor.invert();
				//else// if ( ( InvertBasisPicture && BrowserTextHit ) || ( !InvertBasisPicture && !BrowserTextHit ) )
				//	fxColor = basisPRColor;
				//transparencySlider.set( fxColor );
				//return transparencySlider.ToFXColor();
			}
			//return transparencySlider.ToFXColor();
		}// #/
		else if ( SomeTargetColorHit )//
		{
			if ( !BasisImageStandOutHit )
			{
				if ( UseFadeAtAll && ( BackgroundColorOverlay || TextColorOverlay ) )
					transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( fxColor, TextColorToOverlay, BackgroundColorToOverlay, BackgroundColorOverlay, TextColorOverlay, BrowserTextHit ) );
				if ( !BrowserTextHit )
					return transparencySlider.ToFXColor();
			}
			else// if ( BasisImageStandOutHit )
			{
				if ( !BrowserTextHit )
				{
					if ( UseFadeAtAll )
					{
						if ( BasisOverlaySeperateBackgroundFade )
							if ( ShowBasisOverlayForBackground )
								//transparencySlider.set( Color.BLUEVIOLET );
								transparencySlider.CombineColors( basisPRColor, BasisOverlaySperateBackgroundColor );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( basisPRColor, BasisOverlaySperateTextColor, BasisOverlaySperateBackgroundColor, BasisOverlaySeperateBackgroundFade, BasisOverlaySeperateTextFade, BrowserTextHit ) );
							else// if ( !ShowBasisOverlayForBackground )
								transparencySlider.CombineColors( fxColor, BasisOverlaySperateBackgroundColor );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( fxColor, BasisOverlaySperateTextColor, BasisOverlaySperateBackgroundColor, BasisOverlaySeperateBackgroundFade, BasisOverlaySeperateTextFade, BrowserTextHit ) );
						fxColor = transparencySlider.ToFXColor();
						if ( BackgroundColorOverlay )
							transparencySlider.CombineColors( fxColor, BackgroundColorToOverlay );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( fxColor, TextColorToOverlay, BackgroundColorToOverlay, BackgroundColorOverlay, TextColorOverlay, BrowserTextHit ) );
						else
							if ( ShowBasisOverlayForBackground )
								transparencySlider.set( basisPRColor );
						return transparencySlider.ToFXColor();
					}
					else
						returnImmediatly = false;
				}
				else// if ( BrowserTextHit )
				{
					if ( ShowBasisOverlayForText )
					{
						tempColor = basisPRColor;
						fxColor = tempColor.invert();
						transparencySlider.set( fxColor );
					}
					if ( UseFadeAtAll )
					{
						if ( BasisOverlaySeperateTextFade )//There Can Be Something To Change The Order Of BasisOverlaySeperateTextFade & TextColorOverlay
							if ( !ShowBasisOverlayForText )
								transparencySlider.CombineColors( basisPRColor, BasisOverlaySperateTextColor );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( basisPRColor, BasisOverlaySperateTextColor, BasisOverlaySperateBackgroundColor, BasisOverlaySeperateBackgroundFade, BasisOverlaySeperateTextFade, BrowserTextHit ) );
							else// if ( ShowBasisOverlayForText )
								transparencySlider.CombineColors( fxColor, BasisOverlaySperateTextColor );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( fxColor, BasisOverlaySperateTextColor, BasisOverlaySperateBackgroundColor, BasisOverlaySeperateBackgroundFade, BasisOverlaySeperateTextFade, BrowserTextHit ) );
						fxColor = transparencySlider.ToFXColor();
						if ( TextColorOverlay )
							transparencySlider.CombineColors( fxColor, TextColorToOverlay );//transparencySlider.set( independentTextBackgroundColorPasser.IndependentTextBackgroundColorPasserFunction ( fxColor, TextColorToOverlay, BackgroundColorToOverlay, BackgroundColorOverlay, TextColorOverlay, BrowserTextHit ) );	
						fxColor = transparencySlider.ToFXColor();
						transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
						return transparencySlider.ToFXColor();
					}
					else
						returnImmediatly = false;
					//if ( TextTransitionFactor != 1.0 )
					//System.out.println( "TextTransitionFactor: " + TextTransitionFactor );
					//if ( TextTransitionFactor > 0.01 )
					//if ( !ShowBasisOverlayForText )
					
					//else if ( ShowBasisOverlayForText )
					//{
					//	transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
					//}

					//if ( TextTransitionFactor < 0.01 || TextTransitionFactor > 0.99 )
					//	returnImmediatly = false;
					//return colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, SomeTargetColorHit, !BrowserTextHit, NextStepColorTooSimilarEffect, InvertBasisFromBackground, TypeOfDisplayIsBackgroundToBasisFullDisplay );
					//else
					//	return transparencySlider.ToFXColor();
				}
			}
		}
		else// if ( !SomeTargetColorHit )
		{
			if ( ( InvertBasisPicture && !BrowserTextHit ) || ( !InvertBasisPicture && BrowserTextHit ) )
			{
				returnImmediatly = false;
				fxColor = basisPRColor.invert();
			}
			else if ( BrowserTextHit )
				fxColor = basisPRColor;
			transparencySlider.set( fxColor );
			return transparencySlider.ToFXColor();
		}
		returnImmediatly = false;//BasisImageStandOutHit && BrowserTextHit && !TextOutlineBlendingToBasisInvert && TextTransitionFactor > 0.01 && TextTransitionFactor < 0.99;
		//return transparencySlider.ToFXColor();
		if ( returnImmediatly )// || ( basisImageStandOutHit && browserTextHit && !TextOutlineBlendingToBasisInvert && textTransitionFactor > 0.04 && textTransitionFactor < 0.96 ) )
		{
			return transparencySlider.ToFXColor();
		}
		//fxColor = colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, SomeTargetColorHit, !BrowserTextHit, NextStepColorTooSimilarEffect, InvertBasisFromBackground, TypeOfDisplayIsBackgroundToBasisFullDisplay );
		//return fxColor;
		fxColor = colorDecide.NextColorDecide( basisPRColor, BackgroundBasisPRColor, transparencySlider.ToFXColor(), BrowserPRColor, InitialColorContrastingChoice, ColorTooSimilarReplacementColor, ColorDifference, SomeTargetColorHitFromDisplayType, SomeTargetColorHit, !BrowserTextHit, NextStepColorTooSimilarEffect, InvertBasisFromBackground, TypeOfDisplayIsBackgroundToBasisFullDisplay );
		if ( TextTransitionFactor > 0.999 )
			transparencySlider.set( basisPRColor );
		else if ( TextTransitionFactor < 0.001 )
			transparencySlider.set( fxColor );
		else
			transparencySlider.TransparencySliderFunction( 1, TextTransitionFactor, fxColor, basisPRColor );
		return transparencySlider.ToFXColor();
	}
}
