private void setLinePositions(GridLayoutView glv) {

    // extend imgageView to bounds
    Bitmap bitmapy = BitmapFactory.decodeResource(getResources(), R.drawable.line_y);
    bitmapy = Bitmap.createScaledBitmap(bitmapy, glWidth, bitmapy.getHeight(), true);
    lineY.setImageBitmap(bitmapy);

    Bitmap bitmapx = BitmapFactory.decodeResource(getResources(), R.drawable.line_x);
    bitmapx = Bitmap.createScaledBitmap(bitmapx, bitmapx.getWidth(), glHeight, true);
    lineX.setImageBitmap(bitmapx);

    xParams = (RelativeLayout.LayoutParams) lineX.getLayoutParams();
    yParams = (RelativeLayout.LayoutParams) lineY.getLayoutParams();

    int positionLineXCentre = glv.getAxisXlines().get(glv.getGridSize() / 2).x;
    xParams.leftMargin =
        shapeStartPointX(glv.getZeroPosX(), glv.getLineSpacingX(), lineStartCoordX)
            - bitmapx.getWidth() / 2;
    lineX.setLayoutParams(xParams);

    int positionLineYCentre = glv.getAxisYlines().get(glv.getGridSize() / 2).y;
    yParams.topMargin =
        shapeStartPointY(glv.getZeroPosY(), glv.getLineSpacingY(), lineStartCoordY)
            - bitmapy.getHeight() / 2;
    lineY.setLayoutParams(yParams);
  }
  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    if (firstQuestion == true) {

      // Layout Variables
      glLeft = gridLayout.getLeft();
      Log.i("rlLeft", Integer.toString(glLeft));
      glTop = gridLayout.getTop();
      Log.i("rlTop", Integer.toString(glTop));
      glWidth = gridLayout.getWidth();
      Log.i("rlWidth", Float.toString(glWidth));
      glHeight = gridLayout.getHeight();
      Log.i("rlHeight", Float.toString(glHeight));

      glv.initGrid(glWidth, glHeight);

      setLinePositions(glv);

      // Init Skills Layout
      // Layout Variables
      slLeft = skillsLayout.getLeft();
      // Log.i("rlLeft", Integer.toString(glLeft));
      slTop = skillsLayout.getTop();
      // Log.i("rlTop", Integer.toString(glTop));
      slWidth = skillsLayout.getWidth();
      // Log.i("rlWidth", Float.toString(glWidth));
      slHeight = skillsLayout.getHeight();
      // Log.i("rlHeight", Float.toString(glHeight));

      coordNumbersX.bringToFront();
      coordNumbersY.bringToFront();
      brackets.bringToFront();

      initQuestion();
    }
  }
  // *************************      Initialize Question       *********************************
  private void initQuestion() {
    Log.i("fullCClassName", className);
    if (numberOfQuestionsRemaining < 1) {
      Intent intent = new Intent(NegativeCoordActivity.this, ResultActivity.class);
      intent.putExtra("Score", scoreTotal);
      intent.putExtra("ClassName", className);
      intent.putExtra("Level", 3);
      startActivity(intent);
      finish();
    } else {

      if (firstQuestion == false) {
        numberOfQuestionsRemaining--;

        Random randScore = new Random();
        int low = 0;
        int high = 0;
        if (seconds <= 5) {
          low = 40;
          high = 50;
        }
        if (seconds > 5 && seconds <= 7) {
          low = 30;
          high = 40;
        }
        if (seconds > 7) {
          low = 10;
          high = 30;
        }
        score = randScore.nextInt(high - low + 1) + low;
        scoreTotal = scoreTotal + score;
        scoreText.setText(Integer.toString(score));
        scoreText.startAnimation(scoreTextAnimmation);
        timerHandler.removeCallbacks(timerRunnable);
      }
      firstQuestion = false;
      seconds = 0;
      timerHandler.postDelayed(timerRunnable, 0);

      ProgressBarAnimation anim =
          new ProgressBarAnimation(scoreBar, scoreBar.getProgress(), scoreTotal);
      anim.setDuration(300);
      scoreBar.startAnimation(anim);

      if (STAR_ONE_ENABLED == 0) {
        if (scoreBar.getProgress() >= (scoreBar.getMax() / 2)) {
          StarView star1 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starOne.getWidth(), starOne.getHeight()),
                  starOne);
          scoreLayout.addView(star1);
          star1.translateAndShine(new ImageView(this));
          STAR_ONE_ENABLED = 1;
        }
      }
      if (STAR_TWO_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.7) - scoreBar.getMax())) {
          StarView star2 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starTwo.getWidth(), starTwo.getHeight()),
                  starTwo);
          scoreLayout.addView(star2);
          star2.translateAndShine(new ImageView(this));
          STAR_TWO_ENABLED = 1;
        }
      }
      if (STAR_THREE_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.8) - scoreBar.getMax())) {
          StarView star3 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starThree.getWidth(), starThree.getHeight()),
                  starThree);
          scoreLayout.addView(star3);
          star3.translateAndShine(new ImageView(this));
          STAR_THREE_ENABLED = 1;
        }
      }
      // *****  Type of Question  *****

      // Init question
      Random random = new Random();
      int randomCoordX = random.nextInt(8) - 4;
      int randomCoordY = random.nextInt(8) - 4;
      question = new QuestionCoord(randomCoordX, randomCoordY);

      // Move Lines
      if (numberOfQuestionsRemaining > (numberOfQuestions / 2)) {
        marker.setVisibility(View.INVISIBLE);

        // Positive
        questionCoordX.setText(question.getxString());
        questionCoordY.setText(question.getyString());

        currentLineXcoord = 0;
        currentLineYcoord = 0;
        setLinePositions(glv);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");

      }
      // Drag Number Panels Positive
      else {
        if (numberOfQuestionsRemaining == (numberOfQuestions / 2)) {
          gridLayout.removeView(lineX);
          gridLayout.removeView(lineY);

          questionCoordX.setText("x");
          questionCoordY.setText("y");

          initNumberPadAndAnswePanel();
          initSwitches();
        }

        marker.setVisibility(View.INVISIBLE);

        // Match x&y to question x&y
        AxisX x = null;
        AxisY y = null;
        for (int i = 0; i < glv.getAxisXlines().size(); i++) {
          if (glv.getAxisXlines().get(i).xNumber == question.getXNumber()) {
            x = glv.getAxisXlines().get(i);
          }
          if (glv.getAxisYlines().get(i).yNumber == question.getYNumber()) {
            y = glv.getAxisYlines().get(i);
          }
        }
        marker.setX(((int) x.x) - marker.getWidth() / 2);
        marker.setY(((int) y.y) - marker.getHeight() / 2);
        scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
        scaleIn.setDuration(300);
        scaleIn.setStartOffset(200);
        scaleIn.setInterpolator(new OvershootInterpolator());
        scaleIn.setFillAfter(true);
        scaleIn.setAnimationListener(
            new AnimationListener() {
              @Override
              public void onAnimationEnd(Animation arg0) {}

              @Override
              public void onAnimationRepeat(Animation animation) {}

              @Override
              public void onAnimationStart(Animation animation) {
                marker.setVisibility(View.VISIBLE);
              }
            });
        marker.startAnimation(scaleIn);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");
      }
    }
  }