Example usage for java.awt BasicStroke CAP_BUTT

List of usage examples for java.awt BasicStroke CAP_BUTT

Introduction

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

Prototype

int CAP_BUTT

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

Click Source Link

Document

Ends unclosed subpaths and dash segments with no added decoration.

Usage

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

/**
 *
 *///from   w  w  w. ja va  2  s  .  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);/*  ww  w  .j a  v  a  2  s  .c  om*/
    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 a2  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;
}

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

private void plotCurrentTopRoutes(List<CompositeRoute> _currentRoutes) {
    float width = 1.0f;
    for (CompositeRoute route : _currentRoutes) {
        Color currentColor = Color.BLACK;
        for (CoreRoute routePart : route.getLegs()) {
            Point startP = routePart.getStartPoint();
            Point endP = routePart.getEndPoint();

            XYSeries series = new XYSeries("" + (_numCycles++), false);
            series.add(new XYDataItem(startP.getY(), startP.getX()));
            series.add(new XYDataItem(endP.getY(), endP.getX()));

            // get the shape
            _myData.addSeries(series);/*from   ww w.j  a  va 2s. com*/

            // get the series num
            int num = _myData.getSeriesCount() - 1;
            _renderer.setSeriesPaint(num, currentColor);
            _renderer.setSeriesStroke(num, new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                    1.0f, new float[] { 4.f, width }, 0.0f), false);
            _renderer.setSeriesLinesVisible(num, true);
            _renderer.setSeriesShapesVisible(num, false);
        }
    }
}

From source file:lucee.runtime.img.Image.java

public void setDrawingStroke(Struct attr) throws PageException {

    // empty /*  www.j a v a  2s. c  o  m*/
    if (attr == null || attr.size() == 0) {
        setDrawingStroke(new BasicStroke());
        return;
    }

    // width
    float width = Caster.toFloatValue(attr.get("width", new Float(1F)));
    if (width < 0)
        throw new ExpressionException("key [width] should be a none negativ number");

    // endcaps
    String strEndcaps = Caster.toString(attr.get("endcaps", "square"));
    strEndcaps = strEndcaps.trim().toLowerCase();
    int endcaps;
    if ("square".equals(strEndcaps))
        endcaps = BasicStroke.CAP_SQUARE;
    else if ("butt".equals(strEndcaps))
        endcaps = BasicStroke.CAP_BUTT;
    else if ("round".equals(strEndcaps))
        endcaps = BasicStroke.CAP_ROUND;
    else
        throw new ExpressionException("key [endcaps] has an invalid value [" + strEndcaps
                + "], valid values are [square,round,butt]");

    // linejoins
    String strLinejoins = Caster.toString(attr.get("linejoins", "miter"));
    strLinejoins = strLinejoins.trim().toLowerCase();
    int linejoins;
    if ("bevel".equals(strLinejoins))
        linejoins = BasicStroke.JOIN_BEVEL;
    else if ("miter".equals(strLinejoins))
        linejoins = BasicStroke.JOIN_MITER;
    else if ("round".equals(strLinejoins))
        linejoins = BasicStroke.JOIN_ROUND;
    else
        throw new ExpressionException("key [linejoins] has an invalid value [" + strLinejoins
                + "], valid values are [bevel,miter,round]");

    // miterlimit
    float miterlimit = 10.0F;
    if (linejoins == BasicStroke.JOIN_MITER) {
        miterlimit = Caster.toFloatValue(attr.get("miterlimit", new Float(10F)));
        if (miterlimit < 1F)
            throw new ExpressionException("key [miterlimit] should be greater or equal to 1");
    }

    // dashArray
    Object oDashArray = attr.get("dashArray", null);
    float[] dashArray = null;
    if (oDashArray != null) {
        dashArray = ArrayUtil.toFloatArray(oDashArray);
    }

    // dash_phase
    float dash_phase = Caster.toFloatValue(attr.get("dash_phase", new Float(0F)));

    setDrawingStroke(width, endcaps, linejoins, miterlimit, dashArray, dash_phase);
}

From source file:weka.classifiers.timeseries.eval.graph.JFreeChartDriver.java

protected JFreeChart getFutureForecastChart(TSForecaster forecaster, List<List<NumericPrediction>> preds,
        List<String> targetNames, Instances history) {

    if (forecaster instanceof TSLagUser && history != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (lagMaker.getAdjustForTrends() && !lagMaker.isUsingAnArtificialTimeIndex()) {

            // fill in any missing time stamps only
            history = new Instances(history);
            history = weka.classifiers.timeseries.core.Utils.replaceMissing(history, null,
                    lagMaker.getTimeStampField(), true, lagMaker.getPeriodicity(), lagMaker.getSkipEntries());
        }/*from  www . j av a  2 s  . c  om*/
    }

    // set up a collection of series
    XYIntervalSeriesCollection xyDataset = new XYIntervalSeriesCollection();

    if (history != null) {
        // add actual historical data values
        for (String targetName : targetNames) {
            XYIntervalSeries targetSeries = new XYIntervalSeries(targetName, false, false);
            xyDataset.addSeries(targetSeries);
        }
    }

    // add predicted series
    for (String targetName : targetNames) {
        XYIntervalSeries targetSeries = new XYIntervalSeries(targetName + "-predicted", false, false);
        xyDataset.addSeries(targetSeries);
    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    double artificialTimeStart = 0;
    double lastRealTimeValue = Utils.missingValue();
    if (forecaster instanceof TSLagUser && history != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (!lagMaker.isUsingAnArtificialTimeIndex() && lagMaker.getAdjustForTrends()) {
            String timeName = lagMaker.getTimeStampField();
            if (history.attribute(timeName).isDate()) {
                timeAxis = new DateAxis("");
                timeAxisIsDate = true;
                timeIndex = history.attribute(timeName).index();
            }
        } else {
            try {
                artificialTimeStart = (history != null) ? 1 : lagMaker.getArtificialTimeStartValue() + 1;
            } catch (Exception ex) {
            }
        }
    }

    if (timeAxis == null) {
        timeAxis = new NumberAxis("");
        ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    boolean hasConfidenceIntervals = false;

    // now populate the series
    if (history != null) {

        // do the actuals first
        for (int i = 0; i < history.numInstances(); i++) {
            Instance current = history.instance(i);

            for (String targetName : targetNames) {
                int dataIndex = history.attribute(targetName.trim()).index();

                if (dataIndex >= 0) {
                    XYIntervalSeries actualSeries = null;
                    int actualIndex = xyDataset.indexOf(targetName);
                    actualSeries = xyDataset.getSeries(actualIndex);
                    double x = Utils.missingValue();

                    if (timeAxisIsDate) {
                        x = current.value(timeIndex);
                        if (!Utils.isMissingValue(x)) {
                            lastRealTimeValue = x;
                        }
                    } else {
                        x = artificialTimeStart;
                    }

                    double y = Utils.missingValue();
                    y = current.value(dataIndex);

                    if (!Utils.isMissingValue(x) && !Utils.isMissingValue(y)) {
                        if (actualSeries != null) {
                            actualSeries.add(x, x, x, y, y, y);
                        }
                    }
                }
            }

            if (!timeAxisIsDate) {
                artificialTimeStart++;
            }
        }
    }

    // now do the futures
    List<String> forecasterTargets = AbstractForecaster.stringToList(forecaster.getFieldsToForecast());

    // loop over the steps
    for (int j = 0; j < preds.size(); j++) {
        List<NumericPrediction> predsForStepJ = preds.get(j);

        // advance the real time index (if appropriate)
        if (timeAxisIsDate) {
            lastRealTimeValue = ((TSLagUser) forecaster).getTSLagMaker()
                    .advanceSuppliedTimeValue(lastRealTimeValue);
        }
        for (String targetName : targetNames) {

            // look up this requested target in the list that the forecaster
            // has predicted
            int predIndex = forecasterTargets.indexOf(targetName.trim());
            if (predIndex >= 0) {
                NumericPrediction predsForTargetAtStepJ = predsForStepJ.get(predIndex);
                XYIntervalSeries predSeries = null;
                int datasetIndex = xyDataset.indexOf(targetName + "-predicted");
                predSeries = xyDataset.getSeries(datasetIndex);

                if (predSeries != null) {
                    double y = predsForTargetAtStepJ.predicted();
                    double x = Utils.missingValue();
                    double yHigh = y;
                    double yLow = y;
                    double[][] conf = predsForTargetAtStepJ.predictionIntervals();
                    if (conf.length > 0) {
                        yLow = conf[0][0];
                        yHigh = conf[0][1];
                        hasConfidenceIntervals = true;
                    }

                    if (!timeAxisIsDate) {
                        x = artificialTimeStart;
                    } else {
                        x = lastRealTimeValue;
                    }

                    if (!Utils.isMissingValue(x) && !Utils.isMissingValue(y)) {
                        predSeries.add(x, x, x, y, yLow, yHigh);
                    }
                }
            }
        }

        // advance the artificial time index (if appropriate)
        if (!timeAxisIsDate) {
            artificialTimeStart++;
        }
    }

    String title = "Future forecast for: ";
    for (String s : targetNames) {
        title += s + ",";
    }
    title = title.substring(0, title.lastIndexOf(","));

    /*
     * String algoSpec = forecaster.getAlgorithmName(); title += " (" + algoSpec
     * + ")";
     */

    if (forecaster instanceof WekaForecaster && hasConfidenceIntervals) {
        double confPerc = ((WekaForecaster) forecaster).getConfidenceLevel() * 100.0;
        title += " [" + Utils.doubleToString(confPerc, 0) + "% conf. intervals]";
    }

    XYErrorRenderer renderer = new XYErrorRenderer();

    // renderer.setShapesFilled(true);
    XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, renderer);
    // renderer = (XYErrorRenderer)plot.getRenderer();
    if (history != null) {
        for (String targetName : targetNames) {
            XYIntervalSeries predSeries = null;
            int predIndex = xyDataset.indexOf(targetName + "-predicted");
            predSeries = xyDataset.getSeries(predIndex);

            XYIntervalSeries actualSeries = null;
            int actualIndex = xyDataset.indexOf(targetName);
            actualSeries = xyDataset.getSeries(actualIndex);

            if (actualSeries != null && predSeries != null) {
                // match the color of the actual series
                java.awt.Paint actualPaint = renderer.lookupSeriesPaint(actualIndex);
                renderer.setSeriesPaint(predIndex, actualPaint);

                // now set the line style to dashed
                BasicStroke dashed = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                        new float[] { 5.0f }, 0.0f);

                renderer.setSeriesStroke(predIndex, dashed);
            }
        }
    }

    renderer.setBaseLinesVisible(true);
    renderer.setDrawXError(false);
    renderer.setDrawYError(true);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(java.awt.Color.white);
    TextTitle chartTitle = chart.getTitle();
    String fontName = chartTitle.getFont().getFontName();
    java.awt.Font newFont = new java.awt.Font(fontName, java.awt.Font.PLAIN, 12);
    chartTitle.setFont(newFont);

    return chart;
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

private static BasicStroke toStroke(int style) {
    BasicStroke result = null;//from  w  ww .j  ava2s. com

    float lineWidth = 1.5f;
    float dash[] = { 5.0f };
    float dot[] = { lineWidth };

    if (style == STYLE_LINE) {
        result = new BasicStroke(lineWidth);
    } else if (style == STYLE_DASH) {
        result = new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else if (style == STYLE_DOT) {
        result = new BasicStroke(lineWidth * 2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2.0f, dot, 0.0f);
    }
    return result;
}

From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java

@SuppressWarnings("unchecked")
public void redrawSelectedPlots() {

    if (syncedOption.getSyncWhat().isSync() && !getSelectionChanging()) {
        XYPlot xyplot = getChart().getXYPlot();

        //         curationControls.setSyncedState(true);

        Double yscale = (xyplot.getRangeAxis().getUpperBound() - xyplot.getRangeAxis().getLowerBound()) / 50;
        Double xscale = (xyplot.getDomainAxis().getUpperBound() - xyplot.getDomainAxis().getLowerBound()) / 50;

        Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3 },
                0);/*from ww  w.j a  va  2  s . com*/
        Paint paint = Color.RED;

        for (Annotation anno : (List<Annotation>) xyplot.getAnnotations()) {
            if (anno != intervalAnnotation && anno instanceof XYShapeAnnotation) {
                xyplot.removeAnnotation((XYShapeAnnotation) anno);
            }
        }

        for (Point2D point : selectedPoints) {
            double x = point.getX();
            double y = point.getY();

            double y1 = y - yscale;
            double y2 = y + yscale;
            double x1 = x - xscale;
            double x2 = x + xscale;

            Ellipse2D oval = new Ellipse2D.Double(x1, y1, x2 - x1, y2 - y1);

            XYShapeAnnotation lineanno0 = new XYShapeAnnotation(oval, stroke, paint);
            addRangeMarker(lineanno0);
        }
    }
    curationControls.updateButtons();
}

From source file:windows.sensorWindow.java

/**
 * updates the width of the template plot
 * /*from   ww w.  j  a v  a2  s  . c o  m*/
 * @param UID
 */
public static void updateTmplPlotWidth(String UID, int index) {
    Brick tmpBrick = Brick.getBrick(connectionData.BrickList, UID);
    if (index == 0) {
        if (rendererMap3.containsKey(UID)) {
            XYItemRenderer rendererTmp = rendererMap3.get(UID);
            int width = computeTmplPlotWidth(tmpBrick.tmpl1Width);
            BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);// ,
            // 10.0f,
            // dash,
            // 0.0f);
            rendererTmp.setSeriesPaint(0, Color.GREEN);
            // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) );
            rendererTmp.setSeriesStroke(0, stroke);
            rendererMap3.put(UID, rendererTmp);
            // tmplPlot1Width.put(UID,
            // computeTmplPlotWidth(tmpBrick.tmpl1Width));
        }
    }
    if (index == 1) {
        if (rendererMap4.containsKey(UID)) {
            // TODO
        }
    }
}

From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java

@Override
public void updateSelectedSamples() {

    PlotsByTraitInstance plotsByTraitInstance = selectedValueStore.getSyncedPlotsByTrait();

    intervalAnnotation = null;/*from   ww  w .java2s  . co m*/
    selectedPoints.clear();

    XYPlot xyplot = getChart().getXYPlot();

    Double yscale = (xyplot.getRangeAxis().getUpperBound() - xyplot.getRangeAxis().getLowerBound()) / 50;
    Double xscale = (xyplot.getDomainAxis().getUpperBound() - xyplot.getDomainAxis().getLowerBound()) / 50;

    removeAnnotations();
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3 }, 0);
    Paint paint = Color.RED;

    xyplot.clearRangeMarkers();

    TraitInstanceValueRetriever<?> x_tivr = tivrByTi.get(xInstance);

    double[] xy = new double[2];

    for (TraitInstance ti : plotsByTraitInstance.getTraitInstances()) {

        if (traitInstances.contains(ti) && !xInstance.equals(ti)) {

            TraitInstanceValueRetriever<?> tivr = tivrByTi.get(ti);

            for (PlotOrSpecimen pos : plotsByTraitInstance.getPlotSpecimens((ti))) {
                if (usedPlotSpecimens.isEmpty() || usedPlotSpecimens.contains(pos)) {

                    xy = getXY(x_tivr, tivr, pos, xy);

                    if (xy != null) {
                        double x = xy[0];
                        double y = xy[1];

                        double y1 = y - yscale;
                        double y2 = y + yscale;
                        double x1 = x - xscale;
                        double x2 = x + xscale;

                        selectedPoints.add(new Point2D.Double(x, y));

                        Ellipse2D oval = new Ellipse2D.Double(x1, y1, x2 - x1, y2 - y1);

                        //               Line2D line0 = new Line2D.Double(x1, y2, x2, y1);
                        //               Line2D line1 = new Line2D.Double(x1, y1, x2, y2);
                        //               
                        XYShapeAnnotation lineanno0 = new XYShapeAnnotation(oval, stroke, paint);
                        //               
                        //               XYShapeAnnotation lineanno0 = new XYShapeAnnotation(line0, stroke, paint);   
                        //               XYShapeAnnotation lineanno1 = new XYShapeAnnotation(line1, stroke, paint);

                        addRangeMarker(lineanno0);
                        //               plotPanel.addRangeMarker(lineanno1);

                    }
                }
            }
        }

        getChartPanel().repaint();
    }
    curationControls.updateButtons(false);
}