當前位置: 首頁>>代碼示例>>Java>>正文


Java Context2d.lineTo方法代碼示例

本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.lineTo方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.lineTo方法的具體用法?Java Context2d.lineTo怎麽用?Java Context2d.lineTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.canvas.dom.client.Context2d的用法示例。


在下文中一共展示了Context2d.lineTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: TextDisplayElement

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public TextDisplayElement(String id, int x, int y, int width, int height,
        String text, int[][] coords) {
    super(id, x, y, width, height);
    this.coords = coords;
    this.text = text;
    
 // Create a canvas containing the filled polygon with no border
    Canvas sub_canvas = Canvas.createIfSupported();
    sub_canvas.setCoordinateSpaceWidth(width);
    sub_canvas.setCoordinateSpaceHeight(height);
    
    Context2d context = sub_canvas.getContext2d();
    context.beginPath();
    context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());

    for (int i = 1; i < coords.length; i++) {
    	context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
    }
	
    context.setFillStyle(color_fill);
    context.fill();
    
    context.closePath();
    
    this.image_data = context.getImageData(0, 0, width, height);
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:27,代碼來源:TextDisplayElement.java

示例2: drawRoundRectHelper

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
 * based on http://js-bits.blogspot.co.at/2010/07/canvas-rounded-corner-rectangles.html
 */
private static void drawRoundRectHelper(Context2d ctx, boolean drawOuterLine, final double x, final double y, final double width, final double height, final double radius) {
	ctx.beginPath();
	ctx.moveTo(x + radius, y);
	ctx.lineTo(x + width - radius, y);
	ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
	ctx.lineTo(x + width, y + height - radius);
	ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
	ctx.lineTo(x + radius, y + height);
	ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
	ctx.lineTo(x, y + radius);
	ctx.quadraticCurveTo(x, y, x + radius, y);
	ctx.closePath();
	ctx.fill();
	if (drawOuterLine) {
		ctx.stroke();
	}
}
 
開發者ID:umlet,項目名稱:umlet,代碼行數:21,代碼來源:DrawHandlerGwt.java

示例3: drawDashedLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawDashedLine(int x, int y, int length, int dash, int space, boolean horizontal, Context2d ctx) {
	if (horizontal)
		while (x < length) {
			ctx.moveTo(x, y);
			x += dash;
			ctx.lineTo(x, y);
			x += space;
		}
	else
		while (y < length) {
			ctx.moveTo(x, y);
			y += dash;
			ctx.lineTo(x, y);
			y += space;
		}
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:17,代碼來源:Grid.java

示例4: MultiLineTextDisplayElement

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public MultiLineTextDisplayElement(String id, int x, int y, int width, int height,
        String text, String label, int[][] coords) {
    super(id, x, y, width, height);
    this.coords = coords;
    this.label = label;
    this.text = text;
    
    popup = new PopupPanel(true, false);
    HTML content = new HTML(text);
	
    popup.setStylePrimaryName("PopupPanel");
    popup.addStyleName("AnnotationPopup");
	popup.setWidget(content);
    
 // Create a canvas containing the filled polygon with no border
    Canvas sub_canvas = Canvas.createIfSupported();
    sub_canvas.setCoordinateSpaceWidth(width);
    sub_canvas.setCoordinateSpaceHeight(height);
    
    Context2d context = sub_canvas.getContext2d();
    context.beginPath();
    context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());

    for (int i = 1; i < coords.length; i++) {
    	context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
    }
	
    context.setFillStyle(color_fill);
    context.fill();
    
    context.closePath();
    
    this.image_data = context.getImageData(0, 0, width, height);
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:35,代碼來源:MultiLineTextDisplayElement.java

示例5: PolygonDisplayElement

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public PolygonDisplayElement(String id, int x, int y, int width,
        int height, int[][] coords) {
    super(id, x, y, width, height);
    this.coords = coords;
    
    // Create a canvas containing the filled polygon with no border
    Canvas sub_canvas = Canvas.createIfSupported();
    sub_canvas.setCoordinateSpaceWidth(baseWidth());
    sub_canvas.setCoordinateSpaceHeight(baseHeight());
    
    Context2d context = sub_canvas.getContext2d();
    
    context.save();
    context.beginPath();
    context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());
    
    for (int i = 1; i < coords.length; i++) {
    	context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
    }
    
    context.setFillStyle(fill_color);
    context.fill();
    
	context.closePath();
	
    context.restore();
    
    this.image_data = context.getImageData(0, 0, baseWidth(), baseHeight());
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:30,代碼來源:PolygonDisplayElement.java

示例6: drawPath

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static void drawPath(Path path, Context2d context) {
	context.beginPath();
	for (PathElement e : path.getElements()) {
		switch (e.getType()) {
			case ClosePath:
				context.closePath();
				break;
			case CubicCurveTo:
				CubicCurveTo c = (CubicCurveTo) e;
				context.bezierCurveTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
				break;
			case LineTo:
				LineTo l = (LineTo) e;
				context.lineTo(l.p.x, l.p.y);
				break;
			case MoveTo:
				MoveTo m = (MoveTo) e;
				context.moveTo(m.p.x, m.p.y);
				break;
			case QuadraticCurveTo:
				QuadraticCurveTo q = (QuadraticCurveTo) e;
				context.quadraticCurveTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
				break;
		}
	}
}
 
開發者ID:Xenoage,項目名稱:Zong,代碼行數:27,代碼來源:GwtPath.java

示例7: drawCone

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
 * Draw a cone. Does not call beginPath().
 */
public static void drawCone(Context2d g, double x, double y, double radius, double height) {
  double kappa = .5522848;
  double w = (2 * radius) * SQRT1_5;
  double h = (2 * radius) * SQRT0_5;
  double xm = w / 2f; // x-middle
  double ym = h / 2f; // y-middle
  double ox = xm * kappa; // control point offset horizontal
  double oy = ym * kappa; // control point offset vertical

  g.translate(x, y);
  g.moveTo(w, ym);
  g.bezierCurveTo(w, ym + oy, xm + ox, h, xm, h);
  g.bezierCurveTo(xm - ox, h, 0, ym + oy, 0, ym);
  g.lineTo(xm, ym - height);
  g.closePath();
  g.translate(-x, -y);
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:21,代碼來源:IsometricUtil.java

示例8: drawRoundedRect

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
 * Draw a rounded rect. Does not call beginPath().
 */
public static void drawRoundedRect(Context2d g, double x, double y, double width, double height,
    double topLeftRadiusX, double topLeftRadiusY, double topRightRadiusX, double topRightRadiusY,
    double bottomLeftRadiusX, double bottomLeftRadiusY, double bottomRightRadiusX,
    double bottomRightRadiusY) {
  
  g.translate(x, y);
  g.moveTo(topLeftRadiusX, 0);
  g.lineTo(width - topRightRadiusX, 0);
  x = width;
  y = 0;
  g.bezierCurveTo(x, y, x, y, width, topRightRadiusY);
  g.lineTo(width, height - bottomRightRadiusY);
  x = width;
  y = height;
  g.bezierCurveTo(x, y, x, y, width - bottomRightRadiusX, height);
  g.lineTo(bottomLeftRadiusX, height);
  x = 0;
  y = height;
  g.bezierCurveTo(x, y, x, y, 0, height - bottomLeftRadiusY);
  g.lineTo(0, topLeftRadiusY);
  x = 0;
  y = 0;
  g.bezierCurveTo(x, y, x, y, topLeftRadiusX, 0);
  g.translate(-x, -y);
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:29,代碼來源:GraphicsUtil.java

示例9: continueDrawing

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void continueDrawing(int clientX, int clientY) {
	Context2d context = canv.getContext2d();
	float x = clientX - canv.getAbsoluteLeft() + Window.getScrollLeft();
	float y = clientY - canv.getAbsoluteTop() + Window.getScrollTop();
	
	if (getDistance(last_x, last_y, x, y) > dist_buffer) {
		context.beginPath();
		context.setLineWidth(5);
		context.setStrokeStyle(color);
		context.moveTo(last_x, last_y);
		context.lineTo(x, y);
		context.moveTo(x, y);
		context.closePath();
		context.stroke();
		points.add(new DrawPoint(x, y));
		last_x = x;
		last_y = y;
		if (lastUpdate + updateTime < new Date().getTime()) {
			endDrawing();
			startDrawing(clientX, clientY);
		}
	}
}
 
開發者ID:Mazku,項目名稱:collabsketch_vaadin,代碼行數:24,代碼來源:CollabSketchWidget.java

示例10: drawLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void drawLine(DrawLine line) {
	Context2d context = canv.getContext2d();
	context.beginPath();
	context.setLineWidth(5);
	context.setStrokeStyle(line.color);
	boolean first = true;
	for(DrawPoint point : line.points) {
		if (first) {
			context.moveTo(point.x, point.y);
			first = false;
		} else {
			context.lineTo(point.x, point.y);
			context.moveTo(point.x, point.y);
		}
	}
	context.closePath();
	context.stroke();
	lines++;
}
 
開發者ID:Mazku,項目名稱:collabsketch_vaadin,代碼行數:20,代碼來源:CollabSketchWidget.java

示例11: drawTics

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void drawTics(int count, int len, long factor, String unit) {
	Context2d context = canvas.getContext2d();

	context.setFillStyle(color);
	context.setStrokeStyle(color);

	for (int i = 1; i <= count; i++) {
		context.beginPath();
		context.moveTo(len * i, 0);
		context.lineTo(len * i, 15);
		context.closePath();
		context.stroke();

		context.fillText((i * factor) + unit, len * i, 25, 20);
	}
}
 
開發者ID:metafora-project,項目名稱:ReflectionTool,代碼行數:17,代碼來源:Timeline.java

示例12: drawLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void drawLine(Point startPoint, Point endPoint, ColorModel color) {
    Context2d context2d = getContext(defaultGlobalCompositeOperation);
    context2d.beginPath();
    context2d.setStrokeStyle("#" + color.toStringRgb());
    context2d.moveTo(startPoint.getX(), startPoint.getY());
    context2d.lineTo(endPoint.getX(), endPoint.getY());
    context2d.stroke();
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:10,代碼來源:CanvasViewImpl.java

示例13: eraseLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void eraseLine(Point startPoint, Point endPoint) {
    Context2d context2d = getContext(destinationOutCompositeOperation);
    context2d.beginPath();
    context2d.moveTo(startPoint.getX(), startPoint.getY());
    context2d.lineTo(endPoint.getX(), endPoint.getY());
    context2d.setStrokeStyle(eraserColor);
    context2d.stroke();
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:10,代碼來源:CanvasViewImpl.java

示例14: endDrawingLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
protected void endDrawingLine(String color, int thickness, int clientX, int clientY){
    int x1 = clientX - canv.getAbsoluteLeft() + Window.getScrollLeft();
    int y1 = clientY - canv.getAbsoluteTop() + Window.getScrollTop();
    Context2d ctx = canv.getContext2d();
    ctx.beginPath();
    ctx.setLineWidth(thickness);
    ctx.setStrokeStyle(color);
    ctx.moveTo(x, y);
    ctx.lineTo(x1, y1);
    ctx.closePath();
    ctx.stroke();
    rpc.addItem(new Line(x, y, x1, y1, color));
}
 
開發者ID:LiogkyTeam,項目名稱:DrowGutt,代碼行數:14,代碼來源:CanvasWidget.java

示例15: drawGrid

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawGrid() {
	Context2d ctx = canvasLayer.getContext();
	
	ctx.save();
	ctx.translate(0.5, 0.5);
	ctx.setStrokeStyle(CssColors.BLACK);
	ctx.setLineWidth(1);
	
	ctx.beginPath();

	// Horizontal grid lines
	for (int i = startX; i < height; i += stepY) {
		if (dashed) {
			drawDashedLine(startX, i, width, 2, 2, true, ctx);
		} else {
			ctx.moveTo(startX, i);
			ctx.lineTo(width, i);
		}
	}

	// Vertical grid lines
	for (int i = startY; i < width; i += stepX) {
		if (dashed) {
			drawDashedLine(i, startY, height, 2, 2, false, ctx);
		} else {
			ctx.moveTo(i, startY);
			ctx.lineTo(i, height);
		}

	}
	
	ctx.stroke();
	ctx.restore();
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:35,代碼來源:Grid.java


注:本文中的com.google.gwt.canvas.dom.client.Context2d.lineTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。