if (dy < 0) newEndY -= offset; else newEndY += offset;
if (dy < 0) { newEndY -= offset; } else { newEndY += offset; }
  protected void createArrowHeads() {    //NOTE: xpoints[0] refers to the original copy of the xpoints,    //as opposed to the [1] copy, which gets used when the line    //needs to wrap around the screen and show up on the other    //side.  Might have to think about the [1] points, and adding    //a arrowhead there if it shows up in the future.        int pointIndex = xpoints[0].length - 1;    if (Debug.debugging("arrowheads")) {      Debug.output("createArrowHeads(): Number of points = " + pointIndex);	}    int drawingLinetype = STRAIGHT_LINE;	    if (pointIndex > 1) drawingLinetype = CURVED_LINE;	// Used as the index for points in the xy point array to use	// as anchors for the arrowheads    int[] end = new int[2];    int[] start = new int[2];    end[0] = pointIndex;    start[0] = 0;    end[1] = 0;    start[1] = pointIndex;    int numArrows = 1; // default    // one for the start and end of each arrowhead (there could be two)    Point sPoint1 = new Point();    Point ePoint1 = new Point();    Point sPoint2 = new Point();     Point ePoint2 = new Point();    int arrowDirection = arrowDirectionType;    if (arc != null && arc.getReversed() == true) {      if (arrowDirection == OMArrowHead.ARROWHEAD_DIRECTION_FORWARD) {	arrowDirection = OMArrowHead.ARROWHEAD_DIRECTION_BACKWARD;      } else if (arrowDirection == OMArrowHead.ARROWHEAD_DIRECTION_BACKWARD) {	arrowDirection = OMArrowHead.ARROWHEAD_DIRECTION_FORWARD;      }    }    switch(drawingLinetype) {    case STRAIGHT_LINE:      Debug.message("arrowheads","createArrowHeads(): Inside x-y space");      int newEndX = xpoints[0][end[0]];      int newEndY = ypoints[0][end[0]];      int dx, dy;      float dd;      switch(arrowDirection) {      case OMArrowHead.ARROWHEAD_DIRECTION_BOTH:	// Doing the backward arrow here...	Debug.message("arrowheads","createArrowHeads(): direction backward and");	int newEndX2 = xpoints[0][end[1]];	int newEndY2 = ypoints[0][end[1]];	if (arrowLocation != 100) {	  dx = xpoints[0][end[1]] - xpoints[0][start[1]];	  dy = ypoints[0][end[1]] - ypoints[0][start[1]];	  int offset = 0;	  // Straight up or down	  if (dx == 0) {	    // doesn't matter, start and end the same	    newEndX2 = xpoints[0][start[1]]; 	    // calculate the percentage from start of line	    offset = (int)((float)dy*(arrowLocation/100.0));	    // set the end at the begining...	    newEndY2 = ypoints[0][start[1]];	    // and adjust...	    if (dy < 0) newEndY2 -= offset;	    else newEndY2 += offset;	  } else {	    dd = Math.abs((float)dy/(float)dx);	    // If the line moves more x than y	    if (Math.abs(dx) > Math.abs(dy)) {	      // set the x	      newEndX2 = xpoints[0][start[1]] + 		(int)((float)dx*(arrowLocation/100.0));	      // find the y for that x and set that	      newEndY2 = ypoints[0][start[1]];	      offset = (int)((float)Math.abs(xpoints[0][start[1]] - newEndX2)*dd);	      if (dy < 0) newEndY -= offset;	      else newEndY += offset;	    } else  {	      // switch everything...set y end	      newEndY2 = ypoints[0][start[1]] + 		(int)((float)dy*(arrowLocation/100.0));	      // initialize the x to beginning	      newEndX2 = xpoints[0][start[1]];	      // calculate the difference x has to move based on y end	      offset = (int)((float)Math.abs(ypoints[0][start[1]] - newEndY2)/dd);	      // set the end	      if (dx < 0) {		newEndX2 -= offset;	      } else {		newEndX2 += offset;	      }	    }	  }	}	if (start[1] < 0 ) {	  start[1] = 0;	}	sPoint2.x = xpoints[0][start[1]];	sPoint2.y = ypoints[0][start[1]];	ePoint2.x = newEndX2;	ePoint2.y = newEndY2;	numArrows = 2;      case OMArrowHead.ARROWHEAD_DIRECTION_FORWARD:	Debug.message("arrowheads","createArrowHeads(): direction forward.");	break;      case OMArrowHead.ARROWHEAD_DIRECTION_BACKWARD:	Debug.message("arrowheads","createArrowHeads(): direction backward.");	start[0] = pointIndex;	end[0] = 0;	break;      }      // And doing the forward arrow here...      if (arrowLocation != 100) {	dx = xpoints[0][end[0]] - xpoints[0][start[0]];	dy = ypoints[0][end[0]] - ypoints[0][start[0]];	int offset = 0;	// Straight up or down	if (dx == 0) {	  // doesn't matter, start and end the same	  newEndX = xpoints[0][start[0]]; 	  // calculate the percentage from start of line	  offset = (int)((float)dy*(arrowLocation/100.0));	  // set the end at the begining...	  newEndY = ypoints[0][start[0]];	  // and adjust...	  if (dy < 0) newEndY -= offset;	  else newEndY += offset;	} else {	  dd = Math.abs((float)dy/(float)dx);	  // If the line moves more x than y	  if (Math.abs(dx) > Math.abs(dy)) {	    // set the x	    newEndX = xpoints[0][start[0]] + 	      (int)((float)dx*(arrowLocation/100.0f));	    // find the y for that x and set that	    newEndY = ypoints[0][start[0]];	    offset = (int)((float)Math.abs(xpoints[0][start[0]] - newEndX)*dd);	    if (dy < 0) newEndY -= offset;	    else newEndY += offset;	  } else {	    // switch everything...set y end	    newEndY = ypoints[0][start[0]] + 	      (int)((float)dy*(arrowLocation/100.0));	    // initialize the x to beginning	    newEndX = xpoints[0][start[0]];	    // calculate the difference x has to move based on y end	    offset = (int)((float)Math.abs(ypoints[0][start[0]] - newEndY)/dd);	    // set the end	    if (dx < 0) {	      newEndX -= offset;	    } else {	      newEndX += offset;	    }	  }	}      }      if (start[0] < 0) start[0] = 0;      sPoint1.x = xpoints[0][start[0]];      sPoint1.y = ypoints[0][start[0]];      ePoint1.x = newEndX;      ePoint1.y = newEndY;      break;    case CURVED_LINE:      Debug.message("arrowheads","createArrowHeads(): Curved line arrowhead");      switch(arrowDirection) {      case OMArrowHead.ARROWHEAD_DIRECTION_BOTH:	Debug.message("arrowheads","createArrowHeads(): direction backward and");	start[1] = pointIndex - 	  (int)((float)pointIndex*(float)(arrowLocation/100.0)) - 1;	if (start[1] < 1) start[1] = 1;	end[1] = start[1] - 1;	sPoint2.x = xpoints[0][start[1]];	sPoint2.y = ypoints[0][start[1]];	ePoint2.x = xpoints[0][end[1]];	ePoint2.y = ypoints[0][end[1]];	numArrows = 2;      case OMArrowHead.ARROWHEAD_DIRECTION_FORWARD:	Debug.message("arrowheads", "createArrowHeads(): direction forward.");	pointIndex = (int)((float)pointIndex*(float)(arrowLocation/100.0));	end[0] = pointIndex;	start[0] = pointIndex - 1;	break;      case OMArrowHead.ARROWHEAD_DIRECTION_BACKWARD:	Debug.message("arrowheads", "createArrowHeads(): direction backward.");	start[0] =  pointIndex - 	  (int)((float)pointIndex*(float)(arrowLocation/100.0)) - 1;	if (start[0] < 1) start[0] = 1;	end[0] = start[0] - 1;	break;      }      if (start[0] < 0) start[0] = 0;      if (end[0] < 0) end[0] = 0;      sPoint1.x = xpoints[0][start[0]];      sPoint1.y = ypoints[0][start[0]];      ePoint1.x = xpoints[0][end[0]];       ePoint1.y = ypoints[0][end[0]];      break;    }    arrowHead = new OMArrowHead[numArrows];    arrowHead[0] = new MyArrowHead(sPoint1, ePoint1,lineWidth);    if (numArrows > 1) {      arrowHead[1] = new MyArrowHead(sPoint2, ePoint2,lineWidth);    }  }