Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

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

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:controller.DrawCurve.java

private JPanel createChart() {
    String chartTitle = "Camera Response Curve";
    String xAxisLabel = "log Exposure G(Z)";
    String yAxisLabel = "Intensity pixel Z";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    //Set custom color and thickness for line curve
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    // sets paint color for each series
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.BLUE);

    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(1.5f));
    renderer.setSeriesStroke(1, new BasicStroke(1.5f));
    renderer.setSeriesStroke(2, new BasicStroke(1.5f));

    XYPlot plot = chart.getXYPlot();/*  w  w w . j ava 2s  .c  om*/
    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}

From source file:AntiAlias.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;
    BufferedImage image = // Create an off-screen image
            new BufferedImage(65, 35, BufferedImage.TYPE_INT_RGB);
    Graphics2D ig = image.createGraphics(); // Get its Graphics for drawing

    // Set the background to a gradient fill. The varying color of
    // the background helps to demonstrate the anti-aliasing effect
    ig.setPaint(new GradientPaint(0, 0, Color.black, 65, 35, Color.white));
    ig.fillRect(0, 0, 65, 35);//  ww  w.  j  a v a 2s  .  c o  m

    // Set drawing attributes for the foreground.
    // Most importantly, turn on anti-aliasing.
    ig.setStroke(new BasicStroke(2.0f)); // 2-pixel lines
    ig.setFont(new Font("Serif", Font.BOLD, 18)); // 18-point font
    ig.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
            RenderingHints.VALUE_ANTIALIAS_ON);

    // Now draw pure blue text and a pure red oval
    ig.setColor(Color.blue);
    ig.drawString("Java", 9, 22);
    ig.setColor(Color.red);
    ig.drawOval(1, 1, 62, 32);

    // Finally, scale the image by a factor of 10 and display it
    // in the window. This will allow us to see the anti-aliased pixels
    g.drawImage(image, AffineTransform.getScaleInstance(10, 10), this);

    // Draw the image one more time at its original size, for comparison
    g.drawImage(image, 0, 0, this);
}

From source file:Componentes.TermometroMax.java

@Override
public void pintar(javax.swing.JPanel p, int pos) {
    p.removeAll();//from   w w  w .jav a  2 s . c o  m
    DefaultValueDataset data = new DefaultValueDataset(new Double(ventana.getGraphdata().getTmax()));

    ThermometerPlot plot = new ThermometerPlot(data);
    chart = new JFreeChart("Temperatura Maxima, \nMES: " + Calculos.get_mes(ventana.getMonthdata().getdata()), // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);

    Color Darkorange = new Color(255, 140, 0);
    Color Crimson = new Color(220, 20, 60);
    Color Aquamarine = new Color(127, 255, 212);
    Color Darkslategray = new Color(47, 79, 79);

    plot.setMercuryPaint(Aquamarine);
    plot.setSubrange(NORMAL, 0, 10);
    plot.setSubrange(WARNING, 10.1, 20);
    plot.setSubrange(CRITICAL, 20.1, 50);
    plot.setSubrangePaint(NORMAL, Aquamarine);
    plot.setSubrangePaint(WARNING, Darkorange);
    plot.setSubrangePaint(CRITICAL, Crimson);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Darkslategray);

    plot.setDisplayRange(5, Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));
    plot.setRange(Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 300, 300);
    panel.repaint();
    p.add(panel);
    // jPanel1.repaint();
    p.updateUI();
    // aoIndex=aoAux;
    ///aoAux = 0;
}

From source file:IHM.NewClass.java

/**
 *
 * @param title//from   ww w.j ava 2  s . c  om
 */
public NewClass(String title /*,*JInternalFrame jp*/) {
    super(title);
    // jp = new JInternalFrame("courbes");

    JFreeChart chart = createChart(createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(500, 300));
    setContentPane(panel);
    //  jp.add(panel, BorderLayout.EAST);
    //  jp.setVisible(true);
    panel.setVisible(true);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

}

From source file:de.unibayreuth.bayeos.goat.chart.StatusXYPlot.java

private void addLegendItem(String text, Color col) {

    legendcol.add(new LegendItem(text, text, new Rectangle(10, 10), true, col, col, new BasicStroke(2.0f)));

}

From source file:com.jbombardier.console.charts.LineFormatController.java

public Stroke getStroke(String label) {
    Stroke stroke = seriesStrokes.get(label);
    if (stroke == null) {
        stroke = new BasicStroke(1);
        seriesStrokes.put(label, stroke);
    }//w  ww . j a va  2  s.  co  m
    return stroke;

}

From source file:chart.XYChart.java

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

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForThree(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2),
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f));
    plot.setRenderer(renderer);/*from   w w  w. j  a  va2s .co  m*/
    setContentPane(chartPanel);

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

}

From source file:org.sonar.plugins.core.charts.XradarChart.java

@Override
protected Plot getPlot(ChartParameters params) {
    SpiderWebPlot plot = new SpiderWebPlot(createDataset(params));
    plot.setStartAngle(0D);//from  w w  w .j  a  v  a 2 s.com
    plot.setOutlineVisible(false);
    plot.setAxisLinePaint(Color.decode("0xCCCCCC"));
    plot.setSeriesOutlineStroke(new BasicStroke(2f));

    if (params.getValue(PARAM_INTERIOR_GAP) != null) {
        plot.setInteriorGap(Double.parseDouble(params.getValue(PARAM_INTERIOR_GAP, "0.4", false)));
    }
    if (params.getValue(PARAM_MAX_VALUE) != null) {
        plot.setMaxValue(Double.parseDouble(params.getValue(PARAM_MAX_VALUE, "100", false)));
    }
    configureColors(plot, params);
    return plot;
}

From source file:GraphUI.java

/**
 * Creates new form GraphUI/*from  w ww .j a v  a2  s .c  o  m*/
 */
public GraphUI() {
    try {
        //graphPane is the jPanel in the jFrame
        //cp is the ChartPanel that needs to be held inside jPanel1
        initComponents();
        data = Pinwheel.getData();
        this.batch = data[0];

        //jPanel1 = createChartPanel();
        cp = createChartPanel();
        //cp = new ChartPanel(chart);
        cp.setMouseWheelEnabled(true);

        jPanel1.add(cp);

        XYPlot plot = chart.getXYPlot();

        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

        renderer.setSeriesStroke(0, new BasicStroke(3.0f));
        renderer.setSeriesStroke(1, new BasicStroke(3.0f));

        plot.setBackgroundPaint(Color.DARK_GRAY);

        plot.setRangeGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.BLACK);

        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.BLACK);

        plot.setRenderer(renderer);

        this.addWindowListener(new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent windowEvent) {
                backBtn.doClick();
            }
        });

    } catch (SQLException ex) {
        Logger.getLogger(GraphUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:dbseer.gui.chart.DBSeerXYLineAndShapeRenderer.java

@Override
public Stroke getItemOutlineStroke(int row, int column) {
    if (row == this.lastSeries && column == this.lastCategory) {
        return new BasicStroke(8.0f);
    }/*from  www . j  a v a2  s  .  com*/
    return super.getItemOutlineStroke(row, column);
}