View Single Post
  #1 (permalink)  
Old 02-15-2008, 08:32 AM
sandhyau sandhyau is offline
Member
 
Join Date: Jan 2008
Posts: 7
sandhyau is on a distinguished road
how u rotate the arrow mark as the line moves accordingly
can any one help me how the angles of the arrow mark should rotate as the line moves accordingly. here i am placing the code for arrow mark in the fixed angle.


AffineTransform at = AffineTransform.getTranslateInstance((point2.x + point4.x)/2, (point2.y + point4.y)/2);
int b = 8;
double theta = Math.toRadians(45);
GeneralPath path = new GeneralPath();
path.moveTo(0,0); // distance between line and the arrow mark
int x =(int)(-b * Math.cos(theta));
int y =(int) (b * Math.sin(theta));
path.lineTo(x,y);
x = (int) (-b * Math.cos(-theta));
y = (int) (b * Math.sin(-theta));
path.moveTo(0,0); // distance between line and the arrow mark
path.lineTo(x,y);
Shape shape = at.createTransformedShape(path);
graphics2D.setPaint(Color.black);
graphics2D.draw(shape);
at.rotate(theta,x,y);
drawLine(graphics2D,point2.x,point2.y,point4.x,poi nt4.y);// line drawing 2 points.
Reply With Quote
Sponsored Links