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


Java BasicStroke类代码示例

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


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

示例1: main

import java.awt.BasicStroke; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
    BufferedImage im = getWhiteImage(30, 30);
    Graphics2D g2 = (Graphics2D)im.getGraphics();
    g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
    g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    g2.setBackground(Color.white);
    g2.setColor(Color.black);

    Path2D p = getPath(0, 0, 20);
    g2.draw(p);

    if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
        throw new Exception("This pixel should be black");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Test7019861.java

示例2: DialValueIndicator

import java.awt.BasicStroke; //导入依赖的package包/类
/** 
 * Creates a new instance of <code>DialValueIndicator</code>.
 * 
 * @param datasetIndex  the dataset index.
 * @param label  the label.
 */
public DialValueIndicator(int datasetIndex, String label) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:DialValueIndicator.java

示例3: strokeTo

import java.awt.BasicStroke; //导入依赖的package包/类
public void strokeTo(Shape src,
                     AffineTransform at,
                     BasicStroke bs,
                     boolean thin,
                     boolean normalize,
                     boolean antialias,
                     PathConsumer2D consumer)
{
    System.out.println(name+".strokeTo("+
                       src.getClass().getName()+", "+
                       at+", "+
                       bs+", "+
                       (thin ? "thin" : "wide")+", "+
                       (normalize ? "normalized" : "pure")+", "+
                       (antialias ? "AA" : "non-AA")+", "+
                       consumer.getClass().getName()+")");
    target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:RenderingEngine.java

示例4: redrawCanvas

import java.awt.BasicStroke; //导入依赖的package包/类
public void redrawCanvas(int x, int y, double a){
		
		int R = (int)a;
		int	G =(int) (255-a);
		int B = 0;
		Graphics2D g=  ((Graphics2D) canvas.getGraphics());
		g.setColor(new Color(R,G,B));
		g.setStroke(new BasicStroke(15));
		g.drawLine(x, y,x, y);
		
		g.dispose();
        //((Graphics2D) canvas.getGraphics()).setStroke(new BasicStroke(30));
       // ((Graphics2D) canvas.getGraphics()).drawLine(x, y,x, y);	
        //		   Graphics2D g2 = (Graphics2D) canvas.getGraphics();
//           g2.setStroke(new BasicStroke(10));
//           g2.draw(new Line2D.Double(x, y, x, y));
//           canvas.paint(g2);
	}
 
开发者ID:fmcalcagno,项目名称:Sensors,代码行数:19,代码来源:Interface.java

示例5: getStrokeSpans

import java.awt.BasicStroke; //导入依赖的package包/类
public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d,
                                               Shape s)
{
    ShapeSpanIterator sr = new ShapeSpanIterator(false);

    try {
        sr.setOutputArea(sg2d.getCompClip());
        sr.setRule(PathIterator.WIND_NON_ZERO);

        BasicStroke bs = (BasicStroke) sg2d.stroke;
        boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
        boolean normalize =
            (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);

        RenderEngine.strokeTo(s,
                              sg2d.transform, bs,
                              thin, normalize, false, sr);
    } catch (Throwable t) {
        sr.dispose();
        sr = null;
        throw new InternalError("Unable to Stroke shape ("+
                                t.getMessage()+")", t);
    }
    return sr;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:LoopPipe.java

示例6: scatterGridPlot

import java.awt.BasicStroke; //导入依赖的package包/类
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
    int numDatasets = dataset.size();
    JFreeChart result = ChartFactory.createScatterPlot(chartTitle
            , xLabel
            , yLabel
            , dataset.get(0));
    XYPlot plot = result.getXYPlot();
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));        
    for(int i=1;i<numDatasets;i++){
        plot.setDataset(i,dataset.get(i));
        //XYItemRenderer renderer = plot.getRenderer(i-0);
        plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
        plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
        plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
    }

    return result;
}
 
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:20,代码来源:Chart.java

示例7: testPut

import java.awt.BasicStroke; //导入依赖的package包/类
/**
 * Some checks for the put() method.
 */
public void testPut() {
    StrokeMap m1 = new StrokeMap();
    m1.put("A", new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m1.getStroke("A"));
    
    // a null key should throw an IllegalArgumentException
    boolean pass = false;
    try {
        m1.put(null, new BasicStroke(1.1f));
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:StrokeMapTests.java

示例8: createStroke

import java.awt.BasicStroke; //导入依赖的package包/类
/**
 * 
 */
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,代码行数:29,代码来源:mxGraphics2DCanvas.java

示例9: doDrawShoulders

import java.awt.BasicStroke; //导入依赖的package包/类
final private void doDrawShoulders() {

		// Set graphics :
		final Graphics2D objLjugglerGraphics2D =
													(Graphics2D) (Tools.contains(	this.objGjuggleMasterPro.bytGjugglerVisibility,
																					Constants.bytS_BIT_VISIBILITY_TRAIL)
																														? this.imgGjugglerFrontTrailsBuffer.getGraphics()
																														: this.imgGanimationBuffer.getGraphics());
		objLjugglerGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		this.doOptimizeGraphics(objLjugglerGraphics2D);

		// Draw shoulders :
		objLjugglerGraphics2D.setColor(this.objGjuggleMasterPro.objGjugglerColorA[this.objGjuggleMasterPro.bytGlight]);
		for (byte bytLside = Constants.bytS_ENGINE_LEFT_SIDE; bytLside <= Constants.bytS_ENGINE_RIGHT_SIDE; ++bytLside) {
			if (this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmVisible) {
				objLjugglerGraphics2D.setStroke(new BasicStroke(this.objGjuggleMasterPro.objGstyleA[Constants.bytS_UNCLASS_CURRENT].getArmWidth(this.objGjuggleMasterPro.objGhandA[bytLside].fltGposZ,
																																				(byte) 2,
																																				this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmHandZOrder),
																BasicStroke.CAP_ROUND,
																BasicStroke.JOIN_ROUND));
				this.objGjuggleMasterPro.objGbody.drawArmPart(objLjugglerGraphics2D, this.fltGframeSizeRatio, bytLside, (byte) 2);
			}
		}
		objLjugglerGraphics2D.dispose();
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:26,代码来源:AnimationJFrame.java

示例10: drawPoint

import java.awt.BasicStroke; //导入依赖的package包/类
/**
 * 随机画点
 *
 * @param image 图片
 */
private void drawPoint(BufferedImage image) {
    if (this.pointPower == -1) {
        return;
    }
    Random r = new Random();
    Graphics2D g2 = (Graphics2D) image.getGraphics();
    int max = this.w * this.h / this.pointPower;
    for (int i = 0; i < max; i++) {
        int x = r.nextInt(w);
        int y = r.nextInt(h);
        g2.setStroke(new BasicStroke(1.5F));
        g2.setColor(this.randomColor());
        g2.drawOval(x, y, 1, 1);
    }
    g2.dispose();
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:22,代码来源:VerificationCodeImage.java

示例11: paintComponent

import java.awt.BasicStroke; //导入依赖的package包/类
@Override
public void paintComponent(Graphics g) {
    SwingUtilities.invokeLater(() -> {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) getGraphics();
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.setColor(Color.red);
        g2.drawLine(pressed.x, pressed.y, released.x, released.y);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.drawOval(released.x - 25, released.y - 25, 50, 50);
        g2.fillOval(released.x - 10, released.y - 10, 20, 20);
        g2.dispose();
    });
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:16,代码来源:DragAndDrop.java

示例12: draw

import java.awt.BasicStroke; //导入依赖的package包/类
/**
 * Draws the range.
 * 
 * @param g2  the graphics target.
 * @param plot  the plot.
 * @param frame  the dial's reference frame (in Java2D space).
 * @param view  the dial's view rectangle (in Java2D space).
 */
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, 
        Rectangle2D view) {
    
    Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, 
            this.innerRadius, this.innerRadius);
    Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame, 
            this.outerRadius, this.outerRadius);
    //double range = this.upperBound - this.lowerBound;
    
    DialScale scale = plot.getScaleForDataset(0);
    double angleMin = scale.valueToAngle(this.lowerBound);
    double angleMax = scale.valueToAngle(this.upperBound);

    Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin, 
            angleMax - angleMin, Arc2D.OPEN);
    Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax, 
            angleMin - angleMax, Arc2D.OPEN);
    
    g2.setPaint(this.paint);
    g2.setStroke(new BasicStroke(2.0f));
    g2.draw(arcInner);
    g2.draw(arcOuter);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:StandardDialRange.java

示例13: FlyingToolTip

import java.awt.BasicStroke; //导入依赖的package包/类
public FlyingToolTip(final FlyingToolTipListener source) {
    this.source = source;
    label = new JLabel("test", JLabel.CENTER) {
        @Override
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            int w = getWidth(), h = getHeight();
            g.setColor(getBackground());
            g.fillRect(0,0,w,h);

            if (path != null) {                    
                g2.setStroke(new BasicStroke(4f));
                g2.setColor(getForeground());
                g2.draw(path);
            }
            setOpaque(false);
            super.paintComponent(g2);
            setOpaque(true);
            g2.dispose();
        }
    };    
    label.setBorder(new EmptyBorder(2,4,10,4));
    label.setOpaque(true);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:25,代码来源:FlyingToolTip.java

示例14: DiscreteXYPainter

import java.awt.BasicStroke; //导入依赖的package包/类
DiscreteXYPainter(float lineWidth, Color lineColor, Color fillColor,
                  int width, boolean fixedWidth, boolean topLineOnly,
                  boolean outlineOnly, double dataFactor, PointsComputer computer) {

    super((int)Math.ceil(lineWidth), fillColor != null ||
          (!topLineOnly && !outlineOnly), dataFactor);
    
    if (lineColor == null && fillColor == null)
        throw new IllegalArgumentException("lineColor or fillColor must not be null"); // NOI18N

    this.lineWidth = (int)Math.ceil(lineWidth);
    this.lineColor = Utils.checkedColor(lineColor);
    this.fillColor = Utils.checkedColor(fillColor);

    definingColor = lineColor != null ? lineColor : fillColor;

    this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND,
                                      BasicStroke.JOIN_ROUND);

    this.width = width;
    this.fixedWidth = fixedWidth;
    this.topLineOnly = topLineOnly;
    this.outlineOnly = outlineOnly;

    this.computer = computer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DiscreteXYPainter.java

示例15: drawCurrentPoint

import java.awt.BasicStroke; //导入依赖的package包/类
public void drawCurrentPoint() {
	if( map==null || point==null || !map.isVisible() ) return;
	synchronized (map.getTreeLock() ) {
		Graphics2D g = map.getGraphics2D();
		float zoom = (float)map.getZoom();
		g.setStroke( new BasicStroke( 2f/ zoom ) );
		g.setColor(Color.RED);
		g.setXORMode( Color.white );
		Rectangle2D rect = map.getClipRect2D();
		double wrap = map.getWrap();
		if( wrap>0. ) while( point.x-wrap > rect.getX() ) point.x-=wrap;
		double size = 10./map.getZoom();
		Arc2D.Double arc = new Arc2D.Double( 0., point.y-.5*size, 
						size, size, 0., 360., Arc2D.CHORD);
		if( wrap>0. ) {
			while( point.x < rect.getX()+rect.getWidth() ) {
				arc.x = point.x-.5*size;
				g.draw(arc);
				point.x += wrap;
			}
		} else {
			arc.x = point.x-.5*size;
			g.draw(arc);
		}
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:27,代码来源:CustomDB.java


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