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:ShapeMover.java

public void update(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Dimension dim = getSize();/*from ww w.  j ava 2 s. c o  m*/
    int w = (int) dim.getWidth();
    int h = (int) dim.getHeight();
    g2.setStroke(new BasicStroke(8.0f));

    if (isFirstTime) {
        area = new Rectangle(dim);
        rect.setLocation(w / 2 - 50, h / 2 - 25);
        isFirstTime = false;
    }

    // Clears the rectangle that was previously drawn.
    g2.setPaint(Color.white);
    g2.fillRect(0, 0, w, h);

    g2.setColor(Color.red);
    g2.draw(rect);
    g2.setColor(Color.black);
    g2.fill(rect);
}

From source file:view.FuzzySetView.java

private void fillView() {
    XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setSeriesPaint(0, Color.CYAN);
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2f));
    renderer.setOutline(true);/*from  www .j  ava2 s .c  o  m*/
    plot.setRenderer(renderer);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Thermometer.java

/**
 * Creates a chart of type thermometer.//from w w  w  . j a  v  a 2  s .c  o  m
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart thermometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset);
    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);
    plot.setGap(3);
    plot.setValueLocation(3);
    plot.setValuePaint(labelsValueStyle.getColor());
    plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));

    plot.setRange(lower, upper);

    if (units.equalsIgnoreCase(FAHRENHEIT))
        plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);
    else if (units.equalsIgnoreCase(CELCIUS))
        plot.setUnits(ThermometerPlot.UNITS_CELCIUS);
    else if (units.equalsIgnoreCase(KELVIN))
        plot.setUnits(ThermometerPlot.UNITS_KELVIN);
    else
        plot.setUnits(ThermometerPlot.UNITS_NONE);

    // set subranges   
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval subrange = (KpiInterval) iterator.next();
        int range = 0;
        if (subrange.getLabel().equalsIgnoreCase(NORMAL))
            range = (ThermometerPlot.NORMAL);
        else if (subrange.getLabel().equalsIgnoreCase(WARNING))
            range = (ThermometerPlot.WARNING);
        else if (subrange.getLabel().equalsIgnoreCase(CRITICAL))
            range = (ThermometerPlot.CRITICAL);

        plot.setSubrange(range, subrange.getMin(), subrange.getMax());
        if (subrange.getColor() != null) {
            plot.setSubrangePaint(range, subrange.getColor());
        }
        //plot.setDisplayRange(subrange.getRange(), subrange.getLower(), subrange.getUpper());   
    }
    //plot.setFollowDataInSubranges(true);
    logger.debug("OUT");

    return chart;
}

From source file:DrawingApplet.java

public void setLineWidth(float w) {
    g.setStroke(new BasicStroke(w));
}

From source file:edu.gmu.cs.sim.util.media.chart.BarChartGenerator.java

void reviseRenderer(BarRenderer renderer) {
    renderer.setShadowVisible(false);//from w  w w .java 2s.  c o  m
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBaseOutlineStroke(new BasicStroke(2.0f));
    renderer.setDrawBarOutline(true);
    renderer.setBaseItemLabelGenerator(
            new StandardCategoryItemLabelGenerator("{0}", java.text.NumberFormat.getInstance())); // {0} is the row key, {1} is the column key, {2} is the value
    renderer.setBaseItemLabelsVisible(true);
}

From source file:com.jakemadethis.graphite.visualization.renderers.HyperedgeLabelRenderer.java

public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
    if (label == null || label.length() == 0)
        return;/*from   ww  w  .  j a v a  2  s .c  o  m*/

    Graph<V, E> g = layout.getGraph();

    EdgeLayout<E> edgeLayout = EdgeLayout$.MODULE$.apply(layout);

    Hypergraph<V, E> hg = g;

    if (!drawPredicate.evaluate(Context.<Hypergraph<V, E>, E>getInstance(hg, e)))
        return;

    if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V, E>, E>getInstance(g, e)))
        return;

    Point2D edgePos = edgeLayout.getEdgeLocation(e);
    edgePos = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, edgePos);

    GraphicsDecorator gd = rc.getGraphicsContext();

    Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label,
            rc.getPickedEdgeState().isPicked(e), e);

    Dimension d = component.getPreferredSize();

    AffineTransform old = gd.getTransform();
    AffineTransform xform = new AffineTransform(old);
    xform.translate(edgePos.getX(), edgePos.getY());

    gd.setTransform(xform);
    gd.setStroke(new BasicStroke(1));
    Rectangle rect = new Rectangle(-10, -10, 20, 20);
    gd.setPaint(Color.WHITE);
    gd.fill(rect);
    gd.setPaint(Color.GRAY);
    gd.draw(rect);

    xform.translate(-d.width / 2, -d.height / 2);
    gd.setTransform(xform);

    gd.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);

    gd.setTransform(old);
}

From source file:mainGUI.TrainingJFrame.java

private void initLineChartPanel() {
    series = new XYSeries("MSE");
    seriesCollection = new XYSeriesCollection(series);

    chart = ChartFactory.createXYLineChart("Training", "Epoch Number", "MSE", seriesCollection,
            PlotOrientation.VERTICAL, true, true, true);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);/*from   w w w . ja  va 2 s  .  com*/
    renderer.setBaseStroke(new BasicStroke(3));
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(chartContainerPanel.getWidth(), chartContainerPanel.getHeight());

    chartContainerPanel.add(chartPanel);
}

From source file:edu.cmu.sv.modelinference.eventtool.charting.DataChart.java

private void createChartPanel(JFreeChart chart) {
    chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override/*from   w  w w .  j a v a2s  . c o m*/
        public void chartMouseClicked(ChartMouseEvent arg0) {
            //ignore
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Rectangle2D dataArea = chartPanel.getScreenDataArea();
            JFreeChart chart = event.getChart();
            XYPlot plot = (XYPlot) chart.getPlot();
            ValueAxis xAxis = plot.getDomainAxis();
            double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM);
            ValueAxis yAxis = plot.getRangeAxis();
            double y = yAxis.java2DToValue(event.getTrigger().getY(), dataArea, RectangleEdge.LEFT);

            //Alternatively, obtain y for one of the subplots, which would be very neat.
            //We should find the "nearest" subplot to the cursor -- this is easy
            //double y = DatasetUtilities.findYValue(plot.getDataset(), 0, x);
            xCrosshair.setValue(x);
            yCrosshair.setValue(y);
        }
    });

    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f));
    xCrosshair.setLabelVisible(true);
    yCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f));
    yCrosshair.setLabelVisible(true);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);
    chartPanel.addOverlay(crosshairOverlay);

    chartPanel.setPreferredSize(new java.awt.Dimension(800, 600));
    setContentPane(chartPanel);
}

From source file:org.n52.io.type.quantity.handler.img.LineRenderer.java

private Stroke getSolidLineDefinition(LineStyle lineStyle) {
    return new BasicStroke(lineStyle.getLineWidth());
}

From source file:org.openaltimeter.desktopapp.annotations.XYVarioAnnotation.java

public XYVarioAnnotation(String text, String text2, double x1, double y1, double x2, double y2) {
    this(text, text2, x1, y1, x2, y2, new BasicStroke(1.0f), Color.black);
}