001/**
002 * www.jcoverage.com
003 * Copyright (C)2003 jcoverage ltd.
004 *
005 * This file is part of jcoverage.
006 *
007 * jcoverage is free software; you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published
009 * by the Free Software Foundation; either version 2 of the License,
010 * or (at your option) any later version.
011 *
012 * jcoverage is distributed in the hope that it will be useful, but
013 * WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with jcoverage; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020 * USA
021 *
022 */
023package com.jcoverage.coverage.reporting.html;
024
025import java.io.PrintWriter;
026
027import org.apache.log4j.Logger;
028
029import com.jcoverage.reporting.FormattingContext;
030import com.jcoverage.reporting.Page;
031import com.jcoverage.reporting.html.Writable;
032
033/**
034 *
035 */
036public class NavigationBar implements Writable {
037  
038  static Logger logger=Logger.getLogger(NavigationBar.class);
039  
040  StringBuffer buffer=new StringBuffer();
041
042  public NavigationBar(FormattingContext ctx,Page page) {
043    buffer=new StringBuffer(page.getLabel().toLowerCase());
044
045    Page refpage=page;
046    
047    while (refpage.getMasterLine()!=null && refpage.getMasterLine().getOwner()!=null) {
048      refpage=refpage.getMasterLine().getOwner();
049      buffer.insert(0," | ");
050      buffer.insert(0,"<a href=\""+ctx.getCollator().getPathToPage(ctx,refpage,page)+"\">"+refpage.getLabel().toLowerCase()+"</a>");
051    }
052  }
053
054  public void writeTo(PrintWriter writer) {
055    writer.print("<p class=\"navbar\"><b><a href=\"http://jcoverage.com\">jcoverage</a></b> | ");
056    writer.println(buffer.toString());
057    writer.println("<p>");
058  }
059
060}