Example usage for java.awt BasicStroke JOIN_MITER

List of usage examples for java.awt BasicStroke JOIN_MITER

Introduction

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

Prototype

int JOIN_MITER

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

Click Source Link

Document

Joins path segments by extending their outside edges until they meet.

Usage

From source file:gui.QTLResultsPanel.java

private JPanel getChart(Trait trait) {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position (cM)", "LOD Score", null,
            PlotOrientation.VERTICAL, true, true, false);

    setChartData(chart, trait);/*from w w  w  .  j a v a 2  s.  co m*/

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    chart.setRenderingHints(rh);
    chart.removeLegend();

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(255, 255, 220));
    plot.setDomainGridlinePaint(new Color(128, 128, 128));
    plot.setRangeGridlinePaint(new Color(128, 128, 128));

    ValueAxis axis = plot.getRangeAxis();
    if (trait.maxLOD <= 3) {
        axis.setUpperBound(3);
    }

    PermResult result = trait.getPermResult();
    if (result != null) {
        float[] dashPattern = { 5, 5 };
        BasicStroke s1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0);

        ValueMarker m1 = new ValueMarker(result.getSig90(), new Color(0, 0, 60), s1, null, null, 1.0f);
        ValueMarker m2 = new ValueMarker(result.getSig95(), new Color(0, 0, 60), s1, null, null, 1.0f);

        plot.addRangeMarker(m1);
        plot.addRangeMarker(m2);

        if (result.getSig95() > trait.maxLOD && result.getSig95() >= 3) {
            axis.setUpperBound(result.getSig95() * (1.05));
        }
    }

    chartPanel = new ChartPanel(chart);
    chartPanel.setPopupMenu(null);
    return chartPanel;
}

From source file:ch.algotrader.client.chart.ChartTab.java

private void initTimeSeries(int datasetNumber, XYDataset dataset, SeriesDefinitionVO seriesDefinition) {

    IndicatorDefinitionVO indicatorDefinition = (IndicatorDefinitionVO) seriesDefinition;
    TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) dataset;

    // create the TimeSeries
    TimeSeries series = new TimeSeries(indicatorDefinition.getLabel());
    timeSeriesCollection.addSeries(series);
    this.indicators.put(indicatorDefinition.getName(), series);

    // get the seriesNumber & color
    final int seriesNumber = timeSeriesCollection.getSeriesCount() - 1;

    // configure the renderer
    final XYItemRenderer renderer = getPlot().getRenderer(datasetNumber);
    renderer.setSeriesPaint(seriesNumber, getColor(indicatorDefinition.getColor()));
    renderer.setSeriesVisible(seriesNumber, seriesDefinition.isSelected());
    renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

    if (seriesDefinition.isDashed()) {
        renderer.setSeriesStroke(seriesNumber, new BasicStroke(0.5f, BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f }, 0.0f));
    } else {//from w ww  . j  a  v a2 s .c o  m
        renderer.setSeriesStroke(seriesNumber, new BasicStroke(0.5f));
    }

    // add the menu item
    JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel());
    menuItem.setSelected(seriesDefinition.isSelected());
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetAxis();
            renderer.setSeriesVisible(seriesNumber, ((JCheckBoxMenuItem) e.getSource()).isSelected());
            initAxis();
        }
    });
    this.getPopupMenu().add(menuItem);
}

From source file:ch.algotrader.client.chart.ChartTab.java

private void initMarker(SeriesDefinitionVO seriesDefinition) {

    final MarkerDefinitionVO markerDefinition = (MarkerDefinitionVO) seriesDefinition;

    final Marker marker;
    if (markerDefinition.isInterval()) {
        marker = new IntervalMarker(0, 0);
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); // position of the label
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); // position of the text within the label
    } else {//  w  ww.  ja va2s  .co m
        marker = new ValueMarker(0);
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    }

    marker.setPaint(getColor(markerDefinition.getColor()));
    marker.setLabel(markerDefinition.getLabel());
    marker.setLabelFont(new Font("SansSerif", 0, 9));

    if (seriesDefinition.isDashed()) {
        marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 5.0f }, 0.0f));
    } else {
        marker.setStroke(new BasicStroke(1.0f));
    }

    getPlot().addRangeMarker(marker, markerDefinition.isInterval() ? Layer.BACKGROUND : Layer.FOREGROUND);

    this.markers.put(markerDefinition.getName(), marker);
    this.markersSelectionStatus.put(markerDefinition.getName(), seriesDefinition.isSelected());

    // add the menu item
    JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel());
    menuItem.setSelected(seriesDefinition.isSelected());
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetAxis();
            boolean selected = ((JCheckBoxMenuItem) e.getSource()).isSelected();
            ChartTab.this.markersSelectionStatus.put(markerDefinition.getName(), selected);
            if (selected) {
                if (marker instanceof ValueMarker) {
                    marker.setAlpha(1.0f);
                } else {
                    marker.setAlpha(0.5f);
                }
            } else {
                marker.setAlpha(0);
            }
            initAxis();
        }
    });
    this.getPopupMenu().add(menuItem);
}

From source file:jboost.visualization.HistogramFrame.java

private JFreeChart createHistogramChart() {

    XYBarRenderer renderer1 = new XYBarRenderer();
    renderer1.setSeriesPaint(0, Color.cyan);
    renderer1.setSeriesPaint(1, Color.pink);

    XYPlot histPlot = new XYPlot(histogramDataset, null, new NumberAxis("count"), renderer1);

    XYBarRenderer renderer2 = new XYBarRenderer();
    renderer2.setSeriesPaint(0, Color.green);
    renderer2.setSeriesPaint(1, Color.orange);
    renderer2.setUseYInterval(true);/*from  w ww .j  a  v  a 2s  . c o m*/

    // weight and potential
    if (infoParser.isRobustBoost || infoParser.isAdaBoost || infoParser.isLogLossBoost) {
        StandardXYItemRenderer renderer3 = new StandardXYItemRenderer();
        renderer3.setSeriesPaint(0, Color.blue);
        renderer3.setSeriesPaint(1, Color.red);
        renderer3.setBaseStroke(new BasicStroke(2));

        StandardXYItemRenderer renderer4 = new StandardXYItemRenderer();
        renderer4.setSeriesPaint(0, Color.blue);
        renderer4.setSeriesPaint(1, Color.red);
        renderer4.setBaseStroke(
                new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2, new float[] { 2 }, 0));

        histPlot.setDataset(1, weightDataset);
        histPlot.setRenderer(1, renderer3);

        histPlot.setDataset(2, potentialDataset);
        histPlot.setRenderer(2, renderer4);

        histPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    XYPlot fluctPlot = new XYPlot(fluctDataset, null, new NumberAxis("bin"), renderer2);

    double initialLocation = (upper_limit + lower_limit) / 2.0;
    histMarker = new IntervalMarker(initialLocation, initialLocation);
    histPlot.addDomainMarker(histMarker, Layer.BACKGROUND);
    fluctPlot.addDomainMarker(histMarker, Layer.BACKGROUND);

    // plot.setBackgroundPaint(Color.lightGray);
    // plot.setDomainGridlinePaint(Color.white);
    // plot.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(new NumberAxis("score"));
    combinedPlot.setGap(10.0);

    // add the subplots...
    ValueAxis axis = new NumberAxis();
    axis.setRange(rawData.getMinRange(iter), rawData.getMaxRange(iter));
    combinedPlot.add(histPlot, 3);
    combinedPlot.add(fluctPlot, 1);
    combinedPlot.setOrientation(PlotOrientation.VERTICAL);
    combinedPlot.setDomainAxis(axis);

    JFreeChart chart = new JFreeChart("Histogram", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, false // legend
    );

    return chart;
}

From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java

/**
 * Creates a chart displaying the distribution of certain selected statistical
 * values. Uses red for normal rooms and blue for cellar rooms.
 * //from  w  ww .  j a v a  2 s.  c  om
 * @param title
 *          The headline of the chart. Will be hidden if set to null.
 * @param statistics
 *          The selected statistics of a campaign containing all needed
 *          values.
 * @param roomType
 *          The room type to determine the colour of the chart.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the distribution of certain selected statistical
 *         values.
 */
public static JFreeChart createDistributionChart(String title, DescriptiveStatistics statistics,
        OMRoomType roomType, boolean preview) {
    Color lineColor = new Color(0, 0, 0, 128);
    Color rangeColor = new Color(222, 222, 222, 128);
    if (roomType == OMRoomType.Room) {
        lineColor = new Color(255, 0, 0, 128);
        rangeColor = new Color(255, 222, 222, 128);
    } else {
        if (roomType == OMRoomType.Cellar) {
            lineColor = new Color(0, 0, 255, 128);
            rangeColor = new Color(222, 222, 255, 128);
        } else {
            lineColor = new Color(0, 128, 0, 255);
            rangeColor = new Color(222, 255, 222, 128);
        }
    }
    double[] distValues = statistics.getSortedValues();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries distSeries = new XYSeries("Distribution");
    for (int i = 0; i < distValues.length; i++) {
        distSeries.add(distValues[i], (0.5 + (double) i) / (double) distValues.length);
    }
    dataSet.addSeries(distSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(title, "Rn [Bq/m\u00B3]", "F(emp)", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    float[] dash = { 5, 3 };
    int pos = 0;
    double y = (Double) distSeries.getY(pos);
    XYPointerAnnotation minPointer = new XYPointerAnnotation("MIN=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(minPointer);
    pos = (int) (((double) distValues.length / 100. * 5.0) - 1.0);
    while (pos < 0) {
        pos++;
    }
    if (pos > 0) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos + 1);
    }
    final double posQ5 = distValues[pos];
    XYPointerAnnotation q05Pointer = new XYPointerAnnotation("Q5=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q05Pointer);
    pos = (int) (((double) distValues.length / 2.0) - 1.0);
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation q50Pointer = new XYPointerAnnotation("Q50=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q50Pointer);
    ValueMarker medMarker = new ValueMarker(distValues[pos], lineColor,
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(medMarker);
    pos = (int) (((double) distValues.length / 100.0 * 95.0) - 1.0);
    if (pos < distValues.length - 1) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos - 1);
    }
    final double posQ95 = distValues[pos];
    XYPointerAnnotation q95Pointer = new XYPointerAnnotation("Q95=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(q95Pointer);
    pos = distValues.length - 1;
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation maxPointer = new XYPointerAnnotation("MAX=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(maxPointer);
    IntervalMarker percentiles = new IntervalMarker(posQ5, posQ95);
    percentiles.setPaint(rangeColor);
    percentiles.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(percentiles, Layer.BACKGROUND);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, lineColor);
    return chart;
}

From source file:edu.umn.ecology.populus.plot.BasicPlotInfo.java

private Stroke getLineStroke(int n) {
    JCChartStyle jccs = getChartStyle(n);
    return new BasicStroke((float) jccs.getLineWidth(), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
            getDashArray(jccs.getLinePattern()), 0.0f);
}

From source file:com.planetmayo.debrief.satc_rcp.views.SpatialView.java

private int plotTheseCoordsAsALine(String title, Coordinate[] coords) {
    int num = addSeries(title, coords);

    final float dash1[] = { 10f, 10f };
    final BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1,
            0.0f);// w w w.  j av a2 s .  c  om

    _renderer.setSeriesStroke(num, dashed);
    _renderer.setSeriesLinesVisible(num, true);
    _renderer.setSeriesShapesVisible(num, false);
    _renderer.setSeriesVisibleInLegend(num, false);

    return num;
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

/**
 *
 *//*from w ww  . j av  a 2s  .c om*/
protected JFreeChart createGanttChart() throws JRException {

    JFreeChart jfreeChart = super.createGanttChart();
    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    categoryPlot.setDomainGridlinesVisible(true);
    categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryPlot.setDomainGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);

    categoryPlot.setRangeGridlinesVisible(true);
    categoryPlot.setRangeGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
    categoryPlot.getDomainAxis().setTickLabelsVisible(
            //barPlot.isShowTickLabels()
            true);
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    barRenderer.setSeriesPaint(0, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3));
    barRenderer.setSeriesPaint(1, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0));
    CategoryDataset categoryDataset = categoryPlot.getDataset();
    if (categoryDataset != null) {
        for (int i = 0; i < categoryDataset.getRowCount(); i++) {
            barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
            barRenderer.setSeriesItemLabelsVisible(i, true);
        }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createGanttChart() throws JRException {

    JFreeChart jfreeChart = super.createGanttChart();
    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    categoryPlot.setDomainGridlinesVisible(true);
    categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryPlot.setDomainGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);

    categoryPlot.setRangeGridlinesVisible(true);
    categoryPlot.setRangeGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
    categoryPlot.getDomainAxis().setTickLabelsVisible(
            //barPlot.isShowTickLabels()
            true);// w  w w . j  a v  a 2s.  c  o m
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3));
    barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0));
    CategoryDataset categoryDataset = categoryPlot.getDataset();
    if (categoryDataset != null) {
        for (int i = 0; i < categoryDataset.getRowCount(); i++) {
            barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
            barRenderer.setSeriesItemLabelsVisible(i, true);
        }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
}

From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java

private StandardXYItemRenderer buildTrendLineRenderer(Color color) {
    StandardXYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setSeriesPaint(0, color);/*from w  w w.  j  a v  a  2  s . c  o  m*/
    float dash[] = { 2.0f };
    renderer.setSeriesStroke(0,
            new BasicStroke(0.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f));
    return renderer;
}