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:com.planetmayo.debrief.satc_rcp.views.SpatialView.java

private void plotRoutesWithScores(HashMap<LegWithRoutes, ArrayList<ScoredRoute>> legRoutes) {
    if (legRoutes.size() == 0)
        return;/*from ww w.ja  v a2s.c om*/

    // we need to store the point labels. get ready to store them
    _scoredRouteLabels.clear();
    final DateFormat labelTimeFormat = new SimpleDateFormat("mm:ss");

    // work through the legs
    Iterator<LegWithRoutes> lIter = legRoutes.keySet().iterator();
    while (lIter.hasNext()) {
        final LegWithRoutes thisL = lIter.next();
        final ArrayList<ScoredRoute> scoredRoutes = legRoutes.get(thisL);

        double max = 0, min = Double.MAX_VALUE;
        for (Iterator<ScoredRoute> iterator = scoredRoutes.iterator(); iterator.hasNext();) {
            ScoredRoute route = iterator.next();
            // Ensure thisScore is between 0-100
            double thisScore = route.theScore;

            thisScore = Math.log(thisScore);

            if (max < thisScore) {
                max = thisScore;
            }
            if (min > thisScore) {
                min = thisScore;
            }
        }

        System.out.println(" for leg: " + thisL.getClass().getName() + " min:" + min + " max:" + max);

        for (Iterator<ScoredRoute> iterator = scoredRoutes.iterator(); iterator.hasNext();) {
            ScoredRoute route = iterator.next();

            Point startP = route.theRoute.getStartPoint();
            Point endP = route.theRoute.getEndPoint();

            // Ensure thisScore is between 0-100
            double thisScore = route.theScore;
            thisScore = Math.log(thisScore);

            double thisColorScore = (thisScore - min) / (max - min);

            // System.out.println("this s:" + (int) thisScore + " was:"
            // + route.theScore);

            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);

            // get the series num
            int num = _myData.getSeriesCount() - 1;
            _renderer.setSeriesPaint(num, getHeatMapColorFor(thisColorScore));

            // make the line width inversely proportional to the score, with a max
            // width of 2 pixels
            final float width = (float) (2f - 2 * thisColorScore);

            // make the top score solid, and worse scores increasingly sparse
            final float dash[];
            if (thisScore == min) {
                dash = null;
            } else {
                float thisWid = (float) (1f + Math.exp(thisScore - min) / 3);
                float[] tmpDash = { 4, thisWid };
                dash = tmpDash;
            }

            // and put this line thickness, dashing into a stroke object
            BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f,
                    dash, 0.0f);

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

            // ok, we'll also show the route points
            XYSeries series2 = new XYSeries("" + (_numCycles++), false);

            ArrayList<String> theseLabels = new ArrayList<String>();

            // loop through the points
            Iterator<State> stIter = route.rawRoute.getStates().iterator();
            while (stIter.hasNext()) {
                State state = (State) stIter.next();
                Point loc = state.getLocation();
                XYDataItem newPt = new XYDataItem(loc.getY(), loc.getX());
                series2.add(newPt);
                // and store the label for this point
                theseLabels.add(labelTimeFormat.format(state.getTime()));
            }

            // get the shape
            _myData.addSeries(series2);
            //
            // // get the series num
            num = _myData.getSeriesCount() - 1;

            // ok, we now need to put hte series into the right slot
            _scoredRouteLabels.put(num, theseLabels);

            if (_settings.isShowRoutePointLabels()) {
                _renderer.setSeriesItemLabelGenerator(num, new XYItemLabelGenerator() {

                    @Override
                    public String generateLabel(XYDataset arg0, int arg1, int arg2) {
                        String res = null;
                        ArrayList<String> thisList = _scoredRouteLabels.get(arg1);
                        if (thisList != null) {
                            res = thisList.get(arg2);
                        }
                        return res;
                    }
                });
                _renderer.setSeriesItemLabelPaint(num, getHeatMapColorFor(thisColorScore));
            }

            // _renderer.setSeriesPaint(num, getHeatMapColorFor(thisColorScore));
            _renderer.setSeriesItemLabelsVisible(num, _settings.isShowRoutePointLabels());
            _renderer.setSeriesLinesVisible(num, false);
            _renderer.setSeriesPaint(num, getHeatMapColorFor(thisColorScore));
            _renderer.setSeriesShapesVisible(num, _settings.isShowRoutePoints());
            _renderer.setSeriesVisibleInLegend(num, false);
        }
    }
}

From source file:org.jfree.experimental.swt.SWTGraphics2D.java

/**
 * Returns the AWT line cap corresponding to the specified SWT line cap.
 *
 * @param swtLineCap  the SWT line cap.//from www . j av a  2s .  co  m
 *
 * @return The AWT line cap.
 */
private int toAwtLineCap(int swtLineCap) {
    if (swtLineCap == SWT.CAP_FLAT) {
        return BasicStroke.CAP_BUTT;
    } else if (swtLineCap == SWT.CAP_ROUND) {
        return BasicStroke.CAP_ROUND;
    } else if (swtLineCap == SWT.CAP_SQUARE) {
        return BasicStroke.CAP_SQUARE;
    } else {
        throw new IllegalArgumentException("SWT LineCap " + swtLineCap + " not recognised");
    }
}

From source file:de.fau.amos.ChartRenderer.java

/**
 * Creates Chart (JFreeChart object) using TimeSeriesCollection. Used for forecast only.
 * /*from w  ww .ja  va 2  s  .  c o m*/
 * @param collection TimeSeriesCollection that provides basis for chart.
 * @param time Time where "real" data ends.
 * @param unit Unit of displayed values (kWh,TNF,kWh/TNF)
 * @return Returns finished JFreeChart.
 */
private JFreeChart createForecastChart(final TimeSeriesCollection collection, String time, String unit) {

    // Modification of X-Axis Label
    int day = Integer.parseInt(time.substring(8, 10));
    int month = Integer.parseInt(time.substring(5, 7));
    int year = Integer.parseInt(time.substring(0, 4));
    //get Weekday
    Calendar c = Calendar.getInstance();
    c.set(year, month - 1, day, 0, 0);
    int weekDay = c.get(Calendar.DAY_OF_WEEK);

    String dayString = new DateFormatSymbols(Locale.US).getWeekdays()[weekDay] + ", " + day + ". ";
    String monthString = new DateFormatSymbols(Locale.US).getMonths()[month - 1];
    String xAxisLabel = "" + dayString + monthString + "  " + time.substring(0, 4);

    //Creation of the lineChart
    JFreeChart lineChart = ChartFactory.createTimeSeriesChart("Forecast", // title
            xAxisLabel, // x-axis label
            //            "Energy Consumption "+("1".equals(unit)?"[kWh]":("2".equals(unit)?"[kWh/TNF]":("3".equals(unit)?"[TNF]":""))),       // y-axis label
            ("1".equals(unit) ? "Energy Consumption [kWh]"
                    : ("2".equals(unit) ? "Energy Consumption [kWh/TNF]"
                            : ("3".equals(unit) ? "Produced Pieces [TNF]" : ""))),
            collection, // data
            true, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );

    //graphical modifications for LineChart
    lineChart.setBackgroundPaint(Color.white);

    XYPlot plot = lineChart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        private static final long serialVersionUID = 1L;
        //         Stroke soild = new BasicStroke(2.0f);
        Stroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 10.0f }, 0.0f);

        @Override
        public Stroke getItemStroke(int row, int column) {
            //third series in collection -> forecast collection
            if (row == 2) {
                return dashed;
                //partial dashed->not needed now, maybe later

                //               double x = collection.getXValue(row, column);
                //               
                //               if ( x > 4){
                //                  return dashed;
                //               } else {
                //                  return soild;
                //               } 
            } else
                return super.getItemStroke(row, column);
        }
    };
    renderer.setBaseShapesVisible(false);
    renderer.setBaseShapesFilled(true);
    renderer.setBaseStroke(new BasicStroke(3));
    plot.setRenderer(renderer);

    return lineChart;
}

From source file:org.jfree.experimental.swt.SWTGraphics2D.java

/**
 * Returns the SWT line cap corresponding to the specified AWT line cap.
 *
 * @param awtLineCap  the AWT line cap./*from  w ww  .  j a  v  a  2 s . com*/
 *
 * @return The SWT line cap.
 */
private int toSwtLineCap(int awtLineCap) {
    if (awtLineCap == BasicStroke.CAP_BUTT) {
        return SWT.CAP_FLAT;
    } else if (awtLineCap == BasicStroke.CAP_ROUND) {
        return SWT.CAP_ROUND;
    } else if (awtLineCap == BasicStroke.CAP_SQUARE) {
        return SWT.CAP_SQUARE;
    } else {
        throw new IllegalArgumentException("AWT LineCap " + awtLineCap + " not recognised");
    }
}

From source file:eu.udig.style.advanced.utils.Utilities.java

/**
 * Convert a sld line cap definition to the java awt value. 
 * //ww  w .  j  a v a 2 s  .  c o  m
 * @param sldCap the sld cap string.
 * @return the awt value.
 */
public static int sld2awtCap(String sldCap) {
    if (sldCap.equals("") || sldCap.equals(lineCapNames[1])) {
        return BasicStroke.CAP_BUTT;
    } else if (sldCap.equals(lineCapNames[2])) {
        return BasicStroke.CAP_ROUND;
    } else if (sldCap.equals(lineCapNames[3])) {
        return BasicStroke.CAP_SQUARE;
    } else {
        throw new IllegalArgumentException("unsupported line cap");
    }
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createDailyLoginChart(int width, int height) {
    IntervalXYDataset dataset1 = getDailyLoginsDataSet();
    IntervalXYDataset dataset2 = getDailySiteUserDataSet();

    if ((dataset1 == null) || (dataset2 == null)) {
        return generateNoDataChart(width, height);
    }/*w w  w  .ja va  2s  .c om*/

    // create plot ...
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesPaint(1, Color.BLUE);
    renderer1.setSeriesPaint(2, Color.RED);
    renderer1.setSeriesPaint(3, Color.BLUE);
    renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    BasicStroke dashLineStroke = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0,
            new float[] { 4 }, 0);
    renderer1.setSeriesStroke(2, dashLineStroke);
    renderer1.setSeriesStroke(3, dashLineStroke);

    DateAxis domainAxis = new DateAxis("");
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("yyyy-MM-dd")));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);

    NumberAxis rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesPaint(0, Color.GREEN);
    renderer2.setSeriesPaint(1, Color.BLACK);
    renderer2.setSeriesPaint(2, Color.CYAN);

    rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot2 = new XYPlot(dataset2, null, rangeAxis, renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Parses a string containing a sequence of line style specifications,
 * returning an array of <code>Stroke</code> objects.
 *
 * @param text  the line styles.//from   w  ww . j a  va2  s .  c  o m
 *
 * @return The strokes representing the line styles.
 */
private static Stroke[] parseLineStyles(String text) {
    if (text == null) {
        throw new IllegalArgumentException("Null 'text' argument (in parseStrokes(String)).");
    }
    String[] codes = breakString(text, '|');
    Stroke[] result = new BasicStroke[codes.length];
    for (int i = 0; i < codes.length; i++) {
        float width = 1.0f;
        float lineRun = 1.0f;
        float gapRun = 0.0f;
        int pos = codes[i].indexOf(',');
        if (pos == -1) {
            width = Float.parseFloat(codes[i]);
        } else {
            String widthStr = codes[i].substring(0, pos);
            width = Float.parseFloat(widthStr);
            String remaining = codes[i].substring(pos + 1);
            pos = remaining.indexOf(',');
            if (pos == -1) {
                lineRun = Float.parseFloat(remaining);
                gapRun = lineRun;
            } else {
                String s1 = remaining.substring(0, pos);
                lineRun = Float.parseFloat(s1);
                String s2 = remaining.substring(pos + 1);
                gapRun = Float.parseFloat(s2);
            }
        }
        if (gapRun <= 0.0f) {
            result[i] = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
        } else {
            result[i] = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 5.0f,
                    new float[] { lineRun, gapRun }, 0.0f);
        }
    }
    return result;
}

From source file:jhplot.HChart.java

/**
 * //ww w  . j a  v  a 2  s.  c om
 * @param type
 *            =0 - solid, 1-dashed, 2-dashed-dotted,3 dotted
 * @param width
 *            width
 * @return
 */

private Stroke getStrokes(int type, float width, float dash) {

    float[][] pattern = { { dash }, { dash, dash }, { dash, dash, dash * 0.3f, dash },
            { dash * 0.3f, dash * 2f } };

    if (type == 0)
        return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f); // solid line
    if (type == 1)
        return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, pattern[1], 0.0f); // dashed
    // line
    if (type == 2)
        return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, pattern[2], 0.0f); // dash-dotted
    // line
    if (type == 3)
        return new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, pattern[3], 0.0f); // dotted
    // line

    return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f);
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java

/***********************************************************************************************
 * Create a simple Chart from the specified XYDataset.
 * Choose a TimeSeriesChart or a XYLineChart appropriately.
 * Called from createCustomisedChart() in each ChartUIComponent subclass.
 *
 *
 * @param dataset//from  w  w  w .ja va 2 s.  co m
 * @param timezone
 * @param metadatalist
 * @param channelcount
 * @param temperaturechannel
 * @param updatetype
 * @param displaylimit
 * @param channelselector
 * @param debug
 *
 * @return JFreeChart
 */

public static JFreeChart createChart(final XYDataset dataset, final TimeZone timezone,
        final List<Metadata> metadatalist, final int channelcount, final boolean temperaturechannel,
        final DataUpdateType updatetype, final int displaylimit,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "ChartHelper.createChart() ";
    final JFreeChart chart;
    final String strTitle;
    final String strLabelX;
    final String strLabelY;
    final XYDataset xyDatasetToDisplay;

    // The set of Metadata available should include the Instrument
    // and any items from the current observation
    strTitle = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_TITLE.getKey());
    strLabelX = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_X.getKey());
    // Axis.Y.0 only in this version
    strLabelY = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey() + MetadataDictionary.SUFFIX_SERIES_ZERO);

    // Transform the XYdataset in accordance with the current ChannelSelection Mode before displaying

    channelselector.debugSelector(debug, SOURCE);

    xyDatasetToDisplay = copyTransformedXYDataset(dataset, timezone, updatetype, displaylimit,
            channelselector.isDecimating(), channelselector.getChannelSelectionModes());
    if (dataset instanceof TimeSeriesCollection) {
        chart = ChartFactory.createTimeSeriesChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay,
                channelselector.hasLegend(), true, false);
    } else {
        chart = ChartFactory.createXYLineChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay,
                PlotOrientation.VERTICAL, channelselector.hasLegend(), true, false);
    }

    if ((chart != null) && (chart.getXYPlot() != null) && (chart.getXYPlot().getRangeAxis() != null)) {
        final Stroke strokeCrosshair;
        final XYPlot plot;
        final XYItemRenderer renderer;

        chart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor());

        // Experimental chart configuration
        chart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f));

        plot = chart.getXYPlot();
        plot.setBackgroundPaint(COLOR_PLOT);
        plot.setDomainGridlinePaint(COLOR_GRIDLINES);
        plot.setRangeGridlinePaint(COLOR_GRIDLINES);
        plot.setAxisOffset(PLOT_RECTANGLE_INSETS);

        plot.setDomainCrosshairVisible(true);
        plot.setDomainCrosshairLockedOnData(false);
        plot.setRangeCrosshairVisible(false);

        // Make the Crosshair more visible by changing the width from the default
        strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke
                BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke
                BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet
                0.0f, // The limit to trim the miter join
                new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern
                0.0f); // The offset to start the dashing pattern
        plot.setDomainCrosshairStroke(strokeCrosshair);

        renderer = plot.getRenderer();

        if ((renderer != null) && (renderer instanceof XYLineAndShapeRenderer)) {
            final XYLineAndShapeRenderer xyItemRenderer;
            int intSeriesCount;

            xyItemRenderer = (XYLineAndShapeRenderer) renderer;

            xyItemRenderer.setBaseLinesVisible(true);
            xyItemRenderer.setBaseShapesVisible(false);
            xyItemRenderer.setBaseShapesFilled(true);
            xyItemRenderer.setItemLabelsVisible(true);

            // Set the shape for the Chart legend items
            ChartUIHelper.setLegendShape(xyItemRenderer);

            // Colour only as many Series as we know about
            intSeriesCount = 0;

            // Examine the state of each channel's selection
            for (int channel = 0; channel < channelcount; channel++) {
                final ChannelSelectionMode selectionMode;

                if ((channelselector.getChannelSelectionModes() != null)
                        && (channelselector.getChannelSelectionModes().size() == channelcount)) {
                    // If there is a ChannelSelector, get the gain setting, or OFF
                    selectionMode = channelselector.getChannelSelectionModes().get(channel);
                } else if (!channelselector.showChannels()) {
                    // If there is no ChannelSelector, we assume that all Channels are ON, at X1
                    selectionMode = ChannelSelectionMode.X1;
                } else {
                    // Not sure what to do, so just show all
                    selectionMode = ChannelSelectionMode.X1;
                }

                if (!ChannelSelectionMode.OFF.equals(selectionMode)) {
                    final ColourInterface colour;

                    colour = MetadataHelper.getChannelColour(metadatalist, channel, temperaturechannel);

                    MetadataHelper.showMetadataList(metadatalist, SOURCE + " COLOURS FOR CHART",
                            LOADER_PROPERTIES.isMetadataDebug());

                    if (colour != null) {
                        // Map the Colour to the Series
                        xyItemRenderer.setSeriesPaint(intSeriesCount, colour.getColor());
                    } else {
                        // Use the default colour if the metadata doesn't have it
                        LOGGER.error(SOURCE
                                + "The channel colour was missing or incorrectly specified in the Metadata, using default colour"
                                + " [channel=" + channel + "]");
                        xyItemRenderer.setSeriesPaint(intSeriesCount,
                                ChartUIHelper.getStandardColour(channel).getColor());
                    }

                    // Prepare for the next Series
                    intSeriesCount++;
                }
            }
        }
    }

    return (chart);
}

From source file:beproject.MainGUI.java

void createTimeLine() throws SQLException {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    getTimeLineData(dataset);/*from w  w w.  j  av  a  2 s.c om*/
    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Tweet Count");
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    domain.setAutoRange(true);
    domain.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 2, Regression.sdf));
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);
    range.setTickLabelsVisible(true);

    plot.setDomainGridlinesVisible(false);
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    renderer.setBaseItemLabelsVisible(true);

    JFreeChart liveTweetAnalysisChart = new JFreeChart("Rate of tweets per hour",
            new Font("Tahoma", Font.BOLD, 24), plot, true);
    liveTweetAnalysisChart.setBorderVisible(false);

    ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart);

    domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS);
    range.setTickMarksVisible(false);
    range.setTickLabelInsets(RectangleInsets.ZERO_INSETS);
    domain.setTickMarksVisible(false);
    liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS);

    ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true);
    liveTweetAnalysisChartPanel.setBorder(null);

    if (timeLineChart == null) {
        timeLineChart = liveTweetAnalysisChartPanel;
    } else {
        timeLinePanel.remove(timeLineChart);
        timeLineChart = liveTweetAnalysisChartPanel;
    }
    timeLinePanel.add(timeLineChart);
    timeLinePanel.validate();
}