@Override public int print(Graphics g,PageFormat pageFormat,int pageIndex){
  if (pageIndex > 0) {
    return (NO_SUCH_PAGE);
  }
 else {
    Graphics2D g2d=(Graphics2D)g;
    g2d.translate(pageFormat.getImageableX(),pageFormat.getImageableY());
    double fHeight=pageFormat.getImageableHeight();
    double fWidth=pageFormat.getImageableWidth();
    int xMax=1;
    int yMax=1;
    for (int iNode=0; iNode < m_BayesNet.getNrOfNodes(); iNode++) {
      if (xMax < m_BayesNet.getPositionX(iNode)) {
        xMax=m_BayesNet.getPositionX(iNode);
      }
      if (yMax < m_BayesNet.getPositionY(iNode)) {
        yMax=m_BayesNet.getPositionY(iNode);
      }
    }
    double fCurrentScale=m_fScale;
    xMax+=m_nPaddedNodeWidth + 100;
    if (fWidth / xMax < fHeight / yMax) {
      m_fScale=fWidth / xMax;
    }
 else {
      m_fScale=fHeight / yMax;
    }
    paint(g2d);
    m_fScale=fCurrentScale;
    return (PAGE_EXISTS);
  }
}

@ Override public int print ( Graphics g , PageFormat pageFormat , int pageIndex ) { if ( pageIndex > 0 ) { return ( NO_SUCH_PAGE ) ; } else { Graphics2D g2d = ( Graphics2D ) g ; g2d . translate ( pageFormat . getImageableX ( ) , pageFormat . getImageableY ( ) ) ; double fHeight = pageFormat . getImageableHeight ( ) ; double fWidth = pageFormat . getImageableWidth ( ) ; int xMax = 1 ; int yMax = 1 ; for ( int iNode = 0 ; iNode < m_BayesNet . getNrOfNodes ( ) ; iNode ++ ) { if ( xMax < m_BayesNet . getPositionX ( iNode ) ) { xMax = m_BayesNet . getPositionX ( iNode ) ; } if ( yMax < m_BayesNet . getPositionY ( iNode ) ) { yMax = m_BayesNet . getPositionY ( iNode ) ; } } double fCurrentScale = m_fScale ; xMax += m_nPaddedNodeWidth + 100 ; if ( fWidth / xMax < fHeight / yMax ) { m_fScale = fWidth / xMax ; } else { m_fScale = fHeight / yMax ; } paint ( g2d ) ; m_fScale = fCurrentScale ; return ( PAGE_EXISTS ) ; } }
implementation of printable , used for printing
