public boolean contains(double x, double y) {		
		
		if (currentMode == POINTS_AND_LINES || currentMode == LINES) {
			double dataX = axes.boundsXtoDataX(x);
			
			lineRect.setRect(x*xFactor-4, y*yFactor-4, 7, 7);
			Point2D[] line = xySeries.getLineForXVal(dataX);
			if (line==null || Double.isNaN(line[0].getY()) || Double.isNaN(line[1].getY())) {
				return false;
			}
			else {
				boolean contains = lineRect.intersectsLine(axes.dataXtoBoundsX(line[0].getX())*xFactor, axes.dataYtoBoundsY(line[0].getY())*yFactor, axes.dataXtoBoundsX(line[1].getX())*xFactor, axes.dataYtoBoundsY(line[1].getY())*yFactor);
				return contains;
			}
			
		}
		
		if (currentMode == BOXES) {
			double boxWidth = calculateBoxWidth();


			double yAxis = axes.dataYtoFigureY(0);
			
			double dataX = axes.boundsXtoDataX(x+(boxWidth*boxOffset+Math.ceil(boxWidth/2.0))/xFactor);
			int boxIndex = xySeries.getIndexForXVal(dataX);
			Rectangle2D rect = getBoxForIndex(boxIndex, yAxis); 
			//System.out.println( " click x: " + x*xFactor + " data x: " + dataX + "Box index: " + boxIndex + " x: " + rect.getX() + " height: " + rect.getHeight() + " width: " + rect.getWidth() );
			Point2D pos = new Point2D.Double(x*xFactor, y*yFactor);
			if (rect == null)
				return false;
			else
				return rect.contains(pos);
		}
		
		if (currentMode == POINTS) {
			return pathShape.intersects(x*xFactor-3, y*yFactor-3, 5, 5);
		}
		
		return false;
	}