The setting of the borders occurs in the formatTable method.

package com.att.performance.slides;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;

import org.apache.poi.hslf.model.Line;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.Table;
import org.apache.poi.hslf.model.TableCell;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.model.TextRun;
import org.apache.poi.hslf.model.TextShape;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.StyleTextPropAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.usermodel.RichTextRun;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DatasetRenderingOrder;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.AreaRendererEndType;
import org.jfree.chart.renderer.category.AreaRenderer;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.chart.title.LegendTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

import org.jfree.ui.TextAnchor;

import com.att.performance.data.performanceData;
import com.att.performance.utils.configuration;
import com.att.performance.utils.pptColor;
import com.att.performance.utils.utilities;

public class createAnalysisAndBreakdownSlide {

        public createAnalysisAndBreakdownSlide(SlideShow ppt, java.awt.Color 
proprietaryColor,
                        HashMap<String, performanceData> performanceResultsMap,
                        configuration myConfig) {

                // Get list of service to create breakdown slides with 
volume/average response chart and bar chart
                ArrayList<String> analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServices();
                Collections.sort(analysisAndBreakdownServices);
                Iterator<String> servicesItr = 
analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "");

                } // End of while (servicesItr.hasNext())

                analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServicesApple();
                Collections.sort(analysisAndBreakdownServices);
                servicesItr = analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "Apple");

                } // End of while (servicesItr.hasNext())

                analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServicesEaslivr();
                Collections.sort(analysisAndBreakdownServices);
                servicesItr = analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "Easlivr");

                } // End of while (servicesItr.hasNext())

                analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServicesInternal();
                Collections.sort(analysisAndBreakdownServices);
                servicesItr = analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "Internal");

                } // End of while (servicesItr.hasNext())


                analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServicesNational();
                Collections.sort(analysisAndBreakdownServices);
                servicesItr = analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "National");

                } // End of while (servicesItr.hasNext())


                analysisAndBreakdownServices = 
myConfig.getAnalysisAndBreakdownServicesOnline();
                Collections.sort(analysisAndBreakdownServices);
                servicesItr = analysisAndBreakdownServices.iterator();

                // For each service create a breakdown slide
                while (servicesItr.hasNext()) {
                        String thisService = servicesItr.next();
                        createAnalysisAndBreakdownSlides(ppt, proprietaryColor, 
performanceResultsMap,
                                        myConfig, thisService, thisService + " 
(m2e)", "Online");

                } // End of while (servicesItr.hasNext())

        }

        private void createAnalysisAndBreakdownSlides(SlideShow ppt, 
java.awt.Color proprietaryColor,
                        HashMap<String, performanceData> performanceResultsMap,
                        configuration myConfig, String breakdownService, String 
mainTitle, String categoryTitle) {

                boolean showInMilliseconds = true;
                boolean apple = false;
                boolean easlivr = false;
                boolean internal = false;
                boolean national = false;
                boolean online = false;
                boolean none = true;

                String formatString = "%1.0f";
                if (!showInMilliseconds) {
                        formatString = "%1.2f";
                }

            Slide analysisAndBreakdownSlide = ppt.createSlide();
            utilities.addPicture(ppt,analysisAndBreakdownSlide,
                        "images\\TitleBottomRight.jpg",
                        300, 100, 420, 350);
            TextBox tBox = new TextBox();
            // Use two different fonts for slide title
            String [] titleToken = mainTitle.split("\\(");
            if (titleToken.length > 1) {
                formatTextBoxWithMulitpleStyles(ppt, analysisAndBreakdownSlide, 
10, 30, tBox, titleToken[0], "(" + titleToken[1]);
            }
            else
            {
                formatTextBoxWithMulitpleStyles(ppt, analysisAndBreakdownSlide, 
10, 30, tBox, titleToken[0], "");
            }
            analysisAndBreakdownSlide.addShape(tBox);

            if (!categoryTitle.isEmpty()) {
                TextBox tBox1 = new TextBox();
                RichTextRun rt1 = tBox1.getTextRun().getRichTextRuns()[0];
                formatText(tBox1, rt1, categoryTitle + " Breakdown", 240, 5, 
pptColor.darkOrangeText, 24, false, true); //A darker orange color
                analysisAndBreakdownSlide.addShape(tBox1);

                if (categoryTitle.equals("Apple")) {
                        apple = true;
                        none = false;
                }
                if (categoryTitle.equals("Easlivr")) {
                        easlivr = true;
                        none = false;
                }
                if (categoryTitle.equals("Internal")) {
                        internal = true;
                        none = false;
                }
                if (categoryTitle.equals("National")) {
                        national = true;
                        none = false;
                }
                if (categoryTitle.equals("Online")) {
                        online = true;
                        none = false;
                }
            }

            // Find out how many months of data to show on the slide
            int monthsToShow = 
myConfig.getAnalysisAndBreakdownServicesMonthsToShow();
            // The data array is an arraylist of arraylists.  Each element of 
this array list is, in itself, an array list
            // that contains each column information.  So the size if this 
arraylist is the number of rows, and the size of each
            // arraylist element is the number of columns
            // This data structure ends up being a two dimensional array of 
rows and columns that is passed to formattable
            ArrayList<ArrayList<String>> data = new 
ArrayList<ArrayList<String>>();

            performanceData pData = performanceResultsMap.get(breakdownService);
            if (pData == null) {
                utilities.logger("No data found for " + breakdownService);
                return;
            }

            // Create a blank line
            ArrayList<String> topDataElement = new ArrayList<String>();
            for (int i=0;i<monthsToShow + 1;i++) {
                topDataElement.add("");
            }

            //Add date row to data arraylist
        {
                int counter = monthsToShow - 1;
                ArrayList<String> tempAL = new ArrayList<String>();
                tempAL.add("");
                    while (counter >= 0) {
                        tempAL.add(pData.getSampleDate(counter));
                        counter--;
                    }
                    data.add(tempAL);
        }

        //Add Volume row to data arraylist
        {
                int counter = monthsToShow - 1;
                ArrayList<String> tempAL = new ArrayList<String>();
                tempAL.add("Volume");
                while (counter >= 0) {
                        tempAL.add(utilities.insertCommas((int) 
pData.getMonthlyVolume(counter)));
                        counter--;
                }
                data.add(tempAL);
        }

        //Add End to end row to data arraylist
        {
                int counter = monthsToShow - 1;
                ArrayList<String> tempAL = new ArrayList<String>();
                tempAL.add("End To End");
                while (counter >= 0) {
                        if (none) {
//                              tempAL.add(String.format(formatString, 
pData.getEndToEnd(counter)));
                                        tempAL.add(utilities.insertCommas(new 
Float(pData.getEndToEnd(counter)).intValue()));
                                }
                        if (apple) {
//                                      tempAL.add(String.format(formatString, 
pData.getAppleEndToEnd(counter)));
                                        tempAL.add(utilities.insertCommas(new 
Float(pData.getAppleEndToEnd(counter)).intValue()));
                                }
                        if (national) {
                                        tempAL.add(String.format(formatString, 
pData.getNationalEndToEnd(counter)));
//                                      tempAL.add(utilities.insertCommas(new 
Float(pData.getNationalEndToEnd(counter)).intValue()));
                                }
                        if (easlivr) {
//                                      tempAL.add(String.format(formatString, 
pData.getEaslivrEndToEnd(counter)));
                                        tempAL.add(utilities.insertCommas(new 
Float(pData.getEaslivrEndToEnd(counter)).intValue()));
                                }
                        if (online) {
//                                      tempAL.add(String.format(formatString, 
pData.getOnlineEndToEnd(counter)));
                                        tempAL.add(utilities.insertCommas(new 
Float(pData.getOnlineEndToEnd(counter)).intValue()));
                                }
                        if (internal) {
//                                      tempAL.add(String.format(formatString, 
pData.getInternalEndToEnd(counter)));
                                        tempAL.add(utilities.insertCommas(new 
Float(pData.getInternalEndToEnd(counter)).intValue()));
                                }
                                counter--;
                }
                data.add(tempAL);
        }

        //Add gateway row to data arraylist
        {
                int counter = monthsToShow - 1;
                ArrayList<String> tempAL = new ArrayList<String>();
                tempAL.add("Gateway");
                while (counter >= 0) {
                        if (none) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getGateway(counter)));
                                }
                        if (apple) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getAppleGateway(counter)));
                                }
                        if (national) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getNationalGateway(counter)));
                                }
                        if (easlivr) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getEaslivrGateway(counter)));
                                }
                        if (online) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getOnlineGateway(counter)));
                                }
                        if (internal) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getInternalGateway(counter)));
                                }
                                counter--;
                }
                data.add(tempAL);
        }

        //Add spm row to data arraylist
        {
                int counter = monthsToShow - 1;
                ArrayList<String> tempAL = new ArrayList<String>();
                tempAL.add("SPM");
                while (counter >= 0) {
                        if (none) {
                                        tempAL.add(String.format(formatString,
                                                        pData.getSpm(counter)));
                                }
                        if (apple) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getAppleSpm(counter)));
                                }
                        if (national) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getNationalSpm(counter)));
                                }
                        if (easlivr) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getEaslivrSpm(counter)));
                                }
                        if (online) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getOnlineSpm(counter)));
                                }
                        if (internal) {
                                        tempAL.add(String.format(formatString,
                                                        
pData.getInternalSpm(counter)));
                                }
                                counter--;
                }
                data.add(tempAL);
        }

        //Add adapter rows to data arraylist
        {
                int counter = monthsToShow - 1;
                HashMap<String, ArrayList<String>> breakdownHashmap = new 
HashMap<String, ArrayList<String>>();

                //Get a list of all adapters used in any of the reporting months
                ArrayList<String> listOfAdapters = new ArrayList<String>();
                while (counter >= 0) {
                        String [] nameToken = 
pData.getAdapterNames(counter).split(",");
                                for (int i = 0;i < nameToken.length;i++) {
                                if (!listOfAdapters.contains(nameToken[i]) && 
!nameToken[i].isEmpty() ) {
                                        listOfAdapters.add(nameToken[i]);
                                }
                        }
                        counter--;
                }

                //Now create a hashmap for each adapter that contains values of 
each months response times
                counter = monthsToShow - 1;
                while (counter >= 0) {
                        Iterator<String> listOfAdaptersIterator = 
listOfAdapters.iterator();
                        ArrayList<String> nameTokenList = new 
ArrayList<String>();
                        ArrayList<String> timeTokenList = new 
ArrayList<String>();

                                if (none) {
                                        String [] nameToken = 
pData.getAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }
                                if (apple) {
                                        String [] nameToken = 
pData.getAppleAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getAppleAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }
                                if (national) {
                                        String [] nameToken = 
pData.getAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }
                                if (easlivr) {
                                        String [] nameToken = 
pData.getNationalAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getNationalAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }
                                if (online) {
                                        String [] nameToken = 
pData.getOnlineAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getOnlineAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }
                                if (internal) {
                                        String [] nameToken = 
pData.getInternalAdapterNames(counter).split(",");
                                        String [] timeToken = 
pData.getInternalAdapterTimes(counter).split(",");
                                        for (int i = 0;i < 
nameToken.length;i++){
                                                nameTokenList.add(nameToken[i]);
                                                timeTokenList.add(timeToken[i]);
                                        }
                                }

                        while (listOfAdaptersIterator.hasNext()) {
                                int adapterLocation = 0;
                                boolean foundAdapter = false;
                                String adapterName = 
listOfAdaptersIterator.next();

                                for (int i = 0;i < nameTokenList.size();i++) {
                                        if 
(nameTokenList.get(i).equals(adapterName)) {
                                                adapterLocation = i;
                                                foundAdapter = true;
                                                break;
                                        }
                                }

                                if (!breakdownHashmap.containsKey(adapterName)) 
{
                                        if (foundAdapter) {
                                                        ArrayList<String> 
tempAL = new ArrayList<String>();

                                                        
tempAL.add(String.format(formatString, 
Float.valueOf(timeTokenList.get(adapterLocation))));
                                                        
breakdownHashmap.put(adapterName, tempAL);
                                                }
                                        else
                                        {
                                                        ArrayList<String> 
tempAL = new ArrayList<String>();
                                                        tempAL.add("0");
                                                        
breakdownHashmap.put(adapterName, tempAL);
                                        }
                                } // End of if 
(!breakdownHashmap.containsKey(adapterName))
                                else
                                {
                                        if (foundAdapter) {
                                                        ArrayList<String> 
tempAL = breakdownHashmap.get(adapterName);
                                                        
tempAL.add(String.format(formatString, 
Float.valueOf(timeTokenList.get(adapterLocation))));
                                                        
breakdownHashmap.put(adapterName, tempAL);
                                                }
                                        else
                                        {
                                                        ArrayList<String> 
tempAL = breakdownHashmap.get(adapterName);
                                                        tempAL.add("0");
                                                        
breakdownHashmap.put(adapterName, tempAL);
                                        }
                                }

                        } // End of while (listOfAdaptersIterator.hasNext())


//                      tempAL.add(Float.toString(pData.getSpm(counter)));
                        counter--;
                } // End of while (counter < monthsToShow)

//              counter = 0;

                // Now that all of the adapters are in a hashmap iterate 
through it and add each line to the data structure
                for (String mapKey: breakdownHashmap.keySet()) {
                        ArrayList<String> tempAL = new ArrayList<String>();
                        ArrayList<String> thisAL = breakdownHashmap.get(mapKey);
                        tempAL.add(mapKey);
                        for (int i = 0;i < thisAL.size();i++) {
                                tempAL.add(thisAL.get(i));
                        }
                        data.add(tempAL);
                } //End of for (String mapKey: breakdownHashmap.keySet())

        }

        formatTable(data, topDataElement, analysisAndBreakdownSlide);

        // Create the datasets to be used in creating the charts
        CategoryDataset avgRspDS = createAvgRspDataSet(pData, myConfig, 
categoryTitle);
        CategoryDataset volumeDS = createVolumeDataSet(pData, myConfig);
        CategoryDataset barChartDS = createBarChartDataSet(data);
        // Create the charts
        JFreeChart combinedBarChart = createCombinedDataChart(avgRspDS, 
volumeDS);
        JFreeChart stackedBarChart = createStackedBarChart(barChartDS);

                // Write the chart to a file so it can be added to the slide
        // This first one is a two axis chart
                String fileName = "out.png";
                int chartWidth = 350;
                int chartHeight = 175;
                File chartFile = new File(fileName);
                try {
                        ChartUtilities.saveChartAsPNG(chartFile,
                                        combinedBarChart, chartWidth, 
chartHeight);
                } catch (IOException e) {
                        e.printStackTrace();
                }
            utilities.addPicture(ppt, analysisAndBreakdownSlide,
                        fileName, chartWidth, chartHeight, 10, 60);
            if (!chartFile.delete()) {
                utilities.logger(chartFile + " not deleted.");
            }

            //Add the stacked bar chart
                chartWidth = 300;
                chartHeight = 350;
                chartFile = new File(fileName);
                try {
                        ChartUtilities.saveChartAsPNG(chartFile,
                                        stackedBarChart, chartWidth, 
chartHeight);
                } catch (IOException e) {
                        e.printStackTrace();
                }
            utilities.addPicture(ppt, analysisAndBreakdownSlide,
                        fileName, chartWidth, chartHeight, 350, 60);
            if (!chartFile.delete()) {
                utilities.logger(chartFile + " not deleted.");
            }



        } // End of createAnalysisAndBreakdownSlides method

        // Pass necessary information to format the text in a text box
        private void formatText(TextBox tBox, RichTextRun rt,
                        String myText, int xCoord, int yCoord, Color Mycolor, 
int fontSize, boolean bulletBoolean, boolean isBold) {

            tBox.setText(myText);
            tBox.setHorizontalAlignment(TextBox.AlignLeft);

                if (bulletBoolean) {
                        rt.setBullet(true);
                        rt.setBulletOffset(0);  //bullet offset
                        rt.setTextOffset(50);   //text offset (should be 
greater than bullet offset)
//                      rt.setBulletChar('\u263A'); //bullet character
                }
            tBox.moveTo(xCoord, yCoord);
            tBox.setHorizontalAlignment(TextBox.AlignLeft);
          // Use RichTextRun to work with the text format

            rt.setFontSize(fontSize);
            rt.setFontName("Verdana");
            rt.setBold(isBold);
            rt.setItalic(false);
            rt.setUnderlined(false);
            rt.setFontColor(Mycolor);
            rt.setAlignment(TextBox.AlignLeft);

        } // End of formatText method

        // Use this method if your text for a text box is made up of two 
different strings because they use different
        // fonts, sizes, or colors
        private void formatTextBoxWithMulitpleStyles(SlideShow ppt, Slide 
ytdImprovementSlide, int xCoord, int yCoord,
                        TextBox myTextBox, String str1, String str2) {

                myTextBox.setSheet(ytdImprovementSlide);
                myTextBox.moveTo(xCoord, yCoord);

                TextRun run = myTextBox.getTextRun();
                StyleTextPropAtom styleAtom = null;
                TextCharsAtom textAtom = null;
                for(Record r : run.getRecords()){
                if(r instanceof StyleTextPropAtom) styleAtom = 
(StyleTextPropAtom)r;
                        else if(r instanceof TextCharsAtom) textAtom = 
(TextCharsAtom)r;
                }

                styleAtom.getParagraphStyles().clear();
                styleAtom.getCharacterStyles().clear();

                StringBuffer text = new StringBuffer();
                TextPropCollection prProps, chProps;
                RichTextRun rt;
                String chunk = str1;

                //begin building rich text runs
                //chunk = "Apache";
                text.append(chunk);
                prProps = 
styleAtom.addParagraphTextPropCollection(chunk.length());
                chProps = 
styleAtom.addCharacterTextPropCollection(chunk.length());
                rt = new RichTextRun(myTextBox.getTextRun(), text.length(), 
chunk.length(), null, chProps, false, false);
                rt.supplySlideShow(ppt);
                rt.setFontName("Verdana");
                rt.setFontColor(pptColor.darkOrangeText);
                rt.setBold(true);
                rt.setUnderlined(false);
                rt.setFontSize(24);

                if (!str2.isEmpty()) {
                        //chunk = " POI";
                        chunk = str2;
                        text.append(chunk);
                        prProps = 
styleAtom.addParagraphTextPropCollection(chunk.length());
                        chProps = 
styleAtom.addCharacterTextPropCollection(chunk.length());
                        rt = new RichTextRun(myTextBox.getTextRun(), 
text.length(),
                                        chunk.length(), null, chProps, false, 
false);
                        rt.supplySlideShow(ppt);
                        rt.setFontName("Verdana");
                        rt.setFontColor(pptColor.darkOrangeText);
                        rt.setBold(true);
                        rt.setFontSize(10);
                }
                //sum of chunk lengths must be text.length+1, add a dummy char 
to the end
                styleAtom.addParagraphTextPropCollection(1);
                styleAtom.addCharacterTextPropCollection(1);

                String txt = text.toString();
                textAtom.setText(txt);

                
myTextBox.getTextRun().buildRichTextRuns(styleAtom.getParagraphStyles(), 
styleAtom.getCharacterStyles(), txt);

        } // End of formatTextBoxWithMulitpleStyles method

        // Iterate through the data array and format the table
        private Table formatTable(ArrayList<ArrayList<String>> data, 
ArrayList<String> topDataElement,
                        Slide bracketedResponseSlide) {

            // topDataElement.length is the number of columns
            // data.size is the number of rows

            Table table = new Table(data.size(), topDataElement.size());
            int rowHeight = 1;
            int columnWidth = 60;
            int lastColumn = 0;
            int fontSize = 8;

            Iterator<ArrayList<String>> itr = data.iterator();
            int tableRow = 0;
            Line borderLine = new Line();
            borderLine.setLineColor(Color.BLACK);
            borderLine.setLineStyle(Line.LINE_SIMPLE);
            borderLine.setLineWidth(Line.DEFAULT_LINE_WIDTH);
            table.setAllBorders(borderLine);

            while (itr.hasNext()) {
                ArrayList<String> dataElement = itr.next();
                table.setRowHeight(tableRow, rowHeight);

                for (int tableColumn = 0; tableColumn < 
dataElement.size();tableColumn++) {

                        table.setColumnWidth(tableColumn, columnWidth);

                        if (tableColumn == 0) {
                                table.setColumnWidth(tableColumn, columnWidth + 
35);
                        }

                                TableCell cell = table.getCell(tableRow, 
tableColumn);
                                cell.setText(dataElement.get(tableColumn));
                                cell.setWordWrap(TextShape.WrapByPoints);
                                float margin = 0.1f;
                                cell.setMarginBottom(margin);
                                cell.setMarginLeft(margin);
                                cell.setMarginRight(margin);
                                cell.setMarginTop(margin);


                                if (tableRow == 0) {
                                        
cell.setFillColor(pptColor.rowFillColorGrey);
                                }
                                else
                                {
                                if (tableColumn == 0 && tableRow > 2) {
                                        
cell.setFillColor(pptColor.colorArray[tableRow - 3]);
                                }
                                }

                                
cell.setHorizontalAlignment(TextBox.AlignCenter);

                                RichTextRun rt = 
cell.getTextRun().getRichTextRuns()[0];
                                if (tableRow < 1)
                            {
                                 rt.setBold(true);
                            }
                                else
                                {
                                        rt.setBold(false);
                                }
                                rt.setFontName("Arial");
                            rt.setFontSize(fontSize);
                            rt.setFontColor(Color.BLACK);

//                          cell.setVerticalAlignment(TextBox.AnchorMiddle);
//                          cell.setHorizontalAlignment(TextBox.AlignCenter);
                            lastColumn = tableColumn;
                } // End of ffor (int tableColumn = 0; tableColumn < 
dataElement.length; tableColumn++)
//               table.setColumnWidth(lastColumn, columnWidth + 5);
                 tableRow++;
            } // End of while (itr.hasNext())


//          table.setAnchor(new Rectangle(20, 225, 360, 225));
            bracketedResponseSlide.addShape(table);
            table.moveTo(20,275);
            return table;
        } // End of formatTable method

        // Create the average response time dataset to be used in the tow axis 
chart
        private CategoryDataset createAvgRspDataSet(performanceData pData, 
configuration myConfig, String categoryTitle) {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                int monthsToShow = 
myConfig.getAnalysisAndBreakdownServicesMonthsToShow();

                ArrayList<Integer> intAL = new ArrayList<Integer>();
                if (categoryTitle.isEmpty()) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getEndToEnd(i) > 0.0f) {
                                        intAL.add((int)pData.getEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }

                if (categoryTitle.equals("Apple")) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getAppleEndToEnd(i) > 0.0f) {
                                        
intAL.add((int)pData.getAppleEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }
                if (categoryTitle.equals("Easlivr")) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getEaslivrEndToEnd(i) > 0.0f) {
                                        
intAL.add((int)pData.getEaslivrEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }
                if (categoryTitle.equals("Internal")) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getInternalEndToEnd(i) > 0.0f) {
                                        
intAL.add((int)pData.getInternalEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }
                if (categoryTitle.equals("National")) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getNationalEndToEnd(i) > 0.0f) {
                                        
intAL.add((int)pData.getNationalEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }
                if (categoryTitle.equals("Online")) {
                        for (int i=monthsToShow - 1;i >= 0;i--) {
                                if (pData.getOnlineEndToEnd(i) > 0.0f) {
                                        
intAL.add((int)pData.getOnlineEndToEnd(i));
                                }
                                else
                                {
                                        intAL.add(0);
                                }
                        }
                }


                //Format for addvalue arguments are arg 1 = the data, arg2 is 
the row label, arg 3 is the column label
//              for (int i=monthsToShow - 1;i >= 0;i--) {
                for (int i = 0; i < monthsToShow; i++) {
                                dataset.addValue(intAL.get(i), "AvgRsp",
                                                pData.getSampleDate(i));
                }

                return dataset;
        } // End of createAvgRspDataSet method

        // Create the volume dataset to be used in the tow axis chart
        private CategoryDataset createVolumeDataSet(performanceData pData, 
configuration myConfig) {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                int monthsToShow = 
myConfig.getAnalysisAndBreakdownServicesMonthsToShow();

                //Format for addvalue arguments are arg 1 = the data, arg2 is 
the row label, arg 3 is the column label
                for (int i=monthsToShow - 1;i >= 0;i--) {
                        dataset.addValue(pData.getMonthlyVolume(i)/1000, 
"Volume", pData.getSampleDate(i));
                }

                return dataset;
        }  // End of createVolumeDataSet method

        // Create the two axis chart
        private JFreeChart createCombinedDataChart(CategoryDataset avgRspDS, 
CategoryDataset volumeDS) {
            int fontSize = 9;
            String fontType = "SansSerif";
//          String fontType = "Arial";
                JFreeChart chart = ChartFactory.createAreaChart(
                                "",                                             
        // chart title
                                "Dates",                                        
        // domain axis label
                                "Volume (thousands)",                   // 
range axis label
                                volumeDS,                                       
        // data
                                PlotOrientation.VERTICAL,               // 
orientation
                                true,                                           
        // include legend
                                false,                                          
        // tooltips
                                false);                                         
        // urls

                // Set the color for the chart
                chart.setBackgroundPaint(pptColor.plotBackground);
                CategoryPlot plot = chart.getCategoryPlot();

//              AxisSpace ax = new AxisSpace();
//              ax.setLeft(0.5);
//              ax.setRight(0.5);
//              plot.setFixedDomainAxisSpace(ax);



                // Get the renderer for the area chart
                AreaRenderer areaRenderer = (AreaRenderer) plot.getRenderer();
                areaRenderer.setEndType(AreaRendererEndType.TRUNCATE);

                // Create a line chart renderer
                LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer();
                // Set the line size of the line chart
                lineRenderer.setBaseOutlineStroke(new BasicStroke(1.0f));
                LegendTitle legend = chart.getLegend();

                // Create the second y axis
            NumberAxis rangeAxis2 = new NumberAxis("Avg Response");
            plot.setRangeAxis(1, rangeAxis2);
                plot.setDataset(1, avgRspDS);
                plot.mapDatasetToRangeAxis(1, 1);
                plot.setRenderer(1, lineRenderer);
                plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
//              plot.setForegroundAlpha(0.50f);
            ChartUtilities.applyCurrentTheme(chart);

            // Apply colors after theme is set
            lineRenderer.setSeriesStroke(0, new BasicStroke(2.0f));
                chart.setBackgroundPaint(Color.WHITE);
            plot.setBackgroundPaint(pptColor.plotChartColor);
                areaRenderer.setSeriesPaint(0, pptColor.areaChartColor);
                lineRenderer.setSeriesPaint(0, pptColor.lineChartColor);
                plot.setRangeGridlinePaint(Color.BLACK);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlineStroke(new BasicStroke(1.0f));

                //Format the x and y axes
                CategoryAxis xAxis = plot.getDomainAxis();


                xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
                xAxis.setLowerMargin(0.0);
                xAxis.setUpperMargin(0.0);
                xAxis.setCategoryMargin(0.0);


                NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
                NumberAxis yAxis2 = (NumberAxis) plot.getRangeAxis(1);

                // For the first y axis include 0, for the other, don't
                yAxis.setAutoRangeIncludesZero(true);
                yAxis2.setAutoRangeIncludesZero(false);
                yAxis.setLowerMargin(.0);
                yAxis.setUpperMargin(.10);
                yAxis2.setLowerMargin(.75);
                yAxis2.setUpperMargin(.10);
                yAxis2.setNumberFormatOverride(new DecimalFormat("####"));

                //Set the fonts for the axes and legend
                legend.setItemFont(new Font(fontType, Font.PLAIN, fontSize + 
2));
                xAxis.setLabelFont(new Font(fontType, Font.PLAIN, fontSize));
                xAxis.setTickLabelFont(new Font(fontType, Font.BOLD, fontSize));
                yAxis.setLabelFont(new Font(fontType, Font.PLAIN, fontSize));
//              yAxis.setTickLabelFont(new Font(fontType, Font.BOLD, fontSize));
                yAxis2.setLabelFont(new Font(fontType, Font.PLAIN, fontSize));

                return chart;
        } // End of createCombinedDataChart method

        // Create dataset for the bar chart
        private CategoryDataset 
createBarChartDataSet(ArrayList<ArrayList<String>> data) {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();;

                //Format for addvalue arguments are arg 1 = the data, arg2 is 
the row label, arg 3 is the column label
                for (int i=3;i < data.size();i++) {
                        ArrayList<String> tempAL = data.get(i);
                        for (int j=1; j < tempAL.size();j++) {
                                dataset.addValue(Float.valueOf(tempAL.get(j)), 
tempAL.get(0), data.get(0).get(j));
                        }
                }
                return dataset;
        }  // End of createBarChartDataSet method

        // Create the bar chart
        private JFreeChart createStackedBarChart(CategoryDataset dataset) {

            int fontSize = 8;
            String fontType = "Verdana";
                JFreeChart chart = ChartFactory.createStackedBarChart(
                                "",                     // chart title
                                "Dates",                                        
        // domain axis label
                                "Avg Response",                                 
// range axis label
                                dataset,                                        
        // data
                                PlotOrientation.VERTICAL,               // 
orientation
                                true,                                           
        // include legend
                                false,                                          
        // tooltips
                                false);                                         
        // urls
                chart.setBackgroundPaint(pptColor.plotBackground);
                CategoryPlot plot = chart.getCategoryPlot();
                LegendTitle legend = chart.getLegend();

                plot.setBackgroundPaint(pptColor.plotBackground);
                BarRenderer renderer = (BarRenderer) plot.getRenderer();

                // Iterate through the color array and set the bar colors
                int numberOfDataRows = dataset.getRowCount();
                for (int i = 0; i < numberOfDataRows; i++) {
                        renderer.setSeriesPaint(i, pptColor.colorArray[i]);
                }

                renderer.setBaseItemLabelsVisible(true);
                DecimalFormat decimalFormat = new DecimalFormat("#### ms");
                Font myFont;

                // Add the values to the bar chart
                for (int i = 0; i < dataset.getRowCount(); i++) {

                        renderer.setSeriesItemLabelGenerator(i,
                                        new StandardCategoryItemLabelGenerator(
                                                        
StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING,
                                                      decimalFormat));
                        renderer.setSeriesItemLabelsVisible(i, true);
//                      renderer.setSeriesItemLabelFont(i,
//                                      new Font("Verdana", Font.BOLD, 
fontSize));
                        myFont = renderer.getSeriesItemLabelFont(i);
                        renderer.setSeriesPositiveItemLabelPosition(i,
                                new ItemLabelPosition(ItemLabelAnchor.CENTER,
                                                TextAnchor.CENTER));
                        renderer.setSeriesNegativeItemLabelPosition(i,
                                        new 
ItemLabelPosition(ItemLabelAnchor.CENTER,
                                                        TextAnchor.CENTER));
                }
                renderer.setDrawBarOutline(false);
                renderer.setShadowVisible(false);
                renderer.setMaximumBarWidth(0.25);
                renderer.setGradientPaintTransformer(null);
                renderer.setBarPainter(new StandardBarPainter());

                CategoryAxis xAxis = plot.getDomainAxis();
                NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();

                plot.setRangeGridlinePaint(Color.ORANGE);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlineStroke(new BasicStroke(1.0f));

                xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

                //Set the fonts for the axes and legend
//              legend.setItemFont(new Font(fontType, Font.BOLD, fontSize));
//              xAxis.setLabelFont(new Font(fontType, Font.BOLD, fontSize));
//              xAxis.setTickLabelFont(new Font(fontType, Font.BOLD, fontSize));
//              yAxis.setLabelFont(new Font(fontType, Font.BOLD, fontSize));
//              yAxis.setTickLabelFont(new Font(fontType, Font.BOLD, fontSize));

                return chart;
        } // End of createStackedBarChart method



}

Jeff Oransky
Technical Architect, ACSI
Office: (925)901-7379
Cell: (925) 548-2786
[email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to