Example usage for java.awt Color orange

List of usage examples for java.awt Color orange

Introduction

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

Prototype

Color orange

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

Click Source Link

Document

The color orange.

Usage

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Sets rendering color for all different network type data series. 
 * @param renderer Renderer for the data series
 * @param dataSeries Data series/*  w w w. j a v a 2s .c om*/
 */
static void setRenderingColorForDataSeries(XYItemRenderer renderer,
        final XYIntervalSeriesCollection dataSeries) {
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.none), Color.WHITE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.LTE), Color.RED);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.WIFI), Color.BLUE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.UMTS), Color.PINK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.ETHERNET), Color.BLACK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSDPA), Color.YELLOW);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPA), Color.ORANGE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPAP), Color.MAGENTA);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSUPA), Color.CYAN);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.GPRS), Color.GRAY);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.EDGE), Color.LIGHT_GRAY);
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Set the tab background and foreground color based on whether the tab's data
 * is out of synch with the model or other configuration changes
 *//*from   w  ww . j ava  2 s .c  o  m*/
private void colorCodeTabs() {
    if (hasIncompleteAssertionsInput) {
        tabbedPane.setForegroundAt(0, Color.orange.darker());
        tabbedPane.setBackgroundAt(0, Color.yellow.brighter());
        tabbedPane.setToolTipTextAt(0, "Only part of the assertions file is displayed");
    } else {
        tabbedPane.setForegroundAt(0, NORMAL_TAB_FG);
        tabbedPane.setBackgroundAt(0, NORMAL_TAB_BG);
        tabbedPane.setToolTipTextAt(0, null);
    }

    if (!areInferencesInSyncWithModel && inferredTriples.getText().trim().length() > 0) {
        tabbedPane.setForegroundAt(1, Color.red);
        tabbedPane.setBackgroundAt(1, Color.pink);
        tabbedPane.setToolTipTextAt(1, "Inferences are out of sync with loaded assertions");
    } else {
        tabbedPane.setForegroundAt(1, NORMAL_TAB_FG);
        tabbedPane.setBackgroundAt(1, NORMAL_TAB_BG);
        tabbedPane.setToolTipTextAt(1, null);
    }

    if (!isTreeInSyncWithModel && !ontModelTree.getModel().isLeaf(ontModelTree.getModel().getRoot())) {
        tabbedPane.setForegroundAt(2, Color.red);
        tabbedPane.setBackgroundAt(2, Color.pink);
        tabbedPane.setToolTipTextAt(2, "Tree is out of sync with loaded assertions");
    } else {
        tabbedPane.setForegroundAt(2, NORMAL_TAB_FG);
        tabbedPane.setBackgroundAt(2, NORMAL_TAB_BG);
        tabbedPane.setToolTipTextAt(2, null);
    }

    if (!areSparqlResultsInSyncWithModel && sparqlResultsTable.getRowCount() > 0) {
        tabbedPane.setForegroundAt(3, Color.red);
        tabbedPane.setBackgroundAt(3, Color.pink);
        tabbedPane.setToolTipTextAt(3, "Results are out of sync with loaded assertions");
    } else {
        tabbedPane.setForegroundAt(3, NORMAL_TAB_FG);
        tabbedPane.setBackgroundAt(3, NORMAL_TAB_BG);
        tabbedPane.setToolTipTextAt(3, null);
    }
}

From source file:paquete.HollywoodUI.java

public void dibujarAristas() {
    Graphics2D g = grafico.createGraphics();
    g.setFont(new Font("SansSerif", Font.BOLD, 11));
    adyaTemp = new ArrayList<>(this.HollyUniverseGraph.getEdges());
    for (Actor temp_actor : actoresArray) {
        for (Arista temp_arista : adyaTemp) {
            g.setColor(Color.BLACK);
            g.drawLine(temp_actor.getX(), temp_actor.getY(), temp_arista.getNext().getX(),
                    temp_arista.getNext().getY());
            int nx = (temp_actor.getX() + temp_arista.getNext().getX()) / 2;
            int ny = (temp_actor.getY() + temp_arista.getNext().getY()) / 2;
            g.setColor(Color.ORANGE);
            if (temp_arista.getRelacion().equals("Amistad")) {
                g.setColor(Color.BLUE);
                g.drawString(temp_arista.getRelacion() + "", nx + 10, ny - 3);
            } else if (temp_arista.getRelacion().equals("Noviazgo")) {
                g.setColor(Color.GREEN);
                g.drawString(temp_arista.getRelacion() + "", nx + 10, ny + 23);
            } else if (temp_arista.getRelacion().equals("Matrimonio")) {
                g.setColor(Color.RED);
                g.drawString(temp_arista.getRelacion() + "", nx - 15, ny - 5);
            } else if (temp_arista.getRelacion().equals("Familia")) {
                g.setColor(Color.YELLOW);
                g.drawString(temp_arista.getRelacion() + "", nx - 15, ny - 5);
            }/*from w  ww. j a va  2s  .c o  m*/
        }
    }
    Image img;
    img = Toolkit.getDefaultToolkit().createImage(grafico.getSource()).getScaledInstance(800, 600, 0);
    label_grafico.setIcon(new ImageIcon(img));
}

From source file:mastermind2.pkg0.MasterMind.java

private void naranjaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_naranjaActionPerformed
    color = Color.ORANGE;
}

From source file:v800_trainer.JCicloTronic.java

private static Color getColor(int Farbe) {

    Color Colour = Color.BLACK;
    Farbe = Farbe % 8;//from   ww  w  .  j  ava  2  s  . co  m
    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:ECallCenter21.java

/**
 *
 * @param campaignIdParam/*from  w  w  w . j a v  a  2  s  .  c om*/
 */
public void runCampaign(int campaignIdParam) {
    callCenterStatus = LOADCAMPAIGN;
    runCampaignToggleButton.removeActionListener(runCampaignToggleButton.getActionListeners()[0]);
    final int campaignId = campaignIdParam;
    Thread outboundCallButtonActionPerformedThread7 = new Thread(allThreadsGroup, new Runnable() {
        @Override
        @SuppressWarnings({ "static-access", "static-access", "static-access", "static-access", "static-access",
                "static-access", "static-access" })
        public void run() {
            String[] status = new String[2];
            //              Prepare the Campaign Run loading the data objects
            campaignStopRequested = false;
            campaign = dbClient.loadCampaignFromOrderId(campaignId);

            order = dbClient.selectCustomerOrder(campaign.getOrderId());
            lastMessageDuration = order.getMessageDuration();

            // Load the Campaign Destinations
            destinationArray = dbClient.selectAllOpenCampaignDestinations(campaignId);

            // Get the saved campaignStat record
            int onAC = campaignStat.getOnAC();
            int idleAC = campaignStat.getIdleAC();
            campaignStat = dbClient.selectCampaignStat(campaignId);
            campaignStat.setOnAC(onAC);
            campaignStat.setIdleAC(idleAC);
            campaignStat.resetActiveCounts();
            try {
                lastTimeDashboardCampaignStat = (CampaignStat) campaignStat.clone();
            } catch (CloneNotSupportedException ex) {
                /* Nonsens in this case*/ } // Make sure there is no difference between this and lastCampaignStat (prevent dashboard going wild on first run)
            if (campaignStat.getConnectingTT() == 0) {
                campaign.setCalendarRegisteredStart(Calendar.getInstance(nlLocale));
                dbClient.updateCampaign(campaign);
            } // First run setting starttime

            soundFileToStream = order.getMessageFilename();
            toegangField.setText(usernameField.getText());
            //                durationCallsEpochTime = 0;
            outboundCallsInProgress = true;
            callCenterIsOutBound = true;
            campaignProgressBar.setEnabled(true);
            runCampaignToggleButton.setEnabled(true);
            stopCampaignButton.setEnabled(true);
            campaignProgressBar.setValue(0);

            callRatioChartData.setValue("Connecting", 0);
            callRatioChartData.setValue("Trying", 0);
            callRatioChartData.setValue("Busy", 0);
            callRatioChartData.setValue("Success", 0);
            graphInnerPanel.setVisible(true);
            chartPanel.setVisible(true);

            turnoverStatsTable.setValueAt(0, 0, 2);
            turnoverStatsTable.setValueAt(0, 1, 2);
            turnoverStatsTable.setValueAt(0, 2, 2);

            // Scheduled Start
            campaignLabel.setText("Campaign " + campaign.getId());
            if (campaign.getCalendarScheduledStart().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarScheduledStart().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.MINUTE))
                        + ":"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.SECOND)), 0,
                        1);
            }
            // Scheduled End
            if (campaign.getCalendarScheduledEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarScheduledEnd().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.SECOND)),
                        1, 1);
            }
            // Expect Start
            if (campaign.getCalendarExpectedStart().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarExpectedStart().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.SECOND)),
                        2, 1);
            }
            // Expect End
            if (campaign.getCalendarExpectedEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(
                        String.format("%04d", campaign.getCalendarExpectedEnd().get(Calendar.YEAR)) + "-"
                                + String.format("%02d",
                                        campaign.getCalendarExpectedEnd().get(Calendar.MONTH) + 1)
                                + "-"
                                + String.format(
                                        "%02d", campaign.getCalendarExpectedEnd().get(Calendar.DAY_OF_MONTH))
                                + " "
                                + String.format("%02d",
                                        campaign.getCalendarExpectedEnd().get(Calendar.HOUR_OF_DAY))
                                + ":"
                                + String.format("%02d", campaign.getCalendarExpectedEnd().get(Calendar.MINUTE))
                                + ":"
                                + String.format("%02d", campaign.getCalendarExpectedEnd().get(Calendar.SECOND)),
                        3, 1);
            }
            // Registered Start
            if (campaign.getCalendarRegisteredStart().getTimeInMillis() != 0) {
                campaignTable
                        .setValueAt(
                                String.format("%04d", campaign.getCalendarRegisteredStart().get(Calendar.YEAR))
                                        + "-"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.MONTH) + 1)
                                        + "-"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart()
                                                        .get(Calendar.DAY_OF_MONTH))
                                        + " "
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.HOUR_OF_DAY))
                                        + ":"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.MINUTE))
                                        + ":"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.SECOND)),
                                4, 1);
            }
            // Registered End
            if (campaign.getCalendarRegisteredEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarRegisteredEnd().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.SECOND)),
                        5, 1);
            }
            // The rest
            campaignTable.setValueAt("-", 6, 1); // Time Tot
            campaignTable.setValueAt("-", 7, 1); // Time Elap
            campaignTable.setValueAt("-", 8, 1); // Time End
            campaignTable.setValueAt("-", 9, 1); // Throughput Calls

            // Set the static proxy config

            status = new String[2];
            username = configurationCallCenter.getUsername();
            //                toegang         = prefixField.getText() + configurationCallCenter.getToegang() + suffixField.getText(); // User for Asterisk
            toegang = configurationCallCenter.getToegang();
            filename = "file:" + soundFileToStream;

            String text = destinationTextArea.getText();

            // ==============================================================================================================================

            // Sets the Order Object and after that displays the OrderMembers in the orderTable and turnover info
            orderLabel.setText("Order " + order.getOrderId());
            orderTable.setValueAt(order.getRecipientsCategory(), 0, 1);
            //                orderTable.setValueAt(order.getTimeWindowCategory(), 1, 1);
            orderTable.setValueAt(
                    order.getTimeWindow0() + " " + order.getTimeWindow1() + " " + order.getTimeWindow2(), 1, 1);
            orderTable.setValueAt(order.getTargetTransactionQuantity(), 2, 1);
            orderTable.setValueAt(order.getTargetTransactionQuantity(), 2, 1);
            orderTable.setValueAt(order.getMessageDuration() + " Sec", 3, 1);
            orderTable.setValueAt(order.getMessageRatePerSecond() + " / Sec", 4, 1);
            orderTable.setValueAt(order.getMessageRate(), 5, 1);
            orderTable.setValueAt(order.getSubTotal(), 6, 1);
            turnoverStatsTable
                    .setValueAt((float) (order.getTargetTransactionQuantity() * order.getMessageRate()), 2, 2); // Total Turnover

            // Make sure the outboundBurstRateSlider adapts to the message length in relation to the Call / Message Duration when message is longer than 10 seconds
            if (Math.round(order.getMessageDuration() * 100) < (eCallCenterGUI.callSpeedSlider.getMinimum())) // Soundfile results below minimum
            {
                eCallCenterGUI.callSpeedSlider.setMaximum(eCallCenterGUI.callSpeedSlider.getMinimum());
            } else {
                eCallCenterGUI.callSpeedSlider.setMaximum(order.getMessageDuration() * 50);
                eCallCenterGUI.callSpeedSlider
                        .setMajorTickSpacing(Math.round((eCallCenterGUI.callSpeedSlider.getMaximum()
                                - eCallCenterGUI.callSpeedSlider.getMinimum()) / 10));
                eCallCenterGUI.callSpeedSlider.setPaintLabels(true);
            }
            callSpeedInterval = Math.round(eCallCenterGUI.callSpeedSlider.getMaximum() / 2);
            callSpeedSlider.setValue(callSpeedInterval);

            //                campaignProgressBar.setMaximum(order.getTargetTransactionQuantity()-1);
            campaignProgressBar.setMaximum(dbClient.getNumberOfAllOpenCampaignDestinations(campaign.getId()));

            // This is where the Campaign Re-run loop start
            campaignRerunForLoop: for (int campaignReRunCounter = 1; campaignReRunCounter <= campaignReRunLimit; campaignReRunCounter++) {
                campaignReRunStage = campaignReRunCounter;
                destinationArray = dbClient.selectAllOpenCampaignDestinations(campaignId);

                try {
                    configurationSoftPhone = (Configuration) configurationCallCenter.clone();
                } // clone the config
                catch (CloneNotSupportedException ex) {
                    showStatus(ex.getMessage(), true, true);
                }

                configurationSoftPhone.setUsername(username);
                configurationSoftPhone.setToegang(toegang);

                // ==============================================================================================================================

                destinationsCounter = 0;
                runCampaignCounter = 0;

                // Call Queuer
                // This is where the Call Loop start
                campaignRunForLoop: for (Destination destinationElement : destinationArray) {
                    // TimeWindow Protector
                    if (callCenterIsNetManaged) {
                        //                            if (!TimeWindow.getCurrentTimeWindow().equals(order.getTimeWindowCategory()))

                        boolean legalTimeWindow = false;
                        for (int orderTimewindow : order.getTimewindowIndexArray()) {
                            if (timeTool.getCurrentTimeWindowIndex() == orderTimewindow) {
                                legalTimeWindow = true;
                            }
                        }

                        if (!legalTimeWindow) {
                            showStatus(
                                    "Self Destructing: " + Vergunning.PRODUCT + " running outside TimeWindow !",
                                    true, true);
                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException ex) {
                            }
                            System.exit(0);
                        }
                    }

                    if (campaignStopRequested) {
                        runCampaignToggleButton.addActionListener(new java.awt.event.ActionListener() {
                            @Override
                            public void actionPerformed(java.awt.event.ActionEvent evt) {
                                runCampaignToggleButtonActionPerformed(evt);
                            }
                        });
                        runCampaignToggleButton.setSelected(false);
                        showStatus("Campaign " + campaign.getId() + " Stopped by user.", true, true);
                        runCampaignToggleButton.setText("");
                        runCampaignToggleButton.setForeground(Color.BLACK);
                        callCenterStatus = STOPPED;

                        campaignProgressBar.setValue(0);
                        campaignProgressBar.setEnabled(false);
                        outboundCallsInProgress = false;
                        phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance

                        // Campaign is ready updating open campaignlist
                        String[] openCampaigns = dbClient.getOpenCampaigns();
                        if ((openCampaigns != null) && (openCampaigns.length > 0)) {
                            if (!callCenterIsNetManaged) {
                                campaignComboBox.setModel(new javax.swing.DefaultComboBoxModel(openCampaigns));
                                campaignComboBox.setEnabled(true);
                            }
                        } else {
                            campaignComboBox.setEnabled(false);
                            runCampaignToggleButton.setEnabled(false);
                            stopCampaignButton.setEnabled(false);
                        }
                        return;
                    }

                    destinationElement.resetTimestamps();
                    dbClient.updateDestination(destinationElement); // Makes sure progresstimestamps are reset  on e.g. second campaign round
                    if (runCampaignCounter == outboundSoftPhonesAvailable) {
                        runCampaignCounter = 0;
                    } // This actually makes the loop roundrobin connecting the end with the beginning

                    // Overheat Protector
                    while (
                    //                                (
                    //                                    (order.getTimeWindowCategory().equals(TimeWindow.getDAYTIME_DECRIPTION())) &&
                    //                                    (currentTimeCalendar.get(Calendar.HOUR_OF_DAY)  == TimeWindow.getDAYTIMEENDHOUR()) &&
                    //                                    (currentTimeCalendar.get(Calendar.MINUTE)       == TimeWindow.getDAYTIMEENDMINUTE())
                    //                                )                                                                                           ||
                    //                                (
                    //                                    (order.getTimeWindowCategory().equals(TimeWindow.getEVENING_DECRIPTION())) &&
                    //                                    (currentTimeCalendar.get(Calendar.HOUR_OF_DAY)  == TimeWindow.getEVENINGENDHOUR()) &&
                    //                                    (currentTimeCalendar.get(Calendar.MINUTE)       == TimeWindow.getEVENINGENDMINUTE())
                    //                                )                                                                                           ||

                    ((currentTimeCalendar.get(Calendar.HOUR_OF_DAY) == timeTool.getCurrentTimeWindow()
                            .getEndHour())
                            && (currentTimeCalendar.get(Calendar.MINUTE) == timeTool.getCurrentTimeWindow()
                                    .getEndMinute()))
                            ||

                            (vmUsage >= vmUsagePauseThreashold) || (memFree <= memFreeThreshold)
                            || (heapMemFree <= heapMemFreeThreshold)
                            || (campaignStat.getConnectingAC() >= connectingTallyLimit)
                            || (campaignStat.getCallingAC() >= callingTallyLimit)
                            || (campaignStat.getTalkingAC() >= establishedTallyLimit)
                            || (!runCampaignToggleButton.isSelected()) || (!powerToggleButton.isSelected())) {
                        callCenterStatus = PAUSING;
                        showStatus("Campaign: " + campaign.getId() + " Run: " + campaignReRunCounter + "-"
                                + campaignReRunLimit + " Pausing...", false, false);
                        runCampaignToggleButton.setText("? ?");
                        runCampaignToggleButton.setForeground(Color.ORANGE);
                        if (vmUsage >= vmUsagePauseThreashold) {
                            eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.vmUsagePauseValue.setForeground(Color.RED);
                            eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.vmUsagePauseValue.setForeground(Color.BLACK);
                            eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (memFree <= memFreeThreshold) {
                            eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.memFreeThresholdValue.setForeground(Color.RED);
                            eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.memFreeThresholdValue.setForeground(Color.BLACK);
                            eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (heapMemFree <= heapMemFreeThreshold) {
                            eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.RED);
                            eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.BLACK);
                            eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getConnectingAC() >= connectingTallyLimit) {
                            eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getCallingAC() >= callingTallyLimit) {
                            eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.callingTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.callingTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getTalkingAC() >= establishedTallyLimit) {
                            eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        try {
                            Thread.sleep(outboundBurstDelay);
                        } catch (InterruptedException ex) {
                        }
                    }

                    if (destinationElement.getDestinationCount() > vergunning.getMaxCalls()) {
                        break;
                    }
                    //                        if ((order.getTargetTransactionQuantity() / 100) != 0) {campaignProgressPercentage = Math.round(destinationElement.getDestinationCount() / (order.getTargetTransactionQuantity() / 100));}
                    if ((order.getTargetTransactionQuantity() / 100) != 0) {
                        campaignProgressPercentage = Math
                                .round(destinationsCounter / (order.getTargetTransactionQuantity() / 100));
                    }
                    showStatus(
                            "Campaign: " + Integer.toString(campaign.getId()) + " Run: "
                                    + Integer.toString(campaignReRunCounter) + "-"
                                    + Integer.toString(campaignReRunLimit) + " " + icons.getTalkChar()
                                    + destinationElement.getDestination() + " ("
                                    + Integer.toString(campaignProgressPercentage) + "%) ["
                                    + Integer.toString(destinationElement.getDestinationCount()) + "-"
                                    + Integer.toString(order.getTargetTransactionQuantity()) + "]",
                            false, false);

                    //                    float cumTurnoverPrecise = destinationsCounter * order.getMessageRate();
                    float cumTurnoverPrecise = campaignStat.getCallingTT() * order.getMessageRate();
                    float cumTurnoverRounded = (float) (Math.round(cumTurnoverPrecise * 100.0) / 100.0);
                    turnoverStatsTable.setValueAt(cumTurnoverRounded, 1, 2); // Cummulative Turnover

                    //                        campaignProgressBar.setValue(destinationElement.getDestinationCount());
                    //                        campaignProgressBar.setValue(destinationsCounter);
                    campaignProgressBar.setValue(campaignStat.getCallingTT());
                    runCampaignToggleButton.setText("");
                    runCampaignToggleButton.setForeground(Color.GREEN);
                    callCenterStatus = RUNNING;
                    eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.vmUsagePauseValue.setForeground(Color.BLACK);
                    eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdValue.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.BLACK);

                    //                        outboundSoftPhoneInstance = (SoftPhone) threadArray[runCampaignCounter];
                    // -- Make PhoneCall
                    if ((destinationElement.getDestination().length() != 0) && (destinationElement
                            .getDestination().length() <= vergunning.getDestinationDigits())) // If destination / phonenumber is larger than 0 bytes
                    {
                        try // If destination / phonenumber is larger than 0 bytes
                        {
                            final Destination callDestination = (Destination) destinationElement.clone();
                            Thread campaignCallThread = new Thread(allThreadsGroup, new Runnable() {

                                @Override
                                public void run() {
                                    SoftPhone thisSoftPhone = (SoftPhone) threadArray[runCampaignCounter]; // work from a copy softphone reference as the call loop carries on
                                    int callMode = 0;
                                    if (scanCheckBox.isSelected()) {
                                        callMode = SCANNING;
                                    } else {
                                        callMode = CALLING;
                                    }
                                    thisSoftPhone.setDestination(callDestination); // Load the phonenumber into the softphone instance before calling

                                    String[] status2 = new String[2];
                                    status2[0] = "0";
                                    status2[1] = "";
                                    status2 = thisSoftPhone.userInput(CALLBUTTON,
                                            callDestination.getDestination(), filename,
                                            Integer.toString(callMode));
                                    if (status2[0].equals("1")) {
                                        // Starting Instant SelfHealing Mechanism (I know it's not a mechanism, but it sounds so much better than automation)
                                        if (thisSoftPhone.getSipState() != thisSoftPhone.SIPSTATE_IDLE) {
                                            showStatus(icons.getIdleChar() + " " + thisSoftPhone.getInstanceId()
                                                    + " Unexpected Sipstatus: "
                                                    + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                            .getSipState()]
                                                    + "...", true, true);
                                            if (thisSoftPhone.getSipState() > thisSoftPhone.SIPSTATE_IDLE) {
                                                String[] status3 = new String[2];
                                                status3[0] = "";
                                                status3[1] = "";
                                                status3 = thisSoftPhone.stopListener();
                                                if (status3[0].equals("0")) {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Stopped Successfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                } else {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Stopped Unsuccessfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                }
                                            }
                                            if (thisSoftPhone.getSipState() < thisSoftPhone.SIPSTATE_IDLE) {
                                                String[] status4 = new String[2];
                                                status4[0] = "";
                                                status4[1] = "";
                                                status4 = thisSoftPhone.startListener(
                                                        thisSoftPhone.getConfiguration().getClientPort());
                                                if (status4[0].equals("0")) {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Started Successfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                    thisSoftPhone.userInput(CALLBUTTON,
                                                            callDestination.getDestination(), filename,
                                                            Integer.toString(callMode));
                                                } else {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Started Unsuccessfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                }
                                            }
                                        } else // The softphone is okay, so make the call
                                        {
                                            thisSoftPhone.userInput(CALLBUTTON,
                                                    callDestination.getDestination(), filename,
                                                    Integer.toString(callMode));
                                        }
                                    }
                                }
                            });
                            campaignCallThread.setName("campaignCallThread");
                            campaignCallThread.setDaemon(runThreadsAsDaemons);
                            campaignCallThread.start();
                        } catch (CloneNotSupportedException ex) {
                        }
                    }

                    // -- End of Valid Destinstion Call Routine

                    phoneStatsTable.setValueAt(runCampaignCounter + 1, 1, 1); // ProcessingInstance
                    try {
                        Thread.sleep(outboundBurstDelay);
                    } catch (InterruptedException ex) {
                    }
                    destinationsCounter++;
                    runCampaignCounter++;
                } // CampaignRun Loop

                // Wait until all phone become available again or 1 minute has passed
                callCenterStatus = RERUNBREAK;
                int reRunBreakCounter = 60;
                while ((campaignStat.getIdleAC() < outboundSoftPhonesAvailable) && (reRunBreakCounter > 0)
                        && (!campaignStopRequested)) {
                    showStatus(
                            "Campaign: " + campaign.getId() + " ReRun: " + campaignReRunCounter
                                    + " Break, Waiting Max: " + reRunBreakCounter + " seconds...",
                            false, false);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                    }
                    reRunBreakCounter--;
                }
            } // CampaignReRuns Loop

            runCampaignToggleButton.addActionListener(new java.awt.event.ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    runCampaignToggleButtonActionPerformed(evt);
                }
            });
            runCampaignToggleButton.setSelected(false);
            showStatus("Campaign Completed...", true, true);
            runCampaignToggleButton.setText("");
            runCampaignToggleButton.setForeground(Color.BLACK);

            campaignProgressBar.setValue(0);
            campaignProgressBar.setEnabled(false);
            outboundCallsInProgress = false;
            phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance

            // Writing Completion of campaign to database
            campaign.setCalendarRegisteredEnd(Calendar.getInstance(nlLocale));
            dbClient.updateCampaign(campaign);
            campaignTable.setValueAt(
                    String.format("%04d", campaign.getCalendarRegisteredEnd().get(Calendar.YEAR)) + "-"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MONTH) + 1)
                            + "-"
                            + String.format(
                                    "%02d", campaign.getCalendarRegisteredEnd().get(Calendar.DAY_OF_MONTH))
                            + " "
                            + String.format("%02d",
                                    campaign.getCalendarRegisteredEnd().get(Calendar.HOUR_OF_DAY))
                            + ":"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MINUTE))
                            + ":"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.SECOND)),
                    5, 1);

            // Campaign is ready updating open campaignlist
            String[] openCampaigns = dbClient.getOpenCampaigns();
            if ((openCampaigns != null) && (openCampaigns.length > 0)) {
                campaignComboBox.setModel(new javax.swing.DefaultComboBoxModel(openCampaigns));
                campaignComboBox.setEnabled(true);
            } else {
                campaignComboBox.setEnabled(false);
                runCampaignToggleButton.setEnabled(false);
                stopCampaignButton.setEnabled(false);
            }

            if (autoPowerOff) {
                System.exit(0);
            }
            return;
        }
    });
    outboundCallButtonActionPerformedThread7.setName("outboundCallButtonActionPerformedThread7");
    outboundCallButtonActionPerformedThread7.setDaemon(runThreadsAsDaemons);
    outboundCallButtonActionPerformedThread7.start();
}

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

/**
 * @author wxy pdf/* w  w w.ja 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//from w w  w .ja  v a  2  s .c  o  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 www  .  ja  v  a2  s  .com*/
 * 
 * @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//from w w w.ja v a 2  s . com
 * 
 * @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);
}