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:com.googlecode.logVisualizer.chart.LineChartBuilder.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), xLable, yLable, dataset,
            PlotOrientation.VERTICAL, isIncludeLegend(), true, false);
    final XYPlot plot = (XYPlot) chart.getPlot();

    double lastXValue = 0;
    if (dataset.getSeriesCount() > 0)
        lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1);

    plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue));
    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.setNoDataMessage("No data available");
    if (dataset.getSeriesCount() > 0)
        ((NumberAxis) plot.getDomainAxis()).setUpperBound(lastXValue);
    ((NumberAxis) plot.getRangeAxis()).setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesShapesVisible(i, false);
        renderer.setSeriesStroke(i, new BasicStroke(2));
    }//from ww w .j av  a2 s . c o m
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);

    return chart;
}

From source file:graph_line.java

public void addMarkers(double pos1, double pos2) {
    if (!fftseries.isEmpty()) {
        Marker m1 = new ValueMarker(pos1);
        Marker m2 = new ValueMarker(pos2);

        m1.setStroke(new BasicStroke(2));
        m2.setStroke(new BasicStroke(2));
        m1.setPaint(Color.RED);//from  w  ww . j  a v  a2s .  c  o  m
        m2.setPaint(Color.GREEN);
        plot.addDomainMarker(m1);
        plot.addDomainMarker(m2);
    }

}

From source file:com.opendoorlogistics.components.linegraph.LineGraphPanel.java

@Override
protected JFreeChart createChart(ODLTableReadOnly table, int[] rowFilter) {

    // split by key
    Map<String, List<XY>> lines = api.stringConventions().createStandardisedMap();

    if (rowFilter != null) {
        for (int row : rowFilter) {
            readLine(table, row, lines);
        }/*from   w w w.  jav  a 2 s.co m*/
    } else {
        int n = table.getRowCount();
        for (int row = 0; row < n; row++) {
            readLine(table, row, lines);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (Map.Entry<String, List<XY>> line : lines.entrySet()) {
        XYSeries s = new XYSeries(line.getKey());
        for (XY xy : line.getValue()) {
            s.add(xy.X, xy.Y);
        }
        dataset.addSeries(s);
    }

    JFreeChart chart = ChartFactory.createXYLineChart(
            api.stringConventions().isEmptyString(config.getTitle()) ? null : config.getTitle(), // chart title
            config.getXLabel(), // x axis label
            config.getYLabel(), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, lines.size() > 0, // include legend
            true, // tooltips
            false // urls
    );

    // make lines thicker
    for (int i = 0; i < lines.size(); i++) {
        ((XYPlot) chart.getPlot()).getRenderer().setSeriesStroke(i, new BasicStroke(2));
    }

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:com.bitplan.vzjava.Plot.java

/**
 * Creates a chart./* w  ww  . j  a v  a 2s  .  co  m*/
 * 
 * @param dataset
 *          a dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final ColoredDataSet cdataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Time", "Power", cdataset.dataSet, true,
            true, false);

    chart.setBackgroundPaint(Color.white);

    // final StandardLegend sl = (StandardLegend) chart.getLegend();
    // sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    // plot.setOutlinePaint(null);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(false);

    final XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        renderer.setSeriesStroke(0, new BasicStroke(3.0f));
        renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    }

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

    // http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/DefaultDrawingSupplier-source.html
    DrawingSupplier supplier = new DefaultDrawingSupplier(cdataset.paintSequence,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chart.getPlot().setDrawingSupplier(supplier);
    return chart;
}

From source file:com.xpn.xwiki.plugin.charts.params.DefaultChartParams2.java

protected DefaultChartParams2() throws ParamException {
    set(SERIES, "columns");

    set(HEIGHT, new Integer(600));
    set(WIDTH, new Integer(500));
    set(LINK_ATTRIBUTES, new HashMap());
    set(IMAGE_ATTRIBUTES, new HashMap());

    set(RENDERER, (Class) null); // default renderer is chart type dependent
    set(RENDERER_COLOR, AbstractRenderer.DEFAULT_PAINT);
    set(RENDERER_STROKE, AbstractRenderer.DEFAULT_STROKE);
    set(RENDERER_SHAPE, AbstractRenderer.DEFAULT_SHAPE);
    set(RENDERER_FILL_COLOR, Color.white);
    set(RENDERER_OUTLINE_COLOR, AbstractRenderer.DEFAULT_OUTLINE_PAINT);
    set(RENDERER_OUTLINE_STROKE, AbstractRenderer.DEFAULT_OUTLINE_STROKE);
    set(RENDERER_ITEM_LABEL_VISIBLE, Boolean.FALSE);
    set(RENDERER_ITEM_LABEL_COLOR, AbstractRenderer.DEFAULT_VALUE_LABEL_PAINT);
    set(RENDERER_ITEM_LABEL_FONT, AbstractRenderer.DEFAULT_VALUE_LABEL_FONT);
    set(RENDERER_SERIES_VISIBLE, Boolean.TRUE);
    set(RENDERER_SERIES_VISIBLE_IN_LEGEND, Boolean.TRUE);

    set(BORDER_VISIBLE, Boolean.FALSE);
    set(BORDER_COLOR, Color.black);
    set(BORDER_STROKE, new BasicStroke(1.0f));

    setTitle(TITLE_PREFIX);/*w ww. j  a  va2  s  .  co m*/
    set(TITLE_PREFIX + TITLE_FONT_SUFFIX, JFreeChart.DEFAULT_TITLE_FONT);
    setTitle(SUBTITLE_PREFIX);

    set(ANTI_ALIAS, Boolean.TRUE);
    set(BACKGROUND_COLOR, JFreeChart.DEFAULT_BACKGROUND_PAINT);

    set(PLOT_BACKGROUND_COLOR, Plot.DEFAULT_BACKGROUND_PAINT);
    set(PLOT_BACKGROUND_ALPHA, new Float(Plot.DEFAULT_BACKGROUND_ALPHA));
    set(PLOT_FOREGROUND_ALPHA, new Float(Plot.DEFAULT_FOREGROUND_ALPHA));
    set(PLOT_INSERTS, Plot.DEFAULT_INSETS);
    set(PLOT_OUTLINE_COLOR, Plot.DEFAULT_OUTLINE_PAINT);
    set(PLOT_OUTLINE_STROKE, Plot.DEFAULT_OUTLINE_STROKE);

    set(XYPLOT_ORIENTATION, PlotOrientation.VERTICAL);
    set(XYPLOT_QUADRANT_ORIGIN, new Point2D.Double(0.0, 0.0));
    List colors = new LinkedList();
    colors.add(null);
    colors.add(null);
    colors.add(null);
    colors.add(null);
    set(XYPLOT_QUADRANT_COLORS, colors);

    set(LEGEND_BACKGROUND_COLOR, (Color) null);
    set(LEGEND_ITEM_FONT, LegendTitle.DEFAULT_ITEM_FONT);
    set(LEGEND_ITEM_LABEL_PADDING, new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    set(LEGEND_ITEM_GRAPHIC_ANCHOR, RectangleAnchor.CENTER);
    set(LEGEND_ITEM_GRAPHIC_EDGE, RectangleEdge.LEFT);
    set(LEGEND_ITEM_GRAPHIC_LOCATION, RectangleAnchor.CENTER);
    set(LEGEND_ITEM_GRAPHIC_PADDING, new RectangleInsets(2.0, 2.0, 2.0, 2.0));

    setAxis(AXIS_DOMAIN_PREFIX);
    setAxis(AXIS_RANGE_PREFIX);

    set(TIME_PERIOD_CLASS, Day.class);
    set(DATE_FORMAT, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"));
}

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

/**
 * @param plot/*from  w ww . j a  va2s . c  o m*/
 * @param seriesDL
 * @param seriesUP
 */
private void setDataPlot(XYPlot plot, XYSeries seriesDL, XYSeries seriesUP) {
    serCollection.addSeries(seriesDL);
    serCollection.addSeries(seriesUP);

    XYStepRenderer renderer = new XYStepRenderer();

    LogAxis rangeAxis = new LogAxis(); // new API 
    rangeAxis.setAutoRange(true);
    rangeAxis.setVisible(false);
    plot.setRangeAxis(rangeAxis);
    plot.setRangePannable(true);
    plot.setRangeCrosshairVisible(true);

    renderer = (XYStepRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(2.5f));
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    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 = ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.downlink");
            } else {
                streamInfo = ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.uplink");
            }
            return displayInfo.append("Time: " + tempx + " , " + streamInfo + " : " + tempy + " kbps")
                    .toString();
        }
    });
    plot.setRenderer(renderer);
    plot.setDataset(serCollection);

}

From source file:org.jfree.experimental.chart.plot.dial.DialCap.java

/** 
 * Creates a new instance of <code>StandardDialBackground</code>.  The 
 * default background paint is <code>Color.white</code>.
 *///ww  w . ja  va2 s  . c o m
public DialCap() {
    this.radius = 0.05;
    this.fillPaint = Color.white;
    this.outlinePaint = Color.black;
    this.outlineStroke = new BasicStroke(2.0f);
}

From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java

public static JFreeChart createXYChart(String title, XYDataset data, String xLabel, String yLabel,
        int pointRadius, int lineThickness, ColorTheme theme) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL,
            true, false, false);//from w w  w . jav a  2s  . co m

    formatColorTheme(chart, theme);

    XYPlot plot = (XYPlot) chart.getPlot();
    Shape icon = new Ellipse2D.Double(-pointRadius, -pointRadius, pointRadius * 2, pointRadius * 2);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);

    Color[] colors = generateJetSpectrum(data.getSeriesCount());
    for (int i = 0; i < data.getSeriesCount(); i++) {
        plot.getRenderer().setSeriesStroke(i, new BasicStroke(lineThickness));
        plot.getRenderer().setSeriesShape(i, icon);
        ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesVisible(i, true);
        ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesFilled(i, true);
        plot.getRenderer().setSeriesPaint(i, colors[i]);
    }

    LegendTitle legend = chart.getLegend();
    Font legendFont = legend.getItemFont();
    float legendFontSize = legendFont.getSize();
    Font newLegendFont = legendFont.deriveFont(legendFontSize * 0.6f);
    legend.setItemFont(newLegendFont);

    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Font domainAxisLabelFont = domainAxis.getLabelFont();
    float domainAxisLabelFontSize = domainAxisLabelFont.getSize();
    domainAxis.setLabelFont(domainAxisLabelFont.deriveFont(domainAxisLabelFontSize * 0.6f));

    Font domainAxisTickLabelFont = domainAxis.getTickLabelFont();
    float domainAxisTickLabelFontSize = domainAxisTickLabelFont.getSize();
    domainAxis.setTickLabelFont(domainAxisTickLabelFont.deriveFont(domainAxisTickLabelFontSize * 0.6f));

    ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis();
    Font rangeAxisLabelFont = rangeAxis.getLabelFont();
    float rangeAxisLabelFontSize = rangeAxisLabelFont.getSize();
    rangeAxis.setLabelFont(rangeAxisLabelFont.deriveFont(rangeAxisLabelFontSize * 0.6f));

    Font rangeAxisTickLabelFont = rangeAxis.getTickLabelFont();
    float rangeAxisTickLabelFontSize = rangeAxisTickLabelFont.getSize();
    rangeAxis.setTickLabelFont(rangeAxisTickLabelFont.deriveFont(rangeAxisTickLabelFontSize * 0.6f));

    return chart;
}

From source file:org.jfree.graphics2d.demo.SVGPieChartDemo1.java

/**
 * Creates a chart.//from w  w  w  . j a  v a  2  s .co  m
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title
            dataset);
    chart.removeLegend();

    // set a custom background for the chart
    chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20), RectangleAnchor.TOP_LEFT,
            Color.DARK_GRAY, RectangleAnchor.BOTTOM_RIGHT));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPainter(null);
    plot.setInteriorGap(0.04);
    plot.setBorderPainter(null);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);
    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:org.apache.phoenix.pherf.result.impl.ImageResultHandler.java

@Override
public synchronized void write(Result result) throws Exception {
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    int rowCount = 0;
    int maxLegendCount = 20;
    int chartDimension = 1100;

    ResultValue<DataModelResult> resultValue = result.getResultValues().get(0);
    DataModelResult dataModelResult = resultValue.getResultValue();

    for (ScenarioResult scenarioResult : dataModelResult.getScenarioResult()) {
        for (QuerySetResult querySetResult : scenarioResult.getQuerySetResult()) {
            for (QueryResult queryResult : querySetResult.getQueryResults()) {
                for (ThreadTime tt : queryResult.getThreadTimes()) {
                    TimeSeries timeSeries = new TimeSeries(
                            queryResult.getStatement() + " :: " + tt.getThreadName());
                    rowCount++;/*w w w. j  a v a  2 s  .  c  o m*/
                    synchronized (tt.getRunTimesInMs()) {
                        for (RunTime rt : tt.getRunTimesInMs()) {
                            if (rt.getStartTime() != null) {
                                timeSeries.add(new Millisecond(rt.getStartTime()), rt.getElapsedDurationInMs());
                            }
                        }
                    }
                    timeSeriesCollection.addSeries(timeSeries);
                }
            }
        }
    }
    boolean legend = rowCount > maxLegendCount ? false : true;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(dataModelResult.getName(), "Time", "Query Time (ms)",
            timeSeriesCollection, legend, true, false);
    StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
    chart.getXYPlot().setRenderer(renderer);
    chart.getXYPlot().setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setRangeGridlinePaint(Color.BLACK);
    for (int i = 0; i < rowCount; i++) {
        chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3f));
    }
    try {
        ChartUtilities.saveChartAsJPEG(new File(resultFileName), chart, chartDimension, chartDimension);
    } catch (IOException e) {
        e.printStackTrace();
    }

}