public final BufferedImage paintToImage(final BufferedImage _bi,
			final PaintObjectWriting _o, final boolean _final, 
			final DPoint _p_start, final BufferedImage _g, 
			final DRect _rVisibleScope) {

		//fetch list of points and go to the beginning of the list
		List<DPoint> ls_point = _o.getPoints();
		model.util.adt.list.Element<DPoint> d = _o.getPoints().getElement();
		ls_point.toFirst();

		//if list is empty return the bufferedImage which is not changed.
		if (ls_point.isEmpty()) {
			return _bi;
		}	
		
		final Rectangle rect;
		if (_rVisibleScope == null) {
			rect = null;
		} else {
			rect = _rVisibleScope.getRectangle();
		}
		
		
		//if the painting is not final and id is for mathematics.
		int tempId_operation = id_operation;
		if (!_final && id_operation == Constants.PEN_ID_MATHS) {
			tempId_operation = Constants.PEN_ID_LINES;
		}
		
		switch (tempId_operation) {
		case Constants.PEN_ID_POINT:
		    operationPoint(ls_point, _bi, _final, _p_start, _g, rect);
			
			break;
		case Constants.PEN_ID_LINES:

			operationLine(ls_point, _bi, _final, _p_start, _g, rect);
			
			break;
        case Constants.PEN_ID_MATHS:

            operationMaths(
                    ls_point, _bi, _final, _p_start, _g);
            break;

        case Constants.PEN_ID_MATHS_SILENT:

            System.out.println("c1");
            operationMaths(
                    ls_point, _bi, _final, _p_start, _g);
            break;

        case Constants.PEN_ID_MATHS_SILENT_2:

            System.out.println("c2");
            operationMaths2(
                    _o, _bi, _final, _p_start, _g);

            break;

        default:
            break;
		}
		_o.getPoints().goToElement(d);
		return _bi;
	}