Example usage for java.awt BasicStroke JOIN_ROUND

List of usage examples for java.awt BasicStroke JOIN_ROUND

Introduction

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

Prototype

int JOIN_ROUND

To view the source code for java.awt BasicStroke JOIN_ROUND.

Click Source Link

Document

Joins path segments by rounding off the corner at a radius of half the line width.

Usage

From source file:TextLayoutWithCarets.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

    if (mInitialized == false)
        initialize(g2);/*from  www.j av a2s. c  o m*/

    float x = 20, y = 80;
    mLayout.draw(g2, x, y);

    // Create a plain stroke and a dashed stroke.
    Stroke[] caretStrokes = new Stroke[2];
    caretStrokes[0] = new BasicStroke();
    caretStrokes[1] = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0, new float[] { 4, 4 },
            0);

    // Now draw the carets
    Shape[] carets = mLayout.getCaretShapes(mHit.getInsertionIndex());
    for (int i = 0; i < carets.length; i++) {
        if (carets[i] != null) {
            AffineTransform at = AffineTransform.getTranslateInstance(x, y);
            Shape shape = at.createTransformedShape(carets[i]);
            g2.setStroke(caretStrokes[i]);
            g2.draw(shape);
        }
    }
}

From source file:org.altusmetrum.altosuilib_2.AltosUITime.java

public AltosUISeries(String label, int fetch, AltosUnits units, Color color, boolean enable, AltosUIAxis axis) {
    super(label);
    this.label = label;
    this.fetch = fetch;
    this.units = units;
    this.color = color;
    this.enable = enable;
    this.axis = axis;

    axis.ref(this.enable);

    renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setSeriesPaint(0, color);//from ww  w  .  j  a v a  2  s  .c om
    renderer.setSeriesStroke(0, new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    renderer.setSeriesVisible(0, enable);
    set_units();
}

From source file:sturesy.votinganalysis.TimeChart.java

/**
 * Creates an XYSeries-ChartPanel/*from w ww. j  a v a 2  s  .c o  m*/
 * 
 * @param votes
 *            votes to use
 * @return ChartPanel
 */
private ChartPanel getXYSeriesChart(Set<Vote> votes) {

    final XYSeries series = new XYSeries(Localize.getString("label.votes.over.time"));

    if (votes.size() != 0) {
        double[] dubble = createArrayOfVotes(votes);

        for (int i = 0; i < dubble.length; i++) {
            series.add(i, dubble[i]);
        }
    }
    final XYSeriesCollection data = new XYSeriesCollection(series);

    final JFreeChart chart = ChartFactory.createXYLineChart(Localize.getString("label.votes.over.time"),
            Localize.getString("label.time.seconds"), Localize.getString("label.amount.votes"), data,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(_background);
    chart.getPlot().setNoDataMessage("NO DATA");

    chart.getXYPlot().getRenderer().setSeriesStroke(0,
            new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f));
    chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(255, 140, 0));

    chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartPanel chartpanel = new ChartPanel(chart);
    return chartpanel;
}

From source file:de.perdian.apps.dashboard.mvc.modules.jira.JiraController.java

@RequestMapping(value = "/jira/burndown/")
@ResponseBody// w ww. java2 s  .  c om
JiraControllerResponse doBurndown(@ModelAttribute JiraControllerRequest controllerRequest) {

    BurndownDto burndownDto = this.getJiraService().loadBurndown(controllerRequest.getRapidViewId(),
            controllerRequest.getBurndownBasis(), controllerRequest.getStoryPointFieldName());

    // We want to have twenty lines at maximum, so let's adjust the steps
    // accordingly
    double maxSteps = 20;
    double incrementPerStep = burndownDto.getStoryPointsTotal() / maxSteps;
    int increment = (int) Math.max(1, Math.ceil(incrementPerStep));
    TickUnits rangeTickUnits = new TickUnits();
    for (int i = 0; i < burndownDto.getStoryPointsTotal(); i += increment) {
        rangeTickUnits.add(new NumberTickUnit(i + 1));
    }

    TickUnits domainTickUnits = new TickUnits();
    domainTickUnits.add(new NumberTickUnit(burndownDto.getDays().size() + 1));

    ChartCreator chartCreator = new ChartCreator(controllerRequest);
    chartCreator.setTitle(controllerRequest.getTitle());
    chartCreator.setDomainTickUnits(domainTickUnits);
    chartCreator.setRangeTickUnits(rangeTickUnits);
    chartCreator
            .addStrokeDefinition(new ChartStrokeDefinition(new BasicStroke(7f), chartCreator.getColor(), null));
    chartCreator.addStrokeDefinition(new ChartStrokeDefinition(null, null, false));
    chartCreator.addStrokeDefinition(new ChartStrokeDefinition(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f), chartCreator.getColor(), null));
    chartCreator.setRangeAxisLabel(
            "worklog".equalsIgnoreCase(controllerRequest.getBurndownBasis()) ? "Worklog (Hours)"
                    : "Storypoints");

    JiraControllerResponse controllerResponse = new JiraControllerResponse();
    controllerResponse.setBurndown(burndownDto);
    controllerResponse.setImageContent(chartCreator.createChartAsImageContent(burndownDto.toDataset()));
    return controllerResponse;

}

From source file:org.azrul.langmera.LineChart.java

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), // chart title
            "Number of messages", // x axis label
            "Value of actions", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 10.0f, 6.0f }, 0.0f));
    }

    return chart;

}

From source file:org.n52.io.type.quantity.handler.img.LineRenderer.java

private BasicStroke getDashedLineDefinition(LineStyle lineStyle) {
    int width = lineStyle.getDashGapWidth();
    float[] dashSequence = new float[] { 4.0f * width, 4.0f * width };
    return new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashSequence, 0.0f);
}

From source file:GeMSE.Visualization.ElbowPlot.java

public void Plot(ArrayList<Double[]> pvData, ArrayList<Double[]> dData, int cut) {
    double maxY = 0;

    float[] secYColor = new float[3];
    Color.RGBtoHSB(153, 245, 255, secYColor);

    float[] priYColor = new float[3];
    Color.RGBtoHSB(255, 255, 255, priYColor);

    float[] cutColor = new float[3];
    Color.RGBtoHSB(255, 255, 0, cutColor);

    //create the series - add some dummy data
    XYSeries pvSeries = new XYSeries("Percentage of variance        ");
    for (int i = 1; i < pvData.size(); i++) {
        pvSeries.add(pvData.get(i)[0], pvData.get(i)[1]);
        maxY = Math.max(maxY, pvData.get(i)[1]);
    }/*from w  w w  .j a v a 2s.co m*/

    XYSeries dSeries = new XYSeries("Percentage of differences between slopes        ");
    for (int i = 0; i < dData.size(); i++)
        dSeries.add(dData.get(i)[0], dData.get(i)[1]);

    XYSeries cutSeries = new XYSeries("Cut        ");
    cutSeries.add(cut, 0.0);
    cutSeries.add(cut, maxY);

    //create the datasets
    XYSeriesCollection pvDataSeries = new XYSeriesCollection();
    pvDataSeries.addSeries(pvSeries);

    XYSeriesCollection cutDataSeries = new XYSeriesCollection();
    cutDataSeries.addSeries(cutSeries);

    XYSeriesCollection dDataSeries = new XYSeriesCollection();
    dDataSeries.addSeries(dSeries);

    //construct the plot
    XYPlot plot = new XYPlot();
    plot.setDataset(0, pvDataSeries);
    plot.setDataset(1, cutDataSeries);
    plot.setDataset(2, dDataSeries);

    // use XYSplineRenderer if you want to smooth the lines.
    XYLineAndShapeRenderer pvRenderer = new XYLineAndShapeRenderer();
    pvRenderer.setSeriesPaint(0, Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));

    BasicStroke dstroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 1.0f, 10.0f }, 0.0f);
    XYLineAndShapeRenderer dRenderer = new XYLineAndShapeRenderer();
    dRenderer.setSeriesPaint(0, Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    dRenderer.setSeriesStroke(0, dstroke);

    BasicStroke cutStoke = new BasicStroke(4);
    // use XYSplineRenderer if you want to smooth the lines.
    //XYSplineRenderer cutRenderer = new XYSplineRenderer();
    XYLineAndShapeRenderer cutRenderer = new XYLineAndShapeRenderer();
    cutRenderer.setSeriesPaint(0, Color.getHSBColor(cutColor[0], cutColor[1], cutColor[2]));
    cutRenderer.setSeriesStroke(0, cutStoke);

    plot.setRenderer(0, pvRenderer);
    plot.setRenderer(1, cutRenderer);
    plot.setRenderer(2, dRenderer);

    plot.setRangeAxis(0, new NumberAxis("\n\nPercentage of Variance"));
    plot.setRangeAxis(1, new NumberAxis("Percentage of Difference Between Slopes"));
    plot.setDomainAxis(new NumberAxis("Number of Clusters\n\n"));

    //Map the data to the appropriate axis
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToRangeAxis(1, 0);
    plot.mapDatasetToRangeAxis(2, 1);

    float[] hsbValues = new float[3];
    Color.RGBtoHSB(16, 23, 67, hsbValues);
    plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2]));

    Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14);
    Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12);
    Font legendFont = new Font("Dialog", Font.PLAIN, 14);

    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);

    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setLabelFont(axisLabelFont);
    plot.getDomainAxis().setTickLabelFont(axisTickLabelFont);

    plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));
    plot.getRangeAxis().setLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));
    plot.getRangeAxis().setLabelFont(axisLabelFont);
    plot.getRangeAxis().setTickLabelFont(axisTickLabelFont);

    plot.getRangeAxis(1).setTickLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    plot.getRangeAxis(1).setLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    plot.getRangeAxis(1).setLabelFont(axisLabelFont);
    plot.getRangeAxis(1).setTickLabelFont(axisTickLabelFont);

    //generate the chart
    JFreeChart chart = new JFreeChart("\nSuggested number of clusters determined using Elbow method", getFont(),
            plot, true);

    chart.getTitle().setPaint(Color.white);
    chart.getLegend().setBackgroundPaint(Color.black);
    chart.getLegend().setItemPaint(Color.white);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    chart.getLegend().setItemFont(legendFont);

    float[] hsbValues2 = new float[3];
    Color.RGBtoHSB(36, 43, 87, hsbValues2);
    chart.setBackgroundPaint(Color.getHSBColor(hsbValues2[0], hsbValues2[1], hsbValues2[2]));
    JPanel chartPanel = new ChartPanel(chart);

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    chartPanel.setPreferredSize(
            new java.awt.Dimension((int) Math.round((gd.getDisplayMode().getWidth() * 1.5) / 3.0),
                    (int) Math.round((gd.getDisplayMode().getHeight() * 1.5) / 3.0)));

    setContentPane(chartPanel);
}

From source file:org.encog.workbench.dialogs.activation.EquationPanel.java

/**
 * Creates a line chart using the data from the supplied dataset.
 *
 * @param dataset  the dataset./* w  w w.j ava2 s .co  m*/
 *
 * @return The chart.
 */
public static JFreeChart createChart(XYDataset dataset, ActivationFunction activation, boolean normal) {

    String title;

    if (normal) {
        title = activation.getClass().getSimpleName();
    } else {
        if (activation.hasDerivative()) {
            title = "Derv of " + activation.getClass().getSimpleName();
        } else {
            title = "NO Derv of " + activation.getClass().getSimpleName();
        }
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, "input (x)", "output (y)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    if (normal) {

        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainPannable(true);
        plot.setRangePannable(true);
        ValueAxis xAxis = plot.getDomainAxis();
        xAxis.setLowerMargin(0.0);
        xAxis.setUpperMargin(0.0);
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        r.setDrawSeriesLineAsPath(true);
        r.setSeriesStroke(0, new BasicStroke(1.5f));
        r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f }, 0.0f));
        r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f));
        r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 4.0f, 4.0f }, 0.0f));
    }

    return chart;
}

From source file:net.imglib2.script.analysis.BarChart.java

static private void setBackgroundDefault(final JFreeChart chart) {
    BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 1.0f }, 0.0f);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeGridlineStroke(gridStroke);
    plot.setDomainGridlineStroke(gridStroke);
    plot.setBackgroundPaint(new Color(235, 235, 235));
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setOutlineVisible(false);/* ww  w  .  j  a  va 2 s.c  om*/
    plot.getDomainAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getDomainAxis().setLabelPaint(Color.gray);
    plot.getRangeAxis().setLabelPaint(Color.gray);
    plot.getDomainAxis().setTickLabelPaint(Color.gray);
    plot.getRangeAxis().setTickLabelPaint(Color.gray);
    chart.getTitle().setPaint(Color.gray);
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.TimeChartRenderer.java

public void createChart() {
    XYDataset dataset = (XYDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createTimeSeriesChart(this.datasetStrategy.getTitle(), // title
            this.datasetStrategy.getXAxisLabel(), // x-axis label
            this.datasetStrategy.getYAxisLabel(), // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//from  w  w w  .j  a va2s .  c om

    // report.setBackgroundPaint( Color.lightGray );
    XYPlot plot = report.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    XYItemRenderer xyitemrenderer = plot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyitemrenderer;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);

        renderer.setBaseShapesVisible(true);
        renderer.setDrawOutlines(true);
        renderer.setBaseItemLabelGenerator(
                ((AbstractTimeChartStrategy) this.datasetStrategy).getLabelGenerator());
        renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, 10));
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT));
    }

    Paint[] paints = this.datasetStrategy.getPaintColor();
    for (int i = 0; i < dataset.getSeriesCount() && i < paints.length; i++) {
        xyitemrenderer.setSeriesPaint(i, paints[i]);
        xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    }
    plot.setRangeAxis(((AbstractTimeChartStrategy) this.datasetStrategy).getRangeAxis());
    DashDateAxis axisDate = new DashDateAxis();
    axisDate.setDateFormatOverride(
            ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod().getDateFormat());
    axisDate.setLabel(this.datasetStrategy.getXAxisLabel());
    axisDate.setTickUnit(getTickUnit(((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod()));
    axisDate.setUpperMargin(0.0D);
    axisDate.setDateTickLabelAngle(-0.6);

    if (((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate() != null
            && ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate() != null) {
        axisDate.setRangeWithMargins(
                new DateRange(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(),
                        ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate()));

    }
    plot.setDomainAxis(axisDate);

    Date[] dates = DateUtils.getAllDates(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(),
            ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate(),
            ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod());
    int width = (dates.length * ChartUtils.STANDARD_TIME_ENTRY_WIDTH)
            + ChartUtils.STANDARD_TIME_ADDITIONAL_WIDTH;
    if (width > ChartUtils.MINIMUM_WIDTH) {
        this.setWidth(width);
    } else {
        this.setWidth(ChartUtils.MINIMUM_WIDTH);
    }
}