Example usage for org.jfree.chart.title LegendTitle setFrame

List of usage examples for org.jfree.chart.title LegendTitle setFrame

Introduction

In this page you can find the example usage for org.jfree.chart.title LegendTitle setFrame.

Prototype

public void setFrame(BlockFrame frame) 

Source Link

Document

Sets the frame (or border).

Usage

From source file:org.tiefaces.components.websheet.chart.ChartHelper.java

/**
 * finalize the style for jfreechart. The default setting is different from
 * jfreechart and Excel. We try to minimize the difference.
 * /*  w  w w  .  j a v a  2  s .c o m*/
 * @param chart
 *            jfreechart.
 * @param chartData
 *            contain information gathered from excel chart object.
 */

private void setupPieStyle(final JFreeChart chart, final ChartData chartData) {
    PiePlot plot = (PiePlot) chart.getPlot();
    List<ChartSeries> seriesList = chartData.getSeriesList();
    List<ParsedCell> categoryList = chartData.getCategoryList();
    BasicStroke bLine = new BasicStroke(2.0f);
    for (int i = 0; i < seriesList.size(); i++) {
        ChartSeries chartSeries = seriesList.get(i);
        List<XColor> valueColorList = chartSeries.getValueColorList();
        for (int index = 0; index < categoryList.size(); index++) {
            try {
                String sCategory = getParsedCellValue(categoryList.get(index));
                Color cColor = ColorUtility.xssfClrToClr(valueColorList.get(index).getXssfColor());
                plot.setSectionPaint(sCategory, cColor);
                plot.setSectionOutlineStroke(sCategory, bLine);
            } catch (Exception ex) {
                LOG.log(Level.FINE, "SetupPieStyle error = " + ex.getLocalizedMessage(), ex);
            }
        }

    }
    plot.setBackgroundPaint(ColorUtility.xssfClrToClr(chartData.getBgColor().getXssfColor()));

    // below are modifications for default setting in excel chart
    // to-do: need read setting from xml in future

    plot.setOutlineVisible(false);
    plot.setLegendItemShape(new Rectangle(TieConstants.DEFAULT_LEGENT_ITEM_SHAPE_WIDTH,
            TieConstants.DEFAULT_LEGENT_ITEM_SHAPE_HEIGHT));
    chart.setBackgroundPaint(Color.WHITE);
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setFrame(BlockBorder.NONE);

}

From source file:com.rapidminer.gui.plotter.charts.DistributionPlotter.java

@Override
public void updatePlotter() {

    JFreeChart chart = null;// w  w  w  .j av a2s.  c  om
    Attribute attr = null;
    if (plotColumn != -1 && createFromModel) {
        attr = model.getTrainingHeader().getAttributes().get(model.getAttributeNames()[plotColumn]);
    }
    if (attr != null && attr.isNominal()
            && attr.getMapping().getValues().size() > MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES) {
        // showing no chart because of too many different values
        chart = new JFreeChart(new Plot() {

            private static final long serialVersionUID = 1L;

            @Override
            public String getPlotType() {
                return "empty";
            }

            @Override
            public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
                    PlotRenderingInfo info) {
                String msg = I18N.getGUILabel("plotter_panel.too_many_nominals", "Distribution Plotter",
                        DistributionPlotter.MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES);
                g2.setColor(Color.BLACK);
                g2.setFont(g2.getFont().deriveFont(g2.getFont().getSize() * 1.35f));
                g2.drawChars(msg.toCharArray(), 0, msg.length(), 50, (int) (area.getHeight() / 2 + 0.5d));
            }
        });
        AbstractChartPanel panel = getPlotterPanel();
        // Chart Panel Settings
        if (panel == null) {
            panel = createPanel(chart);
        } else {
            panel.setChart(chart);
        }
        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        preparePlots();

        if (!createFromModel && (groupColumn < 0 || plotColumn < 0)) {
            CategoryDataset dataset = new DefaultCategoryDataset();
            chart = ChartFactory.createBarChart(null, // chart title
                    "Not defined", // x axis label
                    RANGE_AXIS_NAME, // y axis label
                    dataset, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );
        } else {
            try {
                if (model.isDiscrete(translateToModelColumn(plotColumn))) {
                    chart = createNominalChart();
                } else {
                    chart = createNumericalChart();
                }
            } catch (Exception e) {
                // do nothing - just do not draw the chart
            }
        }

        if (chart != null) {
            chart.setBackgroundPaint(Color.white);

            // get a reference to the plot for further customization...
            Plot commonPlot = chart.getPlot();
            commonPlot.setBackgroundPaint(Color.WHITE);
            if (commonPlot instanceof XYPlot) {
                XYPlot plot = (XYPlot) commonPlot;

                plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
                plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

                // domain axis
                if (dataTable != null) {
                    if (dataTable.isDate(plotColumn) || dataTable.isDateTime(plotColumn)) {
                        DateAxis domainAxis = new DateAxis(dataTable.getColumnName(plotColumn));
                        domainAxis.setTimeZone(com.rapidminer.tools.Tools.getPreferredTimeZone());
                        plot.setDomainAxis(domainAxis);
                    } else {
                        NumberAxis numberAxis = new NumberAxis(dataTable.getColumnName(plotColumn));
                        plot.setDomainAxis(numberAxis);
                    }
                }

                plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

                plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

                // ranging
                if (dataTable != null) {
                    Range range = getRangeForDimension(plotColumn);
                    if (range != null) {
                        plot.getDomainAxis().setRange(range, true, false);
                    }

                    range = getRangeForName(RANGE_AXIS_NAME);
                    if (range != null) {
                        plot.getRangeAxis().setRange(range, true, false);
                    }
                }

                // rotate labels
                if (isLabelRotating()) {
                    plot.getDomainAxis().setTickLabelsVisible(true);
                    plot.getDomainAxis().setVerticalTickLabels(true);
                }

            } else if (commonPlot instanceof CategoryPlot) {
                CategoryPlot plot = (CategoryPlot) commonPlot;

                plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
                plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

                plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

                plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getDomainAxis().setTickLabelFont(LABEL_FONT);
            }

            // legend settings
            LegendTitle legend = chart.getLegend();
            if (legend != null) {
                legend.setPosition(RectangleEdge.TOP);
                legend.setFrame(BlockBorder.NONE);
                legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
                legend.setItemFont(LABEL_FONT);
            }

            AbstractChartPanel panel = getPlotterPanel();
            // Chart Panel Settings
            if (panel == null) {
                panel = createPanel(chart);
            } else {
                panel.setChart(chart);
            }

            // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
            panel.getChartRenderingInfo().setEntityCollection(null);
        }
    }
}

From source file:com.rapidminer.gui.plotter.charts.StackedBarChartPlotter.java

@Override
public void updatePlotter() {
    final int categoryCount = prepareData();

    if (categoryCount <= MAX_CATEGORIES) {
        JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title
                null, // domain axis label
                null, // range axis label
                categoryDataSet, // usedCategoryDataSet, // data
                orientationIndex == ORIENTATION_TYPE_VERTICAL ? PlotOrientation.VERTICAL
                        : PlotOrientation.HORIZONTAL, // orientation
                true, // include legend if group by column is set
                true, // tooltips
                false // URLs
        );/*w  w w .  ja  va2 s  . c o m*/

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.WHITE);
        chart.getPlot().setBackgroundPaint(Color.WHITE);

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

        CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setLabelFont(LABEL_FONT_BOLD);
        domainAxis.setTickLabelFont(LABEL_FONT);
        String domainName = groupByColumn >= 0 ? dataTable.getColumnName(groupByColumn) : null;
        domainAxis.setLabel(domainName);

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }

        // set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setLabelFont(LABEL_FONT_BOLD);
        rangeAxis.setTickLabelFont(LABEL_FONT);
        String rangeName = valueColumn >= 0 ? dataTable.getColumnName(valueColumn) : null;
        rangeAxis.setLabel(rangeName);

        // bar renderer
        int length = 0;
        // if ((groupByColumn >= 0) && this.dataTable.isNominal(groupByColumn)) {
        // length = this.dataTable.getNumberOfValues(groupByColumn);
        // } else {
        // length = categoryDataSet.getColumnCount();
        // }
        if (stackGroupColumn >= 0 && this.dataTable.isNominal(stackGroupColumn)) {
            length = this.dataTable.getNumberOfValues(stackGroupColumn);
        } else {
            length = categoryDataSet.getRowCount();
        }
        final double[] colorValues = new double[length];
        for (int i = 0; i < colorValues.length; i++) {
            colorValues[i] = i;
        }
        BarRenderer renderer = new StackedBarRenderer() {

            private static final long serialVersionUID = 1912387984078591157L;

            private ColorProvider colorProvider = getColorProvider(true);

            private double minColor = Double.POSITIVE_INFINITY;
            private double maxColor = Double.NEGATIVE_INFINITY;
            {
                if (colorValues != null) {
                    for (double d : colorValues) {
                        this.minColor = MathFunctions.robustMin(this.minColor, d);
                        this.maxColor = MathFunctions.robustMax(this.maxColor, d);
                    }
                }
            }

            @Override
            public Paint getSeriesPaint(int series) {
                if (colorValues == null || minColor == maxColor || series >= colorValues.length) {
                    return ColorProvider.reduceColorBrightness(Color.RED);
                } else {
                    double normalized = (colorValues[series] - minColor) / (maxColor - minColor);
                    return colorProvider.getPointColor(normalized);
                }
            }
        };

        renderer.setBarPainter(new RapidBarPainter());
        renderer.setDrawBarOutline(true);
        renderer.setShadowVisible(false);
        plot.setRenderer(renderer);

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }

        if (panel instanceof AbstractChartPanel) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        LogService.getRoot().log(Level.INFO,
                "com.rapidminer.gui.plotter.charts.StackedBarChartPlotter.too_many_columns",
                new Object[] { categoryCount, MAX_CATEGORIES });
    }
}

From source file:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java

@Override
public void updatePlotter() {
    final DataTable dataTable = getDataTable();

    prepareData();//from  w  w  w  .j  a va 2 s . c  o m

    JFreeChart chart = ChartFactory.createBubbleChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            xyzDataSet, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // URLs
    );

    if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) {
        if (nominal) {
            int size = xyzDataSet.getSeriesCount();
            chart = ChartFactory.createBubbleChart(null, // chart title
                    null, // domain axis label
                    null, // range axis label
                    xyzDataSet, // data
                    PlotOrientation.VERTICAL, // orientation
                    colorColumn >= 0 && size < 100 ? true : false, // include legend
                    true, // tooltips
                    false // URLs
            );

            // renderer settings
            XYBubbleRenderer renderer = (XYBubbleRenderer) chart.getXYPlot().getRenderer();
            renderer.setBaseOutlinePaint(Color.BLACK);

            if (size > 1) {
                for (int i = 0; i < size; i++) {
                    renderer.setSeriesPaint(i, getColorProvider(true).getPointColor(i / (double) (size - 1)));
                    renderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 7, 7));
                }
            } else {
                renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d));
                renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7));
            }

            // legend settings
            LegendTitle legend = chart.getLegend();
            if (legend != null) {
                legend.setPosition(RectangleEdge.TOP);
                legend.setFrame(BlockBorder.NONE);
                legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
                legend.setItemFont(LABEL_FONT);
            }
        } else {
            chart = ChartFactory.createScatterPlot(null, // chart title
                    null, // domain axis label
                    null, // range axis label
                    xyzDataSet, // data
                    PlotOrientation.VERTICAL, // orientation
                    false, // include legend
                    true, // tooltips
                    false // URLs
            );

            // renderer settings
            ColorizedBubbleRenderer renderer = new ColorizedBubbleRenderer(this.colors);
            renderer.setBaseOutlinePaint(Color.BLACK);
            chart.getXYPlot().setRenderer(renderer);

            // legend settings
            chart.addLegend(new LegendTitle(renderer) {

                private static final long serialVersionUID = 1288380309936848376L;

                @Override
                public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area,
                        java.lang.Object params) {
                    if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn)
                            || dataTable.isDateTime(colorColumn)) {
                        drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7),
                                dataTable, colorColumn, minColor, maxColor);
                        return new BlockResult();
                    } else {
                        final String minColorString = Tools.formatNumber(minColor);
                        final String maxColorString = Tools.formatNumber(maxColor);
                        drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90),
                                (int) (area.getCenterY() + 7), dataTable.getColumnName(colorColumn),
                                minColorString, maxColorString);
                        return new BlockResult();
                    }
                }

                @Override
                public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) {
                    draw(g2, area, null);
                }

            });
        }
    }

    // GENERAL CHART SETTINGS

    // set the background colors for the chart...
    chart.setBackgroundPaint(Color.WHITE);
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.getPlot().setForegroundAlpha(0.7f);

    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // domain axis
    if (axis[X_AXIS] >= 0) {
        if (dataTable.isNominal(axis[X_AXIS])) {
            String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])];
            for (int i = 0; i < values.length; i++) {
                values[i] = dataTable.mapIndex(axis[X_AXIS], i);
            }
            plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values));
        } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) {
            DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS]));
            domainAxis.setTimeZone(Tools.getPreferredTimeZone());
            plot.setDomainAxis(domainAxis);
        } else {
            if (logScales[X_AXIS]) {
                LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS]));
                domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
                plot.setDomainAxis(domainAxis);
            } else {
                plot.setDomainAxis(new NumberAxis(dataTable.getColumnName(axis[X_AXIS])));
            }
        }
        Range range = getRangeForDimension(axis[X_AXIS]);
        if (range != null) {
            plot.getDomainAxis().setRange(range, true, false);
        } else {
            plot.getDomainAxis().setAutoRange(true);
        }
    }
    plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

    // rotate labels
    if (isLabelRotating()) {
        plot.getDomainAxis().setTickLabelsVisible(true);
        plot.getDomainAxis().setVerticalTickLabels(true);
    }

    // range axis
    if (axis[Y_AXIS] >= 0) {
        if (dataTable.isNominal(axis[Y_AXIS])) {
            String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])];
            for (int i = 0; i < values.length; i++) {
                values[i] = dataTable.mapIndex(axis[Y_AXIS], i);
            }
            plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values));
        } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) {
            DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS]));
            rangeAxis.setTimeZone(Tools.getPreferredTimeZone());
            plot.setRangeAxis(rangeAxis);
        } else {
            plot.setRangeAxis(new NumberAxis(dataTable.getColumnName(axis[Y_AXIS])));
        }
        Range range = getRangeForDimension(axis[Y_AXIS]);
        if (range != null) {
            plot.getRangeAxis().setRange(range, true, false);
        } else {
            plot.getRangeAxis().setAutoRange(true);
        }
    }
    plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

    AbstractChartPanel panel = getPlotterPanel();
    // Chart Panel Settings
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.java

public void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT);
    int maxClasses = 20;
    try {//from  www .ja v a2  s . co m
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Pie Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.pie_chart_plotter_parsing_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    if (categoryCount <= MAX_CATEGORIES) {
        JFreeChart chart = createChart(pieDataSet, createLegend);

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        PiePlot plot = (PiePlot) chart.getPlot();

        plot.setBackgroundPaint(Color.WHITE);
        plot.setSectionOutlinesVisible(true);
        plot.setShadowPaint(new Color(104, 104, 104, 100));

        int size = pieDataSet.getKeys().size();
        for (int i = 0; i < size; i++) {
            Comparable<?> key = pieDataSet.getKey(i);
            plot.setSectionPaint(key, getColorProvider(true).getPointColor(i / (double) (size - 1)));

            boolean explode = false;
            for (String explosionGroup : explodingGroups) {
                if (key.toString().startsWith(explosionGroup) || explosionGroup.startsWith(key.toString())) {
                    explode = true;
                    break;
                }
            }

            if (explode) {
                plot.setExplodePercent(key, this.explodingAmount);
            }
        }

        plot.setLabelFont(LABEL_FONT);
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setOutlinePaint(Color.WHITE);

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }

        if (panel instanceof AbstractChartPanel) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        // LogService.getGlobal().logNote("Too many columns (" + categoryCount +
        // "), this chart is only able to plot up to " + MAX_CATEGORIES +
        // " different categories.");
        LogService.getRoot().log(Level.INFO,
                "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.too_many_columns",
                new Object[] { categoryCount, MAX_CATEGORIES });
    }
}

From source file:com.polivoto.vistas.Charts.java

private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    DefaultPieDataset data = new DefaultPieDataset();
    // Fuente de Datos
    for (Opcion opc : opciones) {
        data.setValue(opc.getNombre(), opc.getCantidad());
    }/*w  w  w.  ja v  a 2s  .  c  o  m*/

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS
            false);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setFont(new Font("Roboto", 0, 28));

    // Crear el Panel del Grafico con ChartPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();

    Rectangle bounds = panel.getBounds();
    chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height);

    panel.add(chartPanel);

    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineVisible(false);
    //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}");
    //plot.setLabelGenerator(labels);

    plot.setBaseSectionOutlinePaint(Color.white);
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);

    //#7cb5ec,#f45b5b,#90ed7d,#434348,
    //#f7a35c,#8085e9,#f15c80,#e4d354,
    //#2b908f,#91e8e1
    Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125),
            new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128),
            new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) };
    PieRenderer renderer = new PieRenderer(colors);
    renderer.setColor(plot, data);

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    Font nwfont = new Font("Roboto", 0, 18);
    legend.setItemFont(nwfont);
    legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white));
    legend.setBackgroundPaint(Color.WHITE);
    legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0));
    //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5);
    //legend.setItemLabelPadding(padding);
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}"));
    plot.setLegendItemShape(new Rectangle(25, 25));
    return panel;
}

From source file:com.rapidminer.gui.plotter.charts.BarChartPlotter.java

@Override
public void updatePlotter() {
    final int categoryCount = prepareData();

    SwingUtilities.invokeLater(new Runnable() {

        @Override//from ww w.  jav a  2  s  .co  m
        public void run() {
            scrollablePlotterPanel.remove(viewScrollBar);
        }
    });

    CategoryDataset usedCategoryDataSet = categoryDataSet;
    if (categoryCount > MAX_CATEGORY_VIEW_COUNT && showScrollbar) {
        if (orientationIndex == ORIENTATION_TYPE_VERTICAL) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    viewScrollBar.setOrientation(Adjustable.HORIZONTAL);
                    scrollablePlotterPanel.add(viewScrollBar, BorderLayout.SOUTH);
                }
            });
        } else {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    viewScrollBar.setOrientation(Adjustable.VERTICAL);
                    scrollablePlotterPanel.add(viewScrollBar, BorderLayout.EAST);
                }
            });
        }

        this.slidingCategoryDataSet = new SlidingCategoryDataset(categoryDataSet, 0, MAX_CATEGORY_VIEW_COUNT);
        viewScrollBar.setMaximum(categoryCount);
        viewScrollBar.setValue(0);

        usedCategoryDataSet = this.slidingCategoryDataSet;
    } else {
        this.slidingCategoryDataSet = null;
    }

    if (categoryCount <= MAX_CATEGORIES) {
        JFreeChart chart = ChartFactory.createBarChart(null, // chart title
                null, // domain axis label
                null, // range axis label
                usedCategoryDataSet, // data
                orientationIndex == ORIENTATION_TYPE_VERTICAL ? PlotOrientation.VERTICAL
                        : PlotOrientation.HORIZONTAL, // orientation
                false, // include legend if group by column is set
                true, // tooltips
                false // URLs
        );

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.WHITE);
        chart.getPlot().setBackgroundPaint(Color.WHITE);

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

        CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setLabelFont(LABEL_FONT_BOLD);
        domainAxis.setTickLabelFont(LABEL_FONT);
        String domainName = groupByColumn >= 0 ? dataTable.getColumnName(groupByColumn) : null;
        domainAxis.setLabel(domainName);

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }

        // set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setLabelFont(LABEL_FONT_BOLD);
        rangeAxis.setTickLabelFont(LABEL_FONT);
        String rangeName = valueColumn >= 0 ? dataTable.getColumnName(valueColumn) : null;
        rangeAxis.setLabel(rangeName);

        // bar renderer
        double[] colorValues = null;
        if (groupByColumn >= 0 && this.dataTable.isNominal(groupByColumn)) {
            colorValues = new double[this.dataTable.getNumberOfValues(groupByColumn)];
        } else {
            colorValues = new double[categoryDataSet.getColumnCount()];
        }
        for (int i = 0; i < colorValues.length; i++) {
            colorValues[i] = i;
        }

        BarRenderer renderer = new ColorizedBarRenderer(colorValues);
        renderer.setBarPainter(new RapidBarPainter());
        renderer.setDrawBarOutline(true);
        int size = categoryDataSet.getRowCount();
        if (size > 1) {
            for (int i = 0; i < size; i++) {
                renderer.setSeriesPaint(i, getColorProvider(true).getPointColor(i / (double) (size - 1)));
            }
        }
        plot.setRenderer(renderer);

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }

        if (panel != null) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            scrollablePlotterPanel.add(panel, BorderLayout.CENTER);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        // LogService.getGlobal().logNote("Too many columns (" + categoryCount +
        // "), this chart is only able to plot up to " + MAX_CATEGORIES +
        // " different categories.");
        LogService.getRoot().log(Level.INFO,
                "com.rapidminer.gui.plotter.charts.BarChartPlotter.too_many_columns",
                new Object[] { categoryCount, MAX_CATEGORIES });
    }
}

From source file:com.rapidminer.gui.plotter.charts.MultipleScatterPlotter.java

@Override
public void updatePlotter() {

    prepareData();/*from   www.  j  av  a 2s. co  m*/

    JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // URLs
    );

    if (xAxis >= 0) {
        int size = dataSet.getSeriesCount();
        chart = ChartFactory.createScatterPlot(null, // chart title
                null, // domain axis label
                null, // range axis label
                dataSet, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips
                false // URLs
        );

        // renderer settings
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
        renderer.setBaseOutlinePaint(Color.BLACK);
        renderer.setUseOutlinePaint(true);
        renderer.setDrawOutlines(true);

        for (int i = 0; i < size; i++) {
            renderer.setSeriesShapesVisible(i, this.showPoints[plotIndexToColumnIndexMap.get(i)]);
            renderer.setSeriesLinesVisible(i, this.showLines[plotIndexToColumnIndexMap.get(i)]);
        }

        renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7));

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }
    }

    // GENERAL CHART SETTINGS

    int size = dataSet.getSeriesCount();
    if (size <= 1) {
        chart.getXYPlot().getRenderer().setSeriesPaint(0, getColorProvider().getPointColor(1.0d));
    } else {
        for (int i = 0; i < dataSet.getSeriesCount(); i++) {
            chart.getXYPlot().getRenderer().setSeriesStroke(i,
                    new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
            chart.getXYPlot().getRenderer().setSeriesPaint(i,
                    getColorProvider().getPointColor(i / (double) (dataSet.getSeriesCount() - 1)));
        }
    }

    // set the background colors for the chart...
    chart.setBackgroundPaint(Color.WHITE);
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(false);

    // general plot settings
    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // domain axis
    if (xAxis >= 0) {
        if (dataTable.isNominal(xAxis)) {
            String[] values = new String[dataTable.getNumberOfValues(xAxis)];
            for (int i = 0; i < values.length; i++) {
                values[i] = dataTable.mapIndex(xAxis, i);
            }
            plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(xAxis), values));
        } else if ((dataTable.isDate(xAxis)) || (dataTable.isDateTime(xAxis))) {
            DateAxis domainAxis = new DateAxis(dataTable.getColumnName(xAxis));
            domainAxis.setTimeZone(Tools.getPreferredTimeZone());
            plot.setDomainAxis(domainAxis);
        } else {
            if (xLogScale) {
                LogAxis domainAxis = new LogAxis(dataTable.getColumnName(xAxis));
                domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
                plot.setDomainAxis(domainAxis);
            } else {
                NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(xAxis));
                domainAxis.setAutoRangeStickyZero(false);
                domainAxis.setAutoRangeIncludesZero(false);
                plot.setDomainAxis(domainAxis);
            }
        }
    }
    plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

    // rotate labels
    if (isLabelRotating()) {
        plot.getDomainAxis().setTickLabelsVisible(true);
        plot.getDomainAxis().setVerticalTickLabels(true);
    }

    // range axis
    plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

    // Chart Panel Settings
    if (panel instanceof AbstractChartPanel) {
        panel.setChart(chart);
    } else {
        panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);

        final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
        panel.addMouseListener(controller);
        panel.addMouseMotionListener(controller);

        // react to mouse clicks
        // ATTENTION: ACTIVATING THIS WILL LEAD TO SEVERE MEMORY LEAKS!!! (see below)
        panel.addChartMouseListener(new ChartMouseListener() {

            @Override
            public void chartMouseClicked(ChartMouseEvent e) {
                if (e.getTrigger().getClickCount() > 1) {
                    XYItemEntity entity = (XYItemEntity) e.getEntity();
                    if (entity != null) {
                        String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem()));
                        if (id != null) {
                            ObjectVisualizer visualizer = ObjectVisualizerService
                                    .getVisualizerForObject(dataTable);
                            visualizer.startVisualization(id);
                        }
                    }
                }
            }

            @Override
            public void chartMouseMoved(ChartMouseEvent e) {
            }
        });
    }

    // tooltips
    class CustomXYToolTipGenerator implements XYToolTipGenerator {

        public CustomXYToolTipGenerator() {
        }

        @Override
        public String generateToolTip(XYDataset dataset, int row, int column) {
            String id = idMap.get(new SeriesAndItem(row, column));
            if (id != null) {
                return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", "
                        + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", "
                        + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>";
            } else {
                return "<html>(" + dataset.getSeriesKey(row) + ", "
                        + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", "
                        + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>";
            }
        }
    }

    for (int i = 0; i < dataSet.getSeriesCount(); i++) {
        plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator());
    }
}

From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

public void initialize() {

    final JFreeChart chart = chartNode.getChart();
    final XYPlot plot = chart.getXYPlot();

    // Do not set colors and strokes dynamically. They are instead provided
    // by the dataset and configured in configureRenderer()
    plot.setDrawingSupplier(null);/*from  www .  j  a v a 2 s.co m*/
    plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    // chart properties
    chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));

    // legend properties
    LegendTitle legend = chart.getLegend();
    // legend.setItemFont(legendFont);
    legend.setFrame(BlockBorder.NONE);

    // set the X axis (m/z) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setLabel("m/z");
    xAxis.setUpperMargin(0.03);
    xAxis.setLowerMargin(0.03);
    xAxis.setRangeType(RangeType.POSITIVE);
    xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));

    // set the Y axis (intensity) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel("Intensity");
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    // set the fixed number formats, because otherwise JFreeChart sometimes
    // shows exponent, sometimes it doesn't
    DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    xAxis.setNumberFormatOverride(mzFormat);
    DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    yAxis.setNumberFormatOverride(intensityFormat);

    chartTitle = chartNode.getChart().getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    chartNode.setCursor(Cursor.CROSSHAIR);

    // Remove the dataset if it is removed from the list
    datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> {
        while (c.next()) {
            if (c.wasRemoved()) {
                for (MsSpectrumDataSet ds : c.getRemoved()) {
                    int index = plot.indexOf(ds);
                    plot.setDataset(index, null);
                }
            }
        }
    });

    itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
        for (MsSpectrumDataSet dataset : datasets) {
            int datasetIndex = plot.indexOf(dataset);
            XYItemRenderer renderer = plot.getRenderer(datasetIndex);
            renderer.setBaseItemLabelsVisible(newVal);
        }
    });

    legendVisible.addListener((prop, oldVal, newVal) -> {
        legend.setVisible(newVal);
    });

}

From source file:com.rapidminer.gui.plotter.charts.Abstract2DChartPlotter.java

@Override
public void updatePlotter() {
    prepareData();//from  w  w  w. j a va 2s  .c om
    JFreeChart chart;
    if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0) {
        if (nominal) {
            int size = dataSet.getSeriesCount();
            chart = ChartFactory.createScatterPlot(null, // chart title
                    null, // domain axis label
                    null, // range axis label
                    dataSet, // data
                    PlotOrientation.VERTICAL, // orientation
                    colorColumn >= 0 && size < 100 ? true : false, // include legend
                    true, // tooltips
                    false // URLs
            );

            // renderer settings
            try {
                chart.getXYPlot().setRenderer(getItemRenderer(nominal, size, this.minColor, this.maxColor));
            } catch (Exception e) {
                // do nothing
            }

            // legend settings
            LegendTitle legend = chart.getLegend();
            if (legend != null) {
                legend.setPosition(RectangleEdge.TOP);
                legend.setFrame(BlockBorder.NONE);
                legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
                legend.setItemFont(LABEL_FONT);

                BlockContainer wrapper = new BlockContainer(new BorderArrangement());

                LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn),
                        new Font("SansSerif", Font.BOLD, 12));
                title.setPadding(0, 5, 5, 5);
                wrapper.add(title, RectangleEdge.LEFT);

                BlockContainer items = legend.getItemContainer();
                wrapper.add(items, RectangleEdge.RIGHT);

                legend.setWrapper(wrapper);
            }
        } else {

            chart = ChartFactory.createScatterPlot(null, // chart title
                    null, // domain axis label
                    null, // range axis label
                    dataSet, // data
                    PlotOrientation.VERTICAL, // orientation
                    false, // include legend
                    true, // tooltips
                    false // URLs
            );

            // renderer settings
            try {
                chart.getXYPlot().setRenderer(getItemRenderer(nominal, -1, minColor, maxColor));
            } catch (Exception e) {
                // do nothing
            }

            LegendTitle legendTitle = new LegendTitle(chart.getXYPlot().getRenderer()) {

                private static final long serialVersionUID = 1288380309936848376L;

                @Override
                public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area,
                        java.lang.Object params) {
                    if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn)
                            || dataTable.isDateTime(colorColumn)) {
                        drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7),
                                dataTable, colorColumn, minColor, maxColor);
                        return new BlockResult();
                    } else {
                        final String minColorString = Tools.formatNumber(minColor);
                        final String maxColorString = Tools.formatNumber(maxColor);
                        drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 75),
                                (int) (area.getCenterY() + 7), getDataTable().getColumnName(colorColumn),
                                minColorString, maxColorString);
                        return new BlockResult();
                    }
                }

                @Override
                public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) {
                    draw(g2, area, null);
                }

            };

            BlockContainer wrapper = new BlockContainer(new BorderArrangement());

            LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn),
                    new Font("SansSerif", Font.BOLD, 12));
            title.setPadding(0, 5, 5, 5);
            wrapper.add(title, RectangleEdge.LEFT);

            BlockContainer items = legendTitle.getItemContainer();
            wrapper.add(items, RectangleEdge.RIGHT);

            legendTitle.setWrapper(wrapper);

            chart.addLegend(legendTitle);
        }
    } else {
        chart = ChartFactory.createScatterPlot(null, // chart title
                null, // domain axis label
                null, // range axis label
                dataSet, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips
                false // URLs
        );
    }

    // GENERAL CHART SETTINGS

    // set the background colors for the chart...
    chart.setBackgroundPaint(Color.WHITE);
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(false);

    // general plot settings
    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // domain axis
    if (axis[X_AXIS] >= 0) {
        if (dataTable.isNominal(axis[X_AXIS])) {
            String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])];
            for (int i = 0; i < values.length; i++) {
                values[i] = dataTable.mapIndex(axis[X_AXIS], i);
            }
            plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values));
        } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) {
            DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS]));
            domainAxis.setTimeZone(Tools.getPreferredTimeZone());
            plot.setDomainAxis(domainAxis);
        } else {
            if (logScales[X_AXIS]) {
                LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS]));
                domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
                plot.setDomainAxis(domainAxis);
            } else {
                NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(axis[X_AXIS]));
                domainAxis.setAutoRangeStickyZero(false);
                domainAxis.setAutoRangeIncludesZero(false);
                plot.setDomainAxis(domainAxis);
            }
        }
    }

    if (axis[X_AXIS] >= 0) {
        Range range = getRangeForDimension(axis[X_AXIS]);
        if (range != null) {
            plot.getDomainAxis().setRange(range, true, false);
        } else {
            plot.getDomainAxis().setAutoRange(true);
        }
    }

    plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

    // rotate labels
    if (isLabelRotating()) {
        plot.getDomainAxis().setTickLabelsVisible(true);
        plot.getDomainAxis().setVerticalTickLabels(true);
    }

    // range axis
    if (axis[Y_AXIS] >= 0) {
        if (dataTable.isNominal(axis[Y_AXIS])) {
            String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])];
            for (int i = 0; i < values.length; i++) {
                values[i] = dataTable.mapIndex(axis[Y_AXIS], i);
            }
            plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values));
        } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) {
            DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS]));
            rangeAxis.setTimeZone(Tools.getPreferredTimeZone());
            plot.setRangeAxis(rangeAxis);
        } else {
            if (logScales[Y_AXIS]) {
                LogAxis rangeAxis = new LogAxis(dataTable.getColumnName(axis[Y_AXIS]));
                rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
                plot.setRangeAxis(rangeAxis);
            } else {
                NumberAxis rangeAxis = new NumberAxis(dataTable.getColumnName(axis[Y_AXIS]));
                rangeAxis.setAutoRangeStickyZero(false);
                rangeAxis.setAutoRangeIncludesZero(false);
                plot.setRangeAxis(rangeAxis);
            }
        }
    }
    plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

    if (axis[Y_AXIS] >= 0) {
        Range range = getRangeForDimension(axis[Y_AXIS]);
        if (range != null) {
            plot.getRangeAxis().setRange(range, true, false);
        } else {
            plot.getRangeAxis().setAutoRange(true);
        }
    }

    // Chart Panel Settings
    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);

        // react to mouse clicks
        panel.addChartMouseListener(new ChartMouseListener() {

            @Override
            public void chartMouseClicked(ChartMouseEvent e) {
                if (e.getTrigger().getClickCount() > 1) {
                    if (e.getEntity() instanceof XYItemEntity) {
                        XYItemEntity entity = (XYItemEntity) e.getEntity();
                        if (entity != null) {
                            String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem()));
                            if (id != null) {
                                ObjectVisualizer visualizer = ObjectVisualizerService
                                        .getVisualizerForObject(dataTable);
                                visualizer.startVisualization(id);
                            }
                        }
                    }
                }
            }

            @Override
            public void chartMouseMoved(ChartMouseEvent e) {
            }
        });

    } else {
        panel.setChart(chart);
    }

    // tooltips
    class CustomXYToolTipGenerator implements XYToolTipGenerator {

        public CustomXYToolTipGenerator() {
        }

        private String formatValue(int axis, double value) {
            if (dataTable.isNominal(axis)) {
                // TODO add mapping of value to nominal value
                return Tools.formatIntegerIfPossible(value);
            } else if (dataTable.isNumerical(axis)) {
                return Tools.formatIntegerIfPossible(value);
            } else if (dataTable.isDate(axis)) {
                return Tools.createDateAndFormat(value);
            } else if (dataTable.isTime(axis)) {
                return Tools.createTimeAndFormat(value);
            } else if (dataTable.isDateTime(axis)) {
                return Tools.createDateTimeAndFormat(value);
            }
            return "?";
        }

        @Override
        public String generateToolTip(XYDataset dataset, int row, int column) {
            String id = idMap.get(new SeriesAndItem(row, column));
            if (id != null) {
                return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", "
                        + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", "
                        + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>";

            } else {
                return "<html>(" + dataset.getSeriesKey(row) + ", "
                        + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", "
                        + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>";
            }
        }
    }

    for (int i = 0; i < dataSet.getSeriesCount(); i++) {
        plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator());
    }
}