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:org.jfree.expdemo.SelectionDemo3.java

private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension ext) {
    JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo3", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");

    plot.setDomainPannable(true);/*from   w  w  w.j  a  va 2  s  . c  om*/
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    //XYItemRenderer r = plot.getRenderer();
    XYDotRenderer r = new XYDotRenderer();
    r.setDotHeight(2);
    r.setDotWidth(2);

    r.setSeriesPaint(0, Color.blue);
    r.setSeriesPaint(1, Color.green);
    r.setSeriesPaint(2, Color.yellow);
    r.setSeriesPaint(3, Color.orange);
    plot.setRenderer(r);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);

    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(2.0f);

    domainAxis.setMinorTickCount(2);
    domainAxis.setMinorTickMarksVisible(true);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(2.0f);
    rangeAxis.setMinorTickCount(2);
    rangeAxis.setMinorTickMarksVisible(true);

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(r, ext, Color.red);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.BulletGraph.java

public JFreeChart createChart() {

    logger.debug("IN");
    Number value = null;/*  w  w w.  j ava2 s.  c  o  m*/

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        value = new Double(0);
    } else {
        value = dataset.getValue();
    }

    DefaultCategoryDataset datasetC = new DefaultCategoryDataset();
    datasetC.addValue(value, "", "");

    // customize a bar chart 
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, datasetC, PlotOrientation.HORIZONTAL,
            false, false, false);
    chart.setBorderVisible(false);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(true);
    plot.setOutlinePaint(Color.BLACK);

    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAnchorValue(value.doubleValue());

    // add the target marker 
    if (target != null) {
        ValueMarker marker = new ValueMarker(target.doubleValue(), Color.BLACK, new BasicStroke(2.0f));
        plot.addRangeMarker(marker, Layer.FOREGROUND);
    }

    //sets different marks
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        // add the marks 
        IntervalMarker marker = new IntervalMarker(interval.getMin(), interval.getMax(), interval.getColor());
        plot.addRangeMarker(marker, Layer.BACKGROUND);
        logger.debug("Added new interval to the plot");
    }

    // customize axes 
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(show_axis);
    rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 4));
    // calculate the upper limit 
    //double upperBound = target * upperFactor; 
    rangeAxis.setRange(new Range(lower, upper));
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // customize renderer 
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setMaximumBarWidth(0.18);
    renderer.setSeriesPaint(0, Color.BLACK);
    /*BasicStroke d = new BasicStroke(3f,BasicStroke.CAP_ROUND ,BasicStroke.JOIN_ROUND);
    renderer.setSeriesOutlineStroke(0, d);
    renderer.setSeriesStroke(0, d);
            
    renderer.setStroke(d);*/

    return chart;
}

From source file:guineu.modules.visualization.intensityplot.IntensityPlotFrame.java

public IntensityPlotFrame(ParameterSet parameters) {
    super("", true, true, true, true);

    String title = "Intensity plot [" + GuineuCore.getDesktop().getSelectedDataFiles()[0].getDatasetName()
            + "]";
    String xAxisLabel = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue().toString();

    // create dataset
    dataset = new IntensityPlotDataset(parameters);

    // create new JFreeChart
    logger.finest("Creating new chart instance");

    chart = ChartFactory.createLineChart(title, xAxisLabel, "Height", dataset, PlotOrientation.VERTICAL, true,
            true, false);/*from   ww  w .j ava2 s  . co m*/

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

    // set renderer
    StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
    renderer.setBaseStroke(new BasicStroke(2));
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);

    // set tooltip generator
    CategoryToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
    renderer.setBaseToolTipGenerator(toolTipGenerator);

    CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    chart.setBackgroundPaint(Color.white);

    // create chart JPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    add(chartPanel, BorderLayout.CENTER);

    IntensityPlotToolBar toolBar = new IntensityPlotToolBar(this);
    add(toolBar, BorderLayout.EAST);

    // disable maximum size (we don't want scaling)
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(legendFont);
    legend.setBorder(0, 0, 0, 0);

    Plot dplot = chart.getPlot();

    // set shape provider
    IntensityPlotDrawingSupplier shapeSupplier = new IntensityPlotDrawingSupplier();
    dplot.setDrawingSupplier(shapeSupplier);

    // set y axis properties
    NumberAxis yAxis;

    yAxis = (NumberAxis) ((CategoryPlot) dplot).getRangeAxis();

    NumberFormat yAxisFormat = new DecimalFormat("0.0E0");
    yAxis.setNumberFormatOverride(yAxisFormat);

    setTitle(title);
    setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
    setBackground(Color.white);
    pack();

}

From source file:ws.moor.bt.grapher.ChartBuilder.java

public JFreeChart getChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries,
            showLegend && (timeSeries.getSeriesCount() > 1), false, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();/*from  w  ww .  ja va 2 s  .c om*/
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getRenderer().setSeriesPaint(0, Color.black);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(1, Color.black);
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesPaint(2, Color.black);
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f));

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    return chart;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.AttenuatorPlot.java

/**
 * @param plot/*ww  w.j  ava 2  s  .  c o  m*/
 * @param seriesDL
 * @param seriesUP
 */
private void setDataPlot(XYPlot plot, XYSeries seriesDL, XYSeries seriesUP) {
    XYSeriesCollection sercollection = new XYSeriesCollection();
    sercollection.addSeries(seriesDL);
    sercollection.addSeries(seriesUP);

    XYStepRenderer renderer = new XYStepRenderer();
    XYPlot plot1 = (XYPlot) plot;
    plot1.getRangeAxis().setAutoRangeMinimumSize(2.0);//for the data set is constant value(ex. 0)      
    renderer = (XYStepRenderer) plot1.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesStroke(1, new BasicStroke(4.0f));

    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            StringBuffer displayInfo = new StringBuffer();
            java.lang.Number tempx = dataset.getX(series, item);
            java.lang.Number tempy = dataset.getY(series, item);
            // series 0 -> downstream , stries 1 -> upstream
            String streamInfo = "";
            if (series == 0) {
                streamInfo = "Downlink Delay";
            } else {
                streamInfo = "Uplink Delay";
            }
            return displayInfo.append("Time: " + tempx + " , " + streamInfo + " : " + tempy + "ms").toString();
        }
    });
    plot.setRenderer(renderer);
    plot.setDataset(sercollection);

}

From source file:ec.ui.chart.RevisionChartPanel.java

/**
 * Constructs a new RevisionChartPanel from a given chart
 * @param chart Chart used to construct the chart panel
 *///from  ww w .  j a  v  a  2 s.  c  o  m
public RevisionChartPanel(JFreeChart chart) {
    setLayout(new BorderLayout());
    panel = new JChartPanel(chart);

    refRenderer = new XYLineAndShapeRenderer();
    refRenderer.setBaseShapesVisible(false);
    refRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.RED));
    refRenderer.setBaseStroke(new BasicStroke(2.0f));

    seriesRenderer = new XYLineAndShapeRenderer();
    seriesRenderer.setBaseShapesVisible(false);
    seriesRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.BLUE));
    seriesRenderer.setBaseStroke(new BasicStroke(0.75f));

    panel.setPopupMenu(buildMenu().getPopupMenu());

    //        fillActionMap(getActionMap());
    //        fillInputMap(getInputMap());

    add(panel, BorderLayout.CENTER);
    onColorSchemeChange();
}

From source file:org.jreserve.dummy.plot.charts.AbstractLineChart.java

protected void formatSeries(LineAndShapeRenderer renderer) {
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);//from  ww  w .  ja  v a2s. com
    renderer.setUseFillPaint(true);
    renderer.setBaseStroke(new BasicStroke(2));

    int count = ((CategoryDataset) dataset).getRowCount();
    ColorGenerator colors = format.getColors();
    for (int i = 0; i < count; i++) {
        Color color = colors.nextColor();
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesFillPaint(i, color);
    }
}

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

@RequestMapping(value = "/jira/burndown/")
@ResponseBody//from   ww w. ja v a 2 s  .c  o m
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:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//from  w  w w  .  j  a va 2s.  co  m
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 2; i <= 3; i++) {
        renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical1, double[] YDataNumerical2, double[] YDataNumerical3) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForFour(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2, YDataNumerical3),
            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(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    plot.setRenderer(renderer);/* w  ww.  j  a va2  s .c o m*/
    setContentPane(chartPanel);

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}