当前位置: 首页>>代码示例>>Java>>正文


Java BasicStroke.JOIN_MITER属性代码示例

本文整理汇总了Java中java.awt.BasicStroke.JOIN_MITER属性的典型用法代码示例。如果您正苦于以下问题:Java BasicStroke.JOIN_MITER属性的具体用法?Java BasicStroke.JOIN_MITER怎么用?Java BasicStroke.JOIN_MITER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.BasicStroke的用法示例。


在下文中一共展示了BasicStroke.JOIN_MITER属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getServer

/**
 * @param args the command line arguments
 * @return
 */
public VisualizationImageServer<Integer, String> getServer() {
    // Layout<V, E>, VisualizationComponent<V,E>
    Layout<Integer, String> layout = new CircleLayout<>(
            this);
    layout.setSize(new Dimension(300, 300));
    VisualizationImageServer<Integer, String> vv = new VisualizationImageServer<>(
            layout, new Dimension(350, 350));
    // Setup up a new vertex to paint transformer...
    // Set up a new stroke Transformer for the edges
    float dash[] = {10.0f};
    final Stroke edgeStroke = new BasicStroke(1.0f,
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
            0.0f);
    vv.getRenderContext().setVertexFillPaintTransformer(i -> Color.GREEN);
    vv.getRenderContext().setEdgeStrokeTransformer(
            s -> edgeStroke);
    vv.getRenderContext().setVertexLabelTransformer(
            new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(
            new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer()
            .setPosition(Position.CNTR);

    return vv;
}
 
开发者ID:mstahv,项目名称:svgexamples,代码行数:29,代码来源:JungExample.java

示例2: createDashedBorder

/**
 * Creates a dashed border of the specified {@code paint}, {@code thickness},
 * line shape, relative {@code length}, and relative {@code spacing}.
 * If the specified {@code paint} is {@code null},
 * the component's foreground color will be used to render the border.
 *
 * @param paint      the {@link Paint} object used to generate a color
 * @param thickness  the width of a dash line
 * @param length     the relative length of a dash line
 * @param spacing    the relative spacing between dash lines
 * @param rounded    whether or not line ends should be round
 * @return the {@code Border} object
 *
 * @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or
 *                                  if the specified {@code length} is less than {@code 1}, or
 *                                  if the specified {@code spacing} is less than {@code 0}
 * @since 1.7
 */
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {
    boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);
    if (shared && (sharedDashedBorder != null)) {
        return sharedDashedBorder;
    }
    if (thickness < 1.0f) {
        throw new IllegalArgumentException("thickness is less than 1");
    }
    if (length < 1.0f) {
        throw new IllegalArgumentException("length is less than 1");
    }
    if (spacing < 0.0f) {
        throw new IllegalArgumentException("spacing is less than 0");
    }
    int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;
    int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;
    float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };
    Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);
    if (shared) {
        sharedDashedBorder = border;
    }
    return border;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:BorderFactory.java

示例3: createStroke

private BasicStroke createStroke(float lineThickness) {

            if (dashPattern == null) {
                return new BasicStroke(lineThickness,
                                       BasicStroke.CAP_BUTT,
                                       BasicStroke.JOIN_MITER);
            }
            else {
                return new BasicStroke(lineThickness,
                                       BasicStroke.CAP_BUTT,
                                       BasicStroke.JOIN_MITER,
                                       10.0f,
                                       dashPattern,
                                       0);
            }
        }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Underline.java

示例4: drawRect

public void drawRect(SunGraphics2D sg2d,
                     int x, int y, int w, int h)
{
    if (w >= 0 && h >= 0) {
        if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
            BasicStroke bs = ((BasicStroke) sg2d.stroke);
            if (w > 0 && h > 0) {
                if (bs.getLineJoin() == BasicStroke.JOIN_MITER &&
                    bs.getDashArray() == null)
                {
                    double lw = bs.getLineWidth();
                    drawRectangle(sg2d, x, y, w, h, lw);
                    return;
                }
            } else {
                // Note: This calls the integer version which
                // will verify that the local drawLine optimizations
                // work and call super.drawLine(), if not.
                drawLine(sg2d, x, y, x+w, y+h);
                return;
            }
        }
        super.drawRect(sg2d, x, y, w, h);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:PixelToParallelogramConverter.java

示例5: createStroke

/**
 * 
 */
public Stroke createStroke(Map<String, Object> style)
{
	double width = mxUtils
			.getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale;
	boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED);
	if (dashed)
	{
		float[] dashPattern = mxUtils.getFloatArray(style,
				mxConstants.STYLE_DASH_PATTERN,
				mxConstants.DEFAULT_DASHED_PATTERN, " ");
		float[] scaledDashPattern = new float[dashPattern.length];

		for (int i = 0; i < dashPattern.length; i++)
		{
			scaledDashPattern[i] = (float) (dashPattern[i] * scale * width);
		}

		return new BasicStroke((float) width, BasicStroke.CAP_BUTT,
				BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f);
	}
	else
	{
		return new BasicStroke((float) width);
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:28,代码来源:mxGraphics2DCanvas.java

示例6: createStroke

/**
 * 
 */
public Stroke createStroke(Map<String, Object> style) {
  double width = mxUtils.getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale;
  boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED);
  if (dashed) {
    float[] dashPattern = mxUtils.getFloatArray(style, mxConstants.STYLE_DASH_PATTERN,
        mxConstants.DEFAULT_DASHED_PATTERN, " ");
    float[] scaledDashPattern = new float[dashPattern.length];

    for (int i = 0; i < dashPattern.length; i++) {
      scaledDashPattern[i] = (float) (dashPattern[i] * scale * width);
    }

    return new BasicStroke((float) width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
        scaledDashPattern, 0.0f);
  } else {
    return new BasicStroke((float) width);
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:mxGraphics2DCanvas.java

示例7: paintComponent

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g); //paint background

    if (diagramaAtual == null) {
        return;
    }

    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    Graphics2D Canvas = (Graphics2D) g;
    Canvas.addRenderingHints(renderHints);

    Canvas.setPaint(Color.BLACK);
    Stroke stroke = new BasicStroke(2.f,
            BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
    Canvas.setStroke(stroke);

    Canvas.drawRect(box.getLocation().x, box.getLocation().y, box.getWidth(), box.getHeight());
    Canvas.setPaint(Color.GRAY);
    Canvas.drawRect(box.getLocation().x + 1, box.getLocation().y + 1, box.getWidth(), box.getHeight());
    //Canvas.setPaint(Color.BLACK);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:27,代码来源:Editor.java

示例8: paint

@Override
public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    g2d.addRenderingHints(renderHints);

    g2d.setPaint(Color.BLACK);
    Stroke stroke = new BasicStroke(2.f,
            BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
    g2d.setStroke(stroke);

    PintarTextos(g2d);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:19,代码来源:MasterCli.java

示例9: createStroke

private static BasicStroke createStroke(final float width,
                                        final boolean useDashes,
                                        final float dashMinLen) {
    final float[] dashes;

    if (useDashes) {
        // huge dash array (exceed Dasher.INITIAL_ARRAY)
        dashes = new float[512];

        float cur = dashMinLen;
        float step = 0.01f;

        for (int i = 0; i < dashes.length; i += 2) {
            dashes[i] = cur;
            dashes[i + 1] = cur;
            cur += step;
        }
    } else {
        dashes = null;
    }

    if (USE_ROUND_CAPS_AND_JOINS) {
        // Use both round Caps & Joins:
        return new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 100.0f, dashes, 0.0f);
    }
    return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 100.0f, dashes, 0.0f);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:CrashTest.java

示例10: createSelectionStroke

private Stroke createSelectionStroke() {
    float[] f = new float[4];
    f[0] = 3;
    f[1] = 3;
    f[2] = 3;
    f[3] = 3;

    return new BasicStroke(0.5f, BasicStroke.CAP_SQUARE,
            BasicStroke.JOIN_MITER, 1, f, 0);

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:11,代码来源:Label.java

示例11: selectStylePen

protected boolean selectStylePen(int cap, int join, float width,
                                 Color color) {

    long endCap;
    long lineJoin;

    float[] rgb = color.getRGBColorComponents(null);

    switch(cap) {
    case BasicStroke.CAP_BUTT: endCap = PS_ENDCAP_FLAT; break;
    case BasicStroke.CAP_ROUND: endCap = PS_ENDCAP_ROUND; break;
    default:
    case BasicStroke.CAP_SQUARE: endCap = PS_ENDCAP_SQUARE; break;
    }

    switch(join) {
    case BasicStroke.JOIN_BEVEL:lineJoin = PS_JOIN_BEVEL; break;
    default:
    case BasicStroke.JOIN_MITER:lineJoin = PS_JOIN_MITER; break;
    case BasicStroke.JOIN_ROUND:lineJoin = PS_JOIN_ROUND; break;
    }

    return (selectStylePen(getPrintDC(), endCap, lineJoin, width,
                           (int) (rgb[0] * MAX_WCOLOR),
                           (int) (rgb[1] * MAX_WCOLOR),
                           (int) (rgb[2] * MAX_WCOLOR)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:WPrinterJob.java

示例12: draw

public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        BasicStroke bs = ((BasicStroke) sg2d.stroke);
        if (s instanceof Rectangle2D) {
            if (bs.getLineJoin() == BasicStroke.JOIN_MITER &&
                bs.getDashArray() == null)
            {
                Rectangle2D r2d = (Rectangle2D) s;
                double w = r2d.getWidth();
                double h = r2d.getHeight();
                double x = r2d.getX();
                double y = r2d.getY();
                if (w >= 0 && h >= 0) {
                    double lw = bs.getLineWidth();
                    drawRectangle(sg2d, x, y, w, h, lw);
                }
                return;
            }
        } else if (s instanceof Line2D) {
            Line2D l2d = (Line2D) s;
            if (drawGeneralLine(sg2d,
                                l2d.getX1(), l2d.getY1(),
                                l2d.getX2(), l2d.getY2()))
            {
                return;
            }
        }
    }

    outpipe.draw(sg2d, s);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:PixelToParallelogramConverter.java

示例13: IMGrayUnderline

IMGrayUnderline() {
    stroke = new BasicStroke(DEFAULT_THICKNESS,
                             BasicStroke.CAP_BUTT,
                             BasicStroke.JOIN_MITER,
                             10.0f,
                             new float[] {1, 1},
                             0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:Underline.java

示例14: setStroke

public void setStroke(Stroke stroke) {
    if (stroke instanceof BasicStroke) {
        BasicStroke bs = (BasicStroke) stroke;
        // linewidth
        gc.setLineWidth((int) bs.getLineWidth());

        // line join
        switch (bs.getLineJoin()) {
            case BasicStroke.JOIN_BEVEL :
                gc.setLineJoin(SWT.JOIN_BEVEL);
                break;
            case BasicStroke.JOIN_MITER :
                gc.setLineJoin(SWT.JOIN_MITER);
                break;
            case BasicStroke.JOIN_ROUND :
                gc.setLineJoin(SWT.JOIN_ROUND);
                break;
        }

        // line cap
        switch (bs.getEndCap()) {
            case BasicStroke.CAP_BUTT :
                gc.setLineCap(SWT.CAP_FLAT);
                break;
            case BasicStroke.CAP_ROUND :
                gc.setLineCap(SWT.CAP_ROUND);
                break;
            case BasicStroke.CAP_SQUARE :
                gc.setLineCap(SWT.CAP_SQUARE);
                break;
        }

        // set the line style to solid by default
        gc.setLineStyle(SWT.LINE_SOLID);

        // apply dash style if any
        float[] dashes = bs.getDashArray();
        if (dashes != null) {
            int[] swtDashes = new int[dashes.length];
            for (int i = 0; i < swtDashes.length; i++) {
                swtDashes[i] = (int) dashes[i];
            }
            gc.setLineDash(swtDashes);
        }
    }
    else {
        throw new RuntimeException(
                "Can only handle 'Basic Stroke' at present.");
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:50,代码来源:SWTGraphics2D.java


注:本文中的java.awt.BasicStroke.JOIN_MITER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。