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:lu.lippmann.cdb.graph.renderer.CadralEdgeStrokeTransformer.java

@Override
public Stroke transform(final CEdge edge) {
    if (mapWeigth == null || !mapWeigth.containsKey(edge)) {
        return new BasicStroke(MIN_WIDTH);
    } else {/*from w  w w  . j a  va 2 s. c om*/
        float width = MAX_WIDTH * mapWeigth.get(edge);
        if (width < MIN_WIDTH) {
            return new BasicStroke(MIN_WIDTH);
        } else {
            return new BasicStroke(width);
        }
    }
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeTickBandPaint(new Color(240, 240, 240));
    PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005));
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class,
            new SimpleDateFormat("HH"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
            new SimpleDateFormat("dd-MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);//from w w w  .jav a2 s  .  c  o  m
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 100D);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(0, Color.green);
    xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F));
    ValueMarker valuemarker = new ValueMarker(80D);
    valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    valuemarker.setPaint(Color.red);
    valuemarker.setStroke(new BasicStroke(2.0F));
    valuemarker.setLabel("Temperature Threshold");
    valuemarker.setLabelFont(new Font("SansSerif", 0, 11));
    valuemarker.setLabelPaint(Color.red);
    valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    xyplot.addRangeMarker(valuemarker);
    Hour hour = new Hour(18, 30, 6, 2005);
    Hour hour1 = new Hour(20, 30, 6, 2005);
    double d = hour.getFirstMillisecond();
    double d1 = hour1.getFirstMillisecond();
    IntervalMarker intervalmarker = new IntervalMarker(d, d1);
    intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    intervalmarker.setPaint(new Color(150, 150, 255));
    intervalmarker.setLabel("Automatic Cooling");
    intervalmarker.setLabelFont(new Font("SansSerif", 0, 11));
    intervalmarker.setLabelPaint(Color.blue);
    intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND);
    ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F));
    ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F));
    xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND);
    xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND);
    return jfreechart;
}

From source file:edu.asu.mgb.gui.AggregateTransformer.java

@Override
public Transformer<Action, Stroke> getEdgeStrokeTransformer() {
    return new Transformer<Action, Stroke>() {
        final float dash[] = { 1.0f };

        @Override/*from  w  ww .  j a v a 2  s. co  m*/
        public Stroke transform(Action s) {
            if (s.isHighlighted()) {
                return new BasicStroke(HIGHLIGHT_STROKE);
            } else {
                return new BasicStroke(1.0f + ((float) 10.0 * s.getNormalizedCount()), BasicStroke.CAP_BUTT,
                        BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
            }
        }
    };
}

From source file:Main.java

ThreeDimensionalBorder(Color color, int transparency, int shadowWidth) {
    this.color = color;
    shadowPad = shadowWidth;//w w  w.java  2s . c o m

    stroke = new BasicStroke(thickness);
    strokePad = thickness / 2;

    hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int pad = radius + strokePad;
    int bottomPad = pad + strokePad + shadowPad;
    int rightPad = pad + strokePad + shadowPad;
    insets = new Insets(pad, pad, bottomPad + shadowPad, rightPad);
}

From source file:edu.asu.mgb.gui.GUITransformer.java

public Transformer<State, Stroke> getVertexStrokeTransformer() {
    return new Transformer<State, Stroke>() {
        final float dash[] = { 1.0f };

        @Override//w  ww  .  ja v a2s .  c  o m
        public Stroke transform(State i) {
            if (i.isHighlighted()) {
                return new BasicStroke(5);
            } else {
                return new BasicStroke();
            }
        }
    };
}

From source file:st.jigasoft.dbutil.util.ReportTheme.java

public static void circularTheme(JFreeChart chart, String... colunsName) {
    chart.setBackgroundPaint(/*from   w  w w.ja  va 2s  .  co m*/
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);
    int iCount = 0;

    // use gradients and white borders for the section colours
    for (Object s : colunsName) {
        plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++)));
        if (iCount == MAX_COLUNS_COLOR)
            iCount = 0;
    }

    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    //        // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
}

From source file:de.h_da.fbi.rfid.gui.UHF_GUI.java

public void paintComponent(Graphics g) {
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    Line2D line = new Line2D.Double(300, 300, 80, 80);
    g2.setStroke(new BasicStroke(4));
    g2.draw(line);/* www.j  a va2 s. co m*/
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void commonPrepareJFreeChart(LineAndShapeRenderer renderer) {
    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesStroke(6, new BasicStroke(1));

    renderer.setSeriesItemLabelsVisible(0, true);
    renderer.setSeriesItemLabelsVisible(1, true);
    renderer.setSeriesItemLabelsVisible(2, true);
    renderer.setSeriesItemLabelsVisible(3, true);
    renderer.setSeriesItemLabelsVisible(4, true);
    renderer.setSeriesItemLabelsVisible(5, true);
    renderer.setSeriesItemLabelsVisible(6, true);

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesLinesVisible(2, true);
    renderer.setSeriesLinesVisible(3, true);
    renderer.setSeriesLinesVisible(4, true);
    renderer.setSeriesLinesVisible(5, true);
    renderer.setSeriesLinesVisible(6, true);

    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesShapesVisible(3, true);
    renderer.setSeriesShapesVisible(4, true);
    renderer.setSeriesShapesVisible(5, true);
    renderer.setSeriesShapesVisible(6, true);
}

From source file:inet.CalculationNetworkEditor.Transformers.EdgeStrokeTransformer.java

@Override
public Stroke transform(E i) {
    switch (jtp.getSelectedIndex()) {
    case 0: //Physical
    case 1: { //Virtual
        //return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
        return new BasicStroke(3.0f);
    }//from  w  w w .ja va2s.c o  m
    case 2: { //Both
        if (logic.containsEdge(i)) {
            if (logic.getTypeOfEdge(i) == IStorage.Type.PHYSICAL) {
                return new BasicStroke(3.0f);
            } else if (logic.getTypeOfEdge(i) == IStorage.Type.VIRTUAL) {
                if (logic.getStackedEdgePath(i) == null) {
                    // edge is not stacked
                    BasicStroke dashed = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                            10.0f, dash, 0.0f);
                    return dashed;
                } else {
                    return new BasicStroke(3.0f);
                }
            } else {
                Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "unknown edge type");
            }
        } else {
            // it is an edge which only exists in frontend for visualization purpose
            return new BasicStroke(3.0f);
        }
    }
        break;
    default: {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "unknown view");
    }
    }

    return new BasicStroke(3.0f);
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("Maximum Temperature", "Day", true, "Temperature",
            intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    PeriodAxis periodaxis = new PeriodAxis("Day");
    periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("E"),
            new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false,
            new BasicStroke(0.0F), Color.lightGray);
    aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
            new SimpleDateFormat("MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);//from w  w  w  .jav a  2s .c  o m
    return jfreechart;
}