code: private int getYForX(int newX, int newY) {
  
          int height = (int)Math.floor((newX - m_firstX) * m_heightToWidth);
          int result = m_firstY + height;
          if (((m_firstY - newY) * (m_firstY - result)) < 0) {
              result = m_firstY - height;
          }
          return result;
      }
docs: Calculates the matching Y (top/height) value in case of a fixed height/width ratio.<p>
  
  @param newX the cursor X offset to the selection area
  @param newY the cursor Y offset to the selection area
  
  @return the matching Y value