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:org.jfree.chart.demo.CategoryMarkerDemo2.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25),
            new BasicStroke(1.0F));
    categorymarker.setDrawAsLine(false);
    categorymarker.setAlpha(1.0F);/*www .  java2 s  .co  m*/
    categorymarker.setLabel("Marker Label");
    categorymarker.setLabelFont(new Font("Dialog", 0, 11));
    categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D));
    categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND);
    return jfreechart;
}

From source file:AppPackage.humidity.java

public humidity() {
    try {/*from w  w  w .  j  av  a2  s  . c o  m*/

        JFrame window = new JFrame();
        window.setSize(1000, 615);
        window.setBackground(Color.blue.darker());
        double value = 45;
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
        window.setLocation(x, y);
        DefaultValueDataset dataset = new DefaultValueDataset(value);

        ThermometerPlot thermometerplot = new ThermometerPlot(dataset);

        thermometerplot.setSubrangePaint(0, Color.green.darker());
        thermometerplot.setSubrangePaint(1, Color.orange);
        thermometerplot.setSubrangePaint(2, Color.red);
        JFreeChart jfreechart = new JFreeChart("Humidity readings", JFreeChart.DEFAULT_TITLE_FONT,
                thermometerplot, true);
        thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D));
        thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
        thermometerplot.setThermometerStroke(new BasicStroke(2.0F));
        thermometerplot.setThermometerPaint(Color.BLUE);
        thermometerplot.setUnits(0);
        thermometerplot.setGap(3);

        window.add(new ChartPanel(jfreechart), BorderLayout.CENTER);
        window.setVisible(true);

    } catch (Exception e) {
        System.out.print("Chart exception:" + e);
    }
    initComponents();
}

From source file:AppPackage.Temperature.java

public Temperature() {
    try {//  w ww.j a va2s . c  om

        JFrame window = new JFrame();
        window.setSize(1000, 615);
        window.setBackground(Color.blue.darker());
        double value = 55;
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
        window.setLocation(x, y);
        DefaultValueDataset dataset = new DefaultValueDataset(value);

        ThermometerPlot thermometerplot = new ThermometerPlot(dataset);
        thermometerplot.setSubrangePaint(0, Color.green.darker());
        thermometerplot.setSubrangePaint(1, Color.orange);
        thermometerplot.setSubrangePaint(2, Color.red);
        JFreeChart jfreechart = new JFreeChart("Temperature readings", JFreeChart.DEFAULT_TITLE_FONT,
                thermometerplot, true);
        thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D));
        thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
        thermometerplot.setThermometerStroke(new BasicStroke(2.0F));
        thermometerplot.setThermometerPaint(Color.BLUE);

        thermometerplot.setGap(3);

        window.add(new ChartPanel(jfreechart), BorderLayout.CENTER);
        window.setVisible(true);

    } catch (Exception e) {
        System.out.print("Chart exception:" + e);
    }
    initComponents();
}

From source file:FontRenderContextRenderingHints.java

public void paint(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    int w = getSize().width;
    int h = getSize().height;

    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2D.setRenderingHints(qualityHints);

    AffineTransform at = new AffineTransform();
    at.setToTranslation(-300, -400);/* ww  w. jav  a  2 s  .com*/
    at.shear(-0.5, 0.0);
    FontRenderContext frc = new FontRenderContext(at, false, false);
    TextLayout tl = new TextLayout("World!", font, frc);
    Shape outline = tl.getOutline(null);
    g2D.setColor(Color.blue);

    BasicStroke wideStroke = new BasicStroke(2.0f);
    g2D.setStroke(wideStroke);
    g2D.draw(outline);

}

From source file:grafix.graficos.eixos.EixoCandles.java

protected void completarPlot(final XYPlot plot, final JanelaGraficos janela) {
    OHLCDataset dataCandles = criarOHLCDataset(janela);
    CandlestickRenderer candRenderer = new CandlestickRenderer();
    candRenderer.setUpPaint(Controle.getConfiguracoesUsuario().getCorCandlesAlta());
    candRenderer.setDownPaint(Controle.getConfiguracoesUsuario().getCorCandlesBaixa());
    candRenderer.setSeriesPaint(0, Color.black);
    candRenderer.setStroke(new BasicStroke(.75f));
    candRenderer.setToolTipGenerator(new CandlesToolTipGenerator(janela));
    plot.setDataset(indices.size(), dataCandles);
    plot.setRenderer(indices.size(), candRenderer);
    incluirMarcaIntraday(plot, janela);// w w w  .  j  av  a2s.co m
}

From source file:com.ivli.roim.controls.DomainMarker.java

public DomainMarker(double aV, XYSeries aS) {
    super(aV);/*from w ww.j  a va  2 s . com*/
    iSeries = aS;
    iSeries.addChangeListener(this);
    setLabel(String.format(LABEL_FORMAT, aV));
    setLabelAnchor(RectangleAnchor.CENTER);
    setLabelOffset(RectangleInsets.ZERO_INSETS);

    setAlpha(1.0f);
    setPaint(Color.BLACK);
    setStroke(new BasicStroke(1.0f));

    setOutlinePaint(Color.CYAN);
    setOutlineStroke(new BasicStroke(.0f));
}

From source file:grafix.graficos.indices.IndiceBollinger.java

@Override
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) {
    float[] color = getCor().getComponents(null);
    XYDifferenceRenderer r = new XYDifferenceRenderer(new Color(color[0], color[1], color[2], .1f), Color.red,
            false);/*from  www .  jav a  2 s.c om*/
    r.setStroke(new BasicStroke(.75f));
    r.setPaint(getCor());
    plot.setRenderer(contador, r);
    plot.setDataset(contador, getDataSet(janela));
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {//from w  w  w .j a v a 2s.  c  om
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}

From source file:org.jfree.chart.demo.CylinderChartDemo2.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 2", "Category", "Value",
            categorydataset, PlotOrientation.HORIZONTAL, false, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    Paint apaint[] = createPaint();
    CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint);
    customcylinderrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    customcylinderrenderer.setBaseOutlinePaint(Color.gray);
    customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F));
    customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    categoryplot.setRenderer(customcylinderrenderer);
    return jfreechart;
}

From source file:grafix.graficos.indices.IndiceADX.java

@Override
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) {
    XYLineAndShapeRenderer r = new XYLineAndShapeRenderer();
    r.setSeriesLinesVisible(0, true);/*from w  w  w . j  a v a2 s . co  m*/
    r.setSeriesShapesVisible(0, false);
    r.setSeriesPaint(0, Color.BLUE);
    r.setSeriesStroke(0, new BasicStroke(.75f));

    r.setSeriesPaint(1, Color.RED);
    r.setSeriesStroke(1, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 3.0f, 4.0f }, 0.0f));
    r.setSeriesLinesVisible(1, true);
    r.setSeriesShapesVisible(1, false);

    r.setSeriesPaint(2, new Color(0f, .6f, 0f));
    r.setSeriesStroke(2, new BasicStroke(.6f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f,
            new float[] { 3.0f, 4.0f }, 0.0f));
    r.setSeriesLinesVisible(2, true);
    r.setSeriesShapesVisible(2, false);

    r.setToolTipGenerator(new IndiceToolTipGenerator(this));
    plot.setRenderer(contador, r);
    plot.setDataset(contador, getDataSet(janela));
}