/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2009-2011 Ausenco Engineering Canada Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jaamsim.Graphics;

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 = "The colour of the arrow.",
	         exampleList = {"red"})
	private final ColourInput color;

	@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.",
	         exampleList = {"0.165 0.130 0.0 m"})
	private final Vec3dInput arrowHeadSize;

	{
		color = new ColourInput("Colour", "Graphics", ColourInput.BLACK);
		this.addInput(color);
		this.addSynonym(color, "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( "ArrowHeadSize", "Graphics", new Vec3d(0.1d, 0.1d, 0.0d) );
		arrowHeadSize.setUnitType(DistanceUnit.class);
		arrowHeadSize.setDefaultText("PolylineModel");
		this.addInput( arrowHeadSize );
		this.addSynonym(arrowHeadSize, "ArrowSize");
	}

	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 ) {
			invalidateScreenPoints();
			return;
		}
	}

	@Override
	public PolylineInfo[] buildScreenPoints(double simTime) {
		int w = Math.max(1, width.getValue().intValue());
		PolylineInfo[] ret = new PolylineInfo[1];
		ret[0] = new PolylineInfo(getCurvePoints(), color.getValue(), w);
		return ret;
	}

	public Vec3dInput getArrowHeadSizeInput() {
		return arrowHeadSize;
	}

}

@@ -92,16 +92,60 @@
 da Inc.%0A
+ * Copyright (C) 2017 JaamSim Software Inc.%0A
  *%0A * Li
@@ -903,24 +903,57 @@
 Vec3dInput;%0A
+import com.jaamsim.math.Color4d;%0A
 import com.j
@@ -1612,16 +1612,57 @@
 BLACK);%0A
+%09%09color.setDefaultText(%22PolylineModel%22);%0A
 %09%09this.a
@@ -1712,16 +1712,17 @@
 olor%22);%0A
+%0A
 %09%09width 
@@ -1867,16 +1867,57 @@
 INITY);%0A
+%09%09width.setDefaultText(%22PolylineModel%22);%0A
 %09%09this.a
@@ -2576,16 +2576,57 @@
 %0A%09%09int w
+id = -1;%0A%09%09if (!width.isDefault())%0A%09%09%09wid
  = Math.
@@ -2662,16 +2662,93 @@
 lue());%0A
+%0A%09%09Color4d col = null;%0A%09%09if (!color.isDefault())%0A%09%09%09col = color.getValue();%0A%0A
 %09%09Polyli
@@ -2836,24 +2836,13 @@
  col
-or.getValue()
 , w
+id
 );%0A%09

use the Polyline inputs for Colour and Width as the defaults for Arrow