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:convcao.com.caoAgent.convcaoNeptusInteraction.java

@Override
public void paint(Graphics2D g, StateRenderer2D renderer) {
    Point2D center = renderer.getScreenPosition(coords.squareCenter);
    double width = renderer.getZoom() * coords.cellWidth * coords.numCols;
    double height = renderer.getZoom() * coords.cellWidth * coords.numRows;
    g.setColor(new Color(0, 0, 255, 64));
    g.translate(center.getX(), center.getY());
    g.rotate(-renderer.getRotation());//from w  w w. ja  v a2 s.c o  m
    g.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height));
    g.rotate(renderer.getRotation());
    g.translate(-center.getX(), -center.getY());

    if (!active)
        return;

    g.setColor(Color.orange);
    int pos = 50;
    for (String v : nameTable.values()) {
        g.drawString(v + ": " + depths.get(v) + "m", 15, pos);
        pos += 20;
    }

    for (String vehicle : nameTable.values()) {
        LocationType src = positions.get(vehicle);
        LocationType dst = destinations.get(vehicle);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());
        float dash[] = { 4.0f };
        g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f));
        g.draw(new Line2D.Double(renderer.getScreenPosition(src), renderer.getScreenPosition(dst)));

        Point2D dstPt = renderer.getScreenPosition(dst);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());

        g.fill(new Ellipse2D.Double(dstPt.getX() - 4, dstPt.getY() - 4, 8, 8));
    }
}

From source file:AtomPanel.java

private void initJFreeChart() {
    this.numOfStream = numOfStream;

    datasets = new TimeSeriesCollection();
    trend = new TimeSeriesCollection();
    projpcs = new TimeSeriesCollection();
    spe = new TimeSeriesCollection();

    for (int i = 0; i < MaxNumOfStream; i++) {
        //add streams
        TimeSeries timeseries = new TimeSeries("Stream " + i, Millisecond.class);
        datasets.addSeries(timeseries);//from   ww w  .  jav  a 2 s . c  o m
        timeseries.setHistoryCount(historyRange);
        //add trend variables
        TimeSeries trendSeries = new TimeSeries("Trend " + i, Millisecond.class);
        trend.addSeries(trendSeries);
        trendSeries.setHistoryCount(historyRange);
        //add proj onto PCs variables
        TimeSeries PC = new TimeSeries("Projpcs " + i, Millisecond.class);
        projpcs.addSeries(PC);
        PC.setHistoryCount(historyRange);
        //add spe streams
        TimeSeries speSeries = new TimeSeries("Spe " + i, Millisecond.class);
        spe.addSeries(speSeries);
        speSeries.setHistoryCount(historyRange);
    }
    combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time"));
    //data stream  plot
    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Streams");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setItemLabelsVisible(false);
    renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(datasets, domain, range, renderer);
    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));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot);

    //Trend captured by pca
    DateAxis domain0 = new DateAxis("Time");
    NumberAxis range0 = new NumberAxis("PCA Trend");
    domain0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain0.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range0.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer0 = new DefaultXYItemRenderer();
    renderer0.setItemLabelsVisible(false);
    renderer0.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer0.setSeriesPaint(0, Color.blue);
    renderer0.setSeriesPaint(1, Color.red);
    renderer0.setSeriesPaint(2, Color.magenta);
    XYPlot plot0 = new XYPlot(trend, domain0, range0, renderer0);
    plot0.setBackgroundPaint(Color.lightGray);
    plot0.setDomainGridlinePaint(Color.white);
    plot0.setRangeGridlinePaint(Color.white);
    plot0.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain0.setAutoRange(true);
    domain0.setLowerMargin(0.0);
    domain0.setUpperMargin(0.0);
    domain0.setTickLabelsVisible(false);

    range0.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot0);

    //proj on PCs plot
    DateAxis domain1 = new DateAxis("Time");
    NumberAxis range1 = new NumberAxis("Proj on PCs");
    domain1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain1.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range1.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer1 = new DefaultXYItemRenderer();
    renderer1.setItemLabelsVisible(false);
    renderer1.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);
    renderer1.setSeriesPaint(1, Color.red);
    renderer1.setSeriesPaint(2, Color.magenta);
    plot1 = new XYPlot(projpcs, domain1, range1, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);
    plot1.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain1.setAutoRange(true);
    domain1.setLowerMargin(0.0);
    domain1.setUpperMargin(0.0);
    domain1.setTickLabelsVisible(false);

    range1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot1);

    //spe  plot
    DateAxis domain2 = new DateAxis("Time");
    NumberAxis range2 = new NumberAxis("SPE");
    domain2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer2 = new DefaultXYItemRenderer();
    renderer2.setItemLabelsVisible(false);
    renderer2.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot2 = new XYPlot(spe, domain2, range2, renderer);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);
    plot2.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain2.setAutoRange(true);
    domain2.setLowerMargin(0.0);
    domain2.setUpperMargin(0.0);
    domain2.setTickLabelsVisible(true);

    range2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot2);

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(historyRange); // 60 seconds
    JFreeChart chart;
    if (this.pcaType == AtomUtils.PCAType.pca)
        chart = new JFreeChart("CloudWatch-ATOM with Exact Data", new Font("SansSerif", Font.BOLD, 18),
                combineddomainxyplot, false);
    else if (this.pcaType == AtomUtils.PCAType.pcaTrack)
        chart = new JFreeChart("CloudWatch-ATOM with Fixed Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    else
        chart = new JFreeChart("CloudWatch-ATOM with Dynamic Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    AtomPanel.this.add(chartPanel, BorderLayout.CENTER);
}

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

/**
 *
 *///from  ww w  .  ja v  a 2s  .  com
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_217);

    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_217);
    //      JRBarPlot barPlot = (BarPlot)categoryPlot;
    //      categoryPlot.getDomainAxis().setTickLabelsVisible(
    //            categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().
    //            true
    //            );
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
    barRenderer.setSeriesPaint(0, (Paint) seriesPaints.get(3));
    barRenderer.setSeriesPaint(1, (Paint) seriesPaints.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);
            //         barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]);
            //         CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f));
            //         categoryMarker.setAlpha(0.5f);
            //         categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND);
        }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
}

From source file:convcao.com.agent.ConvcaoNeptusInteraction.java

@Override
public void paint(Graphics2D g2, StateRenderer2D renderer) {
    Graphics2D g = (Graphics2D) g2.create();

    Point2D center = renderer.getScreenPosition(coords.squareCenter);
    double width = renderer.getZoom() * coords.cellWidth * coords.numCols;
    double height = renderer.getZoom() * coords.cellWidth * coords.numRows;
    g.setColor(new Color(0, 0, 255, 64));
    g.translate(center.getX(), center.getY());
    g.rotate(-renderer.getRotation());/*from   w  w  w  . ja v  a  2 s .c om*/
    g.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height));
    g.rotate(renderer.getRotation());
    g.translate(-center.getX(), -center.getY());

    if (!active) {
        g.dispose();
        return;
    }

    g.setColor(Color.orange);
    int pos = 50;
    for (String v : nameTable.values()) {
        g.drawString(v + ": " + depths.get(v) + "m", 15, pos);
        pos += 20;
    }

    for (String vehicle : nameTable.values()) {
        LocationType src = positions.get(vehicle);
        LocationType dst = destinations.get(vehicle);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());
        float dash[] = { 4.0f };
        g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f));
        g.draw(new Line2D.Double(renderer.getScreenPosition(src), renderer.getScreenPosition(dst)));

        Point2D dstPt = renderer.getScreenPosition(dst);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());

        g.fill(new Ellipse2D.Double(dstPt.getX() - 4, dstPt.getY() - 4, 8, 8));
    }

    g.dispose();
}

From source file:nu.nethome.tools.protocol_analyzer.RawMessageDistributionWindow.java

public RawMessageDistributionWindow(Display display, RawProtocolMessage message) {
    m_Message = message;/*from   ww  w  .  j  a va  2 s  .c  om*/
    m_Shell = new Shell(display);
    m_Shell.setSize(1000, 500);
    m_Shell.setLayout(new GridLayout());
    m_Shell.setText("Undecoded Signal");
    Image image = new Image(display, this.getClass().getClassLoader()
            .getResourceAsStream("nu/nethome/tools/protocol_analyzer/radar16.png"));
    m_Shell.setImage(image);

    Iterator<Integer> samples = m_Message.m_Samples.iterator();
    Iterator<Integer> pulses = m_Message.m_PulseList.iterator();
    XYSeries markPulseSeries = new XYSeries("Mark pulses");
    XYSeries spacePulseSeries = new XYSeries("Space pulses");
    XYSeries peakSeries = new XYSeries("peak pulses");
    m_SelectedIntervalSeries = new XYSeries("Selected Interval");

    XYSeries sampleSeries = new XYSeries("Raw data");
    XYSeries pulseSeries = new XYSeries("Parsed data");
    m_SelectedPulseSeries = new XYSeries("Selected Pulses", false);

    double x = 0.0;
    boolean level = false;

    // Create a collection for plotting signal
    m_SignalSeriesCollection = new XYSeriesCollection();

    // Check what kind of data we have, if it is only pulses, the just generate
    // the pulse series and if we have samples, then generate the sampleSeries as well
    if (m_Message.m_Samples.size() == 0) {
        // Just generate pulse series
        for (double pulse : message.m_PulseLengths) {
            pulseSeries.add(x, level ? PARSED_0 : PARSED_1);
            level = !level;
            pulseSeries.add(x, level ? PARSED_0 : PARSED_1);
            x += pulse;
            pulseSeries.add(x, level ? PARSED_0 : PARSED_1);
        }
    } else {
        // Both pulses and samples
        int sampleNumber = 0;
        int nextPulse = pulses.hasNext() ? pulses.next() : 0;

        // Loop through the samples and pulses and generate coordinates for plotting
        while (samples.hasNext()) {
            double value = (double) (samples.next());
            sampleSeries.add(x, value);
            // Check if we have reached a pulse flank
            if (sampleNumber == nextPulse) {
                pulseSeries.add(x, level ? PARSED_1 : PARSED_0);
                level = !level;
                pulseSeries.add(x, level ? PARSED_1 : PARSED_0);
                nextPulse = pulses.hasNext() ? pulses.next() : 0;
            }
            x += 1000.0 / m_Message.m_SampleFrequency;
            sampleNumber++;
        }
        // Only add this series if we have samples
        m_SignalSeriesCollection.addSeries(sampleSeries);
    }

    m_SignalSeriesCollection.addSeries(pulseSeries);
    m_SignalSeriesCollection.addSeries(m_SelectedPulseSeries);

    // Transform data to pulse distribution for mark and space flanks. We only count
    // pulses under 10 ms and group them in 10 us wide groups counting how many
    // pulses are within each 10 us group.
    int markFrequency[] = new int[1000];
    int spaceFrequency[] = new int[1000];

    boolean mark = false;
    for (double length : message.m_PulseLengths) {
        if (length < 10000.0) {
            int lengthInterval = (int) (length / 10);
            if (mark) {
                markFrequency[lengthInterval]++;
                updateMax(markFrequency[lengthInterval]);
            } else {
                spaceFrequency[lengthInterval]++;
                updateMax(spaceFrequency[lengthInterval]);
            }
        }
        mark = !mark;
    }

    for (int i = 0; i < 1000; i++) {
        markPulseSeries.add(i * 10, markFrequency[i]);
        markPulseSeries.add((i + 1) * 10, markFrequency[i]);
        spacePulseSeries.add(i * 10, spaceFrequency[i]);
        spacePulseSeries.add((i + 1) * 10, spaceFrequency[i]);
    }

    // Loop through the pulse distribution groups and find "peaks", which are the centers
    // of pulse groups. Then we sort them to get the highest peaks first and "prime" the 
    // pulse group analyzer with them, so the pulse groups get selected with correct centers. 
    List<PulseLengthIntervalGroup> peakPulseLengthIntervals = new LinkedList<PulseLengthIntervalGroup>();
    findPeaks(markFrequency, true, peakPulseLengthIntervals);
    findPeaks(spaceFrequency, false, peakPulseLengthIntervals);
    Collections.sort(peakPulseLengthIntervals);
    primePulseAnalyzer(peakPulseLengthIntervals);
    analyzePulsLengths2(m_Message.m_PulseLengths);

    int i1 = 0;
    for (PulseLengthIntervalGroup group : peakPulseLengthIntervals) {
        peakSeries.add(group.getCenterLength(), 0);
        peakSeries.add(group.getCenterLength(), m_MaxNumberOfPulses - i1 * m_MaxNumberOfPulses / 20);
        peakSeries.add(group.getCenterLength(), 0);
        i1++;
    }

    // Create a collection for plotting pulse distribution
    m_DistributionData = new XYSeriesCollection();
    m_DistributionData.addSeries(markPulseSeries);
    m_DistributionData.addSeries(spacePulseSeries);
    //m_DistributionData.addSeries(peakSeries);
    m_DistributionData.addSeries(m_SelectedIntervalSeries);

    // Create Tab Folder for the charts
    CTabFolder chartFolder = new CTabFolder(m_Shell, SWT.NONE);
    GridData folderGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    folderGridData.grabExcessHorizontalSpace = true;
    folderGridData.grabExcessVerticalSpace = false;
    folderGridData.heightHint = 280;
    chartFolder.setLayoutData(folderGridData);

    // Create tab for signal
    CTabItem signalTab = new CTabItem(chartFolder, SWT.NONE);
    signalTab.setText("Signal");

    // Create a Chart and a panel for signal
    JFreeChart chart = ChartFactory.createXYLineChart("Signal", "ms", "Amplitude", m_SignalSeriesCollection,
            PlotOrientation.VERTICAL, true, false, false);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(700, 290));
    configurePanelLooks(chart, 2);

    // Create a ChartComposite on our window
    ChartComposite frame = new ChartComposite(chartFolder, SWT.NONE, chart, true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    frame.setDisplayToolTips(true);
    GridData gridDatap = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gridDatap.grabExcessHorizontalSpace = true;
    gridDatap.grabExcessVerticalSpace = false;
    //gridDatap.heightHint = 270;
    frame.setLayoutData(gridDatap);
    signalTab.setControl(frame);

    // Create tab for pulse distribution
    CTabItem distributionTab = new CTabItem(chartFolder, SWT.NONE);
    distributionTab.setText("Pulse length Distribution");

    // Create a Chart and a panel for pulse length distribution
    JFreeChart distributionChart = ChartFactory.createXYLineChart("Pulse Length Distribution",
            "Pulse Length (us)", "# Pulses", m_DistributionData, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel distributionChartPanel = new ChartPanel(distributionChart);
    configurePanelLooks(distributionChart, 2);
    distributionChartPanel.setPreferredSize(new Dimension(700, 270));// 270

    // Make the mark line dashed, so we can see the space line when they overlap
    float pattern[] = { 5.0f, 5.0f };
    BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, pattern,
            0.0f);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) distributionChart.getXYPlot().getRenderer();
    renderer.setSeriesStroke(0, stroke);

    // Create a ChartComposite on our tab for pulse distribution
    ChartComposite distributionFrame = new ChartComposite(chartFolder, SWT.NONE, distributionChart, true);
    distributionFrame.setHorizontalAxisTrace(false);
    distributionFrame.setVerticalAxisTrace(false);
    distributionFrame.setDisplayToolTips(true);
    GridData distributionGridData = new GridData(
            GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    distributionGridData.grabExcessHorizontalSpace = true;
    distributionGridData.grabExcessVerticalSpace = false;
    distributionGridData.heightHint = 270;
    distributionFrame.setLayoutData(distributionGridData);
    distributionTab.setControl(distributionFrame);

    // Create the pulse group table
    m_Table = new Table(m_Shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    m_Table.setLayoutData(gridData);

    // Create the columns in the table
    TableColumn tc0 = new TableColumn(m_Table, SWT.CENTER);
    TableColumn tc1 = new TableColumn(m_Table, SWT.CENTER);
    TableColumn tc2 = new TableColumn(m_Table, SWT.CENTER);
    TableColumn tc3 = new TableColumn(m_Table, SWT.CENTER);
    TableColumn tc4 = new TableColumn(m_Table, SWT.CENTER);
    tc0.setText("Pulse Level");
    tc1.setText("Average Pulse Length");
    tc2.setText("Count");
    tc3.setText("Min Pulse Length");
    tc4.setText("Max Pulse Length");
    tc0.setWidth(80);
    tc1.setWidth(150);
    tc2.setWidth(70);
    tc3.setWidth(150);
    tc4.setWidth(150);
    m_Table.setHeaderVisible(true);

    Iterator<PulseLengthAnalyzer.PulseLengthGroup> spulses = m_PulseFrequency.iterator();
    while (spulses.hasNext()) {
        PulseLengthAnalyzer.PulseLengthGroup l = spulses.next();
        double avg = l.getAvarage();

        TableItem item1 = new TableItem(m_Table, SWT.NONE);
        String text[] = new String[NO_COLUMNS];
        text[0] = l.m_IsMark ? "Mark" : "Space";
        text[1] = String.format("%.0f uS", avg);
        text[2] = Integer.toString(l.getCount());
        text[3] = String.format("%.0f uS (%.1f%%)", l.m_Min, (l.m_Min / avg - 1) * 100);
        text[4] = String.format("%.0f uS (+%.1f%%)", l.m_Max, (l.m_Max / avg - 1) * 100);
        item1.setText(text);
    }

    m_Table.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent arg0) {
            widgetSelected(arg0);

        }

        public void widgetSelected(SelectionEvent arg0) {
            //m_DistributionData.removeSeries(1);
            int selectedRow = m_Table.getSelectionIndex();
            PulseLengthGroup pl = m_PulseFrequency.get(selectedRow);
            markPulseInterval(pl.m_Min, pl.m_Max, pl.m_IsMark);
        }

    });

}

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.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_217);

    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_217);
    //      JRBarPlot barPlot = (BarPlot)categoryPlot;
    //      categoryPlot.getDomainAxis().setTickLabelsVisible(
    //            categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().
    //            true
    //            );
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    @SuppressWarnings("unchecked")
    List<Paint> seriesPaints = (List<Paint>) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.SERIES_COLORS);
    barRenderer.setSeriesPaint(0, seriesPaints.get(3));
    barRenderer.setSeriesPaint(1, seriesPaints.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);
            //         barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]);
            //         CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f));
            //         categoryMarker.setAlpha(0.5f);
            //         categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND);
        }/* w  w w  .  j a v  a 2  s .  com*/
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
}

From source file:ala.soils2sat.DrawingUtils.java

public static void drawRoundedRect(Graphics g, int left, int top, int right, int bottom) {
    Graphics2D g2d = (Graphics2D) g;
    g.drawLine(left + cornerSize, top, right - cornerSize, top);
    g.drawLine(left + cornerSize, bottom, right - cornerSize, bottom);
    g.drawLine(left, top + cornerSize, left, bottom - cornerSize);
    g.drawLine(right, top + cornerSize, right, bottom - cornerSize);
    final Object previousAntiAliasingHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    final Stroke previousStroke = g2d.getStroke();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
    try {/*from w  w  w . j  a  va 2 s .  c om*/
        g.drawLine(left, top + cornerSize, left + cornerSize, top);
        g.drawLine(left, bottom - cornerSize, left + cornerSize, bottom);
        g.drawLine(right, top + cornerSize, right - cornerSize, top);
        g.drawLine(right, bottom - cornerSize, right - cornerSize, bottom);
    } finally {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, previousAntiAliasingHint);
        g2d.setStroke(previousStroke);
    }
}

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 .jav a  2s  .c o 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:SWTGraphics2D.java

/**
 * Sets the stroke for this graphics context.  For now, this implementation
 * only recognises the {@link BasicStroke} class.
 *
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #getStroke()/*  w w w. j a  va2s . c o  m*/
 */
public void setStroke(Stroke stroke) {
    if (stroke instanceof BasicStroke) {
        BasicStroke bs = (BasicStroke) stroke;
        // linewidth
        this.gc.setLineWidth((int) bs.getLineWidth());

        // line join
        switch (bs.getLineJoin()) {
        case BasicStroke.JOIN_BEVEL:
            this.gc.setLineJoin(SWT.JOIN_BEVEL);
            break;
        case BasicStroke.JOIN_MITER:
            this.gc.setLineJoin(SWT.JOIN_MITER);
            break;
        case BasicStroke.JOIN_ROUND:
            this.gc.setLineJoin(SWT.JOIN_ROUND);
            break;
        }

        // line cap
        switch (bs.getEndCap()) {
        case BasicStroke.CAP_BUTT:
            this.gc.setLineCap(SWT.CAP_FLAT);
            break;
        case BasicStroke.CAP_ROUND:
            this.gc.setLineCap(SWT.CAP_ROUND);
            break;
        case BasicStroke.CAP_SQUARE:
            this.gc.setLineCap(SWT.CAP_SQUARE);
            break;
        }

        // set the line style to solid by default
        this.gc.setLineStyle(SWT.LINE_SOLID);

        // apply dash style if any
        float[] dashes = bs.getDashArray();
        if (dashes != null) {
            int[] swtDashes = new int[dashes.length];
            for (int i = 0; i < swtDashes.length; i++) {
                swtDashes[i] = (int) dashes[i];
            }
            this.gc.setLineDash(swtDashes);
        }
    } else {
        throw new RuntimeException("Can only handle 'Basic Stroke' at present.");
    }
}

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 . java 2  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);
}