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:rod_design_compute.ShowPanel.java

private void paintRRR(RRR rodRRR, Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setStroke(new BasicStroke(2f));

    if (rodRRR.flag2 == true || rodRRR.flag3 == true) {
        g2d.setColor(Color.red);/*from  w  w w  . j a  v  a2  s .com*/
        if (rodRRR.flag2 == true) {
            g.drawLine(toScreenX(rodRRR.getPointB().X), toScreenY(rodRRR.getPointB().Y),
                    toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        } else if (rodRRR.flag3 == true) {
            g.drawLine(toScreenX(rodRRR.getPointD().X), toScreenY(rodRRR.getPointD().Y),
                    toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        }
        g.drawLine(toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y),
                toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        drawOtherPoint(rodRRR.getPointE(), g);
        g2d.setColor(Color.black);
    }

    g.drawLine(toScreenX(rodRRR.getPointB().X), toScreenY(rodRRR.getPointB().Y),
            toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y));

    g.drawLine(toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y),
            toScreenX(rodRRR.getPointD().X), toScreenY(rodRRR.getPointD().Y));

    drawJunctionPoint(rodRRR.getPointB(), g);
    drawJunctionPoint(rodRRR.getPointC(), g);
    drawBasePoint(rodRRR.getPointD(), g);
}

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

/**
 * Creates a chart./*from   w  w w.  j av  a2 s .  c om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    final TextTitle title = new TextTitle("Figure 7 | I. Resources - The site offers users relevant, "
            + "informative and educational resources");
    title.setHorizontalAlignment(HorizontalAlignment.LEFT);
    title.setBackgroundPaint(Color.red);
    title.setPaint(Color.white);

    chart.setTitle(title);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setOutlinePaint(null);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePosition(CategoryAnchor.END);
    plot.setDomainGridlineStroke(new BasicStroke(0.5f));
    plot.setDomainGridlinePaint(Color.black);

    plot.setRangeGridlinesVisible(false);
    plot.clearRangeMarkers();

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setCategoryMargin(0.50);

    plot.getRangeAxis().setVisible(false);

    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A));
    renderer.setOutlineStroke(null);
    renderer.setBaseOutlineStroke(null);

    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelFont(new Font("SansSerif", Font.BOLD, 10));
    final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT);
    renderer.setPositiveItemLabelPosition(position);

    final CategoryTextAnnotation a1 = new CategoryTextAnnotation("1. White papers are available.", "Category 1",
            0.0);
    a1.setFont(new Font("SansSerif", Font.BOLD, 12));
    a1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a1.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a1);

    final CategoryTextAnnotation a2 = new CategoryTextAnnotation(
            "2. White papers enhance users " + "understanding of the firm and its expertise.", "Category 2",
            0.0);
    a2.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a2.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a2);

    final CategoryTextAnnotation a3 = new CategoryTextAnnotation(
            "3. White papers are relevant to " + "the firm's prospects and clients.", "Category 3", 0.0);
    a3.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a3.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a3);

    final CategoryTextAnnotation a4 = new CategoryTextAnnotation(
            "4. White papers are relevant to " + "the firm's positioning.", "Category 4", 0.0);
    a4.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a4.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a4);

    final CategoryTextAnnotation a5 = new CategoryTextAnnotation("5. Case studies are available.", "Category 5",
            0.0);
    a5.setFont(new Font("SansSerif", Font.BOLD, 12));
    a5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a5.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a5);

    final CategoryTextAnnotation a6 = new CategoryTextAnnotation(
            "6. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 6",
            0.0);
    a6.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a6.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a6);

    final CategoryTextAnnotation a7 = new CategoryTextAnnotation(
            "7. Case studies are relevant to " + "the firm's prospects and clients.", "Category 7", 0.0);
    a7.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a7.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a7);

    final CategoryTextAnnotation a8 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0);
    a8.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a8.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a8);

    final CategoryTextAnnotation a9 = new CategoryTextAnnotation("9. Case studies are available.", "Category 9",
            0.0);
    a9.setFont(new Font("SansSerif", Font.BOLD, 12));
    a9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a9.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a9);

    final CategoryTextAnnotation a10 = new CategoryTextAnnotation(
            "10. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 10",
            0.0);
    a10.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a10.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a10);

    final CategoryTextAnnotation a11 = new CategoryTextAnnotation(
            "11. Case studies are relevant " + "to the firm's prospects and clients.", "Category 11", 0.0);
    a11.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a11.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a11);

    final CategoryTextAnnotation a12 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0);
    a12.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a12.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a12);

    final CategoryTextAnnotation a13 = new CategoryTextAnnotation(
            "13. Users can easily access " + "resources based on viewer interest.", "Category 13", 0.0);
    a13.setFont(new Font("SansSerif", Font.BOLD, 12));
    a13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a13.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a13);

    final CategoryTextAnnotation a14 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant " + "information.",
            "Category 14", 0.0);
    a14.setFont(new Font("SansSerif", Font.BOLD, 12));
    a14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a14.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a14);

    final CategoryTextAnnotation a15 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.", "Overall", 0.0);
    a15.setFont(new Font("SansSerif", Font.BOLD, 12));
    a15.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a15.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a15);

    return chart;

}

From source file:MWC.GUI.JFreeChart.NewFormattedJFreeChart.java

/**
 * set the width of the data line//from w  ww.j  a  v  a 2  s .co  m
 * 
 * @param dataLineWidth
 *          width in pixels
 */
public void setDataLineWidth(final int dataLineWidth) {
    this._dataLineWidth = dataLineWidth;

    // and update the data
    final XYPlot thePlot = (XYPlot) getPlot();
    final Stroke[] theStrokes = new Stroke[] { new BasicStroke(_dataLineWidth) };
    for (int i = 0; i < theStrokes.length; i++) {
        final Stroke stroke = theStrokes[i];
        thePlot.getRenderer().setSeriesStroke(i, stroke);
    }
}

From source file:tilt.image.page.Line.java

/**
 * Draw the line on the image for debugging
 * @param g the graphics environment to draw in
 * @param n the number of the line/*ww  w.ja v  a 2 s  . c o  m*/
 */
public void draw(Graphics g, int n) {
    Point p1, p2 = null;
    for (int i = 0; i < points.size(); i++) {
        p1 = p2;
        p2 = points.get(i);
        if (p1 != null) {
            int x1 = Math.round(p1.x);
            int y1 = Math.round(p1.y);
            int x2 = Math.round(p2.x);
            int y2 = Math.round(p2.y);
            if (!rogue) {
                g.drawLine(x1, y1, x2, y2);
            } else {
                Graphics2D g2 = (Graphics2D) g;
                g2.setStroke(new BasicStroke(3));
                g2.draw(new Line2D.Float(x1, y1, x2, y2));
                g2.setStroke(new BasicStroke(1));
            }
        }
    }
    Rectangle bounds = getPointsBounds();
    String num = Integer.toString(n);
    g.drawString(num, bounds.x - 30, (bounds.y * 2 + bounds.height) / 2);
    //System.out.println("width of line"+n+": "+bounds.width);
}