Java Code Examples for org.jfree.data.general.DatasetUtilities#isEmptyOrNull()

The following examples show how to use org.jfree.data.general.DatasetUtilities#isEmptyOrNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JGenProg2017_0081_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
    }
    return foundData;
    
}
 
Example 2
Source File: PolarPlot.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a representation of the data within the dataArea region, using the
 * current m_Renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param info  an optional object for collection dimension 
 *              information (<code>null</code> permitted).
 */
protected void render(Graphics2D g2,
                   Rectangle2D dataArea,
                   PlotRenderingInfo info) {
  
    // now get the data and plot it (the visual representation will depend
    // on the m_Renderer that has been set)...
    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        int seriesCount = this.dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            this.renderer.drawSeries(g2, dataArea, info, this, 
                    this.dataset, series);
        }
    }
    else {
        drawNoDataMessage(g2, dataArea);
    }
}
 
Example 3
Source File: PlotUtilities.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if all the datasets belonging to the specified
 * plot are empty or <code>null</code>, and <code>false</code> otherwise.
 *
 * @param plot  the plot (<code>null</code> permitted).
 *
 * @return A boolean.
 *
 * @since 1.0.7
 */
public static boolean isEmptyOrNull(XYPlot plot) {
    if (plot != null) {
        for (int i = 0, n = plot.getDatasetCount(); i < n; i++) {
            final XYDataset dataset = plot.getDataset(i);
            if (!DatasetUtilities.isEmptyOrNull(dataset)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 4
Source File: Chart_15_PiePlot_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing 
 *              (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState, PlotRenderingInfo info) {

    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }

    drawBackground(g2, area);
    drawOutline(g2, area);

    Shape savedClip = g2.getClip();
    g2.clip(area);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
            getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        drawPie(g2, area, info);
    }
    else {
        drawNoDataMessage(g2, area);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, area);

}
 
Example 5
Source File: PolarPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a representation of the data within the dataArea region, using the
 * current m_Renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param info  an optional object for collection dimension
 *              information (<code>null</code> permitted).
 */
protected void render(Graphics2D g2, Rectangle2D dataArea,
        PlotRenderingInfo info) {

    // now get the data and plot it (the visual representation will depend
    // on the m_Renderer that has been set)...
    boolean hasData = false;
    int datasetCount = this.datasets.size();
    for (int i = datasetCount - 1; i >= 0; i--) {
        XYDataset dataset = getDataset(i);
        if (dataset == null) {
            continue;
        }
        PolarItemRenderer renderer = getRenderer(i);
        if (renderer == null) {
            continue;
        }
        if (!DatasetUtilities.isEmptyOrNull(dataset)) {
            hasData = true;
            int seriesCount = dataset.getSeriesCount();
            for (int series = 0; series < seriesCount; series++) {
                renderer.drawSeries(g2, dataArea, info, this, dataset,
                        series);
            }
        }
    }
    if (!hasData) {
        drawNoDataMessage(g2, dataArea);
    }
}
 
Example 6
Source File: PiePlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing 
 *              (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState, PlotRenderingInfo info) {

    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }

    drawBackground(g2, area);
    drawOutline(g2, area);

    Shape savedClip = g2.getClip();
    g2.clip(area);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
            getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        drawPie(g2, area, info);
    }
    else {
        drawNoDataMessage(g2, area);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, area);

}
 
Example 7
Source File: PolarPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a representation of the data within the dataArea region, using the
 * current m_Renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param info  an optional object for collection dimension
 *              information (<code>null</code> permitted).
 */
protected void render(Graphics2D g2, Rectangle2D dataArea,
        PlotRenderingInfo info) {

    // now get the data and plot it (the visual representation will depend
    // on the m_Renderer that has been set)...
    boolean hasData = false;
    int datasetCount = this.datasets.size();
    for (int i = datasetCount - 1; i >= 0; i--) {
        XYDataset dataset = getDataset(i);
        if (dataset == null) {
            continue;
        }
        PolarItemRenderer renderer = getRenderer(i);
        if (renderer == null) {
            continue;
        }
        if (!DatasetUtilities.isEmptyOrNull(dataset)) {
            hasData = true;
            int seriesCount = dataset.getSeriesCount();
            for (int series = 0; series < seriesCount; series++) {
                renderer.drawSeries(g2, dataArea, info, this, dataset,
                        series);
            }
        }
    }
    if (!hasData) {
        drawNoDataMessage(g2, dataArea);
    }
}
 
Example 8
Source File: PlotUtilities.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if all the datasets belonging to the specified
 * plot are empty or <code>null</code>, and <code>false</code> otherwise.
 *
 * @param plot  the plot (<code>null</code> permitted).
 *
 * @return A boolean.
 *
 * @since 1.0.7
 */
public static boolean isEmptyOrNull(XYPlot plot) {
    if (plot != null) {
        for (int i = 0, n = plot.getDatasetCount(); i < n; i++) {
            final XYDataset dataset = plot.getDataset(i);
            if (!DatasetUtilities.isEmptyOrNull(dataset)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 9
Source File: PlotUtilities.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if all the datasets belonging to the specified
 * plot are empty or <code>null</code>, and <code>false</code> otherwise.
 *
 * @param plot  the plot (<code>null</code> permitted).
 *
 * @return A boolean.
 *
 * @since 1.0.7
 */
public static boolean isEmptyOrNull(XYPlot plot) {
    if (plot != null) {
        for (int i = 0, n = plot.getDatasetCount(); i < n; i++) {
            final XYDataset dataset = plot.getDataset(i);
            if (!DatasetUtilities.isEmptyOrNull(dataset)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 10
Source File: PolarPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a representation of the data within the dataArea region, using the
 * current m_Renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param info  an optional object for collection dimension
 *              information (<code>null</code> permitted).
 */
protected void render(Graphics2D g2, Rectangle2D dataArea,
        PlotRenderingInfo info) {

    // now get the data and plot it (the visual representation will depend
    // on the m_Renderer that has been set)...
    boolean hasData = false;
    int datasetCount = this.datasets.size();
    for (int i = datasetCount - 1; i >= 0; i--) {
        XYDataset dataset = getDataset(i);
        if (dataset == null) {
            continue;
        }
        PolarItemRenderer renderer = getRenderer(i);
        if (renderer == null) {
            continue;
        }
        if (!DatasetUtilities.isEmptyOrNull(dataset)) {
            hasData = true;
            int seriesCount = dataset.getSeriesCount();
            for (int series = 0; series < seriesCount; series++) {
                renderer.drawSeries(g2, dataArea, info, this, dataset,
                        series);
            }
        }
    }
    if (!hasData) {
        drawNoDataMessage(g2, dataArea);
    }
}
 
Example 11
Source File: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 12
Source File: CategoryPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(
            g2, dataArea, this, index, info
        );
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 13
Source File: Nopol2017_005_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 14
Source File: 1_CategoryPlot.java    From SimFix with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 15
Source File: Chart_14_CategoryPlot_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 16
Source File: jMutRepair_0021_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 17
Source File: Cardumen_006_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; (org.jfree.chart.plot.CategoryPlot.this.domainGridlinesVisible) != (drawSharedDomainAxis); pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}
 
Example 18
Source File: SpiderWebPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing.
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }

    drawBackground(g2, area);
    drawOutline(g2, area);

    Shape savedClip = g2.getClip();

    g2.clip(area);
    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        int seriesCount = 0, catCount = 0;

        if (this.dataExtractOrder == TableOrder.BY_ROW) {
            seriesCount = this.dataset.getRowCount();
            catCount = this.dataset.getColumnCount();
        }
        else {
            seriesCount = this.dataset.getColumnCount();
            catCount = this.dataset.getRowCount();
        }

        // ensure we have a maximum value to use on the axes
        if (this.maxValue == DEFAULT_MAX_VALUE)
            calculateMaxValue(seriesCount, catCount);

        // Next, setup the plot area

        // adjust the plot area by the interior spacing value

        double gapHorizontal = area.getWidth() * getInteriorGap();
        double gapVertical = area.getHeight() * getInteriorGap();

        double X = area.getX() + gapHorizontal / 2;
        double Y = area.getY() + gapVertical / 2;
        double W = area.getWidth() - gapHorizontal;
        double H = area.getHeight() - gapVertical;

        double headW = area.getWidth() * this.headPercent;
        double headH = area.getHeight() * this.headPercent;

        // make the chart area a square
        double min = Math.min(W, H) / 2;
        X = (X + X + W) / 2 - min;
        Y = (Y + Y + H) / 2 - min;
        W = 2 * min;
        H = 2 * min;

        Point2D  centre = new Point2D.Double(X + W / 2, Y + H / 2);
        Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H);

        // draw the axis and category label
        for (int cat = 0; cat < catCount; cat++) {
            double angle = getStartAngle()
                    + (getDirection().getFactor() * cat * 360 / catCount);

            Point2D endPoint = getWebPoint(radarArea, angle, 1);
                                                 // 1 = end of axis
            Line2D  line = new Line2D.Double(centre, endPoint);
            g2.setPaint(this.axisLinePaint);
            g2.setStroke(this.axisLineStroke);
            g2.draw(line);
            drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / catCount);
        }

        // Now actually plot each of the series polygons..
        for (int series = 0; series < seriesCount; series++) {
            drawRadarPoly(g2, radarArea, centre, info, series, catCount,
                    headH, headW);
        }
    }
    else {
        drawNoDataMessage(g2, area);
    }
    g2.setClip(savedClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, area);
}
 
Example 19
Source File: CategoryPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * @param crosshairState  a state object for tracking crosshair info
 *        (<code>null</code> permitted).
 *
 * @return A boolean that indicates whether or not real data was found.
 *
 * @since 1.0.11
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index,
        PlotRenderingInfo info, CategoryCrosshairState crosshairState) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {

        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        state.setCrosshairState(crosshairState);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this,
                                    domainAxis, rangeAxis, currentDataset,
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this,
                                    domainAxis, rangeAxis, currentDataset,
                                    row, column, pass);
                        }
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this,
                                    domainAxis, rangeAxis, currentDataset,
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this,
                                    domainAxis, rangeAxis, currentDataset,
                                    row, column, pass);
                        }
                    }
                }
            }
        }
    }
    return foundData;

}
 
Example 20
Source File: JGenProg2017_0081_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Draws a representation of a dataset within the dataArea region using the
 * appropriate renderer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param index  the dataset and renderer index.
 * @param info  an optional object for collection dimension information.
 * 
 * @return A boolean that indicates whether or not real data was found.
 */
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, 
                      PlotRenderingInfo info) {

    boolean foundData = false;
    CategoryDataset currentDataset = getDataset(index);
    CategoryItemRenderer renderer = getRenderer(index);
    CategoryAxis domainAxis = getDomainAxisForDataset(index);
    ValueAxis rangeAxis = getRangeAxisForDataset(index);
    boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset);
    if (hasData && renderer != null) {
        
        foundData = true;
        CategoryItemRendererState state = renderer.initialise(g2, dataArea,
                this, index, info);
        int columnCount = currentDataset.getColumnCount();
        int rowCount = currentDataset.getRowCount();
        int passCount = renderer.getPassCount();
        for (int pass = 0; pass < passCount; pass++) {            
            if (this.columnRenderingOrder == SortOrder.ASCENDING) {
                for (int column = 0; column < columnCount; column++) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
            else {
                for (int column = columnCount - 1; column >= 0; column--) {
                    if (this.rowRenderingOrder == SortOrder.ASCENDING) {
                        for (int row = 0; row < rowCount; row++) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }
                    }
                    else {
                        for (int row = rowCount - 1; row >= 0; row--) {
                            renderer.drawItem(g2, state, dataArea, this, 
                                    domainAxis, rangeAxis, currentDataset, 
                                    row, column, pass);
                        }                        
                    }
                }
            }
        }
    }
    return foundData;
    
}