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


Java BasicStroke.CAP_BUTT属性代码示例

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


在下文中一共展示了BasicStroke.CAP_BUTT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paint

@Override
public void paint(Graphics g) {
    if (g == null || !(g instanceof Graphics2D)) {
        return;
    }
    g.setColor(Color.white);
    g.setXORMode(Color.black);
    Graphics2D dg = (Graphics2D) g;
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER,
            10.0f,
            new float[]{1.0f, 1.0f},
            0.0f);
    dg.setStroke(stroke);
    try {
        dg.draw(new Line2D.Float(10, 10, 20, 20));
    } catch (Throwable e) {
        synchronized (this) {
            theError = e;
        }
    } finally {
        didDraw.countDown();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:DrawXORModeTest.java

示例3: 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

示例4: 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

示例5: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:Underline.java

示例6: 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

示例7: main

public static void main(String[] args) {

        GeneralPath shape = new GeneralPath();
        int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
        double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
        double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
        shape.moveTo(xpoints[0], ypoints[0]);
        for (int i = 1; i < pointTypes.length; i++) {
            if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
                shape.quadTo(xpoints[i], ypoints[i],
                             xpoints[i + 1], ypoints[i + 1]);
            } else {
                shape.lineTo(xpoints[i], ypoints[i]);
            }
        }

        BufferedImage image = new
            BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = image.createGraphics();

        Color color = new Color(124, 0, 124, 255);
        g2.setColor(color);
        Stroke stroke = new BasicStroke(1.0f,
                                        BasicStroke.CAP_BUTT,
                                        BasicStroke.JOIN_BEVEL,
                                        10.0f, new float[] {9, 6}, 0.0f);
        g2.setStroke(stroke);
        g2.draw(shape);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:DashStrokeTest.java

示例8: 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

示例9: 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

示例10: paint

/** Renders the caret */
public @Override void paint(Graphics g) {
    JTextComponent c = component;
    if (c == null) return;

    // #70915 Check whether the caret was moved but the component was not
    // validated yet and therefore the caret bounds are still null
    // and if so compute the bounds and scroll the view if necessary.
    if (getDot() != 0 && caretBounds == null) {
        update(true);
    }
    if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("BaseCaret.paint(): caretBounds=" + caretBounds + dumpVisibility() + '\n');
    }
    if (caretBounds != null && isVisible() && blinkVisible) {
        paintCustomCaret(g);
    }
    if (rectangularSelection && rsPaintRect != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] {4, 2}, 0);
        Stroke origStroke = g2d.getStroke();
        Color origColor = g2d.getColor();
        try {
            // Render translucent rectangle
            Color selColor = c.getSelectionColor();
            g2d.setColor(selColor);
            Composite origComposite = g2d.getComposite();
            try {
                g2d.setComposite(AlphaComposite.SrcOver.derive(0.2f));
                g2d.fill(rsPaintRect);
            } finally {
                g2d.setComposite(origComposite);
            }
            // Paint stroked line around rectangular selection rectangle
            g.setColor(c.getCaretColor());
            g2d.setStroke(stroke);
            Rectangle onePointSmallerRect = new Rectangle(rsPaintRect);
            onePointSmallerRect.width--;
            onePointSmallerRect.height--;
            g2d.draw(onePointSmallerRect);

        } finally {
            g2d.setStroke(origStroke);
            g2d.setColor(origColor);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:BaseCaret.java

示例11: paintComponent

@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g); //paint background
        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);
//        Canvas.draw3DRect(0, 0, getWidth() - 4, getHeight() - 4, true);
        Canvas.setPaint(Color.BLACK);
        Stroke stroke = new BasicStroke(1.f,
                BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
        Canvas.setStroke(stroke);

        Canvas.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        Canvas.setPaint(Color.GRAY);
        Canvas.drawRect(0, 0, getWidth() - 2, getHeight() - 2);

        if (pgatual == 0) {
            return;
        }
        float[] dash4 = {2f, 2f, 2f};

        BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,
                2f);
        Canvas.setStroke(bs4);

        Canvas.drawLine(l - 1, 1, l - 1, getHeight() - 1);
        Canvas.drawLine(l + w + 1, 1, l + w + 1, getHeight() - 1);
        Canvas.drawLine(1, t - 1, getWidth() - 1, t - 1);
        Canvas.drawLine(1, t + h + 1, getWidth() - 1, t + h + 1);

        Canvas.setStroke(new BasicStroke(
                1f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND));
        Canvas.setPaint(Color.BLACK);
        DrawPagina(Canvas);
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:44,代码来源:ImpressorPreview.java

示例12: getDottedStroke

static public BasicStroke getDottedStroke() {
	return new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10.0f, new float[] { 1f, 1f }, 0.0f);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:3,代码来源:LineFormat.java

示例13: plotXY

public void plotXY( Graphics2D g, 
				Rectangle2D bounds,
				double xScale, double yScale,
				int k) {
		GeneralPath path = new GeneralPath();
		boolean start = true;
		for( int i=0 ; i<rows.size() ; i++) {
			if( !plot[k][i] )continue;
			double[] row = (double[])rows.get(i);
			String[] notesRow = (String[])rowsNotes.get(i);
			float x = Float.NaN;
			if ( !Double.toString(row[k+1]).equals("NaN") ) {
				x = (float)((row[k+1]-bounds.getX())*xScale);
			}
			float y = (float)((row[0]-bounds.getY())*yScale);
			if( start ) {
				path.moveTo(x,y);
				start = false;
				if ( rows.size() > 1 ) {
					double[] nextRow = (double[])rows.get( i + 1 );
//					System.out.println("previousRow[0]: " + nextRow[0] + " row[0]: " + row[0]);
					if ( Math.abs( nextRow[0] - row[0] ) > 10 ) {
						if ( !Float.toString(x).equals("NaN") ) {
							path.lineTo(x,y);
						}
						else if (notesRow[k+1] != null){
							System.out.println(row[k+1]);
							g.drawString(notesRow[k+1], 0, y);
						}
					}
				}
			} 
			else {
				double[] previousRow = (double[])rows.get(i-1);
//				System.out.println("previousRow[0]: " + previousRow[0] + " row[0]: " + row[0]);
				if ( Math.abs( previousRow[0] - row[0] ) < 10 ) {
					if ( !Float.toString(x).equals("NaN") ) {
						path.lineTo(x,y);
					}
					else if ( notesRow[k+1] == null ) {
						path.moveTo(x,y);
					}
					else {
						System.out.println(row[k+1]);
						g.drawString(notesRow[k+1], 0, y);
					}
				}
				else {
					if ( !Float.toString(x).equals("NaN") ) {
//						path.moveTo( x, y );
//						path.lineTo( x, y );
						float dash1[] = {10.0f};
						BasicStroke dashed = new BasicStroke(1.0f,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
						g.setStroke(dashed);
						g.setColor(Color.CYAN);
						g.drawLine( (int)path.getCurrentPoint().getX(), (int)path.getCurrentPoint().getY(), (int)x, (int)y );
						path.moveTo( x, y );
						path.lineTo( x, y );
					}
					else if ( notesRow[k+1] == null ) {
						path.moveTo(x,y);
					}
					else {
						System.out.println(row[k+1]);
						g.drawString(notesRow[k+1], 0, y);
					}
				}
			}
		}
		g.setColor( Color.white );
		g.setStroke( new BasicStroke(4f) );
		g.draw(path);
		g.setColor( Color.black );
		g.setStroke( new BasicStroke(2f) );
		g.draw(path);
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:76,代码来源:DensityBRGTable.java

示例14: getLongDashedStroke

static public BasicStroke getLongDashedStroke() {
	return new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10.0f, new float[] { 7f, 3f }, 0.0f);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:3,代码来源:LineFormat.java

示例15: paintComponent

@Override
public void paintComponent(Graphics g) {
	if (getModel().isArmed()) {
		((Graphics2D) g).translate(1.1, 1.1);
	}

	((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	Graphics2D g2 = (Graphics2D) g.create();

	// the default background is transparent
	if (hovered || customBackgroundColor != null) {
		// fill background
		g2.setColor(customBackgroundColor != null ? customBackgroundColor : BACKGROUND_COLOR);
		g2.fillRect(0, 0, getWidth() - 6, getHeight() - 6);
	}

	if (hovered) {
		// draw border which complements the DropShadow
		g2.setColor(customBorderColor != null ? customBorderColor : BORDER_LIGHTEST_GRAY);
		g2.drawRect(0, 0, getWidth() - 6, getHeight() - 6);
	} else if (customBorderColor != null) {
		g2.setColor(customBorderColor);
		g2.drawRect(0, 0, getWidth() - 6, getHeight() - 6);
	}

	if (hovered) {
		if (drawArrow) {
			// draw arrow
			GeneralPath path = new GeneralPath();
			path.moveTo(getWidth() * 0.82, getHeight() * 0.3);
			path.lineTo(getWidth() * 0.92, getHeight() * 0.5);
			path.lineTo(getWidth() * 0.82, getHeight() * 0.7);
			Stroke arrowStroke = new BasicStroke(5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
			g2.setStroke(arrowStroke);
			g2.setColor(HOVERED_TEXTCOLOR);
			g2.draw(path);
		}

		// cut off arrow ends so the cut looks like an imaginary vertical line
		g2.setColor(customBackgroundColor != null ? customBackgroundColor : BACKGROUND_COLOR);
		g2.fillRect((int) (getWidth() * 0.81), (int) (getHeight() * 0.29), 7, (int) (getHeight() * 0.5));
	}
	g2.dispose();

	super.paintComponent(g);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:46,代码来源:FancyButton.java


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