Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

In this page you can find the example usage for java.awt Color YELLOW.

Prototype

Color YELLOW

To view the source code for java.awt Color YELLOW.

Click Source Link

Document

The color yellow.

Usage

From source file:mastermind2.pkg0.MasterMind.java

private void amarilloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_amarilloActionPerformed
    color = Color.YELLOW;
}

From source file:v800_trainer.JCicloTronic.java

private static Color getColor(int Farbe) {

    Color Colour = Color.BLACK;
    Farbe = Farbe % 8;// w w w  . j av a  2  s. c om
    switch (Farbe) {
    case 2:
        Colour = Color.BLACK;
        break;
    case 1:
        Colour = Color.BLUE;
        break;
    case 0:
        Colour = Color.RED;
        break;
    //     case 3: Colour = Color.GREEN; break;
    case 4:
        Colour = Color.MAGENTA;
        break;
    case 5:
        Colour = Color.ORANGE;
        break;
    case 3:
        Colour = Color.PINK;
        break;
    //            case 7: Colour = Color.CYAN; break;
    case 6:
        Colour = Color.YELLOW;
        break;
    case 7:
        Colour = Color.WHITE;
        break;

    }
    return Colour;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchObjdumpButtonActionPerformed(ActionEvent evt) {
    if (jTextField1.getText().length() > 0) {
        Highlighter h = jEditorPane1.getHighlighter();
        h.removeAllHighlights();/*from w  w w. j a v a 2  s  . c om*/
        String text = jEditorPane1.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jTextField1.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jTextField1.getText().length())
                    .equals(jTextField1.getText().toLowerCase())) {
                try {
                    if (j >= jEditorPane1.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jTextField1.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jTextField1.getText().length();
                    } else {
                        h.addHighlight(j, j + jTextField1.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jEditorPane1.setCaretPosition(nextPosition);
        } else {
            jEditorPane1.setCaretPosition(0);
        }
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchRelPltButtonActionPerformed(ActionEvent evt) {
    if (jSearchRelPltTextField.getText().length() > 0) {
        Highlighter h = jSearchRelPltEditorPane.getHighlighter();
        h.removeAllHighlights();//  w  ww .  j  a  v  a2 s  . co m
        String text = jSearchRelPltEditorPane.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jSearchRelPltTextField.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jSearchRelPltTextField.getText().length())
                    .equals(jSearchRelPltTextField.getText().toLowerCase())) {
                try {
                    if (j >= jSearchRelPltEditorPane.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jSearchRelPltTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jSearchRelPltTextField.getText().length();
                    } else {
                        h.addHighlight(j, j + jSearchRelPltTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jSearchRelPltEditorPane.setCaretPosition(nextPosition);
        } else {
            jSearchRelPltEditorPane.setCaretPosition(0);
        }
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchDynamicButtonActionPerformed(ActionEvent evt) {
    if (jSearchDynamicTextField.getText().length() > 0) {
        Highlighter h = jSearchDynamicEditorPane.getHighlighter();
        h.removeAllHighlights();/*from www  . j  a  va2 s . com*/
        String text = jSearchDynamicEditorPane.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jSearchDynamicTextField.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jSearchDynamicTextField.getText().length())
                    .equals(jSearchDynamicTextField.getText().toLowerCase())) {
                try {
                    if (j >= jSearchDynamicEditorPane.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jSearchDynamicTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jSearchDynamicTextField.getText().length();
                    } else {
                        h.addHighlight(j, j + jSearchDynamicTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jSearchDynamicEditorPane.setCaretPosition(nextPosition);
        } else {
            jSearchDynamicEditorPane.setCaretPosition(0);
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author wxy pdf// w  ww  .j  a v a  2 s  .  c o  m
 * @param filename
 * @date 2010-3-27
 */
public void createReport_ServiceEventPdf(String filename) throws IOException {

    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        List eventlist = new ArrayList();
        eventlist = (List) reportHash.get("eventlist");
        String ip = "";
        String sum = "";
        String levelone = "";
        String leveltwo = "";
        String levelthree = "";
        String servicename = "";
        if (eventlist != null && eventlist.size() > 0) {

            List _eventlist = (List) eventlist.get(0);
            if (_eventlist != null && _eventlist.size() > 0) {
                ip = (String) _eventlist.get(0);
                servicename = (String) _eventlist.get(1);
                sum = (String) _eventlist.get(2);
                levelone = (String) _eventlist.get(3);
                leveltwo = (String) _eventlist.get(4);
                levelthree = (String) _eventlist.get(5);
            }
        }

        Paragraph title = new Paragraph(servicename + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(6);
        // 
        context.setFirstLineIndent(6);
        document.add(context);
        document.add(new Paragraph("\n"));

        PdfPTable servTable = new PdfPTable(6);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        servTable.setWidths(cellWidths);
        servTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("IP", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(ip, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(servicename, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(levelone, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(leveltwo, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        cell = new PdfPCell(new Phrase(levelthree, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        servTable.addCell(cell);
        document.add(servTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable eventTable = new PdfPTable(6);
        float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        int index = 0;
        java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
        List list = (ArrayList) reportHash.get("list");
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                index++;
                EventList event = (EventList) list.get(i);
                Date cc = event.getRecordtime().getTime();
                Integer eventid = event.getId();
                String eventlocation = event.getEventlocation();
                String content = event.getContent();
                String level = String.valueOf(event.getLevel1());
                String status = String.valueOf(event.getManagesign());
                String s = status;
                String showlevel = null;
                String act = "";
                if ("1".equals(level)) {
                    showlevel = "";
                } else if ("2".equals(level)) {
                    showlevel = "";
                } else {
                    showlevel = "";
                }
                if ("0".equals(status)) {
                    status = "";
                }
                if ("1".equals(status)) {
                    status = "";
                }
                if ("2".equals(status)) {
                    status = "";
                }
                String rptman = event.getReportman();
                String rtime1 = _sdf.format(cc);
                cell = new PdfPCell(new Phrase(String.valueOf(index), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                if ("3".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.red);
                    eventTable.addCell(cell);
                } else if ("2".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.orange);
                    eventTable.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.yellow);
                    eventTable.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(content, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rtime1, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rptman, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(status, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
            }
        }
        document.add(eventTable);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI pdf/* w  w  w.j av a2  s  . co  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_EventPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        DBVo vo = (DBVo) reportHash.get("vo");
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        String hostname = (String) reportHash.get("dbname");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        PdfPTable dbTable = new PdfPTable(5);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        dbTable.setWidths(cellWidths);
        dbTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("IP", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(vo.getDbName(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(ip, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(typename, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(downnum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(count, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        document.add(dbTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable eventTable = new PdfPTable(6);
        float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        int index = 0;
        java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
        List list = (ArrayList) reportHash.get("list");
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                index++;
                EventList eventlist = (EventList) list.get(i);
                Date cc = eventlist.getRecordtime().getTime();
                Integer eventid = eventlist.getId();
                String eventlocation = eventlist.getEventlocation();
                String content = eventlist.getContent();
                String level = String.valueOf(eventlist.getLevel1());
                String status = String.valueOf(eventlist.getManagesign());
                String s = status;
                String showlevel = null;
                String act = "";
                if ("1".equals(level)) {
                    showlevel = "";
                } else if ("2".equals(level)) {
                    showlevel = "";
                } else {
                    showlevel = "";
                }
                if ("0".equals(status)) {
                    status = "";
                }
                if ("1".equals(status)) {
                    status = "";
                }
                if ("2".equals(status)) {
                    status = "";
                }
                String rptman = eventlist.getReportman();
                String rtime1 = _sdf.format(cc);
                cell = new PdfPCell(new Phrase(String.valueOf(index), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                if ("3".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.red);
                    eventTable.addCell(cell);
                } else if ("2".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.orange);
                    eventTable.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.yellow);
                    eventTable.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(content, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rtime1, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rptman, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(status, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
            }
        }

        document.add(eventTable);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * PDF//from w w w.  j a  v  a  2  s  . c  o  m
 * 
 * @param document
 * @throws DocumentException
 * @throws IOException
 */
private void addEventLisToPdf(Document document) throws DocumentException, IOException {
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

    Cell cell;
    Table eventListTable = new Table(6);
    this.setTableFormat(eventListTable);
    float[] eventListWidths = { 220f, 220f, 440f, 220f, 220f, 220f };
    eventListTable.setWidths(eventListWidths);
    // eventListTable.setWidthPercentage(100);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(6);
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    int index = 0;
    java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
    List list = (ArrayList) reportHash.get("list");
    if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
            index++;
            EventList eventlist = (EventList) list.get(i);
            Date cc = eventlist.getRecordtime().getTime();
            Integer eventid = eventlist.getId();
            String eventlocation = eventlist.getEventlocation();
            String content = eventlist.getContent();
            String level = String.valueOf(eventlist.getLevel1());
            String status = String.valueOf(eventlist.getManagesign());
            String s = status;
            String showlevel = null;
            String act = "";
            if ("1".equals(level)) {
                showlevel = "";
            } else if ("2".equals(level)) {
                showlevel = "";
            } else {
                showlevel = "";
            }
            if ("0".equals(status)) {
                status = "";
            }
            if ("1".equals(status)) {
                status = "";
            }
            if ("2".equals(status)) {
                status = "";
            }
            String rptman = eventlist.getReportman();
            String rtime1 = _sdf.format(cc);
            cell = new Cell(new Phrase(String.valueOf(index), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            if ("3".equals(level)) {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.red);
                eventListTable.addCell(cell);
            } else if ("2".equals(level)) {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.orange);
                eventListTable.addCell(cell);
            } else {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.yellow);
                eventListTable.addCell(cell);
            }
            cell = new Cell(new Phrase(content, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(rtime1, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(rptman, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(status, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
        }
    }

    document.add(eventListTable);
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * DOC/* www  .  j  ava  2 s .  co  m*/
 * 
 * @param document
 * @param titleFont
 * @param contextFont
 * @throws BadElementException
 * @throws DocumentException
 */
private void addEventListToDoc(Document document, Font titleFont, Font contextFont)
        throws BadElementException, DocumentException {
    Cell cell;
    // 
    Table eventTable = new Table(6);
    this.setTableFormat(eventTable);
    // float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
    // eventTable.setWidths(eventWidths);
    // eventTable.setWidth(100); //  90%
    // eventTable.setAlignment(Element.ALIGN_CENTER);// 
    // eventTable.setAutoFillEmptyCells(true); // 
    // eventTable.setBorderWidth(1); // 
    // eventTable.setBorderColor(new Color(0, 125, 255)); // 
    // eventTable.setPadding(2);// 
    // eventTable.setSpacing(0);// 
    // eventTable.setBorder(2);// 
    // eventTable.endHeaders();
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    cell.setColspan(6);
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("  ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("   ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);

    int index = 0;
    java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
    List list = (ArrayList) reportHash.get("list");
    if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
            index++;
            EventList eventlist = (EventList) list.get(i);
            Date cc = eventlist.getRecordtime().getTime();
            Integer eventid = eventlist.getId();
            String eventlocation = eventlist.getEventlocation();
            String content = eventlist.getContent();
            String level = String.valueOf(eventlist.getLevel1());
            String status = String.valueOf(eventlist.getManagesign());
            String s = status;
            String showlevel = null;
            String act = "";
            if ("1".equals(level)) {
                showlevel = "";
            } else if ("2".equals(level)) {
                showlevel = "";
            } else {
                showlevel = "";
            }
            if ("0".equals(status)) {
                status = "";
            }
            if ("1".equals(status)) {
                status = "";
            }
            if ("2".equals(status)) {
                status = "";
            }
            String rptman = eventlist.getReportman();
            String rtime1 = _sdf.format(cc);

            cell = new Cell(new Phrase(String.valueOf(index), contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(showlevel, contextFont));
            this.setCellFormat(cell, false);
            if ("3".equals(level)) {
                cell.setBackgroundColor(Color.red);
            } else if ("2".equals(level)) {
                cell.setBackgroundColor(Color.orange);
            } else {
                cell.setBackgroundColor(Color.yellow);
            }
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(content, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(rtime1, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(rptman, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(status, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
        }
    }
    document.add(eventTable);
}