src/main/java/com/mxgraph/swing/mxGraphComponent.java
public int print(Graphics g, PageFormat printFormat, int page)
	{
		int result = NO_SUCH_PAGE;

		// Disables double-buffering before printing
		RepaintManager currentManager = RepaintManager
				.currentManager(mxGraphComponent.this);
		currentManager.setDoubleBufferingEnabled(false);

		// Gets the current state of the view
		mxGraphView view = graph.getView();

		// Stores the old state of the view
		boolean eventsEnabled = view.isEventsEnabled();
		mxPoint translate = view.getTranslate();

		// Disables firing of scale events so that there is no
		// repaint or update of the original graph while pages
		// are being printed
		view.setEventsEnabled(false);

		// Uses the view to create temporary cell states for each cell
		mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
				1 / pageScale);

		try
		{
			view.setTranslate(new mxPoint(0, 0));

			mxGraphics2DCanvas canvas = createCanvas();
			canvas.setGraphics((Graphics2D) g);
			canvas.setScale(1 / pageScale);

			view.revalidate();

			mxRectangle graphBounds = graph.getGraphBounds();
			Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
					+ graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
					.getY() + graphBounds.getHeight()) + 1);

			int w = (int) (printFormat.getImageableWidth());
			int h = (int) (printFormat.getImageableHeight());
			int cols = (int) Math.max(
					Math.ceil((double) (pSize.width - 5) / (double) w), 1);
			int rows = (int) Math.max(
					Math.ceil((double) (pSize.height - 5) / (double) h), 1);

			if (page < cols * rows)
			{
				int dx = (int) ((page % cols) * printFormat.getImageableWidth());
				int dy = (int) (Math.floor(page / cols) * printFormat
						.getImageableHeight());

				g.translate(-dx + (int) printFormat.getImageableX(), -dy
						+ (int) printFormat.getImageableY());
				g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
						(int) (dy + printFormat.getHeight()));

				graph.drawGraph(canvas);

				result = PAGE_EXISTS;
			}
		}
		finally
		{
			view.setTranslate(translate);

			tempStates.destroy();
			view.setEventsEnabled(eventsEnabled);

			// Enables double-buffering after printing
			currentManager.setDoubleBufferingEnabled(true);
		}

		return result;
	}
/**
	 * Prints the specified page on the specified graphics using
	 * <code>pageFormat</code> for the page format.
	 * 
	 * @param g
	 *            The graphics to paint the graph on.
	 * @param printFormat
	 *            The page format to use for printing.
	 * @param page
	 *            The page to print
	 * @return Returns {@link Printable#PAGE_EXISTS} or
	 *         {@link Printable#NO_SUCH_PAGE}.
	 */
Prints the specified page on the specified graphics using
pageFormat for the page format.

@param g
The graphics to paint the graph on.
@param printFormat
The page format to use for printing.
@param page
The page to print
@return Returns  Printable#PAGE_EXISTS or
Printable#NO_SUCH_PAGE.
Prints the specified page on the specified graphics using pageFormat for the page format . @param g The graphics to paint the graph on . @param printFormat The page format to use for printing . @param page The page to print @return Returns Printable#PAGE_EXISTS or Printable#NO_SUCH_PAGE .
public int print(Graphics g, PageFormat printFormat, int page)
	{
		int result = NO_SUCH_PAGE;
		RepaintManager currentManager = RepaintManager
				.currentManager(mxGraphComponent.this);
		currentManager.setDoubleBufferingEnabled(false);
		mxGraphView view = graph.getView();
		boolean eventsEnabled = view.isEventsEnabled();
		mxPoint translate = view.getTranslate();
		view.setEventsEnabled(false);
		mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
				1 / pageScale);
		try
		{
			view.setTranslate(new mxPoint(0, 0));
			mxGraphics2DCanvas canvas = createCanvas();
			canvas.setGraphics((Graphics2D) g);
			canvas.setScale(1 / pageScale);
			view.revalidate();
			mxRectangle graphBounds = graph.getGraphBounds();
			Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
					+ graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
					.getY() + graphBounds.getHeight()) + 1);
			int w = (int) (printFormat.getImageableWidth());
			int h = (int) (printFormat.getImageableHeight());
			int cols = (int) Math.max(
					Math.ceil((double) (pSize.width - 5) / (double) w), 1);
			int rows = (int) Math.max(
					Math.ceil((double) (pSize.height - 5) / (double) h), 1);
			if (page < cols * rows)
			{
				int dx = (int) ((page % cols) * printFormat.getImageableWidth());
				int dy = (int) (Math.floor(page / cols) * printFormat
						.getImageableHeight());
				g.translate(-dx + (int) printFormat.getImageableX(), -dy
						+ (int) printFormat.getImageableY());
				g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
						(int) (dy + printFormat.getHeight()));
				graph.drawGraph(canvas);
				result = PAGE_EXISTS;
			}
		}
		finally
		{
			view.setTranslate(translate);
			tempStates.destroy();
			view.setEventsEnabled(eventsEnabled);
			currentManager.setDoubleBufferingEnabled(true);
		}
		return result;
	}
public int print ( Graphics g , PageFormat printFormat , int page ) { int result = NO_SUCH_PAGE ; RepaintManager currentManager = RepaintManager . currentManager ( mxGraphComponent . this ) ; currentManager . setDoubleBufferingEnabled ( false ) ; mxGraphView view = graph . getView ( ) ; boolean eventsEnabled = view . isEventsEnabled ( ) ; mxPoint translate = view . getTranslate ( ) ; view . setEventsEnabled ( false ) ; mxTemporaryCellStates tempStates = new mxTemporaryCellStates ( view , 1 / pageScale ) ; try { view . setTranslate ( new mxPoint ( 0 , 0 ) ) ; mxGraphics2DCanvas canvas = createCanvas ( ) ; canvas . setGraphics ( ( Graphics2D ) g ) ; canvas . setScale ( 1 / pageScale ) ; view . revalidate ( ) ; mxRectangle graphBounds = graph . getGraphBounds ( ) ; Dimension pSize = new Dimension ( ( int ) Math . ceil ( graphBounds . getX ( ) + graphBounds . getWidth ( ) ) + 1 , ( int ) Math . ceil ( graphBounds . getY ( ) + graphBounds . getHeight ( ) ) + 1 ) ; int w = ( int ) ( printFormat . getImageableWidth ( ) ) ; int h = ( int ) ( printFormat . getImageableHeight ( ) ) ; int cols = ( int ) Math . max ( Math . ceil ( ( double ) ( pSize . width - 5 ) / ( double ) w ) , 1 ) ; int rows = ( int ) Math . max ( Math . ceil ( ( double ) ( pSize . height - 5 ) / ( double ) h ) , 1 ) ; if ( page < cols * rows ) { int dx = ( int ) ( ( page % cols ) * printFormat . getImageableWidth ( ) ) ; int dy = ( int ) ( Math . floor ( page / cols ) * printFormat . getImageableHeight ( ) ) ; g . translate ( - dx + ( int ) printFormat . getImageableX ( ) , - dy + ( int ) printFormat . getImageableY ( ) ) ; g . setClip ( dx , dy , ( int ) ( dx + printFormat . getWidth ( ) ) , ( int ) ( dy + printFormat . getHeight ( ) ) ) ; graph . drawGraph ( canvas ) ; result = PAGE_EXISTS ; } } finally { view . setTranslate ( translate ) ; tempStates . destroy ( ) ; view . setEventsEnabled ( eventsEnabled ) ; currentManager . setDoubleBufferingEnabled ( true ) ; } return result ; }
Prints the specified page on the specified graphics using
 <code>pageFormat</code> for the page format.
Prints the specified page on the specified graphics using <code > pageFormat< / code > for the page format .
// Disables double-buffering before printing // Gets the current state of the view // Stores the old state of the view // Disables firing of scale events so that there is no // repaint or update of the original graph while pages // are being printed // Uses the view to create temporary cell states for each cell // Enables double-buffering after printing