private float printLine(GraphicRenderer g2, Position lastpos, Position pos, float zpos, float time,long starttime,boolean travel) {

		float x1 = Math.min((lastpos.x + Xoffset) * zoom,bedSquareZoomed);
		float y1 = (bedSquare/extrazoom * zoom) - ((lastpos.y + Yoffset) * zoom);
		float x2 = Math.min((pos.x + Xoffset) * zoom, bedSquareZoomed);
		float y2 = (bedSquare/extrazoom * zoom) - ((pos.y + Yoffset) * zoom);

		if (!ffLayer && fftoGcode == 0 && fftoLayer == 0 && speedup < 10 ) {
			// Instead of painting one long line and wait , we split the line
			// into segments to have a smoother painting
			float distx = x2 - x1;
			float disty = y2 - y1;
			int maxdist = (int) Math.max(Math.abs(distx), Math.abs(disty)) / 5; // paint
																				// each
																				// 5mm
			if (maxdist > 5) {
				float stepx = distx / maxdist;
				float stepy = disty / maxdist;
				for (int i = 0; i < maxdist; i++) {
					float nx=(x1 + ((i + 1) * stepx));
					float lx=x1 + (i * stepx);
					float ly=y1 + (i * stepy);
					float ny=( y1+ ((i + 1) * stepy));
					
					g2.setPos((int)(nx*extrazoom),(int)(ny*extrazoom));
					g2.drawline(lx*extrazoom, ly*extrazoom, nx*extrazoom, ny*extrazoom);
					printLineHorizontal2(g2,lx*extrazoom,ly*extrazoom,nx*extrazoom,ny*extrazoom, zpos*extrazoom,travel);
					try {
						g2.repaint();
						long paintdur=System.currentTimeMillis()-starttime;
						long sleepremain = Math.max(0,((long)time)-paintdur);
						long dosleep = Math.min(sleepremain, (long)(time / maxdist));
						Thread.sleep(dosleep ); // pause not done
					} catch (InterruptedException e) {
						time = 0;
					}
				}
				return 0; // already slept enough , no sleep in main loop
			}
		}

		g2.drawline(x1*extrazoom, y1*extrazoom, x2*extrazoom, y2*extrazoom);
		printLineHorizontal2(g2,x1*extrazoom,y1*extrazoom,x2*extrazoom,y2*extrazoom, zpos*extrazoom,travel);
		return time; // not slept, sleep in the main loop
	}