Example usage for java.awt Font BOLD

List of usage examples for java.awt Font BOLD

Introduction

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

Prototype

int BOLD

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

Click Source Link

Document

The bold style constant.

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.XyLineChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from   www  .jav  a2s. co  m*/

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass());
    Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible());
    Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationChart.java

private TextTitle getTitle(final DiagView template) {
    final TitleFormat format = template.getTitleFormat();

    final int size = format.getFontSize();
    final FontWeight weight = format.getFontWeight();

    Font font = null;/*w  w w  .j av  a 2 s  .com*/
    if (FontWeight.BOLD.equals(weight))
        font = new Font(format.getFontFamily(), Font.BOLD, size);
    else if (FontWeight.NORMAL.equals(weight))
        font = new Font(format.getFontFamily(), Font.PLAIN, size);
    else if (FontWeight.ITALIC.equals(weight))
        font = new Font(format.getFontFamily(), Font.ITALIC, size);

    final Alignment alignment = format.getAlignment();
    if (Alignment.CENTER.equals(alignment))
        return new TextTitle(template.getTitle(), font, HorizontalAlignment.CENTER);
    else if (Alignment.LEFT.equals(alignment))
        return new TextTitle(template.getTitle(), font, HorizontalAlignment.LEFT);
    else if (Alignment.RIGHT.equals(alignment))
        return new TextTitle(template.getTitle(), font, HorizontalAlignment.RIGHT);

    return new TextTitle(template.getTitle(), font, HorizontalAlignment.CENTER);
}

From source file:edu.ucla.stat.SOCR.analyses.jri.gui.SimpleLinearRegression.java

/**Initialize the Analysis*/
public void init() {
    super.init();

    analysisType = AnalysisType.SIMPLE_LINEAR_REGRESSION;
    ////////System.out.println("SLR analysisType = " + analysisType);
    useInputExample = false;// w ww.java  2 s  .c  o  m
    useLocalExample = false;
    useRandomExample = true;
    useServerExample = false;
    useStaticExample = true;
    useGraph = true;
    callServer = true;

    onlineDescription = "http://mathworld.wolfram.com/LinearRegression.html";
    depMax = 1; // max number of dependent var
    indMax = 1; // max number of independent var
    resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize));
    frame = getFrame(this);
    setName("Regression & Correlation Analysis");
    // Create the toolBar
    toolBar = new JToolBar();
    createActionComponents(toolBar);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    chartFactory = new Chart();
    resetGraph();
    validate();
    //      reset();
}

From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java

@Override
public JComponent getMainFrame() {
    jpMainPanel = new JPanel(new GridBagLayout());
    jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2),
            BorderFactory.createEmptyBorder()));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;// w w w. ja v a2s.  c  o  m

    // --- XPath Expression ---

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    JLabel jlXPathExpression = new JLabel("XPath Expression:");
    jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
    jpMainPanel.add(jlXPathExpression, c);

    c.gridx++;
    c.weightx = 1.0;
    tfXPathExpression = new JTextField();
    tfXPathExpression.setEditable(false);
    jpMainPanel.add(tfXPathExpression, c);

    // --- Label to Show/Hide Mapping Table ---

    final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
    jlShowHideNamespaceMappings.setForeground(Color.BLUE);
    jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
            jlShowHideNamespaceMappings.setText(
                    (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings...");
            thisContextualView.revalidate();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jpMainPanel.add(jlShowHideNamespaceMappings, c);

    // --- Namespace Mapping Table ---

    xpathNamespaceMappingsTableModel = new DefaultTableModel() {
        /**
         * No cells should be editable
         */
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return (false);
        }
    };
    xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
    xpathNamespaceMappingsTableModel.addColumn("Namespace URI");

    jtXPathNamespaceMappings = new JTable();
    jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
    jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
    // TODO - next line is to be enabled when Taverna is migrated to Java
    // 1.6; for now it's fine to run without this
    // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
    // that when the dedicated area is larger than the table, the latter is
    // stretched vertically to fill the empty space

    jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
    // relative
    // sizes of
    // columns
    jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);

    c.gridy++;
    spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
    spXPathNamespaceMappings.setVisible(false);
    jpMainPanel.add(spXPathNamespaceMappings, c);

    // populate the view with values
    refreshView();

    return jpMainPanel;
}

From source file:com.xilinx.ultrascale.gui.BarCharts.java

License:asdf

private void makeChart(String name) {
    dataset = new DefaultCategoryDataset();
    //        chart = ChartFactory.createLineChart("", "", name, dataset, PlotOrientation.VERTICAL, true, true, false);
    //        chart = ChartFactory.createBarChart("asd", "asd", "asdffa", dataset, PlotOrientation.HORIZONTAL, true, true, false);

    chart = ChartFactory.createBarChart("power", "Time Interval", "Throughput (Gbps)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(bg);//from w ww.  ja v  a2  s  . com

    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.BLACK);
    chart.setTitle(ttitle);

    CategoryPlot plot = chart.getCategoryPlot();
    //        BarRenderer renderer = (BarRenderer)plot.getRenderer();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    ValueAxis axis = plot.getRangeAxis();
    upperBounds(65);

    axis.setTickLabelPaint(new Color(0, 0, 0));//(185, 185, 185)

    axis.setLabelPaint(new Color(0, 0, 0));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(0, 0, 0));
    caxis.setLabelPaint(new Color(0, 0, 0));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0x2e, 0x90, 0x18));//(0x17, 0x7b, 0x7c));
    renderer.setSeriesPaint(1, new Color(0x12, 0x45, 0x73));//(0xa2, 0x45, 0x73)
    renderer.setSeriesPaint(3, new Color(0xff, 0x80, 0x40));
    renderer.setSeriesPaint(2, new Color(0x6f, 0x2c, 0x85));
    //        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    //renderer.setMaximumBarWidth(0.05);
    addDummy();
}

From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java

private JTable getTable() {
    if (table == null) {
        model = new VideoPreferenceTableModel(loadPrefs());
        table = new JTable(model);
        table.setGridColor(Color.LIGHT_GRAY);
        table.setFocusable(false);/* w w w  .  j a va  2s.c  om*/
        table.setRowSelectionAllowed(false);
        table.setShowGrid(true);
        table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        table.getColumnModel().getColumn(0).setPreferredWidth(225);
        table.getColumnModel().getColumn(1).setPreferredWidth(50);
        table.getColumnModel().getColumn(2).setPreferredWidth(50);
        table.getModel().addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent e) {
                sError = model.getValidationError();
                if (!sError.toString().isEmpty()) {
                    compileResultsField.setVisible(true);
                    compileResultsField.setForeground(Color.red);
                    compileResultsField.setText(String.format("ERROR : %s", sError.toString()));
                } else {
                    compileResultsField.setText("");
                    compileResultsField.setVisible(false);
                }
            }
        });
    } else {
        model.setData(loadPrefs());
        table.setModel(model);
    }
    return table;
}

From source file:MenuDemo.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    JMenu menuFile = new JMenu("File");
    menuFile.setMnemonic('f');

    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setIcon(new ImageIcon("file_new.gif"));
    menuItem.setMnemonic('n');
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("New");
        }/*  w w  w.  j  av  a 2 s .  c om*/
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuItem = new JMenuItem("Open...");
    menuItem.setIcon(new ImageIcon("file_open.gif"));
    menuItem.setMnemonic('o');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MenuDemo.this.repaint();
            if (fileChooser.showOpenDialog(MenuDemo.this) != JFileChooser.APPROVE_OPTION)
                return;
            System.out.println(fileChooser.getSelectedFile());
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuItem = new JMenuItem("Save...");
    menuItem.setIcon(new ImageIcon("file_save.gif"));
    menuItem.setMnemonic('s');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Save...");
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuFile.addSeparator();

    menuItem = new JMenuItem("Exit");
    menuItem.setMnemonic('x');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);
    menuBar.add(menuFile);

    ActionListener fontListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateMonitor();
        }
    };

    JMenu mFont = new JMenu("Font");
    mFont.setMnemonic('o');

    ButtonGroup group = new ButtonGroup();
    menus = new JMenuItem[FontNames.length];
    for (int i = 0; i < FontNames.length; i++) {
        int m = i + 1;
        menus[i] = new JRadioButtonMenuItem(m + " " + FontNames[i]);
        boolean selected = (i == 0);
        menus[i].setSelected(selected);
        menus[i].setMnemonic('1' + i);
        menus[i].setFont(fontArray[i]);
        menus[i].addActionListener(fontListener);
        group.add(menus[i]);
        mFont.add(menus[i]);
    }

    mFont.addSeparator();

    boldMenuItem = new JCheckBoxMenuItem("Bold");
    boldMenuItem.setMnemonic('b');
    Font fn = fontArray[1].deriveFont(Font.BOLD);
    boldMenuItem.setFont(fn);
    boldMenuItem.setSelected(false);
    boldMenuItem.addActionListener(fontListener);
    mFont.add(boldMenuItem);

    italicMenuItem = new JCheckBoxMenuItem("Italic");
    italicMenuItem.setMnemonic('i');
    fn = fontArray[1].deriveFont(Font.ITALIC);
    italicMenuItem.setFont(fn);
    italicMenuItem.setSelected(false);
    italicMenuItem.addActionListener(fontListener);
    mFont.add(italicMenuItem);

    menuBar.add(mFont);

    return menuBar;
}

From source file:eu.cassandra.platform.gui.GUI.java

public GUI() {
    //redirectSystemStreams();
    a = new ListenInstallationComboBox();
    installationCombo.setPreferredSize(new Dimension(300, 20));

    startButton.addActionListener(new ListenStartButton());
    exitButton.addActionListener(new ListenExitButton());
    projectFileField.addMouseListener(new ListenProjectFileField());

    logTextAreaScrollPane.setPreferredSize(new Dimension(400, 500));

    projectFileField.setPreferredSize(new Dimension(600, 20));
    //      projectFileField.setText(new File(Params.SIM_PROPS).getAbsolutePath());
    projectFileField.setText("");
    projectFileField.setEditable(false);

    f.setJMenuBar(menuBar);/* ww  w .  java  2s  .c  o  m*/

    menuFile.add(menuItemQuit);
    menuHelp.add(menuItemAbout);
    menuBar.add(menuFile);
    menuBar.add(menuHelp);

    statsTextArea.setFont(new Font("Tahoma", Font.BOLD, 12));

    TimeSeries series = new TimeSeries("");
    dataset = new TimeSeriesCollection(series);
    JFreeChart chart = createChart("Consumption", dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    graphScrollPane = new JScrollPane(chartPanel);

    buttonPanel.add(projectFileField);
    buttonPanel.add(startButton);
    buttonPanel.add(holdButton);
    buttonPanel.add(installationCombo);
    buttonPanel.add(exitButton);

    statsTextArea.setText("Statistics:\n");
    logTextArea.setText("Logs:\n");

    JSplitPane textAreaSplitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    textAreaSplitPanel.setDividerLocation((int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2));
    textAreaSplitPanel.add(statsTextAreaScrollPane, JSplitPane.TOP);
    textAreaSplitPanel.add(logTextAreaScrollPane, JSplitPane.BOTTOM);

    JSplitPane mainSplitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    mainSplitPanel.add(graphScrollPane, JSplitPane.LEFT);
    mainSplitPanel.add(textAreaSplitPanel, JSplitPane.RIGHT);
    mainSplitPanel.setDividerLocation((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 1.5));

    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(mainSplitPanel, BorderLayout.CENTER);
    f.getContentPane().add(buttonScrollPane, BorderLayout.SOUTH);

    f.addWindowListener(new ListenCloseWdw());
    menuItemQuit.addActionListener(new ListenMenuQuit());
}

From source file:com.std.StockPanel.java

public void setHistoricalData() {
    this.setLayout(new BorderLayout());
    nameAndChangePanel.setLayout(new BoxLayout(nameAndChangePanel, BoxLayout.PAGE_AXIS));
    nameAndChangePanel.add(nameLbl);//from  ww  w  .  j a v  a 2s .  c o m
    nameAndChangePanel.add(priceChangePercentLbl);

    data = new Object[30][2];
    String[] colnames = { "1", "2" };

    GridBagConstraints c = new GridBagConstraints();
    dataAndGraph.setLayout(new GridBagLayout());
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0;
    c.gridheight = 1;
    c.insets = new Insets(0, 20, 0, 20);
    dataAndGraph.add(nameAndChangePanel, c);
    c.weightx = 0;
    c.weighty = 1;
    c.insets = new Insets(0, 20, 0, 0);
    //c.ipady = 20;
    c.gridx = 0;
    c.gridy = 1;
    remainingInfoTable = new StockTable(data, colnames);
    remainingInfoTable.setShowGrid(false);
    remainingInfoTable.setTableHeader(null);
    remainingInfoTable.setBackground(this.getBackground());
    remainingInfoTable.setFocusable(false);
    remainingInfoTable.setColumnSelectionAllowed(false);
    remainingInfoTable.setRowSelectionAllowed(false);
    remainingInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    dataAndGraph.add(remainingInfoTable, c);
    this.add(dataAndGraph, BorderLayout.CENTER);

    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0;
    c.gridheight = 2;
    //c.ipady = 20;
    c.gridx = 1;
    c.gridy = 0;
    dataAndGraph.add(chartPane, c);
    chartPane.setVisible(false);
    this.add(dataAndGraph, BorderLayout.CENTER);

    Test.show_hist_data(currentStock, b);
    currentStock.calculate_beta(sp500, 1200);

    nameLbl.setText(currentStock.get_name() + " (" + currentStock.get_symbol() + ")");
    nameLbl.setFont(new Font(nameLbl.getName(), Font.BOLD, 24));
    priceChangePercentLbl.setText(currentStock.get_price() + " ");
    String message = currentStock.get_change() + " " + currentStock.get_percent_change();
    if (Double.parseDouble(currentStock.get_change()) < 0)
        priceChangePercentLbl.setText(String.format("<html>%s<font color='red'>%s</font></html>",
                priceChangePercentLbl.getText(), message));
    else
        priceChangePercentLbl.setText(String.format("<html>%s<font color='green'>%s</font></html>",
                priceChangePercentLbl.getText(), message));
    priceChangePercentLbl.setFont(new Font(priceChangePercentLbl.getName(), Font.PLAIN, 15));

    data[0][0] = "Prev Close: " + currentStock.get_prev_close();
    data[1][0] = "Open: " + currentStock.get_open_price();
    data[2][0] = "Bid: " + currentStock.get_bid();
    data[3][0] = "Ask: " + currentStock.get_ask();
    data[4][0] = "One Year Target: " + currentStock.get_one_year_target();
    data[5][0] = "Ebita: " + currentStock.get_ebitda();
    data[0][1] = "Day Range: " + currentStock.get_days_range();
    data[1][1] = "52 Week Range: " + currentStock.get_year_range();
    data[2][1] = "Volume: " + currentStock.get_volume();
    data[3][1] = "Average Daily Volume: " + currentStock.get_avg_daily_volume();
    data[4][1] = "Market Cap: " + currentStock.get_market_cap();
    data[5][1] = "P/E: " + currentStock.get_pe();
    data[6][1] = "EPS: " + currentStock.get_earnings_per_share();
    data[7][1] = "Dividend (Yield): " + currentStock.get_dividend_per_share() + "("
            + currentStock.get_dividend_yield() + ")";
    data[6][0] = "Reveune:" + currentStock.get_revenue();
    data[7][0] = "Earnings Estimate: " + currentStock.get_earnings_estimate_current_year();
    data[8][0] = "Beta: " + currentStock.get_beta();
    data[8][1] = "PEG Ratio: " + currentStock.get_peg_ratio();
    data[9][0] = "Short Ratio: " + currentStock.get_short_ratio();

    data[11][0] = "50 Day MA: " + currentStock.get_fiftyday_moving_avg();
    data[12][0] = "200 Day MA: " + currentStock.get_twohundredday_moving_avg();
    if (currentStock.get_change_from_fiftyday_moving_avg() != null
            && currentStock.get_change_from_fiftyday_moving_avg().contains("-")) {
        data[13][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 50 Day MA: ",
                currentStock.get_change_from_fiftyday_moving_avg());
        data[14][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 50 Day MA: ",
                currentStock.get_percent_change_from_fiftyday_moving_avg());

    } else {
        data[13][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 50 Day MA: ",
                currentStock.get_change_from_fiftyday_moving_avg());
        data[14][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 50 Day MA: ",
                currentStock.get_percent_change_from_fiftyday_moving_avg());
    }
    if (currentStock.get_change_from_twohundredday_moving_avg() != null
            && currentStock.get_change_from_twohundredday_moving_avg().contains("-")) {
        data[15][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 200 Day MA: ",
                currentStock.get_change_from_twohundredday_moving_avg());
        data[16][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 200 Day MA: ",
                currentStock.get_percent_change_from_twohundredday_moving_avg());
    } else {
        data[15][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 200 Day MA: ",
                currentStock.get_change_from_twohundredday_moving_avg());
        data[16][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 200 Day MA: ",
                currentStock.get_percent_change_from_twohundredday_moving_avg());
    }
    data[17][0] = "Year High: " + currentStock.get_year_high();
    data[18][0] = "Year Low: " + currentStock.get_year_low();
    if (currentStock.get_change_from_year_high() != null
            && currentStock.get_change_from_year_high().contains("-")) {
        data[19][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Change: ",
                currentStock.get_change_from_year_high());
        data[20][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Percent: ",
                currentStock.get_percent_change_from_year_high());
    } else {
        data[19][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Change: ",
                currentStock.get_change_from_year_high());
        data[20][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Percent: ",
                currentStock.get_percent_change_from_year_high());
    }
    if (currentStock.get_change_from_year_low() != null
            && currentStock.get_change_from_year_low().contains("-")) {
        data[21][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Change: ",
                currentStock.get_change_from_year_low());
        data[22][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Percent:  ",
                currentStock.get_percent_change_from_year_low());
    } else {
        data[21][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Change: ",
                currentStock.get_change_from_year_low());
        data[22][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Percent:  ",
                currentStock.get_percent_change_from_year_low());
    }
    if (currentStock.get_five_day_change()[0] != null && currentStock.get_five_day_change()[0].contains("-"))
        data[11][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5D Change: ",
                currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")");
    else
        data[11][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5D Change: ",
                currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")");
    if (currentStock.get_one_month_change()[0] != null && currentStock.get_one_month_change()[0].contains("-"))
        data[12][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1M Change: ",
                currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")");
    else
        data[12][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1M Change: ",
                currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")");
    if (currentStock.get_three_month_change()[0] != null
            && currentStock.get_three_month_change()[0].contains("-"))
        data[13][1] = String.format("<html>%s<font color='red'>%s</font></html>", "3M Change: ",
                currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1]
                        + ")");
    else
        data[13][1] = String.format("<html>%s<font color='green'>%s</font></html>", "3M Change: ",
                currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1]
                        + ")");
    if (currentStock.get_six_month_change()[0] != null && currentStock.get_six_month_change()[0].contains("-"))
        data[14][1] = String.format("<html>%s<font color='red'>%s</font></html>", "6M Change: ",
                currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")");
    else
        data[14][1] = String.format("<html>%s<font color='green'>%s</font></html>", "6M Change: ",
                currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")");
    if (currentStock.get_ytd_change()[0] != null && currentStock.get_ytd_change()[0].contains("-"))
        data[15][1] = String.format("<html>%s<font color='red'>%s</font></html>", "YTD Change: ",
                currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")");
    else
        data[15][1] = String.format("<html>%s<font color='green'>%s</font></html>", "YTD Change: ",
                currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")");
    if (currentStock.get_one_year_change()[0] != null && currentStock.get_one_year_change()[0].contains("-"))
        data[16][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1Y Change: ",
                currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")");
    else
        data[16][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1Y Change: ",
                currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")");
    if (currentStock.get_five_year_change()[0] != null && currentStock.get_five_year_change()[0].contains("-"))
        data[17][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5Y Change: ",
                currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")");
    else
        data[17][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5Y Change: ",
                currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")");
    if (currentStock.get_ten_year_change()[0] != null && currentStock.get_ten_year_change()[0].contains("-"))
        data[18][1] = String.format("<html>%s<font color='red'>%s</font></html>", "10Y Change: ",
                currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")");
    else
        data[18][1] = String.format("<html>%s<font color='green'>%s</font></html>", "10Y Change: ",
                currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")");
    if (currentStock.get_max_year_change()[0] != null && currentStock.get_max_year_change()[0].contains("-"))
        data[19][1] = String.format("<html>%s<font color='red'>%s</font></html>", "Max Change: ",
                currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")");
    else
        data[19][1] = String.format("<html>%s<font color='green'>%s</font></html>", "Max Change: ",
                currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")");

    data[24][0] = "Earnings Est Next Quarter: " + currentStock.get_earnings_estimate_next_quarter();
    data[25][0] = "Earnings Est Current Year: " + currentStock.get_earnings_estimate_current_year();
    data[26][0] = "Earnings Est Next Year: " + currentStock.get_earnings_estimate_next_year();
    data[24][1] = "P/E Est Current Year: " + currentStock.get_price_eps_estimate_current_year();
    data[25][1] = "P/E Est Next Year: " + currentStock.get_price_eps_estimate_next_year();
    remainingInfoTable.setFont(new Font(remainingInfoTable.getName(), Font.PLAIN, 15));
    remainingInfoTable.packColumn(0, 4);
    remainingInfoTable.packColumn(1, 4);

    try {
        dataAndGraph.remove(chartPane);
        chartPane = new JTabbedPane();
        chartPane.setVisible(true);
        ChartPanel intradayChart = new IntradayChart(currentStock).getChartPanel();
        intradayChart.setPopupMenu(graphMenu);
        chartPane.addTab("1d", intradayChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_1);

        ChartPanel fivedayChart = new FiveDayChart(currentStock).getChartPanel();
        fivedayChart.setPopupMenu(graphMenu);
        chartPane.addTab("5d", fivedayChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_2);

        ChartPanel onemonthChart = new OneMonthChart(currentStock).getChartPanel();
        onemonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("1m", onemonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_3);

        ChartPanel threemonthChart = new ThreeMonthChart(currentStock).getChartPanel();
        threemonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("3m", threemonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_4);

        ChartPanel sixmonthChart = new SixMonthChart(currentStock).getChartPanel();
        sixmonthChart.setPopupMenu(graphMenu);
        chartPane.addTab("6m", sixmonthChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_5);

        ChartPanel ytdChart = new YTDChart(currentStock).getChartPanel();
        ytdChart.setPopupMenu(graphMenu);
        chartPane.addTab("ytd", ytdChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_6);

        ChartPanel oneyearChart = new OneYearChart(currentStock).getChartPanel();
        oneyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("1y", oneyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_7);

        ChartPanel fiveyearChart = new FiveYearChart(currentStock).getChartPanel();
        fiveyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("5y", fiveyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_8);

        ChartPanel tenyearChart = new TenYearChart(currentStock).getChartPanel();
        tenyearChart.setPopupMenu(graphMenu);
        chartPane.addTab("10y", tenyearChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_9);

        ChartPanel maxChart = new MaxChart(currentStock).getChartPanel();
        maxChart.setPopupMenu(graphMenu);
        chartPane.addTab("max", maxChart);
        chartPane.setMnemonicAt(0, KeyEvent.VK_0);

        c = new GridBagConstraints();
        c.anchor = GridBagConstraints.NORTHWEST;
        c.fill = GridBagConstraints.BOTH;
        c.weightx = 1;
        c.weighty = 0;
        c.gridheight = 2;
        //c.ipady = 20;
        c.gridx = 1;
        c.gridy = 0;
        dataAndGraph.add(chartPane, c);

    } catch (ParseException ex) {
        Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
    }
    chartPane.revalidate();
    chartPane.repaint();
    revalidate();
    repaint();
    finished = true;
}

From source file:guineu.modules.visualization.intensityboxplot.IntensityBoxPlotFrame.java

public IntensityBoxPlotFrame(ParameterSet parameters) {
    super("", true, true, true, true);

    String title = "Intensity box plot [" + GuineuCore.getDesktop().getSelectedDataFiles()[0].getDatasetName()
            + "]";
    String xAxisLabel = parameters.getParameter(IntensityBoxPlotParameters.xAxisValueSource).getValue()
            .toString();//  w w w  .  j a v  a2s.  c o  m
    this.xAxisValueSource = parameters.getParameter(IntensityBoxPlotParameters.xAxisValueSource).getValue();
    // create dataset
    this.selectedFiles = parameters.getParameter(IntensityBoxPlotParameters.dataFiles).getValue();

    this.selectedRows = parameters.getParameter(IntensityBoxPlotParameters.selectedRows).getValue();

    this.dataset = this.createSampleDataset();
    // create new JFreeChart
    logger.finest("Creating new chart instance");
    //      chart = ChartFactory.createLineChart(title, xAxisLabel, "Intensity",
    //               dataset, PlotOrientation.VERTICAL, true, true, false);

    //  CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set renderer
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);
    // set tooltip generator               
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    //  plot.setRenderer(renderer);
    //  plot.setBackgroundPaint(Color.white);
    //   CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    //  xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    // set y axis properties

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    NumberFormat yAxisFormat = new DecimalFormat("0.0E0");
    yAxis.setNumberFormatOverride(yAxisFormat);
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart("Intensity Box plot", new Font("SansSerif", Font.BOLD, 14), plot,
            true);
    chart.setBackgroundPaint(Color.white);

    // create chart JPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    add(chartPanel, BorderLayout.CENTER);

    //                IntensityBoxPlotToolBar toolBar = new IntensityBoxPlotToolBar(this);
    //   add(toolBar, BorderLayout.EAST);

    // disable maximum size (we don't want scaling)
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(legendFont);
    legend.setBorder(0, 0, 0, 0);

    // set shape provider
    IntensityBoxPlotDrawingSupplier shapeSupplier = new IntensityBoxPlotDrawingSupplier();

    plot.setDrawingSupplier(shapeSupplier);

    setTitle(title);
    setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
    setBackground(Color.white);
    pack();

}