Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:graficarfreechart.GraficarFreeChart.java

public GraficarFreeChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);//w w w.j  a va 2  s.c om
    setContentPane(chartPanel);
}

From source file:SpiderChartCustomizer.java

@Override
public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}

From source file:SyntheticData.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle, String xaxislabel, String yaxislabel,
        XYSeriesCollection dataset) throws IOException {

    super(applicationTitle);
    JFreeChart xylinechart = ChartFactory.createXYLineChart(chartTitle, xaxislabel, yaxislabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel cpanel = new ChartPanel(xylinechart);
    cpanel.setPreferredSize(new java.awt.Dimension(500, 500));
    final XYPlot xyplot = xylinechart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    xyplot.setRenderer(renderer);/*from   w w w  . j  a va 2s  .com*/
    setContentPane(cpanel);
    File saveImageFile = new File("" + applicationTitle + ".jpg");
    ChartUtilities.saveChartAsJPEG(saveImageFile, xylinechart, 1920, 1080);
}

From source file:cv.mikusher.freechart.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);//  w ww.  ja  v  a 2 s.  c om
    setContentPane(chartPanel);
}

From source file:net.sf.jasperreports.samples.spiderchartcomponent.SpiderChartCustomizer.java

public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}

From source file:org.drugis.addis.gui.LyndOBrienChartFactory.java

public static JFreeChart buildScatterPlot(LyndOBrienModel model) {
    XYDataset data = new ScatterPlotDataset(model);
    JFreeChart chart = ChartFactory.createScatterPlot("Benefit-Risk plane", model.getXAxisName(),
            model.getYAxisName(), data, PlotOrientation.VERTICAL, false, false, false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setUseOutlinePaint(true);//ww w. j  av  a  2  s .  com
    renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, 2.0, 4.0, 4.0));

    // draw lines through origin.
    chart.getXYPlot().setDomainZeroBaselineVisible(true);
    chart.getXYPlot().setRangeZeroBaselineVisible(true);

    // Explicitly set the stroke-width to avoid a rendering error in Linux
    Stroke stroke = new BasicStroke(1.0f);
    chart.getXYPlot().setDomainZeroBaselineStroke(stroke);
    return chart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 1", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    CategoryMarker categorymarker = new CategoryMarker("Category 4", Color.blue, new BasicStroke(1.0F));
    categorymarker.setDrawAsLine(true);/*from   www  .  j  av a 2 s  .com*/
    categorymarker.setLabel("Marker Label");
    categorymarker.setLabelFont(new Font("Dialog", 0, 11));
    categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D));
    categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND);
    return jfreechart;
}

From source file:evaluation.simulator.gui.results.LineJFreeChartCreator.java

/**
 * Creates a chart.//from  ww w  .j  a  v a 2  s  .c o  m
 * 
 * @param dataset
 *            the data for the chart.
 * 
 * @return a chart.
 */
private static JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYLineChart("Latency Mix Message", // chart title
            "BATCH_SIZE", // x axis label
            "ms", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // Spezial berschreiben des Aussehen der Striche im Graphen
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        private static final long serialVersionUID = 1L;
        Stroke soild = new BasicStroke(2.0f);

        @Override
        public Stroke getItemStroke(int row, int column) {
            return this.soild;
        }
    };

    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);

    return chart;

}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 1", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    Paint apaint[] = createPaint();
    CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint);
    customcylinderrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    customcylinderrenderer.setBaseOutlinePaint(Color.gray);
    customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F));
    customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    categoryplot.setRenderer(customcylinderrenderer);
    return jfreechart;
}

From source file:GeneralPathDemo.java

public void paintComponent(Graphics g) {
    // super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    if (firstTime) {
        Dimension dim = getSize();
        int w = dim.width;
        int h = dim.height;
        oddShape = createPath();/*  w ww .  j  a va  2s  .  c om*/
        area = new Rectangle(w, h);
        bi = (BufferedImage) createImage(w, h);
        big = bi.createGraphics();
        big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        firstTime = false;
    }

    // Clears the shape that was previously drawn.
    big.setColor(Color.white);
    big.fillRect(0, 0, area.width, area.height);

    big.setColor(Color.magenta);
    big.setStroke(new BasicStroke(3.0f));
    big.draw(oddShape);
    // Draws the buffered image to the screen.
    g2.drawImage(bi, 0, 0, this);

}