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

@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" })
public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase) 

Source Link

Document

Constructs a new BasicStroke with the specified attributes.

Usage

From source file:sanger.team16.gui.genevar.eqtl.snp.RegionalLinePlot.java

private JFreeChart createChart(String chromosome, int position, int distance, double threshold,
        XYDataset dataset) {/*from w  w  w  .j a  v  a  2 s .c o m*/
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position on chromosome " + chromosome + " (bp)",
            "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    //renderer.setShapesFilled(false);   //CHANGED 12/12/11
    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    /*       
           XYItemRenderer renderer = plot.getRenderer();  
           int size = dataset.getSeriesCount();
           for (int i=0 ; i<size ; i++) {
    //renderer.setSeriesPaint(i, new Color(255, 0, 0));
    renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
    renderer.setBaseSeriesVisibleInLegend(false);
           }
          */
    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(position - distance, -0.05);
    series.add(position + distance, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:com.github.errantlinguist.latticevisualiser.EdgeStrokeTransformer.java

@Override
public Stroke transform(final Edge edge) {
    // Edges are negative log probabilities
    final double probability = Math.pow(10, -edge.getWeight());
    final float weight = (float) probability * WEIGHT_FACTOR;
    // System.out.println(Float.toString(weight));
    Stroke stroke;// w  w  w .ja v a2  s .  com
    if (nonwords != null && nonwords.contains(edge.getOutputSymbol())) {
        stroke = new BasicStroke(weight, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, STROKE_DASH,
                0.0f);
    } else {
        stroke = new BasicStroke(weight);
    }

    return stroke;
}

From source file:edu.coeia.charts.LineChartPanel.java

/**
 * Creates a sample chart.//from w  w w .  j a  va 2 s  .c o  m
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("Frequency of Messages", // chart title
            "Time of Messages", // domain axis label
            "Number of Messages", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 10.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 6.0f }, 0.0f));

    return chart;
}

From source file:org.sonar.server.charts.deprecated.BaseChart.java

protected BasicStroke getDashedStroke(float width) {
    return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f },
            0.0f);//from w ww  .j av  a  2s . com
}

From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java

/**
 * This method should be called after a chart dataset is updated. It
 * will iterate over all XYDatasets and provide the line color and lineStyle.
 * If it is called before a chart has a dataset, it will not have an effect.
 *
 * @param plot//from  w  ww  .j  ava 2 s. c o m
 */
public void setXYPlotRenderer(XYPlot plot) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    int n = plot.getSeriesCount();

    for (int i = 0; i < n; i++) {
        Stroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                getLineStyle(i), 0.0f);
        renderer.setSeriesStroke(i, stroke);
        renderer.setSeriesPaint(i, getPaintColor(i));
    }
    renderer.setLegendLine(new Line2D.Double(0, 5, 40, 5));
    renderer.setBaseShapesFilled(false);
    renderer.setBaseShapesVisible(showMarkers);
    renderer.setDrawSeriesLineAsPath(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRenderer(renderer);
}

From source file:hudson.plugins.testlink.TestLinkGraph.java

/**
 * Creates TestLink trend graph./*from ww  w . ja v a2  s . com*/
 * 
 * @return the JFreeChart graph object.
 */
protected JFreeChart createGraph() {
    final JFreeChart chart = ChartFactory.createLineChart(null, null, yLabel, categoryDataset,
            PlotOrientation.VERTICAL, true, true, false);

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.8f);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.darkGray);

    final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);
    plot.setDomainAxis(domainAxis);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);
    rangeAxis.setAutoRangeMinimumSize(5);
    rangeAxis.setLowerBound(0);

    final CategoryItemRenderer renderer = plot.getRenderer();

    renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f,
            new float[] { 1.0f, 1.0f }, 0.0f));
    renderer.setSeriesPaint(0, new Color(35, 20, 89));

    renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f,
            new float[] { 1.0f, 1.0f }, 0.0f));
    renderer.setSeriesPaint(1, new Color(0, 145, 0));

    renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f,
            new float[] { 1.0f, 1.0f }, 0.0f));
    renderer.setSeriesPaint(2, new Color(207, 69, 21));

    renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f,
            new float[] { 1.0f, 1.0f }, 0.0f));
    renderer.setSeriesPaint(3, Color.orange);

    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    return chart;
}

From source file:playground.artemc.socialCost.SocialCostWriter.java

private ChartUtil getGraphic(String yAxisTitle, double[] meanData, double[] medianData, double[] quantil25Data,
        double[] quantil75Data) {

    double[] iterations = new double[iteration + 1];
    for (int i = 0; i <= iteration; i++) {
        iterations[i] = i;/*from www  .j a v  a2  s  .  c  om*/
    }

    XYLineChart chart = new XYLineChart("Social Costs", "iteration", yAxisTitle);
    chart.addSeries("mean", iterations, meanData);
    chart.addSeries("median", iterations, medianData);
    chart.addSeries("25% quantil", iterations, quantil25Data);
    chart.addSeries("75% qunatil", iterations, quantil75Data);

    XYPlot plot = chart.getChart().getXYPlot();
    plot.getRenderer().setSeriesPaint(0, Color.red);
    plot.getRenderer().setSeriesPaint(1, Color.blue);
    plot.getRenderer().setSeriesPaint(2, Color.blue);
    plot.getRenderer().setSeriesPaint(3, Color.blue);
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 8.0f, 4.0f }, 0.0f));
    plot.getRenderer().setSeriesStroke(3, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 2.0f, 4.0f }, 0.0f));

    chart.addMatsimLogo();

    return chart;
}

From source file:sanger.team16.gui.genevar.eqtl.gene.RegionalPlot.java

private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold,
        XYDataset dataset) {//from  w ww.  java 2  s  .  c o m
    JFreeChart chart = ChartFactory.createScatterPlot(null,
            "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.lightGray);
    //plot.setRangeCrosshairVisible(true);

    //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setRange(geneStart - distance, geneStart + distance);       
    //domainAxis.setUpperMargin(1000);
    //domainAxis.setLowerMargin(1000);

    //ValueAxis rangeAxis = plot.getRangeAxis();
    //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5);
    //rangeAxis.setLowerBound(0);

    XYItemRenderer renderer = plot.getRenderer();
    int size = dataset.getSeriesCount();
    for (int i = 0; i < size; i++) {
        //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4);
        //renderer.setSeriesPaint(i, new Color(255, scale, scale));

        renderer.setSeriesPaint(i, new Color(255, 0, 0));
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
        renderer.setBaseSeriesVisibleInLegend(false);
    }

    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);        
    //upperMarker.setLabel("-log10(10E-4)");
    //upperMarker.setLabelPaint(Color.red);
    //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(geneStart - distanceToTSS, -0.05);
    series.add(geneStart + distanceToTSS, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:sanger.team16.gui.genevar.mqtl.gene.RegionalPlot.java

private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold,
        XYDataset dataset) {/* ww w  .  java2 s  . c  om*/
    JFreeChart chart = ChartFactory.createScatterPlot(null,
            "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.lightGray);
    //plot.setRangeCrosshairVisible(true);

    //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setRange(geneStart - distance, geneStart + distance);       
    //domainAxis.setUpperMargin(1000);
    //domainAxis.setLowerMargin(1000);

    //ValueAxis rangeAxis = plot.getRangeAxis();
    //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5);
    //rangeAxis.setLowerBound(0);

    XYItemRenderer renderer = plot.getRenderer();
    int size = dataset.getSeriesCount();
    for (int i = 0; i < size; i++) {
        //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4);
        //renderer.setSeriesPaint(i, new Color(255, scale, scale));

        renderer.setSeriesPaint(i, new Color(50, 205, 50));
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
        renderer.setBaseSeriesVisibleInLegend(false);
    }

    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);        
    //upperMarker.setLabel("-log10(10E-4)");
    //upperMarker.setLabelPaint(Color.red);
    //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(geneStart - distanceToTSS, -0.05);
    series.add(geneStart + distanceToTSS, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

/**
 * @see ca.nengo.plot.Plotter#doPlot(ca.nengo.util.TimeSeries, ca.nengo.util.TimeSeries, java.lang.String)
 *//*from   ww w .ja va  2s. co m*/
public void doPlot(TimeSeries ideal, TimeSeries actual, String title) {
    XYSeriesCollection idealDataset = getDataset(ideal);
    XYSeriesCollection actualDataset = getDataset(actual);

    JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", idealDataset,
            PlotOrientation.VERTICAL, false, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDataset(1, actualDataset);

    XYLineAndShapeRenderer idealRenderer = new XYLineAndShapeRenderer(true, false);
    idealRenderer.setDrawSeriesLineAsPath(true);
    idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f,
            new float[] { 10f, 10f }, 0f));
    plot.setRenderer(plot.indexOf(idealDataset), idealRenderer);

    XYLineAndShapeRenderer actualRenderer = new XYLineAndShapeRenderer(true, false);
    actualRenderer.setDrawSeriesLineAsPath(true);
    //idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f, new float[]{10f, 10f}, 0f));
    plot.setRenderer(plot.indexOf(actualDataset), actualRenderer);

    showChart(chart, "Time Series Plot");
}