Example usage for java.awt BasicStroke JOIN_MITER

List of usage examples for java.awt BasicStroke JOIN_MITER

Introduction

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

Prototype

int JOIN_MITER

To view the source code for java.awt BasicStroke JOIN_MITER.

Click Source Link

Document

Joins path segments by extending their outside edges until they meet.

Usage

From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java

/**
 * This method should be called after a chart dataset is updated. It
 * will iterate over all XYDatasets and provide the line color and lineStyle.
 * If it is called before a chart has a dataset, it will not have an effect.
 *
 * @param plot/*from w  w  w  .j a  v a  2  s  . c o m*/
 */
public void setXYPlotRenderer(XYPlot plot) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    int n = plot.getSeriesCount();

    for (int i = 0; i < n; i++) {
        Stroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                getLineStyle(i), 0.0f);
        renderer.setSeriesStroke(i, stroke);
        renderer.setSeriesPaint(i, getPaintColor(i));
    }
    renderer.setLegendLine(new Line2D.Double(0, 5, 40, 5));
    renderer.setBaseShapesFilled(false);
    renderer.setBaseShapesVisible(showMarkers);
    renderer.setDrawSeriesLineAsPath(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRenderer(renderer);
}

From source file:net.sf.statcvs.output.xml.chart.LocChart.java

public LocChart(CvsContent content, Author author) {
    super("loc_per_author.png", I18n.tr("Lines Of Code (per Author)"));

    // init timelines per author
    Iterator authorsIt = content.getAuthors().iterator();
    Map authorTimeLineMap = new HashMap();
    IntegerMap authorsLoc = new IntegerMap();
    while (authorsIt.hasNext()) {
        Author aut = (Author) authorsIt.next();
        TimeLine locTL = new TimeLine(aut.getName());
        locTL.setInitialValue(0);//from ww w . j  av  a  2 s  .  com
        authorTimeLineMap.put(aut, locTL);
    }

    // fill timelines and symbolic names map
    RevisionIterator allRevs = new RevisionSortIterator(content.getRevisionIterator());
    while (allRevs.hasNext()) {
        CvsRevision rev = allRevs.next();
        updateSymbolicNamesMap(rev);
        TimeLine timeline = (TimeLine) authorTimeLineMap.get(rev.getAuthor());
        if (!rev.getFile().isBinary()) {
            authorsLoc.addInt(rev.getAuthor(), rev.getLinesOfCodeChange());
            timeline.addTimePoint(rev.getDate(), authorsLoc.get(rev.getAuthor()));
        }
    }

    // create chart
    Iterator it = authorTimeLineMap.keySet().iterator();
    int i = 0;
    while (it.hasNext()) {
        Author aut = (Author) it.next();
        addTimeLine((TimeLine) authorTimeLineMap.get(aut));
        if (author != null) {
            setFilename("loc_" + AuthorDocument.escapeAuthorName(author.getName()) + ".png");
            // make line thicker
            if (author.equals(aut)) {
                getChart().getXYPlot().getRenderer().setSeriesStroke(i,
                        new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
            }
        }
        i++;
    }
    setupLocChart();
}

From source file:ruc.edu.window.DynamicDataDemo2.java

/**
 * Constructs a new demonstration application.
 *
 * @param title  the frame title./* ww  w .  j a v a 2 s .c  om*/
 */
public DynamicDataDemo2(final String title) {

    super(title);
    this.series1 = new TimeSeries("Random 1");
    this.series2 = new TimeSeries("Random 2");
    final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1);
    final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value",
            dataset1, true, true, false);
    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainPannable(true);
    //      plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4));
    final ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    //axis.setAutoRangeMinimumSize(600000.0);
    axis.setFixedAutoRange(5000.0); // 60 seconds

    plot.setDataset(1, dataset2);
    //final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2");
    /// rangeAxis2.setAutoRangeIncludesZero(false);
    plot.setRenderer(0, new DefaultXYItemRenderer());
    plot.setRenderer(1, new DefaultXYItemRenderer());

    //plot.setRangeAxis(1, rangeAxis2);
    plot.mapDatasetToRangeAxis(1, 0);

    plot.getRenderer().setSeriesPaint(0, new Color(91, 155, 213));
    plot.getRenderer(1).setSeriesPaint(0, Color.BLUE);

    XYLineAndShapeRenderer render2 = new XYLineAndShapeRenderer() {
        Stroke soild = new BasicStroke(2.0f);
        Stroke dashed = new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 10.0f }, 0.0f);

        @Override
        public Stroke getItemStroke(int row, int column) {
            return dashed;
        }
    };

    plot.setRenderer(1, render2);

    final JPanel content = new JPanel(new BorderLayout());

    final ChartPanel chartPanel = new ChartPanel(chart);
    content.add(chartPanel);

    final JButton button1 = new JButton("Add To Series 1");
    button1.setActionCommand("ADD_DATA_1");
    button1.addActionListener(this);

    final JButton button2 = new JButton("Add To Series 2");
    button2.setActionCommand("ADD_DATA_2");
    button2.addActionListener(this);

    final JButton button3 = new JButton("Add To Both");
    button3.setActionCommand("ADD_BOTH");
    button3.addActionListener(this);

    final JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(button1);
    buttonPanel.add(button2);
    buttonPanel.add(button3);

    content.add(buttonPanel, BorderLayout.SOUTH);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(content);

}

From source file:ancat.visualizers.EdgeTransformers.java

/**
 * Configuration of the Stroke used for drawing edges. It processes the
 * following values://from   w  w w .  j av a 2  s  . c o m
 * 
 * <code> edge:style </code> may be set to solid, dashed or dotted. By default
 * the edge style is set to dashed.
 * 
 * <code> edge:stroke-width </code> The width of the stroke used for
 * rendering.
 * 
 * <code> edge:dash-pattern</code> Contains an array of float values
 * describing the dash pattern. See documentation of Java Stroke class to
 * understand the pattern style</code>
 */
protected void setupStroke() {
    String style = "solid";
    float width = 0.5f;
    float dash[] = null;

    Map<String, String> edgeConfig = _renderConfig.edgeConfiguration();

    if (edgeConfig.containsKey("edge:style")) {
        style = edgeConfig.get("edge:style");

        if (!style.equalsIgnoreCase("solid") && !style.equalsIgnoreCase("dashed")
                && !style.equalsIgnoreCase("dotted")) {
            _logger.error("unsupported edge style attribute: " + style + " allowed is solid, dashed, dotted");

            style = "solid";
        }
    }

    if (edgeConfig.containsKey("edge:stroke-width")) {
        try {
            width = Float.parseFloat(edgeConfig.get("edge:stroke-width"));
        } catch (Exception e) {
            _logger.error("unsupported specification of float value for edge width, changing to default");
        }
    }

    if (edgeConfig.containsKey("edge:dash-pattern")) {
        try {
            StringTokenizer tokenizer = new StringTokenizer(edgeConfig.get("edge:dash-pattern"), ",");

            dash = new float[tokenizer.countTokens()];

            int counter = 0;

            while (tokenizer.hasMoreElements()) {
                dash[counter] = Float.parseFloat(tokenizer.nextToken().trim());
                counter += 1;
            }
        } catch (Exception e) {
            _logger.error("Error while parsing dash style, changing to default");

            dash = new float[] { 10.0f };
        }
    }

    if (style.equalsIgnoreCase("dashed")) {
        _edgeStroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else if (style.equalsIgnoreCase("dotted")) {
        dash = new float[] { 2.0f, 2.0f };
        _edgeStroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else if (style.equalsIgnoreCase("solid")) {
        _edgeStroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
    }
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java

@Override
public void run() {
    ProgressHandle handle = ProgressHandleFactory.createHandle("Creating fold change plot");
    try {/*from w  ww . j  a  v  a  2s .  c  om*/
        handle.setDisplayName("Loading fold change elements");//+new File(this.files.getResourceLocation()).getName());
        handle.start(5);
        handle.progress("Reading settings", 1);
        RTUnit rtAxisUnit = RTUnit.valueOf(sp.getProperty("rtAxisUnit", "SECONDS"));
        handle.progress("Retrieving data", 2);
        XYShapeRenderer renderer = new XYShapeRenderer() {

            @Override
            protected Paint getPaint(XYDataset dataset, int series, int item) {
                double x = dataset.getXValue(series, item);
                double y = dataset.getYValue(series, item);
                if (Math.abs(x) < 1.0) {
                    Paint p = super.getPaint(dataset, series, item);
                    if (p instanceof Color) {
                        Color color = (Color) p;
                        float[] values = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                                new float[3]);
                        Color hsb = new Color(
                                Color.HSBtoRGB(values[0], (float) Math.max(0.1, values[1] - 0.9), values[2]));
                        return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), 64);
                    }
                }
                return super.getPaint(dataset, series, item);
            }

        };
        renderer.setAutoPopulateSeriesFillPaint(true);
        renderer.setAutoPopulateSeriesOutlinePaint(true);
        renderer.setBaseCreateEntities(true);
        handle.progress("Building plot", 3);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("log2 fold change"), new NumberAxis("-log10 p-value"),
                renderer);
        BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f,
                new float[] { 5.0f }, 0.0f);
        ValueMarker marker = new ValueMarker(-Math.log10(0.05), Color.RED, dashed);
        marker.setLabel("p-value=0.05");
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
        marker.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 0, 50, 10, 0));
        marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        marker.setLabelPaint(Color.LIGHT_GRAY);
        plot.addRangeMarker(marker);

        Font font1 = new Font("SansSerif", Font.PLAIN, 12);
        SelectionAwareXYTooltipGenerator tooltipGenerator = cvtc.getLookup()
                .lookup(SelectionAwareXYTooltipGenerator.class);
        if (tooltipGenerator == null) {
            tooltipGenerator = new SelectionAwareXYTooltipGenerator(tooltipGenerator) {
                @Override
                public String createSelectionAwareTooltip(XYDataset xyd, int i, int i1) {
                    FoldChangeDataset dataset = (FoldChangeDataset) xyd;
                    FoldChangeElement fce = dataset.getNamedElementProvider().get(i).get(i1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("<html>");
                    sb.append(fce.getPeakGroup().getMajorityDisplayName());
                    sb.append("<br>");
                    sb.append("log2 fold change=");
                    sb.append(fce.getFoldChange());
                    sb.append("<br>");
                    sb.append("p-value=");
                    sb.append(Math.pow(10, -fce.getPvalue()));
                    sb.append("</html>");
                    return sb.toString();
                }
            };
        }
        tooltipGenerator.setXYToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset xyd, int i, int i1) {
                Comparable comp = xyd.getSeriesKey(i);
                double x = xyd.getXValue(i, i1);
                double y = xyd.getYValue(i, i1);
                StringBuilder sb = new StringBuilder();
                sb.append("<html>");
                sb.append(comp);
                sb.append("<br>");
                sb.append("log2 fold change=");
                sb.append(x);
                sb.append("<br>");
                sb.append("p-value=");
                sb.append(sb.append(Math.pow(10, -y)));
                sb.append("</html>");
                return sb.toString();
            }
        });
        plot.getRenderer().setBaseToolTipGenerator(tooltipGenerator);
        handle.progress("Configuring plot", 4);
        configurePlot(plot, rtAxisUnit);
        final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
        Range domainRange = null;
        Range valueRange = null;
        if (cmhp != null) {
            XYPlot xyplot = cmhp.getPlot();
            if (xyplot != null) {
                ValueAxis domain = xyplot.getDomainAxis();
                domainRange = domain.getRange();
                ValueAxis range = xyplot.getRangeAxis();
                valueRange = range.getRange();
            }
        }

        if (domainRange != null) {
            plot.getDomainAxis().setRange(domainRange);
        }
        if (valueRange != null) {
            Logger.getLogger(getClass().getName()).info("Setting previous value range!");
        }
        handle.progress("Adding plot to panel", 5);
        final XYPlot targetPlot = plot;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
                cmhp.setPlot(targetPlot);
                cvtc.requestActive();
            }
        });
    } finally {
        handle.finish();
    }
}

From source file:ch.epfl.lis.gnwgui.jungtransformers.EdgeTransformer.java

public Stroke getBasicStroke(final float d) {
    float[] dash = { d };
    return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
}

From source file:ega.projekt.graphDraw.DrawGraph.java

public static BasicVisualizationServer<Node, Edge> generatePanel(ega.projekt.graph.Graph dataGraph,
        int panelWidth, int panelHeight) {
    if (dataGraph.getEdges().isEmpty())
        System.out.println("Error initializing graph");
    DrawGraph graphView = new DrawGraph(dataGraph);
    Layout<Node, Edge> layout = new StaticLayout(graphView.drawGraph);
    for (Node n : graphView.drawGraph.getVertices()) {
        layout.setLocation(n, new java.awt.geom.Point2D.Double(n.getX(), n.getY()));
    }//  w  w w .  j  a v  a2 s  .c o  m
    layout.setSize(new Dimension(panelWidth, panelHeight));
    BasicVisualizationServer<Node, Edge> vv = new BasicVisualizationServer<>(layout);
    vv.setPreferredSize(new Dimension(panelWidth, panelHeight));
    Transformer<Node, Paint> vertexPaint = new Transformer<Node, Paint>() {
        public Paint transform(Node i) {
            return Color.GREEN;
        }
    };
    final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
    Transformer<Edge, Stroke> edgeStrokeTransformer = new Transformer<Edge, Stroke>() {
        public Stroke transform(Edge e) {
            return edgeStroke;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Node, Edge>());
    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Edge, String>() {
        public String transform(Edge e) {
            return (e.getFlowString() + "/" + Integer.toString(e.getCapacity()));
        }
    });
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() {
        public String transform(Node n) {
            return (Integer.toString(n.getID()));
        }
    });
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    return vv;
}

From source file:ch.epfl.lis.gnwgui.jungtransformers.EdgeTransformer.java

public Stroke getBasicStroke(final float[] dash) {
    return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
}

From source file:net.automatalib.visualization.jung.JungGraphVisualizationProvider.java

protected static NodeVisualization createNodeVisualization(Map<String, String> props, int id) {
    String label = props.get(NodeAttrs.LABEL);
    if (label == null) {
        label = "v" + id;
    }//from   w w  w. ja va 2 s.co m
    Color drawColor = getColor(props, "color", Color.BLACK);
    Color fillColor = getColor(props, "fillcolor", Color.WHITE);

    String shapeName = props.get(NodeAttrs.SHAPE);
    if (shapeName == null) {
        shapeName = "circle";
    }
    ShapeLibrary shapeLib = ShapeLibrary.getInstance();

    Shape shape = shapeLib.createShape(shapeName);
    if (shape == null) {
        System.err.println("Could not create shape " + shapeName);
        shape = shapeLib.createShape("circle");
    }

    String[] styles = {};
    String styleAttr = props.get("style");
    if (styleAttr != null) {
        styles = styleAttr.toLowerCase().split(",");
    }
    List<String> styleList = Arrays.asList(styles);

    float penWidth = 1.0f;
    Stroke stroke;
    if (styleList.contains("bold")) {
        penWidth = 3.0f;
    }

    if (styleList.contains("dashed")) {
        float[] dash = { 10.0f };
        stroke = new BasicStroke(penWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else if (styleList.contains("dotted")) {
        float[] dash = { penWidth, penWidth + 7.0f };
        stroke = new BasicStroke(penWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
    } else {
        stroke = new BasicStroke(penWidth);
    }

    return new NodeVisualization(label, drawColor, fillColor, shape, stroke);
}

From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java

public void setXYPlotRendererWithPoints(XYPlot plot) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    int n = plot.getSeriesCount();
    int half = (int) (n / 2.0);

    //assume first half are series for lines and second half are series for points

    for (int i = 0; i < n; i++) {
        if (i < half) {
            //Add lines
            Stroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                    getLineStyle(i), 0.0f);
            renderer.setSeriesStroke(i, stroke);
            renderer.setSeriesPaint(i, getPaintColor(i));
            renderer.setSeriesShapesFilled(i, false);
            renderer.setSeriesShapesVisible(i, showMarkers);
            renderer.setLegendLine(new Line2D.Double(0, 5, 40, 5));
            renderer.setDrawSeriesLineAsPath(true);

        } else {/* w ww.  ja v a  2  s .  c o m*/
            //Add points
            renderer.setSeriesLinesVisible(i, false);
            renderer.setSeriesShapesFilled(i, false);
            renderer.setSeriesShapesVisible(i, true);
            renderer.setSeriesPaint(i, getPaintColor(i - half));
        }
    }

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRenderer(renderer);
}