Example usage for java.awt BasicStroke JOIN_MITER

List of usage examples for java.awt BasicStroke JOIN_MITER

Introduction

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

Prototype

int JOIN_MITER

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

Click Source Link

Document

Joins path segments by extending their outside edges until they meet.

Usage

From source file:wef.articulab.view.ui.CombinedBNXYPlot.java

private XYPlot createPlot(ChartContainer chartContainer) {
    createDataset(chartContainer);/*from  ww w  .  ja v a2  s  .com*/
    chartContainer.target = new IntervalMarker(14, 16);
    chartContainer.target.setLabel("Activation Threshold");
    chartContainer.target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    chartContainer.target.setLabelAnchor(RectangleAnchor.LEFT);
    chartContainer.target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    chartContainer.target.setPaint(new Color(222, 222, 255, 128));
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    BasicStroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    for (int i = 0; i < chartContainer.series.length - 1; i++) {
        renderer.setSeriesStroke(i, stroke);
    }
    renderer.setSeriesStroke(chartContainer.series.length - 1, new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f));

    NumberAxis rangeAxis = new NumberAxis("Activation");
    NumberAxis domainAxis = new NumberAxis("Time");
    XYPlot plot = new XYPlot(chartContainer.dataset, domainAxis, rangeAxis, renderer);
    plot.addRangeMarker(chartContainer.target, Layer.BACKGROUND);
    plot.setRenderer(renderer);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    chartContainer.plot = plot;
    return plot;
}

From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java

public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();

    String members = req.getParameter("categories");
    String graphTitle = req.getParameter("title");

    int w = Integer.parseInt(req.getParameter("width"));
    int h = Integer.parseInt(req.getParameter("height"));

    List<String> memberList = Arrays.asList(members.split(","));
    List<List<String>> memberLists = new ArrayList<List<String>>();

    for (String s : memberList) {
        memberLists.add(Arrays.asList(s.split(" ")));
    }// www  .ja  v a  2 s.c o m

    List<ValueMarker> markers = new ArrayList<ValueMarker>();

    double max = Double.MIN_VALUE;
    Set<String> drawnMarker = new HashSet<String>();

    String scale = getRecorder().scale;

    for (MemoryMapBuildAction membuild = this; membuild != null; membuild = membuild.getPreviousAction()) {
        ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(membuild.build);
        MemoryMapConfigMemory result = membuild.getMemoryMapConfig();
        MemoryMapConfigMemory resultBlacklist = new MemoryMapConfigMemory();
        for (List<String> list : memberLists) {
            double value = 0.0d;
            double maxx = 0.0d;
            String labelName = "";
            for (MemoryMapConfigMemoryItem res : result) {
                if (list.contains(res.getName()) && !resultBlacklist.contains(res)) {
                    resultBlacklist.add(res);
                    if (labelName.equals("")) {
                        labelName = res.getName();
                    } else {
                        labelName = String.format("%s+%s", labelName, res.getName());
                    }

                    if (getRecorder().getShowBytesOnGraph()) {
                        maxx = maxx + HexUtils.byteCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.byteCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    } else {
                        maxx = maxx + HexUtils.wordCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.wordCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    }
                } else {
                }

                if (maxx > max) {
                    max = maxx;
                }
                if (value > max) {
                    max = value;
                }
            }
            if (!labelName.equals("")) {
                dataset.add(value, labelName, label);
            }

            boolean makeMarker = true;
            for (ValueMarker vm : markers) {
                if (maxx == vm.getValue() && !vm.getLabel().contains(labelName) && !labelName.equals("")) {
                    drawnMarker.add(vm.getLabel().replace("(MAX) - ", "") + " - " + labelName);
                    String s = vm.getLabel().replace("(MAX) - ", "");

                    vm.setLabel(String.format("%s - %s", vm.getLabel(), labelName));
                    //this is the size of chars used for setting the offset right
                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));

                    makeMarker = false;
                }
            }

            if ((!labelName.equals("")) && (drawnMarker.add(labelName))) {
                if (makeMarker) {
                    ValueMarker vm = new ValueMarker((double) maxx, Color.BLACK,
                            new BasicStroke(1.2f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f,
                                    new float[] { 6.0f, 6.0f }, 0.0f));

                    vm.setLabel(String.format("(MAX) - %s", labelName));

                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));
                    vm.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                    vm.setPaint(Color.BLACK);
                    vm.setOutlinePaint(Color.BLACK);
                    vm.setAlpha(1.0f);
                    markers.add(vm);
                }
            }
        }
    }

    String s = "";
    if (scale.equalsIgnoreCase("kilo")) {
        s = "k";
    } else if (scale.equalsIgnoreCase("mega")) {
        s = "M";
    } else if (scale.equalsIgnoreCase("giga")) {
        s = "G";
    }

    String byteLegend = s + "Bytes";
    String wordLegend = s + "Words";

    String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend;

    JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataset.build(), markers);

    chart.setBackgroundPaint(Color.WHITE);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ChartUtil.generateGraph(req, rsp, chart, w, h);
}

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   ww  w.jav 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)
        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:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *///from w  w w.jav  a  2s.c  o m
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());//w  w w . j a  v a 2 s  . com
    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;/*  ww  w.  j av  a  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:Applet.EmbeddedChart.java

/**
 * Creates a chart.//  w ww .j av  a 2s. c  o  m
 * 
 * @param dataset
 *            the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String title, boolean gofr) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart
            // title
            "Radial Distance,  r/\u03c3", // x axis label
            title, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);

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

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    XYTitleAnnotation xyta = new XYTitleAnnotation(0.98, 0.98, chart.getLegend(), RectangleAnchor.TOP_RIGHT);
    chart.removeLegend();
    plot.addAnnotation(xyta);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    for (int i = 0; i < 2; i++) {
        renderer.setSeriesPaint(i * 6 + 0, new Color(255, 0, 0));
        renderer.setSeriesPaint(i * 6 + 1, new Color(0, 0, 255));
        renderer.setSeriesPaint(i * 6 + 2, new Color(0, 139, 0));
        renderer.setSeriesPaint(i * 6 + 3, new Color(255, 165, 0));
        renderer.setSeriesPaint(i * 6 + 4, new Color(255, 0, 255));
        renderer.setSeriesPaint(i * 6 + 5, new Color(0, 0, 0));

        renderer.setSeriesStroke(i * 6 + 0, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f));
        renderer.setSeriesStroke(i * 6 + 1, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 50.0f, 2.0f }, 0.0f));
        renderer.setSeriesStroke(i * 6 + 2, new BasicStroke(1.3f, BasicStroke.JOIN_ROUND,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 30.0f, 1.0f, 1.0f }, 0.0f));
        renderer.setSeriesStroke(i * 6 + 3, new BasicStroke(1.3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                10.0f, new float[] { 1.0f, 3.0f }, 0.0f));
        renderer.setSeriesStroke(i * 6 + 4, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 1.0f, 2.0f, 3.0f, 4.0f }, 0.0f));
        renderer.setSeriesStroke(i * 6 + 5, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f, 1.0f, 20.0f, 1.0f }, 0.0f));
    }

    plot.setRenderer(renderer);

    return chart;

}

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 . co m*/
    }
    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 {/* ww  w  .  jav a  2  s .co  m*/
        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: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  .  jav a2s.  com
 */
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.");
    }
}