當前位置: 首頁>>代碼示例>>Java>>正文


Java Layer類代碼示例

本文整理匯總了Java中org.jfree.ui.Layer的典型用法代碼示例。如果您正苦於以下問題:Java Layer類的具體用法?Java Layer怎麽用?Java Layer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Layer類屬於org.jfree.ui包,在下文中一共展示了Layer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createChart

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Creates a sample chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(IntervalXYDataset dataset,String s) {
    final JFreeChart chart = ChartFactory.createXYBarChart(
        "Histogram Plot: "+s,
        "Keyword index", 
        false,
        "frequency", 
        dataset,
        PlotOrientation.VERTICAL,
        true,
        true,
        false
    );
    
    XYPlot plot = (XYPlot) chart.getPlot();
    final IntervalMarker target = new IntervalMarker(400.0, 700.0);
    //target.setLabel("Target Range");
    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);
    return chart;    
}
 
開發者ID:Subarno,項目名稱:SentimentAnalysisJava,代碼行數:31,代碼來源:HistogramExample.java

示例2: drawDomainMarkers

import org.jfree.ui.Layer; //導入依賴的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).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, 
                                 Layer layer) {
                                             
    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxis(index);
    // TODO: get the axis that the renderer maps to
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:XYPlot.java

示例3: drawRangeMarkers

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Draws the range markers (if any) for a renderer 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).
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index,
                                Layer layer) {
                                             
    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxis(index);
    // TODO: get the axis that the renderer maps to
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:XYPlot.java

示例4: drawRangeMarkers

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Draws the range 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).
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index,
                                Layer layer) {
                                             
    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:CategoryPlot.java

示例5: addAnnotation

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Adds an annotation to the specified layer.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        notifyListeners(new RendererChangeEvent(this));
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        notifyListeners(new RendererChangeEvent(this));
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:AbstractXYItemRenderer.java

示例6: drawAnnotations

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            ValueAxis domainAxis,
                            ValueAxis rangeAxis,
                            Layer layer,
                            PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                0, info);
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:36,代碼來源:AbstractXYItemRenderer.java

示例7: drawDomainMarkers

import org.jfree.ui.Layer; //導入依賴的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).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }    
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:33,代碼來源:XYPlot.java

示例8: drawRangeMarkers

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Draws the range markers (if any) for a renderer 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).
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea,
                                int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:XYPlot.java

示例9: drawDomainMarkers

import org.jfree.ui.Layer; //導入依賴的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

示例10: drawRangeMarkers

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * Draws the range 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 #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, 
                                int index, Layer layer) {
                                             
    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:31,代碼來源:CategoryPlot.java

示例11: testSerialization4

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * This test ensures that a plot with markers is serialized correctly.
 */
@Test
public void testSerialization4() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createBarChart(
            "Test Chart", "Category Axis", "Value Axis",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.addRangeMarker(new ValueMarker(1.1), Layer.FOREGROUND);
    plot.addRangeMarker(new IntervalMarker(2.2, 3.3), Layer.BACKGROUND);
    JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart);
    assertEquals(chart, chart2);

    // now check that the chart is usable...
    try {
        chart2.createBufferedImage(300, 200);
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:24,代碼來源:CategoryPlotTest.java

示例12: testDomainMarkerIndices

import org.jfree.ui.Layer; //導入依賴的package包/類
@Test
public void testDomainMarkerIndices() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second x axis
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(1, "R1", "C1");
    plot.setDataset(99, dataset);    
    CategoryAxis xAxis2 = new CategoryAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);
    
    CategoryMarker xMarker1 = new CategoryMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:24,代碼來源:CategoryPlotTest.java

示例13: testSerialization4

import org.jfree.ui.Layer; //導入依賴的package包/類
/**
 * A test to reproduce a bug in serialization: the domain and/or range
 * markers for a plot are not being serialized.
 */
@Test
public void testSerialization4() {

    XYSeriesCollection dataset = new XYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart("Test Chart",
            "Domain Axis", "Range Axis", dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND);
    plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND);
    plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND);
    plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND);
    JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart);
    assertEquals(chart, chart2);
    try {
        chart2.createBufferedImage(300, 200);
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:25,代碼來源:XYPlotTest.java

示例14: testDomainMarkerIndices

import org.jfree.ui.Layer; //導入依賴的package包/類
@Test
public void testDomainMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second x axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);
    
    ValueMarker xMarker1 = new ValueMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:24,代碼來源:XYPlotTest.java

示例15: testRangeMarkerIndices

import org.jfree.ui.Layer; //導入依賴的package包/類
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);
    
    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:23,代碼來源:XYPlotTest.java


注:本文中的org.jfree.ui.Layer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。