@Override
	public int print(Graphics g, PageFormat pageFormat, int pageIndex)
			throws PrinterException {
		
		if (tripsOfDay.size() == 0)
			return NO_SUCH_PAGE;

		Font oldFont = g.getFont();
        g.setFont(MainWindow.setupData.getPrintElementSetupList().getPrintElementSetup (PrintElementSetupList.FONT_SUMMARY_SHEET).getPrintFont());
        g.setColor(MainWindow.setupData.getPrintElementSetupList().getPrintElementSetup (PrintElementSetupList.FONT_SUMMARY_SHEET).getPrintColor());
        Graphics2D g2d = (Graphics2D) g;

        Integer page = 1;
        // X/Y = border size
        Point a = MainWindow.setupData.getPrintElementSetupList().getPrintElementSetup (PrintElementSetupList.FONT_SUMMARY_SHEET).getAnchorPoint();
        int y;
        if (pageIndex == 0)
            y = putHeader (g2d, a.x, a.y, page);
        else 
        	y = getHeaderHeight (g2d, a.y);
        
        for (Integer t = 0; t < tripsOfDay.size(); t++) {
        	
        	String s = getTripText (t);
        	Integer textHeight = getTextBlockHeight (g2d, s);
        	
           	if (!g2d.hitClip(a.x, y + textHeight + TRIP_DISTANCE, 1, 1)) {
        		page += 1;
        		if (page == pageIndex+1)
        			y = putHeader (g2d, a.x, a.y, page);
        		else
        			y = getHeaderHeight (g2d, a.y);
        	}
   
        	if (page == pageIndex+1)
        		y = putTextBlock (g2d, s, a.x, y) + TRIP_DISTANCE;
        	else 
        		y += textHeight + TRIP_DISTANCE;
        }
		
        g.setFont(oldFont);
        
		if (pageIndex > page-1)
			return NO_SUCH_PAGE;
		return PAGE_EXISTS;
	}