public void setCenter(Point pt){
    double scale = _panel.getScale();
    
    Point point=new Point((int)(pt.getX()*scale),(int)(pt.getY()*scale));
    
    double w = getViewport().getWidth();
    double h = getViewport().getHeight();

    // Turn the top left coordinates into the center coordinates of the viewport
    int halfW = (int) (w/2.0);
    int halfH = (int) (h/2.0);

    // Move back to top left
    point.translate(-halfW, -halfH);
    
    if(point.getX()<0){
     point.setLocation(0,point.getY()); 
    }
    if(point.getY()<0){
     point.setLocation(point.getX(),0); 
    }

    // Set this to be the new top left coordinates of the viewport
    getViewport().setViewPosition(point);
  }