@SuppressWarnings("unchecked")
void setLineBits(float dx, float dy) {    
    slope = (dx != 0 ?  dy / dx : dy >= 0 ? Float.MAX_VALUE  : -Float.MAX_VALUE);
    lineTypeX = (slope <=1 && slope >= -1);
    lineDirection = (slope < 0 ? -1 : 1);
    if (getCachedLine())
      return;
    nBits = (lineTypeX ? g3d.width : g3d.height);
    lineBits = new BitSet(nBits);
    dy = Math.abs(dy);
    dx = Math.abs(dx);
    if (dy > dx) {
      float t = dx;
      dx = dy;
      dy = t;
    }
    int twoDError = 0;
    float twoDx = dx + dx, twoDy = dy + dy;
    for (int i = 0; i < nBits; i++) {
      twoDError += twoDy;
      if (twoDError > dx) {
        lineBits.set(i);
        twoDError -= twoDx;
      }
    }    
    lineCache.put(slopeKey, lineBits);
    nCached++;
    //if (--test > 0 || ((100-test) % 100 == 0)) System.out.println(test+" "+dx + " " + dy + " " + lineBits);
  }