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.JmetrikXYLineAndShapeRenderer.java

@Override
public Stroke getItemStroke(int row, int col) {
    Stroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
            getLineStyle(row), 0.0f);//w  ww .ja  v a  2s. c o m
    return stroke;
}

From source file:grafos.JUNGraph.java

/**
 * Cria visualizao grfica do grafo//w w  w  .j  av  a2  s .  c om
 * @param grafo 
 * @return  
 */
//public static void createGraphVisualization(List<Grafo> grafo, List<Vertex> path, String origem, String destino){
public static BasicVisualizationServer<Integer, String> createGraphVisualization(List<Grafo> grafo) {

    JUNGraph sgv = new JUNGraph(grafo);

    Layout<Integer, String> layout = new CircleLayout(sgv.g);
    layout.setSize(new Dimension(500, 500));
    BasicVisualizationServer<Integer, String> vv = new BasicVisualizationServer<>(layout);
    vv.setPreferredSize(new Dimension(500, 500));

    Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() {
        @Override
        public Paint transform(Integer i) {
            return Color.ORANGE;
        }
    };

    float dash[] = { 5.0f };
    final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash,
            0.0f);
    Transformer<String, Stroke> edgeStrokeTransformer = new Transformer<String, Stroke>() {
        @Override
        public Stroke transform(String s) {
            return edgeStroke;
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    return vv;

}

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 .  j a  v  a 2s  .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:Charts2D.java

public Charts2D() {
    super("2D Charts");
    setSize(720, 280);/*from   www. ja  v  a  2  s. c  om*/
    getContentPane().setLayout(new GridLayout(1, 3, 10, 0));
    getContentPane().setBackground(Color.white);

    int[] xData = new int[8];
    int[] yData = new int[8];
    for (int i = 0; i < xData.length; i++) {
        xData[i] = i;
        yData[i] = (int) (Math.random() * 100);
        if (i > 0)
            yData[i] = (yData[i - 1] + yData[i]) / 2;
    }

    JChart2D chart = new JChart2D(JChart2D.LineChart, xData.length, xData, yData, "Line Chart");
    chart.setStroke(new BasicStroke(5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
    chart.setLineColor(new Color(0, 28, 28));
    getContentPane().add(chart);

    chart = new JChart2D(JChart2D.ColumnChart, xData.length, xData, yData, "Column Chart");
    GradientPaint gp = new GradientPaint(0, 100, Color.white, 0, 300, Color.blue, true);
    chart.setGradient(gp);
    chart.setEffectIndex(JChart2D.Gradientffect);
    chart.setDrawShadow(true);
    getContentPane().add(chart);

    chart = new JChart2D(JChart2D.PieChart, xData.length, xData, yData, "Pie Chart");
    ImageIcon icon = new ImageIcon("largeJava2slogo.GIF");
    chart.setForegroundImage(icon.getImage());
    chart.setEffectIndex(JChart2D.ImageEffect);
    chart.setDrawShadow(true);
    getContentPane().add(chart);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:StrokeUtility.java

/**
 * Creates a new Stroke-Object for the given type and with.
 * //ww  w.java 2 s .  com
 * @param type
 *          the stroke-type. (Must be one of the constants defined in this
 *          class.)
 * @param width
 *          the stroke's width.
 * @return the stroke, never null.
 */
public static Stroke createStroke(final int type, final float width) {

    final boolean useWidthForStrokes = true;

    final float effectiveWidth;
    if (useWidthForStrokes) {
        effectiveWidth = width;
    } else {
        effectiveWidth = 1;
    }

    switch (type) {
    case STROKE_DASHED:
        return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 6 * effectiveWidth, 6 * effectiveWidth }, 0.0f);
    case STROKE_DOTTED:
        return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 5.0f,
                new float[] { 0.0f, 2 * effectiveWidth }, 0.0f);
    case STROKE_DOT_DASH:
        return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                new float[] { 0, 2 * effectiveWidth, 6 * effectiveWidth, 2 * effectiveWidth }, 0.0f);
    case STROKE_DOT_DOT_DASH:
        return new BasicStroke(
                width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 0,
                        2 * effectiveWidth, 0, 2 * effectiveWidth, 6 * effectiveWidth, 2 * effectiveWidth },
                0.0f);
    default:
        return new BasicStroke(width);
    }
}

From source file:de.d3web.empiricaltesting.casevisualization.jung.EdgeStrokeTransformer.java

/**
 * Transforms a Finding to color depending on the state of the next
 * RatedTestCase//ww w . j a  va  2s  .c  o m
 */
@Override
public Stroke transform(EdgeFinding f) {

    RatedTestCase rtc = graph.getDest(f);
    String strength = ConfigLoader.getInstance().getProperty("edgeWidthNewCase");

    if (rtc.wasTestedBefore()) {
        strength = ConfigLoader.getInstance().getProperty("edgeWidthOldCase");
    }

    return new BasicStroke(Float.parseFloat(strength) / 2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);

}

From source file:SimpleAttributes.java

public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setBackground(Color.GRAY);
    g2d.clearRect(0, 0, getWidth(), getHeight());

    // String and line with default attributes
    g2d.drawString("Default Font", 10, 20);
    g2d.drawLine(10, 22, 80, 22);/*from   w w w. j ava  2  s  .  c om*/

    // Change the font, foreground color, and Stroke
    g2d.setFont(g.getFont().deriveFont(Font.BOLD | Font.ITALIC, 24f));
    g2d.setColor(Color.WHITE);
    g2d.setStroke(new BasicStroke(10f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));

    // String and line with new attributes
    g2d.drawString("New Font", 10, 50);
    g2d.drawLine(10, 57, 120, 57);
    g2d.dispose();
}

From source file:StrokeTest.java

public StrokeTestFrame() {
    setTitle("StrokeTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    canvas = new StrokeComponent();
    add(canvas, BorderLayout.CENTER);

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(3, 3));
    add(buttonPanel, BorderLayout.NORTH);

    ButtonGroup group1 = new ButtonGroup();
    makeCapButton("Butt Cap", BasicStroke.CAP_BUTT, group1);
    makeCapButton("Round Cap", BasicStroke.CAP_ROUND, group1);
    makeCapButton("Square Cap", BasicStroke.CAP_SQUARE, group1);

    ButtonGroup group2 = new ButtonGroup();
    makeJoinButton("Miter Join", BasicStroke.JOIN_MITER, group2);
    makeJoinButton("Bevel Join", BasicStroke.JOIN_BEVEL, group2);
    makeJoinButton("Round Join", BasicStroke.JOIN_ROUND, group2);

    ButtonGroup group3 = new ButtonGroup();
    makeDashButton("Solid Line", false, group3);
    makeDashButton("Dashed Line", true, group3);
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.renderer.FormattedXYErrorRenderer.java

@Override
public void renderFormatDelegateChanged(RenderFormatDelegate source) {
    SeriesFormat seriesFormat = source.getSeriesFormat();
    if (seriesFormat != null) {
        setErrorStroke(new BasicStroke(Math.round(seriesFormat.getLineWidth() / 2.0), BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER));
    }/*from   w  ww . j av  a2 s  .c  o  m*/
}

From source file:org.openfaces.component.chart.impl.PropertiesConverter.java

public static Stroke toStroke(StyleBorderModel border) {
    Stroke stroke = null;//w  ww  . j a v  a2 s  .  c o  m

    if (border != null) {
        int width = border.getWidth();
        String style = border.getStyle();

        if (style.equalsIgnoreCase("DASHED")) {
            float[] dash = { width * 4 };
            stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, width * 3, dash, 1F);
        } else if (style.equalsIgnoreCase("DOTTED")) {
            float[] dash = { width };
            stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, width * 3, dash, 1F);
        } else {
            stroke = new BasicStroke(width);
        }
    }
    return stroke;
}