int rw = (int)(Constants.CONNECTOR_WIDTH * scale / 2); int rh = (int)(Constants.CONNECTOR_HEIGHT * scale / 2);
posX = startVertex.getRx() - offsetX; posY = startVertex.getRy() - offsetY;
protected void draw(Graphics g, boolean hilited){	ViewState view = ViewState.getInstance();	int offsetX = view.getRx();	int offsetY = view.getRy();		int posX = getRx() - offsetX;	int posY = getRy() - offsetY;	int rwidth = getRwidth();	int rheight = getRheight();	if((hilited) && (!((posX > view.getViewWidth()) || (posY > view.getViewHeight())		|| ((posX + rwidth) < 0) || ((posY + rheight) < 0))))	{		g.setColor(Constants.HILITE_COLOR);		g.drawRect(posX, posY, rwidth, rheight);	}	g.setColor(getColor());	double scale = view.getScale();		int rw = (int)(Constants.CONNECTOR_WIDTH * scale / 2);	int rh = (int)(Constants.CONNECTOR_HEIGHT * scale / 2);		posX = startVertex.getRx() + rw - offsetX;	posY = startVertex.getRy() + rh - offsetY;		int posX2 = endVertex.getRx() + rw - offsetX;	int posY2 = endVertex.getRy() + rh - offsetY;	int dirX = (posX < posX2) ? (1) : (-1);	int dirY = (posY < posY2) ? (1) : (-1);	if((dashed) && ((posX != posX2) || (posY != posY2)))	{		double angle = Math.atan(((double)(Math.abs(posY2 - posY))) / Math.abs(posX2 - posX));		double cos = dirX * Math.cos(angle) * Constants.DASHED_LINE_DENSITY;		double sin = dirY * Math.sin(angle) * Constants.DASHED_LINE_DENSITY;					double curX = posX;		double curY = posY;		int step = 0;								while(((curX * dirX) <= (posX2 * dirX)) && ((curY * dirY) <= (posY2 * dirY)))		{			step++;			double curX2 = posX + cos * step;			double curY2 = posY + sin * step;							if(((curX2 * dirX) > (posX2 * dirX)) || ((curY2 * dirY) > (posY2 * dirY)))			{							curX2 = posX2;				curY2 = posY2;			}							g.drawLine((int)curX, (int)curY, (int)curX2, (int)curY2);			step++;							curX = posX + cos * step;			curY = posY + sin * step;		}	}	else		g.drawLine(posX, posY, posX2, posY2);	if(startArrow || endArrow)	{		double angle = Math.atan(((double)(Math.abs(posY2 - posY))) / Math.abs(posX2 - posX));		double arrowSize = Constants.ARROW_SIZE * getRscale();		double lineLength = Math.sqrt((posX2 - posX) * (posX2 - posX) + (posY2 - posY) * (posY2 - posY));		if(arrowSize > lineLength / 2)			arrowSize = lineLength / 2;				int[] vertexX = new int[3];		int[] vertexY = new int[3];					if(startArrow)		{			vertexX[0] = posX;			vertexY[0] = posY;					vertexX[1] = (int)(posX + dirX * Math.cos(angle + Constants.ARROW_SHARPNESS) * arrowSize);			vertexY[1] = (int)(posY + dirY * Math.sin(angle + Constants.ARROW_SHARPNESS) * arrowSize);						vertexX[2] = (int)(posX + dirX * Math.cos(angle - Constants.ARROW_SHARPNESS) * arrowSize);			vertexY[2] = (int)(posY + dirY * Math.sin(angle - Constants.ARROW_SHARPNESS) * arrowSize);			g.fillPolygon(vertexX, vertexY, 3);		}		if(endArrow)		{			vertexX[0] = posX2;			vertexY[0] = posY2;					vertexX[1] = (int)(posX2 - dirX * Math.cos(angle + Constants.ARROW_SHARPNESS) * arrowSize);			vertexY[1] = (int)(posY2 - dirY * Math.sin(angle + Constants.ARROW_SHARPNESS) * arrowSize);						vertexX[2] = (int)(posX2 - dirX * Math.cos(angle - Constants.ARROW_SHARPNESS) * arrowSize);			vertexY[2] = (int)(posY2 - dirY * Math.sin(angle - Constants.ARROW_SHARPNESS) * arrowSize);			g.fillPolygon(vertexX, vertexY, 3);		}			}}