/* * Created on Feb 28, 2006 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package implementation.source.java.nodes; import java.awt.Color; /** * @author Timothy Ober * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class DFInputPort extends DFPort { /** * */ public DFInputPort(DFNode nd) { super(nd); } protected void drawArrow(float x0, float y0, float x1, float y1) { float o = y1 - y0; float a = x1 - x0; float theta = (float)Math.atan(o / a); //Offsets center the arrow at x1, y1, rather than placing its tip there float x1Offset = (float)((ARROW_LENGTH / 2) * Math.cos(theta)); float y1Offset = (float)((ARROW_LENGTH / 2) * Math.sin(theta)); reset(); if (x1 > x0) { moveTo(x1 - x1Offset, y1 - y1Offset); lineTo((float)(x1 - x1Offset + (ARROW_LENGTH * Math.cos(theta + ARROW_WIDTH / 2))), (float)(y1 - y1Offset + (ARROW_LENGTH * Math.sin(theta + ARROW_WIDTH / 2)))); lineTo((float)(x1 - x1Offset + (ARROW_LENGTH * Math.cos(theta - ARROW_WIDTH / 2))), (float)(y1 - y1Offset + (ARROW_LENGTH * Math.sin(theta - ARROW_WIDTH / 2)))); } else { moveTo(x1 + x1Offset, y1 + y1Offset); lineTo((float)(x1 + x1Offset - (ARROW_LENGTH * Math.cos(theta + ARROW_WIDTH / 2))), (float)(y1 + y1Offset - (ARROW_LENGTH * Math.sin(theta + ARROW_WIDTH / 2)))); lineTo((float)(x1 + x1Offset - (ARROW_LENGTH * Math.cos(theta - ARROW_WIDTH / 2))), (float)(y1 + y1Offset - (ARROW_LENGTH * Math.sin(theta - ARROW_WIDTH / 2)))); } closePath(); setPaint(Color.BLACK); } }