/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2009-2011 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package com.jaamsim.Graphics;

import com.jaamsim.input.BooleanInput;
import com.jaamsim.input.ColourInput;
import com.jaamsim.input.Input;
import com.jaamsim.input.Keyword;
import com.jaamsim.input.ValueInput;
import com.jaamsim.input.Vec3dInput;
import com.jaamsim.math.Vec3d;
import com.jaamsim.units.DimensionlessUnit;
import com.jaamsim.units.DistanceUnit;

public class Arrow extends DisplayEntity {
	@Keyword(description = "If TRUE, then a drop shadow appears for the arrow.",
	         exampleList = {"TRUE"})
	private final BooleanInput dropShadow;

	@Keyword(description = "The colour of the drop shadow, defined using a colour keyword or RGB values.",
	         exampleList = {"blue"})
	private final ColourInput dropShadowColor;

	@Keyword(description = "A set of { x, y, z } offsets in each direction of the drop shadow from the Arrow.",
	         exampleList = {"0.1 0.1 0.0 m"})
	private final Vec3dInput dropShadowOffset;

	@Keyword(description = "The width of the Arrow line segments in pixels.",
	         exampleList = {"1"})
	private final ValueInput width;

	@Keyword(description = "A set of { x, y, z } numbers that define the size of the arrowhead " +
	                "in those directions at the end of the connector.",
	         exampleList = {"0.165 0.130 0.0 m"})
	private final Vec3dInput arrowHeadSize;

	@Keyword(description = "The colour of the arrow, defined using a colour keyword or RGB values.",
	         exampleList = {"red"})
	private final ColourInput color;

	{
		width = new ValueInput("Width", "Graphics", 1.0d);
		width.setUnitType(DimensionlessUnit.class);
		width.setValidRange(0.0d, Double.POSITIVE_INFINITY);
		this.addInput(width);

		arrowHeadSize = new Vec3dInput( "ArrowSize", "Graphics", new Vec3d(0.1d, 0.1d, 0.0d) );
		arrowHeadSize.setUnitType(DistanceUnit.class);
		this.addInput( arrowHeadSize );

		color = new ColourInput("Color", "Graphics", ColourInput.BLACK);
		this.addInput(color);
		this.addSynonym(color, "Colour");

		dropShadow = new BooleanInput( "DropShadow", "Graphics", false );
		this.addInput( dropShadow );

		dropShadowColor = new ColourInput("DropShadowColour", "Graphics", ColourInput.BLACK);
		this.addInput(dropShadowColor);
		this.addSynonym(dropShadowColor, "DropShadowColor");

		dropShadowOffset = new Vec3dInput( "DropShadowOffset", "Graphics", new Vec3d() );
		dropShadowOffset.setUnitType(DistanceUnit.class);
		this.addInput( dropShadowOffset );
	}

	public Arrow() {}

	@Override
	public void updateForInput( Input<?> in ) {
		super.updateForInput(in);

		// If Points were input, then use them to set the start and end coordinates
		if( in == pointsInput || in == color || in == width ) {
			synchronized(screenPointLock) {
				cachedPointInfo = null;
			}
			return;
		}
	}

	@Override
	public PolylineInfo[] getScreenPoints() {
		synchronized(screenPointLock) {
			if (cachedPointInfo == null) {
				int w = Math.max(1, width.getValue().intValue());
				cachedPointInfo = new PolylineInfo[1];
				cachedPointInfo[0] = new PolylineInfo(pointsInput.getValue(), color.getValue(), w);
			}
			return cachedPointInfo;
		}
	}

	public Vec3d getArrowHeadSize() {
		return arrowHeadSize.getValue();
	}

}

@@ -635,47 +635,8 @@
 s;%0A%0A
-import com.jaamsim.input.BooleanInput;%0A
 impo
@@ -665,24 +665,24 @@
 olourInput;%0A
+
 import com.j
@@ -970,540 +970,8 @@
 ty %7B
-%0A%09@Keyword(description = %22If TRUE, then a drop shadow appears for the arrow.%22,%0A%09         exampleList = %7B%22TRUE%22%7D)%0A%09private final BooleanInput dropShadow;%0A%0A%09@Keyword(description = %22The colour of the drop shadow, defined using a colour keyword or RGB values.%22,%0A%09         exampleList = %7B%22blue%22%7D)%0A%09private final ColourInput dropShadowColor;%0A%0A%09@Keyword(description = %22A set of %7B x, y, z %7D offsets in each direction of the drop shadow from the Arrow.%22,%0A%09         exampleList = %7B%220.1 0.1 0.0 m%22%7D)%0A%09private final Vec3dInput dropShadowOffset;
 %0A%0A%09@
@@ -1971,24 +1971,24 @@
 put(color);%0A
+
 %09%09this.addSy
@@ -2014,460 +2014,8 @@
 r%22);
-%0A%0A%09%09dropShadow = new BooleanInput( %22DropShadow%22, %22Graphics%22, false );%0A%09%09this.addInput( dropShadow );%0A%0A%09%09dropShadowColor = new ColourInput(%22DropShadowColour%22, %22Graphics%22, ColourInput.BLACK);%0A%09%09this.addInput(dropShadowColor);%0A%09%09this.addSynonym(dropShadowColor, %22DropShadowColor%22);%0A%0A%09%09dropShadowOffset = new Vec3dInput( %22DropShadowOffset%22, %22Graphics%22, new Vec3d() );%0A%09%09dropShadowOffset.setUnitType(DistanceUnit.class);%0A%09%09this.addInput( dropShadowOffset );
 %0A%09%7D%0A

remove unused drop-shadow input for Arrow