Example usage for java.awt Font ROMAN_BASELINE

List of usage examples for java.awt Font ROMAN_BASELINE

Introduction

In this page you can find the example usage for java.awt Font ROMAN_BASELINE.

Prototype

int ROMAN_BASELINE

To view the source code for java.awt Font ROMAN_BASELINE.

Click Source Link

Document

The baseline used in most Roman scripts when laying out text.

Usage

From source file:com.ouc.cpss.view.EmpSaleChartBuilder.java

private static JFreeChart createJFreeChart(CategoryDataset dataset) {
    /**/*from   ww  w  .  j  a va2  s  .  c  om*/
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //?
    JFreeChart jfreeChart = ChartFactory.createBarChart3D("", "", "?", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    /**
     * JFreeChart
     */
    jfreeChart.setTitle(new TextTitle("", new Font("", Font.BOLD + Font.ITALIC, 20)));
    CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));

    return jfreeChart;
}

From source file:GUI.Main.java

static private WebPanel createAdminPanel(String url, String firstName, String lastName, final int myId)
        throws IOException {

    mainPanel.setPaintFocus(true);/*from  ww  w  .  j  a v  a2  s.  com*/

    // Text field input Search
    textSearchField = new WebTextField(15);
    textSearchField.setInputPrompt("Search");
    textSearchField.setInputPromptFont(textSearchField.getFont().deriveFont(Font.ROMAN_BASELINE));
    textSearchField.setTrailingComponent(new WebImage("resources/search.png"));
    System.out.println("My id" + myId);
    // Boite Message
    WebButton boiteMessageButton = new WebButton("Ouvrir ma Boite Message");
    boiteMessageButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFrame boiteFrame = new JFrame("Boite de messages");
            boiteFrame.setLocationRelativeTo(null);
            JPanel boite = new JPanel(new BorderLayout());
            boite.add(new BoiteReception(myId), BorderLayout.CENTER);
            boiteFrame.add(boite);
            boiteFrame.setIconImage(new ImageIcon(getClass().getResource("/images/message.png")).getImage());
            boiteFrame.pack();
            boiteFrame.setLocationRelativeTo(boite);
            boiteFrame.setVisible(true);
        }
    });
    // Text Button Search
    WebButton SearchButton = new WebButton("Search");
    SearchButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {

                new ListOfOffres1().openListOfOffresFrameagn(1, textSearchField.getText(), myId);
            } catch (IOException ex) {
                Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    // Exit Button 
    WebButton logOutButton = new WebButton("Exit");
    logOutButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ListOfOffresFrame.setVisible(false); //you can't see me!
            ListOfOffresFrame.dispose(); //Destroy the JFrame object
            ListOfOffresFrame = null;
            System.exit(0);
        }
    });
    // Text Button Retour
    exitButton = new WebButton("Retour");

    exitButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Retour clicked");
            ListOfOffres1.openPleaseWait();
            try {
                System.out.println("aaaaaaaaaaaaaaaaaaaaaaaa" + myId);
                new ListOfOffres1().openListOfOffresFrameagn(0, "", myId);
            } catch (IOException ex) {
                Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    });
    final WebPanel descPanel = new WebPanel(false);

    GroupPanel OffrePanel = new GroupPanel(GroupingType.fillFirst, 5, false);

    descPanel.setOpaque(false);
    descPanel.setMargin(50, 50, 50, 50);
    mainPanel.setPaintFocus(true);
    mainPanel.setMargin(10);
    System.out.print(url);
    // load the image once

    mainPanel.setPreferredSize(new Dimension(300, 100));
    OffrePanel.add(new GroupPanel(GroupingType.fillFirst, 5, false, loadImageX(url),
            new WebLabel("<html><body><h1><font color=#555555>" + firstName + " " + lastName
                    + "</font></h1></body></html>", WebLabel.CENTER),
            textSearchField, SearchButton, new WhiteSpace(),
            new GroupPanel(GroupingType.fillFirst, false, new WhiteSpace(), boiteMessageButton,
                    new GroupPanel(GroupingType.fillFirstAndLast, 5, true, exitButton, logOutButton))));
    mainPanel.add(OffrePanel);
    return mainPanel;
}

From source file:com.baidu.rigel.biplatform.ma.auth.resource.RandomValidateCode.java

/**
 * /* w w  w . j  ava  2 s .co m*/
 * @param request
 * @param response
 * @param cacheManagerForResource 
 */
public static void getRandcode(HttpServletRequest request, HttpServletResponse response,
        CacheManagerForResource cacheManagerForResource) {
    // BufferedImageImage,Image????
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
    Graphics g = image.getGraphics(); // ImageGraphics,?????
    g.fillRect(0, 0, width, height);
    g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));
    g.setColor(getRandColor(110, 133));
    // 
    for (int i = 0; i <= lineSize; i++) {
        drowLine(g);
    }
    // ?
    String randomString = "";
    for (int i = 1; i <= stringNum; i++) {
        randomString = drowString(g, randomString, i);
    }
    String key = null;
    if (request.getCookies() != null) {
        for (Cookie tmp : request.getCookies()) {
            if (tmp.getName().equals(Constants.RANDOMCODEKEY)) {
                key = tmp.getName();
                cacheManagerForResource.removeFromCache(key);
                break;
            }
        }
    }
    if (StringUtils.isEmpty(key)) {
        key = String.valueOf(System.nanoTime());
    }
    cacheManagerForResource.setToCache(key, randomString);
    final Cookie cookie = new Cookie(Constants.RANDOMCODEKEY, key);
    cookie.setPath(Constants.COOKIE_PATH);
    response.addCookie(cookie);
    g.dispose();
    try {
        ImageIO.write(image, "JPEG", response.getOutputStream()); // ??
    } catch (Exception e) {
        LOG.info(e.getMessage());
    }
}

From source file:com.ouc.cpss.view.ChartProBuilder.java

private static JFreeChart createJFreeChart(CategoryDataset dataset) {
    /**/*from   w w  w. j av a 2  s. com*/
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //?
    // ?
    JFreeChart jfreeChart = null;
    if (choice == 1) {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        /**
          * JFreeChart
          */
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    } else {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    }
    return jfreeChart;
}

From source file:Panels.LocationPanel.java

public LocationPanel() throws IOException, ParserConfigurationException, SAXException {//create LocationPanel object and set parameters

    this.locationfromInternetIcon = new ImageIcon(getClass().getResource(locationInternetIconSetting));//location from internet label icon
    this.loaderIcon = new ImageIcon(getClass().getResource(loaderSettingsPath));
    this.setLayout(null);
    this.setVisible(true);
    this.setSize(400, 340);
    this.color = Color.WHITE;
    this.setOpaque(false);

    this.locationFromInternet = new JLabel();
    this.countriesLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1049));
    this.citiesLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1050));
    this.longitudeLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1051));
    this.latitudeLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1052));
    this.timezoneLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1053));
    this.longitudeValue = new JLabel();
    this.latitudeValue = new JLabel();
    this.timezoneValue = new JLabel();
    this.getLocationFromInternet = new JLabel(PropertiesHandler.getSingleton().getValue(1105));
    this.getLocationFromInternet.setFont(new Font("TimesRoman", Font.ROMAN_BASELINE, 13));
    this.applyButton = new JButton(PropertiesHandler.getSingleton().getValue(1054));
    this.applyButton.setEnabled(false);
    this.applyButton.addActionListener(new ActionListener() {

        @Override// www.  jav  a 2s  .  com
        public void actionPerformed(ActionEvent e) {//Applay button click handler
            try {
                applyButtonListener(e);
            } catch (Exception e1) {
                try {
                    JOptionPane.showMessageDialog(null, PropertiesHandler.getSingleton().getValue(1070),
                            PropertiesHandler.getSingleton().getValue(1069), JOptionPane.ERROR_MESSAGE);
                } catch (Exception e2) {
                }
            }
        }
    });

    if (UserConfig.getSingleton().getLanguage().equalsIgnoreCase(ar)) {
        this.getLocationFromInternet.setBounds(50, 20, 280, 20);
        this.locationFromInternet.setBounds(10, 10, 30, 30);
    } else if (UserConfig.getSingleton().getLanguage().equalsIgnoreCase(eng)) {
        this.getLocationFromInternet.setBounds(10, 20, 280, 20);
        this.locationFromInternet.setBounds(280, 10, 30, 30);
    } else {
        this.getLocationFromInternet.setBounds(10, 20, 280, 20);
        this.locationFromInternet.setBounds(250, 10, 30, 30);
    }

    this.locationFromInternet.setIcon(locationfromInternetIcon);
    this.locationFromInternet.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if (locationFromInternet.isEnabled()) {
                        locationFromInternet.setEnabled(false);
                        locationFromInternet.setIcon(loaderIcon);
                        locationFromInternetLabelMouseClicked(e);
                    }
                }
            }).start();
        }
    });

    this.countriesLabel.setForeground(color);
    this.citiesLabel.setForeground(color);
    this.longitudeLabel.setForeground(color);
    this.latitudeLabel.setForeground(color);
    this.timezoneLabel.setForeground(color);
    this.longitudeValue.setForeground(color);
    this.latitudeValue.setForeground(color);
    this.timezoneValue.setForeground(color);
    this.getLocationFromInternet.setForeground(color);

    this.countriesLabel.setBounds(5, 50, 100, 25);
    this.citiesLabel.setBounds(195, 50, 100, 25);

    this.longitudeLabel.setBounds(10, 240, 120, 30);
    this.latitudeLabel.setBounds(140, 240, 120, 30);
    this.timezoneLabel.setBounds(260, 240, 120, 30);
    this.longitudeValue.setBounds(20, 265, 120, 30);
    this.latitudeValue.setBounds(150, 265, 120, 30);
    this.timezoneValue.setBounds(270, 265, 60, 30);
    this.applyButton.setBounds(125, 300, 150, 30);

    this.countriesModel = new DefaultListModel();
    this.citiesModel = new DefaultListModel();

    this.countriesList = new JList();
    this.countriesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.countriesList.setSelectedIndex(0);

    this.countriesList.setSelectionBackground(Color.GRAY);
    this.countriesList.setSelectionForeground(Color.WHITE);

    this.citiesList = new JList();
    this.citiesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.citiesList.setSelectedIndex(0);

    this.citiesList.setSelectionBackground(Color.GRAY);
    this.citiesList.setSelectionForeground(Color.WHITE);

    this.countriesList.setModel(countriesModel);
    this.citiesList.setModel(citiesModel);

    this.arrayCountries = new ArrayList<Country>();
    this.arrayCountries = XmlHandler.getSingleton().getAllCountries();//get all countries names from country xml file 
    this.arrayCities = new ArrayList<City>();
    this.arrayCities = XmlHandler.getSingleton().getAllCities(arrayCountries.get(0).getName());//get all cities for first country from xml file

    for (Country country : arrayCountries) {
        countriesModel.addElement(country.getName());//set all countries names to countries model
    }

    this.countriesList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!country.equalsIgnoreCase("") && countriesList.getSelectedIndex() == 0) {

            } else {
                citiesModel.clear();
                try {
                    arrayCities2 = XmlHandler.getSingleton()
                            .getAllCities((String) countriesList.getSelectedValue());
                } catch (Exception e1) {
                    try {
                        JOptionPane.showMessageDialog(null, PropertiesHandler.getSingleton().getValue(1070),
                                PropertiesHandler.getSingleton().getValue(1069), JOptionPane.ERROR_MESSAGE);
                    } catch (Exception e2) {
                    }
                }
                for (City city : arrayCities2) {
                    citiesModel.addElement(city.getName());//set all cities names to cities model for selected country
                }
            }
        }
    });

    for (City city : arrayCities) {
        citiesModel.addElement(city.getName());//set all cities names to cities model
    }

    this.citiesList.addListSelectionListener(new ListSelectionListener() {//set longitude , latitude and time zone from selected city

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!city.equalsIgnoreCase("") && citiesList.getSelectedIndex() == 0) {
            } else {
                applyButton.setEnabled(true);
                if (arrayCities2 != null && arrayCities2.size() >= 1) {
                    if (citiesList != null && citiesList.getSelectedIndex() >= 0) {
                        City city = arrayCities2.get(citiesList.getSelectedIndex());
                        longitudeValue.setText(String.valueOf(Double.valueOf(city.getLongitude()) / 10000));
                        latitudeValue.setText(String.valueOf(Double.valueOf(city.getLatitude()) / 10000));
                        timezoneValue.setText(String.valueOf(Double.valueOf(city.getTimezone()) / 100));
                    }
                }
            }
        }
    });

    //set longitude , latitude and time zone values to labels from selected city
    this.longitudeValue.setText(String.valueOf(Double.valueOf(arrayCities.get(0).getLongitude()) / 10000));
    this.latitudeValue.setText(String.valueOf(Double.valueOf(arrayCities.get(0).getLatitude()) / 10000));
    this.timezoneValue.setText(String.valueOf(Double.valueOf(arrayCities.get(0).getTimezone()) / 100));

    this.countriesListScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.countriesListScrollPane.setViewportView(countriesList);
    this.countriesListScrollPane.setBounds(5, 80, 180, 150);

    this.citiesListScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.citiesListScrollPane.setViewportView(citiesList);
    this.citiesListScrollPane.setBounds(195, 80, 180, 150);

    this.add(countriesLabel);
    this.add(citiesLabel);
    this.add(countriesListScrollPane);
    this.add(citiesListScrollPane);
    this.add(longitudeLabel);
    this.add(longitudeValue);
    this.add(latitudeLabel);
    this.add(latitudeValue);
    this.add(timezoneLabel);
    this.add(timezoneValue);
    this.add(applyButton);
    this.add(locationFromInternet);
    this.add(getLocationFromInternet);

    this.setVisible(true);
}

From source file:MainProgram.MainProgram.java

private void initComponents() throws InterruptedException {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    welcomeMessage = new JLabel();
    welcomeMessage2 = new JLabel();
    pennIDLabel = new JLabel();
    pennIDTextField = new JTextField();
    pennPassLabel = new JLabel();
    pennPassField = new JPasswordField();
    emailLabel = new JLabel();
    emailTextField = new JTextField();
    emailDomainLabel = new JLabel();
    emailPassLabel = new JLabel();
    emailPassField = new JPasswordField();
    semesterLabel = new JLabel();
    semesterComboBox = new JComboBox(semestersString);
    credentials = new JLabel();
    dropLabel = new JLabel();
    dropCheckBox = new JCheckBox();
    button = new JButton();
    stopWatchLabel = new JLabel();
    checkMail = false;/*from ww  w. j a  v  a 2 s  . c om*/
    testConnection = false;

    mailCheckTimeInitializer();
    StopWatchInitializer();
    try {
        setUIFont(new javax.swing.plaf.FontUIResource("Segoe UI", Font.ROMAN_BASELINE, 12));
    } catch (Exception e) {
        e.printStackTrace(MainProgram.errorLog);
    }

    String lcOSName = System.getProperty("os.name").toLowerCase();
    boolean IS_MAC = lcOSName.startsWith("mac os x");
    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 81, 5, 119, 5, 0, 0 };
    if (!IS_MAC) {
        ((GridBagLayout) getLayout()).rowHeights = new int[] { 17, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0, 0,
                0 };
    }
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;

    //---- welcomeMessage ----
    welcomeMessage.setText("Course Registration");
    welcomeMessage.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- welcomeMessage2 ----
    welcomeMessage2.setText("for Penn State (BETA)");
    welcomeMessage2.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDLabel ----
    pennIDLabel.setText("Penn State ID: ");
    pennIDLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennIDLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDTextField ----
    pennIDTextField.setText("xxx123");
    add(pennIDTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennPassLabel ----
    pennPassLabel.setText("Penn State Password: ");
    pennPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennPassLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(pennPassField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailLabel ----
    emailLabel.setText("Email: ");
    emailLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailTextField ----
    emailTextField.setText("myEmail");
    add(emailTextField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailDomainLabel ----
    emailDomainLabel.setText("@mail.com");
    add(emailDomainLabel, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailPassLabel ----
    emailPassLabel.setText("Email Password: ");
    emailPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailPassLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(emailPassField, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester label ----
    semesterLabel.setText("Semester/Drop Option: ");
    semesterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(semesterLabel, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester ComboBox ----
    add(semesterComboBox, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Drop CheckBox ----
    add(dropCheckBox, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- button ----
    button.setText("Start");
    add(button, new GridBagConstraints(1, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- stopWatchLabel ----
    stopWatchLabel.setText("  " + stopWatchSplitting[0]);
    stopWatchLabel.setHorizontalAlignment(SwingConstants.LEFT);
    add(stopWatchLabel, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- label11 ----
    credentials.setText(" Created by Daniyar Yeralin");
    credentials.setForeground(Color.gray);
    credentials.setHorizontalAlignment(SwingConstants.RIGHT);
    credentials.setFont(new Font("Cambria", Font.ITALIC, 12));
    add(credentials, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    /*button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
     JComponent.WHEN_FOCUSED);
            
     button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true),
     JComponent.WHEN_FOCUSED);*/
    StartButtonHandler buttonListener = new StartButtonHandler();
    button.addActionListener(buttonListener);

}

From source file:Classes.MainForm.java

private void initMainForm() throws IOException {//create sally form
    switch (getPrayerTimesHandler().getActualPrayerTime()) {//set background
    case 0://  w  w  w.  j a v a  2 s . c  o  m
        this.backgroundImage = new ImageIcon(getClass().getResource(duhrBackground)).getImage();
        break;
    case 1:
        this.backgroundImage = new ImageIcon(getClass().getResource(shorou9Background)).getImage();
        break;
    case 2:
        this.backgroundImage = new ImageIcon(getClass().getResource(fajrBackground)).getImage();
        break;
    case 3:
        this.backgroundImage = new ImageIcon(getClass().getResource(ishaaBackground)).getImage();
        break;
    case 4:
        this.backgroundImage = new ImageIcon(getClass().getResource(maghribBackground)).getImage();
        break;
    case 5:
        this.backgroundImage = new ImageIcon(getClass().getResource(asrBackground)).getImage();
        break;
    default:
        this.backgroundImage = new ImageIcon(getClass().getResource(shorou9Background)).getImage();
        break;
    }
    this.mainFrame = new JFrame();
    this.mainPanel = new MainImagePanel(getBackgroundImage(), prayerTimesHandler.getActualPrayerTime());
    this.mainPanel.setLayout(null);
    this.font = new Font("TimesRoman", Font.ITALIC, 15);
    this.locationFont = new Font("TimesRoman", Font.ITALIC, 22);
    this.digitalClockfont = new Font("TimesRoman", Font.ROMAN_BASELINE, 20);
    this.fontMiladiHijriTimes = new Font("TimesRoman", Font.ROMAN_BASELINE, 13);
    this.fontNextPrayer = new Font("TimesRoman", Font.ROMAN_BASELINE, 20);
    this.exitLabel = new JLabel();
    this.hijriTime = new JLabel("", SwingConstants.RIGHT);
    this.miladiTime = new JLabel();
    this.location = new JLabel(locationValue);
    this.location.setHorizontalAlignment(SwingConstants.CENTER);
    this.locationFromInternet = new JLabel();

    //get all translated salat names
    this.fajrName = new JLabel(PropertiesHandler.getSingleton().getValue(1020));
    this.fajrName.setHorizontalAlignment(SwingConstants.CENTER);
    this.fajrTime = new JLabel();
    this.fajrTime.setHorizontalAlignment(SwingConstants.CENTER);
    this.shorou9Name = new JLabel(PropertiesHandler.getSingleton().getValue(1021));
    this.shorou9Name.setHorizontalAlignment(SwingConstants.CENTER);
    this.shorou9Time = new JLabel();
    this.shorou9Time.setHorizontalAlignment(SwingConstants.CENTER);
    this.duhrName = new JLabel(PropertiesHandler.getSingleton().getValue(1022));
    this.duhrName.setHorizontalAlignment(SwingConstants.CENTER);
    this.duhrTime = new JLabel();
    this.duhrTime.setHorizontalAlignment(SwingConstants.CENTER);
    this.asrName = new JLabel(PropertiesHandler.getSingleton().getValue(1023));
    this.asrName.setHorizontalAlignment(SwingConstants.CENTER);
    this.asrTime = new JLabel();
    this.asrTime.setHorizontalAlignment(SwingConstants.CENTER);
    this.maghribName = new JLabel(PropertiesHandler.getSingleton().getValue(1024));
    this.maghribName.setHorizontalAlignment(SwingConstants.CENTER);
    this.maghribTime = new JLabel();
    this.maghribTime.setHorizontalAlignment(SwingConstants.CENTER);
    this.ishaaName = new JLabel(PropertiesHandler.getSingleton().getValue(1025));
    this.ishaaName.setHorizontalAlignment(SwingConstants.CENTER);
    this.ishaaTime = new JLabel();
    this.ishaaTime.setHorizontalAlignment(SwingConstants.CENTER);

    this.digitalClock = new JLabel();
    this.nextPrayer = new JLabel();

    this.settings = new JLabel();

    this.exitLabel.setIcon(exitIcon);
    this.settings.setIcon(settingsIcon);
    this.locationFromInternet.setIcon(locationfromInternetIconMain);

    this.nextDayPrayerTimes = new JLabel(new ImageIcon(getClass().getResource(nextDayPrayerTimesIcon)));
    this.previousDayPrayerTimes = new JLabel(new ImageIcon(getClass().getResource(previousDayPrayerTimesIcon)));
    this.actualDayPrayerTimes = new JLabel(new ImageIcon(getClass().getResource(actualDayPrayerTimesIcon)));

    this.previousDayPrayerTimes.setBounds(480, 275, 15, 15);
    this.actualDayPrayerTimes.setBounds(500, 275, 15, 15);
    this.nextDayPrayerTimes.setBounds(520, 275, 15, 15);

    this.nextDayPrayerTimes.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            nextPreviousDay++;
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, nextPreviousDay);
            try {
                PrayersTimes prayerTimes = new PrayersTimes(cal);
                MiladiTime miladiTime = new MiladiTime(cal);
                HijriTime hijriTime = new HijriTime(cal);
                setAllLabelsTimesHijriMiladiValues2(prayerTimes, hijriTime, miladiTime);
            } catch (IOException e1) {
            }
        }
    });
    this.previousDayPrayerTimes.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            nextPreviousDay--;
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, nextPreviousDay);
            try {
                PrayersTimes prayerTimes = new PrayersTimes(cal);
                MiladiTime miladiTime = new MiladiTime(cal);
                HijriTime hijriTime = new HijriTime(cal);
                setAllLabelsTimesHijriMiladiValues2(prayerTimes, hijriTime, miladiTime);
            } catch (IOException e1) {
            }
        }
    });
    this.actualDayPrayerTimes.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                nextPreviousDay = 0;
                setAllLabelsTimesHijriMiladiValues(prayersTimes, hijriTimeObj, miladiTimeObj);
            } catch (IOException e1) {
            } //set all values to all labels
        }
    });

    //set foreground color to all salat names and times
    this.duhrName.setForeground(Color.WHITE);
    this.shorou9Name.setForeground(Color.WHITE);
    this.fajrName.setForeground(Color.WHITE);
    this.ishaaName.setForeground(Color.WHITE);
    this.maghribName.setForeground(Color.WHITE);
    this.asrName.setForeground(Color.WHITE);

    this.duhrTime.setForeground(Color.WHITE);
    this.shorou9Time.setForeground(Color.WHITE);
    this.fajrTime.setForeground(Color.WHITE);
    this.ishaaTime.setForeground(Color.WHITE);
    this.maghribTime.setForeground(Color.WHITE);
    this.asrTime.setForeground(Color.WHITE);
    this.miladiTime.setForeground(Color.WHITE);
    this.hijriTime.setForeground(Color.WHITE);
    this.location.setForeground(Color.WHITE);
    this.digitalClock.setForeground(Color.WHITE);
    this.nextPrayer.setForeground(Color.WHITE);

    //set font to all salat names and times
    this.duhrName.setFont(font);
    this.shorou9Name.setFont(font);
    this.fajrName.setFont(font);
    this.ishaaName.setFont(font);
    this.maghribName.setFont(font);
    this.asrName.setFont(font);
    this.duhrTime.setFont(font);
    this.shorou9Time.setFont(font);
    this.fajrTime.setFont(font);
    this.ishaaTime.setFont(font);
    this.maghribTime.setFont(font);
    this.asrTime.setFont(font);
    this.digitalClock.setFont(digitalClockfont);
    this.nextPrayer.setFont(fontNextPrayer);
    this.miladiTime.setFont(fontMiladiHijriTimes);
    this.hijriTime.setFont(fontMiladiHijriTimes);
    this.location.setFont(locationFont);

    //set position color to all salat names and times
    this.exitLabel.setBounds(510, 0, 40, 40);
    if (UserConfig.getSingleton().getLanguage().equalsIgnoreCase(ar)) {
        this.hijriTime.setBounds(100, 3, 250, 20);
        this.miladiTime.setBounds(20, 3, 250, 20);
    } else {
        this.hijriTime.setBounds(150, 3, 250, 20);
        this.miladiTime.setBounds(5, 3, 250, 20);
    }
    this.location.setBounds(0, 40, 550, 30);

    this.donateLabel = new JLabel(PropertiesHandler.getSingleton().getValue(1106));
    this.donateLabel.setFont(fontMiladiHijriTimes);
    this.donateLabel.setBounds(420, 3, 50, 20);
    this.donateLabel.setForeground(Color.WHITE);
    this.donateLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            String url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FJDAFTPKN2S2W";
            String os = System.getProperty("os.name").toLowerCase();
            Runtime rt = Runtime.getRuntime();

            try {

                if (os.indexOf("win") >= 0) {

                    // this doesn't support showing urls in the form of "page.html#nameLink" 
                    rt.exec("rundll32 url.dll,FileProtocolHandler " + url);

                } else if (os.indexOf("mac") >= 0) {

                    rt.exec("open " + url);

                } else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) {

                    // Do a best guess on unix until we get a platform independent way
                    // Build a list of browsers to try, in this order.
                    String[] browsers = { "epiphany", "firefox", "mozilla", "konqueror", "netscape", "opera",
                            "links", "lynx" };

                    // Build a command string which looks like "browser1 "url" || browser2 "url" ||..."
                    StringBuffer cmd = new StringBuffer();
                    for (int i = 0; i < browsers.length; i++)
                        cmd.append((i == 0 ? "" : " || ") + browsers[i] + " \"" + url + "\" ");

                    rt.exec(new String[] { "sh", "-c", cmd.toString() });

                } else {
                }
            } catch (Exception ex) {
            }
        }
    });

    this.locationFromInternet.setBounds(260, 70, 20, 20);
    this.locationFromInternet.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    if (locationFromInternet.isEnabled()) {
                        locationFromInternet.setEnabled(false);
                        locationFromInternet.setIcon(loaderMain);
                        locationFromInternetLabelMouseClicked(e);
                    }
                }
            }).start();
        }
    });

    this.fajrAthan = new JLabel();
    this.fajrAthan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(0);
            } catch (Exception e1) {
            }
        }
    });
    this.shorou9Athan = new JLabel();
    this.shorou9Athan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(1);
            } catch (Exception e1) {
            }
        }
    });
    this.duhrAthan = new JLabel();
    this.duhrAthan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(2);
            } catch (Exception e1) {
            }
        }
    });
    this.asrAthan = new JLabel();
    this.asrAthan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(3);
            } catch (Exception e1) {
            }
        }
    });
    this.maghribAthan = new JLabel();
    this.maghribAthan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(4);
            } catch (Exception e1) {
            }
        }
    });
    this.ishaaAthan = new JLabel();
    this.ishaaAthan.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                allAthanClickHandler(5);
            } catch (Exception e1) {
            }
        }
    });

    this.duhrAthan.setBounds(152, 132, 28, 28);
    this.shorou9Athan.setBounds(322, 132, 28, 28);
    this.fajrAthan.setBounds(492, 132, 28, 28);
    this.ishaaAthan.setBounds(152, 212, 28, 28);
    this.maghribAthan.setBounds(322, 212, 28, 28);
    this.asrAthan.setBounds(492, 212, 28, 28);

    setAllAthanIcons();

    this.duhrName.setBounds(30, 100, 150, 30);
    this.duhrTime.setBounds(30, 130, 150, 30);
    this.shorou9Name.setBounds(200, 100, 150, 30);
    this.shorou9Time.setBounds(200, 130, 150, 30);
    this.fajrName.setBounds(370, 100, 150, 30);
    this.fajrTime.setBounds(370, 130, 150, 30);

    this.ishaaName.setBounds(30, 180, 150, 30);
    this.ishaaTime.setBounds(30, 210, 150, 30);
    this.maghribName.setBounds(200, 180, 150, 30);
    this.maghribTime.setBounds(200, 210, 150, 30);
    this.asrName.setBounds(370, 180, 150, 30);
    this.asrTime.setBounds(370, 210, 150, 30);

    this.digitalClock.setBounds(10, 250, 200, 50);
    this.nextPrayer.setBounds(150, 262, 350, 30);

    this.settings.setBounds(470, 0, 40, 40);
    this.settings.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            settingsLabelMouseClicked(e);
        }
    });

    this.exitLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            exitLabelMouseClicked(e);
        }
    });
    this.mainFrame.addMouseMotionListener(new MouseAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            mainFrameMouseDragged(e);
        }
    });
    this.mainFrame.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            mainFrameMousePressed(e);
        }
    });
    this.mainFrame.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            mainFrameMouseReleased(e);
        }
    });

    this.mainFrame.setSize(550, 300);
    this.mainFrame.setLocationRelativeTo(null);
    this.mainFrame.setUndecorated(true);
    this.mainFrame.setResizable(false);

    //adding all labels objects to main panel
    this.mainPanel.add(exitLabel);
    this.mainPanel.add(hijriTime);
    this.mainPanel.add(miladiTime);
    this.mainPanel.add(location);
    this.mainPanel.add(locationFromInternet);

    this.mainPanel.add(duhrName);
    this.mainPanel.add(duhrTime);
    this.mainPanel.add(shorou9Name);
    this.mainPanel.add(shorou9Time);
    this.mainPanel.add(fajrName);
    this.mainPanel.add(fajrTime);
    this.mainPanel.add(ishaaName);
    this.mainPanel.add(ishaaTime);
    this.mainPanel.add(maghribName);
    this.mainPanel.add(maghribTime);
    this.mainPanel.add(asrName);
    this.mainPanel.add(asrTime);
    this.mainPanel.add(digitalClock);
    this.mainPanel.add(nextPrayer);
    this.mainPanel.add(settings);
    this.mainPanel.add(donateLabel);

    this.mainPanel.add(fajrAthan);
    this.mainPanel.add(shorou9Athan);
    this.mainPanel.add(duhrAthan);
    this.mainPanel.add(asrAthan);
    this.mainPanel.add(maghribAthan);
    this.mainPanel.add(ishaaAthan);

    this.mainPanel.add(nextDayPrayerTimes);
    this.mainPanel.add(previousDayPrayerTimes);
    this.mainPanel.add(actualDayPrayerTimes);

    this.mainFrame.add(mainPanel);
    this.pack();

    trayConfig();//create try icon

    this.setAllLabelsTimesHijriMiladiValues(prayersTimes, hijriTimeObj, miladiTimeObj);//set all values to all labels
    this.prayerTimesHandler.start();//start prayer times handler thread
}

From source file:unalcol.termites.boxplots.SucessfulRatesGlobal.java

private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18));
    jfreechart.setBackgroundPaint(new Color(221, 223, 238));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    BarRenderer renderer = (BarRenderer) categoryplot.getRenderer();
    //categoryplot.setBackgroundPaint(new Color(221, 223, 238));

    renderer.setSeriesPaint(0, new Color(130, 165, 70));
    renderer.setSeriesPaint(1, new Color(220, 165, 70));
    renderer.setSeriesPaint(4, new Color(255, 165, 70));
    renderer.setDrawBarOutline(false);//  www  .  j av a2  s  .c om
    renderer.setShadowVisible(false);
    // renderer.setMaximumBarWidth(1);
    renderer.setGradientPaintTransformer(null);
    renderer.setDefaultBarPainter(new StandardBarPainter());

    categoryplot.setRenderer(renderer);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.25D);
    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    categoryitemrenderer.setBaseItemLabelsVisible(true);
    categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null));
    numberaxis.setRange(0, 100);
    //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());

    Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12);
    numberaxis.setTickLabelFont(font);
    CategoryAxis axisd = categoryplot.getDomainAxis();
    ValueAxis axisr = categoryplot.getRangeAxis();
    axisd.setTickLabelFont(font);
    axisr.setTickLabelFont(font);

    final ChartPanel chartPanel = new ChartPanel(jfreechart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));

    FileOutputStream output;
    try {
        output = new FileOutputStream("successGlobalRates" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 650, 370, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jfreechart;
}

From source file:unalcol.termites.boxplots.SucessfulRatesHybrid.java

private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18));
    jfreechart.setBackgroundPaint(new Color(221, 223, 238));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    BarRenderer renderer = (BarRenderer) categoryplot.getRenderer();
    //categoryplot.setBackgroundPaint(new Color(221, 223, 238));

    renderer.setSeriesPaint(0, new Color(130, 165, 70));
    renderer.setSeriesPaint(1, new Color(220, 165, 70));
    renderer.setSeriesPaint(4, new Color(255, 165, 70));
    renderer.setDrawBarOutline(false);/*  ww  w.ja va2 s . c o m*/
    renderer.setShadowVisible(false);
    // renderer.setMaximumBarWidth(1);
    renderer.setGradientPaintTransformer(null);
    renderer.setDefaultBarPainter(new StandardBarPainter());

    categoryplot.setRenderer(renderer);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.25D);
    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    categoryitemrenderer.setBaseItemLabelsVisible(true);
    categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null));
    numberaxis.setRange(0, 100);
    //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());

    Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12);
    numberaxis.setTickLabelFont(font);
    CategoryAxis axisd = categoryplot.getDomainAxis();
    ValueAxis axisr = categoryplot.getRangeAxis();
    axisd.setTickLabelFont(font);
    axisr.setTickLabelFont(font);

    axisd.setMaximumCategoryLabelLines(5);

    final ChartPanel chartPanel = new ChartPanel(jfreechart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1300, 370));

    FileOutputStream output;
    try {
        output = new FileOutputStream("sucessrates1" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 1300, 370, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jfreechart;
}

From source file:unalcol.termites.boxplots.SucessfulRates.java

private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18));
    jfreechart.setBackgroundPaint(new Color(221, 223, 238));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    BarRenderer renderer = (BarRenderer) categoryplot.getRenderer();
    //categoryplot.setBackgroundPaint(new Color(221, 223, 238));

    renderer.setSeriesPaint(0, new Color(130, 165, 70));
    renderer.setSeriesPaint(1, new Color(220, 165, 70));
    renderer.setSeriesPaint(4, new Color(255, 165, 70));
    renderer.setDrawBarOutline(false);/*from   w w  w  . j a  v  a2s  .c  o m*/
    renderer.setShadowVisible(false);
    // renderer.setMaximumBarWidth(1);
    renderer.setGradientPaintTransformer(null);
    renderer.setDefaultBarPainter(new StandardBarPainter());

    categoryplot.setRenderer(renderer);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.25D);
    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    categoryitemrenderer.setBaseItemLabelsVisible(true);
    categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null));
    numberaxis.setRange(0, 100);
    //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());

    Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12);
    numberaxis.setTickLabelFont(font);
    CategoryAxis axisd = categoryplot.getDomainAxis();
    ValueAxis axisr = categoryplot.getRangeAxis();
    axisd.setTickLabelFont(font);
    axisr.setTickLabelFont(font);

    final ChartPanel chartPanel = new ChartPanel(jfreechart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));

    FileOutputStream output;
    try {
        output = new FileOutputStream("sucessrates1" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 650, 370, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jfreechart;
}