当前位置: 首页>>代码示例>>Java>>正文


Java CategoryAxis类代码示例

本文整理汇总了Java中org.jfree.chart.axis.CategoryAxis的典型用法代码示例。如果您正苦于以下问题:Java CategoryAxis类的具体用法?Java CategoryAxis怎么用?Java CategoryAxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CategoryAxis类属于org.jfree.chart.axis包,在下文中一共展示了CategoryAxis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawItem

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the bar for a single (series, category) data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the data area.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset dataset,
                     int row,
                     int column) {

     if (dataset instanceof IntervalCategoryDataset) {
         IntervalCategoryDataset d = (IntervalCategoryDataset) dataset;
         drawInterval(g2, state, dataArea, plot, domainAxis, rangeAxis, d, row, column);
     }
     else {
         super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column);
     } 
     
 }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:IntervalBarRenderer.java

示例2: calculateBarWidth

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateBarWidth(CategoryPlot plot, 
                                 Rectangle2D dataArea, 
                                 int rendererIndex,
                                 CategoryItemRendererState state) {

    // calculate the bar width
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset data = plot.getDataset(rendererIndex);
    if (data != null) {
        PlotOrientation orientation = plot.getOrientation();
        double space = 0.0;
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaxBarWidth();
        int columns = data.getColumnCount();
        double categoryMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }

        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
                                 - categoryMargin);
        if (columns > 0) {
            state.setBarWidth(Math.min(used / columns, maxWidth));
        }
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:StackedBarRenderer3D.java

示例3: drawItem

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the bar for a single (series, category) data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the data area.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset dataset,
                     int row,
                     int column) {

     if (dataset instanceof GanttCategoryDataset) {
         GanttCategoryDataset gcd = (GanttCategoryDataset) dataset;
         drawTasks(g2, state, dataArea, plot, domainAxis, rangeAxis, gcd, row, column);
     }
     else {  // let the superclass handle it...
         super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column);
     }
 
 }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:GanttRenderer.java

示例4: calculateItemWidth

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateItemWidth(CategoryPlot plot, 
                                  Rectangle2D dataArea, 
                                  int rendererIndex,
                                  CategoryItemRendererState state) {
                                     
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaxItemWidth();
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
                                 - categoryMargin - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
        }
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:LevelRenderer.java

示例5: drawItem

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the plot area.
 * @param plot  the plot.
 * @param domainAxis  the domain (category) axis.
 * @param rangeAxis  the range (value) axis.
 * @param data  the data.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset data,
                     int row,
                     int column) {

    PlotOrientation orientation = plot.getOrientation();
    if (orientation == PlotOrientation.HORIZONTAL) {
        drawHorizontalItem(g2, state, dataArea,
                           plot, domainAxis, rangeAxis, data, row, column);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawVerticalItem(g2, state, dataArea,
                         plot, domainAxis, rangeAxis, data, row, column);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:LayeredBarRenderer.java

示例6: createPlot

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainCategoryPlot createPlot() {
    
    CategoryDataset dataset1 = createDataset1();
    NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);
    
    CategoryDataset dataset2 = createDataset2();
    NumberAxis rangeAxis2 = new NumberAxis("Value");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Category");
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);
    return plot;
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:CombinedDomainCategoryPlotTests.java

示例7: add

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @param subplot  the subplot (<code>null</code> not permitted).
 * @param weight  the weight (must be >= 1).
 */
public void add(CategoryPlot subplot, int weight) {
    if (subplot == null) {
        throw new IllegalArgumentException("Null 'subplot' argument.");
    }
    if (weight < 1) {
        throw new IllegalArgumentException("Require weight >= 1.");
    }
    subplot.setParent(this);
    subplot.setWeight(weight);
    subplot.setInsets(new Insets(0, 0, 0, 0));
    subplot.setDomainAxis(null);
    subplot.setOrientation(getOrientation());
    subplot.addChangeListener(this);
    this.subplots.add(subplot);
    this.totalWeight += weight;
    CategoryAxis axis = getDomainAxis();
    if (axis != null) {
        axis.configure();
    }
    notifyListeners(new PlotChangeEvent(this));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:CombinedDomainCategoryPlot.java

示例8: setDomainAxis

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Sets a domain axis.
 *
 * @param index  the axis index.
 * @param axis  the axis.
 */
public void setDomainAxis(int index, CategoryAxis axis) {

    CategoryAxis existing = (CategoryAxis) this.domainAxes.get(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    if (axis != null) {
        axis.setPlot(this);
    }

    this.domainAxes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    notifyListeners(new PlotChangeEvent(this));

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:CategoryPlot.java

示例9: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        dataset.addValue(2.0, "S1", "C2");
        dataset.addValue(3.0, "S2", "C1");
        dataset.addValue(4.0, "S2", "C2");
        GroupedStackedBarRenderer renderer 
            = new GroupedStackedBarRenderer();
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:GroupedStackedBarRendererTests.java

示例10: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new LevelRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:LevelRendererTests.java

示例11: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset 
            = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),
                new Double(0.0), new Double(4.0), new Double(0.5), 
                new Double(4.5), new Double(-0.5), new Double(5.5), 
                null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new BoxAndWhiskerRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:BoxAndWhiskerRendererTests.java

示例12: drawDomainMarkers

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is 
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 * 
 * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, 
                                 int index, Layer layer) {
                                             
    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:CategoryPlot.java

示例13: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultStatisticalCategoryDataset dataset 
            = new DefaultStatisticalCategoryDataset();
        dataset.add(1.0, 2.0, "S1", "C1");
        dataset.add(3.0, 4.0, "S1", "C2");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new StatisticalBarRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:StatisticalBarRendererTests.java

示例14: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        double[][] starts = new double[][] {{0.1, 0.2, 0.3}, 
                {0.3, 0.4, 0.5}};
        double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}};
        DefaultIntervalCategoryDataset dataset 
            = new DefaultIntervalCategoryDataset(starts, ends);        
        IntervalBarRenderer renderer = new IntervalBarRenderer();
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:IntervalBarRendererTests.java

示例15: testDrawWithNullInfo

import org.jfree.chart.axis.CategoryAxis; //导入依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new MinMaxCategoryRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:MinMaxCategoryRendererTests.java


注:本文中的org.jfree.chart.axis.CategoryAxis类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。