Example usage for org.jfree.chart ChartUtilities applyCurrentTheme

List of usage examples for org.jfree.chart ChartUtilities applyCurrentTheme

Introduction

In this page you can find the example usage for org.jfree.chart ChartUtilities applyCurrentTheme.

Prototype

public static void applyCurrentTheme(JFreeChart chart) 

Source Link

Document

Applies the current theme to the specified chart.

Usage

From source file:net.nosleep.superanalyzer.analysis.views.YearView.java

private void createChart() {

    NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR"));
    xAxis.setAutoRangeIncludesZero(false);

    NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT"));
    yAxis.setAutoRangeIncludesZero(true);

    xAxis.setNumberFormatOverride(new DecimalFormat("0"));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer);

    // create and return the chart panel...
    _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));

    LegendTitle legend = _chart.getLegend();
    legend.setFrame(BlockBorder.NONE);//  w  ww  .  java 2s  . c  o m

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP")));

    XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"),
            new DecimalFormat("0.00"));
    renderer.setToolTipGenerator(generator);

    ChartUtilities.applyCurrentTheme(_chart);

    // format the lines after applying the theme
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0));

    _chart.setPadding(new RectangleInsets(10, 10, 10, 10));

    Misc.formatChart(plot);
}

From source file:org.emftrace.quarc.ui.views.RatioView.java

/**
 * create a SpiderChart /*from   w w  w .  j a v  a 2 s. c o m*/
 * @param dataset the dataset for the chart
 * @param weighted include weights?
 * @return the created SpiderChart
 */
private JFreeChart createSpiderChart(DefaultCategoryDataset dataset, boolean weighted) {

    SpiderWebPlot plot = new SpiderWebPlot(dataset);
    plot.setMaxValue(200.0f);

    plot.setStartAngle(54);
    plot.setInteriorGap(0.40);
    plot.setToolTipGenerator(new CategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset dataset, int section, int index) {
            Float ratingValue = (Float) dataset.getValue(section, index);
            if (ratingValue == null)
                ratingValue = 0.0f;
            else
                ratingValue -= 100.0f;
            return String.valueOf("(" + dataset.getRowKey(section) + "," + dataset.getColumnKey(index) + ") = "
                    + String.format("%.2f", ratingValue));
        }

    });
    plot.setNoDataMessage("No data to display");
    String titleStr = "ratings of selected elements";
    if (weighted)
        titleStr = "weighted " + titleStr;
    JFreeChart chart = new JFreeChart(titleStr, TextTitle.DEFAULT_FONT, plot, false);
    LegendTitle legend = new LegendTitle(plot);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legend);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;

}

From source file:eu.delving.stats.ChartHelper.java

private static JFreeChart finishBarChart(JFreeChart chart, Color... colors) {
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    if (colors.length > 0)
        categoryplot.setRenderer(new CustomRenderer(colors));
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemLabelAnchorOffset(9D);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barrenderer.setMaximumBarWidth(0.05);
    barrenderer.setItemMargin(0.03D);/*from www.  j  av a2  s  .co  m*/
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT,
            -1.5707963267948966D);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT,
            -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    categoryaxis.setCategoryMargin(0.25D);
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortCounterPlotWorker.java

@Override
protected Void doInBackground() throws Exception {
    // 1.  counter value (already done, just add following to this)
    // 2.  delta/period
    ///*w  w  w  .  j a  va 2s  .  c  o m*/
    //    -- if error counter --
    // 3.  include xmit and rcv traffic deltas? (own scale)
    //
    //
    //    -- if traffic counter --
    // 3.  include rate and utilization values?
    //

    // this is a SwingWorker thread from its pool, give it a recognizable name
    Thread.currentThread().setName("PortCounterPlotWorker");

    logger.info("Worker Building Plot");
    SMT_UpdateService updateService = SMT_UpdateService.getInstance();
    OMS_Collection history = updateService.getCollection();
    OSM_FabricDeltaCollection deltaHistory = history.getOSM_FabricDeltaCollection();

    XYPlot plot = (XYPlot) Chart.getPlot();

    // AXIS 2 - the change, or delta value of the desired counter
    NumberAxis axis2 = new NumberAxis(PortCounterAxisLabel.DELTA.getName());
    axis2.setFixedDimension(10.0);
    axis2.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, axis2);

    XYDataset dataset2 = createDeltaDataset(deltaHistory, PortCounter, PortCounterAxisLabel.DELTA.getName());
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    plot.setRenderer(1, renderer2);

    // the other two axis are optional, and vary depending on the
    // type of counter
    NumberAxis axis3 = null;
    XYDataset dataset3 = null;
    XYItemRenderer renderer3 = null;
    NumberAxis axis4 = null;
    XYDataset dataset4 = null;
    XYItemRenderer renderer4 = null;

    if (AddExtra) {
        if (isError) {

            // add rcv deltas
            PortCounterName pcr = PortCounterName.rcv_data;
            axis3 = new NumberAxis(PortCounterAxisLabel.RCV_DELTA.getName());
            axis3.setFixedDimension(10.0);
            axis3.setAutoRangeIncludesZero(false);
            plot.setRangeAxis(2, axis3);

            dataset3 = createDeltaDataset(deltaHistory, pcr, pcr.getName());
            plot.setDataset(2, dataset3);
            plot.mapDatasetToRangeAxis(2, 2);
            renderer3 = new StandardXYItemRenderer();
            plot.setRenderer(2, renderer3);

            // add xmit deltas
            pcr = PortCounterName.xmit_data;
            axis4 = new NumberAxis(PortCounterAxisLabel.XMT_DELTA.getName());
            axis4.setFixedDimension(10.0);
            axis4.setAutoRangeIncludesZero(false);
            plot.setRangeAxis(3, axis4);

            dataset4 = createDeltaDataset(deltaHistory, pcr, pcr.getName());
            plot.setDataset(3, dataset4);
            plot.mapDatasetToRangeAxis(3, 3);
            renderer4 = new StandardXYItemRenderer();
            plot.setRenderer(3, renderer4);

            // use a common scale for both xmit and rcv counters
            double minRange = axis3.getLowerBound() < axis4.getLowerBound() ? axis3.getLowerBound()
                    : axis4.getLowerBound();
            double maxRange = axis3.getUpperBound() < axis4.getUpperBound() ? axis4.getUpperBound()
                    : axis3.getUpperBound();
            axis3.setAutoRange(false);
            axis4.setAutoRange(false);
            axis3.setRange(minRange, maxRange);
            axis4.setRange(minRange, maxRange);
        } else {
            // add rate
            PortCounterName pcr = PortCounter;
            axis3 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.RATE.getUnits());
            axis3.setFixedDimension(10.0);
            axis3.setAutoRangeIncludesZero(true);
            plot.setRangeAxis(2, axis3);

            dataset3 = createRateDataset(deltaHistory, pcr, PortCounterAxisLabel.RATE.getName());
            plot.setDataset(2, dataset3);
            plot.mapDatasetToRangeAxis(2, 2);
            renderer3 = new StandardXYItemRenderer();
            plot.setRenderer(2, renderer3);

            // add utilization
            axis4 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.UTILIZATION.getUnits());
            axis4.setFixedDimension(10.0);
            //         axis4.setAutoRangeIncludesZero(true);
            axis4.setRange(0.0, 100.0);
            plot.setRangeAxis(3, axis4);

            dataset4 = createUtilizationDataset(deltaHistory, pcr, PortCounterAxisLabel.UTILIZATION.getName());
            plot.setDataset(3, dataset4);
            plot.mapDatasetToRangeAxis(3, 3);
            renderer4 = new StandardXYItemRenderer();
            plot.setRenderer(3, renderer4);
        }
    }
    ChartUtilities.applyCurrentTheme(Chart);

    Color c1 = Color.black;
    Color c2 = Color.blue;

    Color c3 = Color.green;
    Color c4 = Color.magenta;

    Color ce = Color.red;

    if (isError)
        c2 = ce;

    // change the series and axis colours after the theme has
    // been applied...
    plot.getRenderer().setSeriesPaint(0, c1);

    renderer2.setSeriesPaint(0, c2);
    axis2.setLabelPaint(c2);
    axis2.setTickLabelPaint(c2);

    if (AddExtra) {
        renderer3.setSeriesPaint(0, c3);
        axis3.setLabelPaint(c3);
        axis3.setTickLabelPaint(c3);

        renderer4.setSeriesPaint(0, c4);
        axis4.setLabelPaint(c4);
        axis4.setTickLabelPaint(c4);
    }

    return null;
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

/**
  * Creates a chart./*from   w ww . j  a v  a2s.com*/
  * 
  * @param dataset  a dataset.
 * @param clusters 
  * 
  * @return A chart.
  */
//    private JFreeChart createChart(final XYDataset dataset, ArrayList<Cluster_DBScan> clusters) {
//
//        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
//            "Sensors",
//            "Time", "Erlang",
//            dataset,
//            false, //t
//            true, //t
//            false //f
//        );
//
//        ChartUtilities.applyCurrentTheme(chart);
//        
//        //chart.setBackgroundPaint(Color.white);
//
////        final StandardLegend sl = (StandardLegend) chart.getLegend();
////        sl.setDisplaySeriesShapes(true);
//
//        final XYPlot plot = chart.getXYPlot();
//        plot.setBackgroundPaint(Color.WHITE);
//        plot.setDomainGridlinePaint(Color.white);
//        plot.setRangeGridlinePaint(Color.white);
////        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
//        plot.setDomainCrosshairVisible(true);
//        plot.setRangeCrosshairVisible(true);
//        
//        final XYItemRenderer renderer = plot.getRenderer();
//        
//        if (renderer instanceof StandardXYItemRenderer) 
//        {
//            final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
//            //rr.setPlotShapes(true);
//            rr.setShapesFilled(true);
//            rr.setItemLabelsVisible(true);
//        }
//
//        int temp_count = 0;
//        
//        //for (int i = 0; i < clusters.size(); i++)
//        for (int i = 0; (i < 11) && (i < clusters.size()); i++)
//      {
//         Cluster_DBScan current_cluster = clusters.get(i);   
//         ArrayList<Day_24d> member_time_series = current_cluster.getMembership();
//         
//         for (int j = 0; j < member_time_series.size(); j++)
//         {
//            renderer.setSeriesPaint(j+temp_count, getColor(i));
//         }
//         temp_count = temp_count + member_time_series.size();
//      }
//        
//        final DateAxis axis = (DateAxis) plot.getDomainAxis();    
//        axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
//        
//        final ValueAxis axis_y = plot.getRangeAxis();
//        axis_y.setRange(0, 100);
//        
//        return chart;
//
//    }

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

    //        final StandardLegend sl = (StandardLegend) chart.getLegend();
    //        sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Day_24d> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:org.jfree.chart.demo.ThumbnailDemo1.java

public static JPanel createDemoPanel() {
    JPanel jpanel = new JPanel(new GridLayout(2, 3));
    JFreeChart jfreechart = createChart1(createDataset1());
    ChartUtilities.applyCurrentTheme(jfreechart);
    java.awt.image.BufferedImage bufferedimage = jfreechart.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon = new ImageIcon(bufferedimage);
    jpanel.add(new JButton(imageicon));
    JFreeChart jfreechart1 = createChart2(createDataset2());
    ChartUtilities.applyCurrentTheme(jfreechart1);
    java.awt.image.BufferedImage bufferedimage1 = jfreechart1.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon1 = new ImageIcon(bufferedimage1);
    jpanel.add(new JButton(imageicon1));
    JFreeChart jfreechart2 = createChart3(createDataset3());
    ChartUtilities.applyCurrentTheme(jfreechart2);
    java.awt.image.BufferedImage bufferedimage2 = jfreechart2.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon2 = new ImageIcon(bufferedimage2);
    jpanel.add(new JButton(imageicon2));
    JFreeChart jfreechart3 = createChart4(createDataset4());
    ChartUtilities.applyCurrentTheme(jfreechart3);
    java.awt.image.BufferedImage bufferedimage3 = jfreechart3.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon3 = new ImageIcon(bufferedimage3);
    jpanel.add(new JButton(imageicon3));
    JFreeChart jfreechart4 = createChart5(createDataset5());
    ChartUtilities.applyCurrentTheme(jfreechart4);
    java.awt.image.BufferedImage bufferedimage4 = jfreechart4.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon4 = new ImageIcon(bufferedimage4);
    jpanel.add(new JButton(imageicon4));
    JFreeChart jfreechart5 = createChart6(createDataset6());
    ChartUtilities.applyCurrentTheme(jfreechart5);
    java.awt.image.BufferedImage bufferedimage5 = jfreechart5.createBufferedImage(120, 80, 360D, 240D, null);
    ImageIcon imageicon5 = new ImageIcon(bufferedimage5);
    jpanel.add(new JButton(imageicon5));
    return jpanel;
}

From source file:jhplot.HChart.java

private void applyThemeToChart() {

    for (int i1 = 0; i1 < N1final; i1++) {
        for (int i2 = 0; i2 < N2final; i2++) {
            if (chart[i1][i2] != null) {
                ChartUtilities.applyCurrentTheme(chart[i1][i2]);
            }//from ww w.  j  a v a  2s  .com
        }
    }
}

From source file:pr.ui.InputForm.java

private void showErrorsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showErrorsBtnActionPerformed
    DefaultCategoryDataset categorydataset = new DefaultCategoryDataset();
    for (int i = 0; i < algorithm.getErrorLog().size(); i++) {
        categorydataset.addValue(algorithm.getErrorLog().get(i), "Global error", "" + i);
    }//  w  w  w .j  av  a 2 s  .  c om
    JFreeChart jfreechart = ChartFactory.createLineChart("Error Graph", null, "Error Graph", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangePannable(true);
    categoryplot.setRangeGridlinesVisible(false);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ChartUtilities.applyCurrentTheme(jfreechart);

    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setMouseWheelEnabled(true);

    Utils.showDialoj("Error Graph", chartpanel, this);
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

/**
 * Zeichne die eigentliche Grafik Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * /*from www  .j av a  2s. c om*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.07.2012
 * @param dbId
 *          dbid in Tabelle D_TABLE_DIVEDETAIL
 * @param device
 */
private void makeGraphForLog(int dbId, String device) {
    Vector<Integer[]> diveList;
    Vector<String> diluents;
    int[] headData;
    XYPlot thePlot;
    JFreeChart logChart;
    int min, sec;
    // das alte Zeug entsorgen
    releaseGraph();
    //
    // Daten eines TG lesen
    //
    lg.debug("read dive log from DB...");
    diveList = databaseUtil.getDiveDataFromIdLog(dbId);
    if (diveList == null || diveList.isEmpty()) {
        return;
    }
    //
    // verwendete Diluents finden
    //
    diluents = getDiluentNamesFromDive(diveList);
    // Anzeigen
    String diluentString = StringUtils.join(diluents, ", ");
    diluentLabel.setText(
            String.format(LangStrings.getString("spx42LogGraphPanel.diluentLabel.text"), diluentString));
    lg.debug(diluents);
    //
    // Labels fr Tachgangseckdaten fllen
    //
    headData = databaseUtil.getHeadDiveDataFromIdLog(dbId);
    notesLabel.setText(databaseUtil.getNotesForIdLog(dbId));
    showingUnitSystem = SpxPcloggerProgramConfig.unitsProperty;
    savedUnitSystem = headData[6];
    // jetzt die Strings fr Masseinheiten holen
    String[] labels = getUnitsLabel(showingUnitSystem, savedUnitSystem);
    depthUnitName = labels[0];
    tempUnitName = labels[1];
    pressureUnitName = labels[2];
    //
    // entscheide ob etwas umgerechnet werden sollte
    //
    if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) {
        // nein, alles schick
        maxDepthValueLabel.setText(String.format(maxDepthLabelString, (headData[3] / 10.0), depthUnitName));
        coldestTempValueLabel.setText(String.format(coldestLabelString, (headData[2] / 10.0), tempUnitName));
    } else {
        // umrechnen!
        if (showingUnitSystem == ProjectConst.UNITS_IMPERIAL) {
            // metrisch-> imperial konvertieren
            // 1 foot == 30,48 cm == 0.3048 Meter
            maxDepthValueLabel
                    .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) / 0.3048, depthUnitName));
            // t F = 5?9 (t  32) C
            coldestTempValueLabel.setText(
                    String.format(coldestLabelString, (5.0 / 9.0) * ((headData[2] / 10.0) - 32), tempUnitName));
        } else {
            maxDepthValueLabel
                    .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) * 0.3048, depthUnitName));
            // t C = (9?5 t + 32) F
            coldestTempValueLabel.setText(
                    String.format(coldestLabelString, ((9.0 / 5.0) * (headData[2] / 10.0)) + 32, tempUnitName));
        }
    }
    min = headData[5] / 60;
    sec = headData[5] % 60;
    diveLenValueLabel.setText(String.format(diveLenLabelString, min, sec, "min"));
    //
    // einen Plot machen (Grundlage des Diagramms)
    //
    lg.debug("create graph...");
    thePlot = new XYPlot();
    //
    // Eigenschaften definieren
    //
    thePlot.setBackgroundPaint(Color.lightGray);
    thePlot.setDomainGridlinesVisible(true);
    thePlot.setDomainGridlinePaint(Color.white);
    thePlot.setRangeGridlinesVisible(true);
    thePlot.setRangeGridlinePaint(Color.white);
    thePlot.setDomainPannable(true);
    thePlot.setRangePannable(false);
    //
    // ein Chart zur Anzeige in einem Panel erzeugen
    //
    logChart = new JFreeChart(LangStrings.getString("spx42LogGraphPanel.graph.chartTitle"), thePlot);
    logChart.setAntiAlias(true);
    logChart.addSubtitle(new TextTitle(LangStrings.getString("spx42LogGraphPanel.graph.chartSubTitle")));
    // ein Thema zufgen, damit ich eigene Farben einbauen kann
    ChartUtilities.applyCurrentTheme(logChart);
    //
    // ein Diagramm-Panel erzeugen
    //
    chartPanel = new ChartPanel(logChart);
    chartPanel.setMouseZoomable(true);
    chartPanel.setAutoscrolls(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDisplayToolTips(false);
    chartPanel.setZoomTriggerDistance(10);
    add(chartPanel, BorderLayout.CENTER);
    //
    // Datumsachse umformatieren
    //
    final NumberAxis axis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.dateAxisTitle"));
    MinuteFormatter formatter = new MinuteFormatter(
            LangStrings.getString("spx42LogGraphPanel.graph.dateAxisUnit"));
    axis.setNumberFormatOverride(formatter);
    thePlot.setDomainAxis(axis);
    //
    // Temperatur einfgen
    //
    if (SpxPcloggerProgramConfig.showTemperature) {
        makeTemperatureGraph(diveList, thePlot, labels);
    }
    //
    // Partialdruck einfgen
    // die Achse erst mal machen
    final NumberAxis ppo2Axis = new NumberAxis(
            LangStrings.getString("spx42LogGraphPanel.graph.ppo2AxisTitle") + " " + pressureUnitName);
    final NumberAxis percentAxis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.inertgas"));
    //
    // wenn eine der Achsen dargesstellt werden muss, dann sollte die Achse auch in der Grafil da sein
    //
    if (SpxPcloggerProgramConfig.showPpo01 || SpxPcloggerProgramConfig.showPpo02
            || SpxPcloggerProgramConfig.showPpo03 || SpxPcloggerProgramConfig.showPpoResult
            || SpxPcloggerProgramConfig.showSetpoint) {
        ppo2Axis.setAutoRangeIncludesZero(false);
        ppo2Axis.setAutoRange(false);
        //
        // wie skaliere ich die Achse?
        //
        if (showingUnitSystem == ProjectConst.UNITS_DEFAULT) {
            // so wie gespeichert
            if (savedUnitSystem == ProjectConst.UNITS_METRIC) {
                ppo2Axis.setRange(0.0, 3.5);
            } else {
                ppo2Axis.setRange(0.0, (3.5 * 14.504));
            }
        } else if (showingUnitSystem == ProjectConst.UNITS_METRIC) {
            ppo2Axis.setRange(0.0, 3.5);
        } else {
            ppo2Axis.setRange(0.0, (3.5 * 14.504));
        }
        ppo2Axis.setLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR));
        ppo2Axis.setTickLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR));
        thePlot.setRangeAxis(GRAPH_PPO2ALL, ppo2Axis);
    }
    if (SpxPcloggerProgramConfig.showHe || SpxPcloggerProgramConfig.showN2) {
        percentAxis.setAutoRangeIncludesZero(false);
        percentAxis.setAutoRange(false);
        percentAxis.setRange(0.0, 100.0);
        percentAxis.setLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR));
        percentAxis.setTickLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR));
        thePlot.setRangeAxis(GRAPH_HE, percentAxis);
    }
    //
    // Partialdrcke der einzelnen Sensoren einfgen
    //
    // Sensor 01 anzeigen
    if (SpxPcloggerProgramConfig.showPpo01) {
        makePpoGraph(diveList, thePlot, 1);
    }
    // Sensor 02 anzeigen
    if (SpxPcloggerProgramConfig.showPpo02) {
        makePpoGraph(diveList, thePlot, 2);
    }
    // Sensor 03 anzeigen
    if (SpxPcloggerProgramConfig.showPpo03) {
        makePpoGraph(diveList, thePlot, 3);
    }
    // Resultierenden PPO anzeigen
    if (SpxPcloggerProgramConfig.showPpoResult) {
        makePpoGraph(diveList, thePlot, 0);
        // makePpoResultGraph( diveList, thePlot );
    }
    if (SpxPcloggerProgramConfig.showSetpoint) {
        makeSetpointGraph(diveList, thePlot);
    }
    //
    // Helium und Stickstoffanteil im Gas?
    //
    if (SpxPcloggerProgramConfig.showHe) {
        makeInnertGasGraph(diveList, thePlot, "he");
    }
    if (SpxPcloggerProgramConfig.showN2) {
        makeInnertGasGraph(diveList, thePlot, "n2");
    }
    //
    // die Nullzeit auf Wunsch
    //
    if (SpxPcloggerProgramConfig.showNulltime) {
        makeNulltimeGraph(diveList, thePlot);
    }
    //
    // die Tiefe einfgen
    //
    makeDepthGraph(diveList, thePlot);
    //
    showingDbIdForDiveWasShowing = dbId;
    lg.debug("create graph...OK");
}

From source file:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java

/**
 * Visualization of the correlation of principal components with factors or the date samples were run.
 *
 * @param svdo SVD value object/*from   www . ja  v a 2s  .c  o  m*/
 */
private void writePCAFactors(OutputStream os, ExpressionExperiment ee, SVDValueObject svdo) throws Exception {
    Map<Integer, Map<Long, Double>> factorCorrelations = svdo.getFactorCorrelations();
    // Map<Integer, Map<Long, Double>> factorPvalues = svdo.getFactorPvalues();
    Map<Integer, Double> dateCorrelations = svdo.getDateCorrelations();

    assert ee.getId().equals(svdo.getId());

    if (factorCorrelations.isEmpty() && dateCorrelations.isEmpty()) {
        this.writePlaceholderImage(os);
        return;
    }
    ee = expressionExperimentService.thawLite(ee); // need the experimental design
    int maxWidth = 10;

    Map<Long, String> efs = this.getFactorNames(ee, maxWidth);

    DefaultCategoryDataset series = new DefaultCategoryDataset();

    /*
     * With two groups, or a continuous factor, we get rank correlations
     */
    int MAX_COMP = 3;
    double STUB = 0.05; // always plot a little thing so we know its there.
    for (Integer component : factorCorrelations.keySet()) {
        if (component >= MAX_COMP)
            break;
        for (Long efId : factorCorrelations.get(component).keySet()) {
            Double a = factorCorrelations.get(component).get(efId);
            String facname = efs.get(efId) == null ? "?" : efs.get(efId);
            if (a != null && !Double.isNaN(a)) {
                Double corr = Math.max(STUB, Math.abs(a));
                series.addValue(corr, "PC" + (component + 1), facname);
            }
        }
    }

    for (Integer component : dateCorrelations.keySet()) {
        if (component >= MAX_COMP)
            break;
        Double a = dateCorrelations.get(component);
        if (a != null && !Double.isNaN(a)) {
            Double corr = Math.max(STUB, Math.abs(a));
            series.addValue(corr, "PC" + (component + 1), "Date run");
        }
    }
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createBarChart("", "Factors", "Component assoc.", series,
            PlotOrientation.VERTICAL, true, false, false);

    chart.getCategoryPlot().getRangeAxis().setRange(0, 1);
    BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
    renderer.setBasePaint(Color.white);
    renderer.setShadowVisible(false);
    chart.getCategoryPlot().setRangeGridlinesVisible(false);
    chart.getCategoryPlot().setDomainGridlinesVisible(false);
    ChartUtilities.applyCurrentTheme(chart);

    CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    for (int i = 0; i < MAX_COMP; i++) {
        /*
         * Hue is straightforward; brightness is set medium to make it muted; saturation we vary from high to low.
         */
        float saturationDrop = (float) Math.min(1.0, i * 1.3f / MAX_COMP);
        renderer.setSeriesPaint(i, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));

    }

    /*
     * Give figure more room .. up to a limit
     */
    int width = ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX;
    if (chart.getCategoryPlot().getCategories().size() > 3) {
        width = width + 40 * (chart.getCategoryPlot().getCategories().size() - 2);
    }
    int MAX_QC_IMAGE_SIZE_PX = 500;
    width = Math.min(width, MAX_QC_IMAGE_SIZE_PX);
    ChartUtilities.writeChartAsPNG(os, chart, width, ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX);
}