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


Java GeneralPath.lineTo方法代碼示例

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


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

示例1: drawLine

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
private void drawLine(Graphics g, LinePlot line, int width, int height) {
	double[] data = line.lineData;
	float columnDistance = (float) width / (float) (data.length - 1);
	GeneralPath path = new GeneralPath();
	float xPos = 0.0f;
	path.moveTo(xPos, normY(data[0]) * height);
	for (int d = 1; d < data.length; d++) {
		xPos += columnDistance;
		path.lineTo(xPos, normY(data[d]) * height);
	}
	Color color = Color.RED;
	if (colorColumn != -1) {
		color = getColorProvider().getPointColor(line.color);
	}
	g.setColor(color);
	((Graphics2D) g).draw(path);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:AndrewsCurves.java

示例2: createDiamondShape

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/** Creates a diamond shape inscribed in the bounds given in the parameters. */
private Shape createDiamondShape(double x, double y, double width, double height) {
    GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
    result.moveTo(x + width / 2, y);
    result.lineTo(x + width, y + height / 2);
    result.lineTo(x + width / 2, y + height);
    result.lineTo(x, y + height / 2);
    result.closePath();
    return result;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:11,代碼來源:JVertexView.java

示例3: drawGlassEffect

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the glass effect
 */
public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) {
  double size = 0.4;
  canvas.getGraphics()
      .setPaint(new GradientPaint((float) state.getX(), (float) state.getY(),
          new Color(1, 1, 1, 0.9f), (float) (state.getX()),
          (float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f)));

  float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1)
      * canvas.getScale() / 2);

  GeneralPath path = new GeneralPath();
  path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
  path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size));
  path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
      (float) (state.getY() + state.getHeight() * 0.7),
      (float) (state.getX() + state.getWidth() + sw),
      (float) (state.getY() + state.getHeight() * size));
  path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw);
  path.closePath();

  canvas.getGraphics().fill(path);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:26,代碼來源:mxLabelShape.java

示例4: getStar

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Return the basic five-point star.
 *
 * @return the basic star shape
 */
private static GeneralPath getStar() {
    GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    double angle = 2 * Math.PI / 5;
    double radius = STAR_SIZE / 2;
    double x = 0;
    double y = -radius;
    star.moveTo(x, y);
    int[] vertex = { 2, 4, 1, 3 };
    for (int i : vertex) {
        double phi = i * angle;
        x = radius * Math.sin(phi);
        y = -radius * Math.cos(phi);
        star.lineTo(x, y);
    }
    star.closePath();
    return star;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:23,代碼來源:Flag.java

示例5: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
		Selects the area represented by poly
	*/
	void selectLasso(XYGraph xyg) {
		GeneralPath path = new GeneralPath();

		for (int i=0; i<poly.npoints; i++){
			Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
			Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
			if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
			else path.lineTo((float)point.getX(), (float) point.getY());
		}
		path.closePath();
		Rectangle2D r = path.getBounds();

		ds.dataT.getSelectionModel().setValueIsAdjusting(true);
		if (scatter) {
			int n = 0;
			while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
				n++;
			}
			if (n>=x.length) return;
			for (int i = n; i < x.length; i++) {
				if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
				if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
					ds.dataT.getSelectionModel().addSelectionInterval(i, i);
				}
			}
		}

		unDrawLasso(xyg);
//		selectionChangedRedraw(ds.selected);

		ds.dataT.getSelectionModel().setValueIsAdjusting(false);

		if (ds.dataT.getSelectedRow() != -1)
			ds.dataT.ensureIndexIsVisible(ds.dataT.getSelectedRow());
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:39,代碼來源:DataSetGraph.java

示例6: getGeneralPath

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
GeneralPath getGeneralPath(Point2D[] pts) {
	Projection proj = map.getProjection();
	GeneralPath path = new GeneralPath();
	float[] lastP = null;
	float wrap = (float)map.getWrap()/2f;

	boolean tf = profileTypes != null && straightLine.isSelected();


	for( int k=0 ; k<pts.length ; k++) {

		Point2D p = proj.getMapXY( pts[k] );
		float x = (float)p.getX();
		float y = (float)p.getY();
		//System.out.println("wrap " + wrap);
		//System.out.println("" + (lastP!=null));

		if( lastP!=null && wrap>0f ) {
			while( x-lastP[0] <-wrap ){x+=wrap*2f;}
			while( x-lastP[0] > wrap ){x-=wrap*2f;}
		}
		lastP = new float[] {x, y};
		if( k==0 ) path.moveTo( x, y );
		else path.lineTo( x, y );
	}
	return path;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:28,代碼來源:GMAProfile.java

示例7: getRhombus

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
private GeneralPath getRhombus() {
    GeneralPath rhombus = new GeneralPath();
    rhombus.moveTo(WIDTH / 2, BEND_Y);
    rhombus.lineTo(WIDTH - BEND_X, HEIGHT / 2);
    rhombus.lineTo(WIDTH / 2, HEIGHT - BEND_Y);
    rhombus.lineTo(BEND_X, HEIGHT / 2);
    return rhombus;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:9,代碼來源:Flag.java

示例8: drawGlassEffect

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the glass effect
 */
public static void drawGlassEffect(mxGraphics2DCanvas canvas,
		mxCellState state)
{
	double size = 0.4;
	canvas.getGraphics().setPaint(
			new GradientPaint((float) state.getX(), (float) state.getY(),
					new Color(1, 1, 1, 0.9f), (float) (state.getX()),
					(float) (state.getY() + state.getHeight() * size),
					new Color(1, 1, 1, 0.3f)));

	float sw = (float) (mxUtils.getFloat(state.getStyle(),
			mxConstants.STYLE_STROKEWIDTH, 1) * canvas.getScale() / 2);

	GeneralPath path = new GeneralPath();
	path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
	path.lineTo((float) state.getX() - sw,
			(float) (state.getY() + state.getHeight() * size));
	path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
			(float) (state.getY() + state.getHeight() * 0.7),
			(float) (state.getX() + state.getWidth() + sw),
			(float) (state.getY() + state.getHeight() * size));
	path.lineTo((float) (state.getX() + state.getWidth() + sw),
			(float) state.getY() - sw);
	path.closePath();

	canvas.getGraphics().fill(path);
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:31,代碼來源:mxLabelShape.java

示例9: draw

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public void draw( Graphics2D g ) {
	Rectangle area = g.getClipBounds();
	currentPoint = null;
	if( !intersects(area) ) return;
	Color color = g.getColor();
	g.setColor( offColor);
	GeneralPath path = new GeneralPath();
	float offset = (float)this.offset;
	for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
		path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
		for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
			path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
		}
	}
	g.draw(path);
	double wrap = map.getWrap();
	if(wrap>0) {
		AffineTransform xform = g.getTransform();
		offset += (float)wrap;
		while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
			g.translate( (double)wrap, 0.d );
			g.draw(path);
			offset += (float)wrap;
		}
		g.setTransform( xform );
	}
	g.setColor( onColor );
	drawCurrentSeg(g, true);
	g.setColor( color );
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:31,代碼來源:ShipData.java

示例10: drawCoOrdinates

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public static void drawCoOrdinates(double[]x,double[]y,int size, Graphics2D g){

		GeneralPath path = new GeneralPath();
		path.moveTo(x[0],-y[0]);

		for(int j=1;j<(size+1);j++){
			path.lineTo(x[j], -y[j]);
		}
		path.closePath();
		g.setColor(Color.BLACK);
		g.fill(path);

	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:14,代碼來源:FMSDraw.java

示例11: paintGraph

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintGraph(Graphics2D g, int width, int height) {
	FontMetrics fm = g.getFontMetrics();
	float min = (Integer) minSpinner.getValue();
	float max = (Integer) maxSpinner.getValue();
	float range = max - min;

	g.setColor(scaleTextColor);

	g.drawString(String.format("%.1f", range/2f+min), scaleTextInset, (height+fm.getHeight())/2 - fm.getDescent());
	g.setColor(lineColor);

	g.setStroke(new BasicStroke(3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));

	ArrayList<Keyframe<Integer>> copy = new ArrayList<>(keyframes);
	if(dragFrame != null)
		copy.add(dragFrame);
	Collections.sort(copy);

	if(copy.get(0).getTime() != 0f)
		copy.add(0, new Keyframe<Integer>(0f, copy.get(0).getValue()));
	if(copy.get(copy.size()-1).getTime() != 1f)
		copy.add(new Keyframe<Integer>(1f, copy.get(copy.size()-1).getValue()));

	GeneralPath path = new GeneralPath();
	path.moveTo(copy.get(0).getTime() * width, Math.round(((1f - (copy.get(0).getValue()-min)/range) * height)));
	for(int i = 1; i < copy.size(); i++)
		path.lineTo(copy.get(i).getTime() * width, Math.round((1f - (copy.get(i).getValue()-min)/range) * height)-.5f);
	g.draw(path);

	g.setStroke(new BasicStroke(3)); //Draw red bar at each keyframe
	g.setColor(keyframeIndicatorColor);
	for(int i = 1; i < copy.size()-1; i++)
		g.drawLine((int) (copy.get(i).getTime() * width), 0, (int) (copy.get(i).getTime() * width), height);
	if(min < 0 && max > 0) {
		g.setColor(zeroLineColor);
		g.drawLine(0, (int) ((1-(-min/range))*height), width, (int) ((1-(-min/range))*height));
	}
}
 
開發者ID:CalebKussmaul,項目名稱:GIFKR,代碼行數:40,代碼來源:IntInterpolator.java

示例12: drawCosx

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private void drawCosx(GeneralPath gp, Graphics2D g2d) {
	for (double i = 0.000001; i <= 8 * Math.PI; i += 0.0001 * Math.PI) {
		gp.lineTo(20 * i, 100 * -Math.cos(i));
	}
	g2d.draw(gp);

	// 將當前畫筆以Y中為對稱軸,畫偶函數(關於Y軸對稱)
	g2d.scale(-1, 1);
	g2d.draw(gp);
}
 
開發者ID:followwwind,項目名稱:javase,代碼行數:12,代碼來源:Sinx.java

示例13: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
	Selects the area represented by poly
*/	
void selectLasso(XYGraph xyg) {
	GeneralPath path = new GeneralPath();

	for (int i=0; i<poly.npoints; i++){
		Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
		Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
		if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
		else path.lineTo((float)point.getX(), (float) point.getY());
	}
	path.closePath();
	Rectangle2D r = path.getBounds();

	int n = 0;
	while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
		n++;
	}
	if (n>=x.length) return;
	
	table.getSelectionModel().setValueIsAdjusting(true);
	table.clearSelection();
	for (int i = n; i < x.length; i++) {
		if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
		if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
			table.getSelectionModel().addSelectionInterval(i, i);
		}
	}
	table.getSelectionModel().setValueIsAdjusting(false);

	unDrawLasso(xyg);
	if (table.getSelectedRow() != -1)
		table.ensureIndexIsVisible(table.getSelectedRow());
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:36,代碼來源:PDBDataSetGraph.java

示例14: paintComponent

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g) {
	if (mainButton != null && mainButton.getModel().isArmed() || getModel().isArmed()) {
		((Graphics2D) g).translate(1.1, 1.1);
	}
	((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	super.paintComponent(g);

	Graphics2D g2 = (Graphics2D) g.create();

	// fill background white
	g2.setColor(BACKGROUND_COLOR);
	g2.fillRect(3, 0, getWidth() - 9, getHeight() - 6);

	// draw border which complements the DropShadow
	g2.setColor(BORDER_LIGHTEST_GRAY);
	g2.drawLine(3, 0, 3, getHeight() - 6);
	g2.drawLine(getWidth() - 6, 0, getWidth() - 6, getHeight() - 6);
	g2.drawLine(3, getHeight() - 6, getWidth() - 6, getHeight() - 6);
	g2.drawLine(3, 0, getWidth() - 6, 0);

	// draw arrow
	GeneralPath arrow = new GeneralPath();
	int w, h;
	h = (int) (2 * sizeFactor);
	w = (int) (4 * sizeFactor);
	arrow.moveTo(getWidth() / 2 - w, getHeight() / 2);
	arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
	arrow.lineTo(getWidth() / 2, getHeight() / 2 + 2 * h);
	arrow.closePath();
	if (isEnabled()) {
		g2.setColor(HOVERED_TEXTCOLOR);
	} else {
		g2.setColor(BORDER_LIGHTEST_GRAY);
	}
	g2.fill(arrow);
	g2.dispose();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:39,代碼來源:FancyDropDownButton.java

示例15: createStrokedShape

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * @see java.awt.Stroke#createStrokedShape(java.awt.Shape)
 */
public Shape createStrokedShape (Shape shape) {
	GeneralPath result = new GeneralPath();
	shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape);
	PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS);
	float points[] = new float[6];
	float moveX = 0, moveY = 0;
	float lastX = 0, lastY = 0;
	float thisX = 0, thisY = 0;
	int type = 0;
	float next = 0;
	while (!it.isDone()) {
		type = it.currentSegment(points);
		switch (type) {
		case PathIterator.SEG_MOVETO:
			moveX = lastX = randomize(points[0]);
			moveY = lastY = randomize(points[1]);
			result.moveTo(moveX, moveY);
			next = 0;
			break;

		case PathIterator.SEG_CLOSE:
			points[0] = moveX;
			points[1] = moveY;
			// Fall into....

		case PathIterator.SEG_LINETO:
			thisX = randomize(points[0]);
			thisY = randomize(points[1]);
			float dx = thisX - lastX;
			float dy = thisY - lastY;
			float distance = (float)Math.sqrt(dx * dx + dy * dy);
			if (distance >= next) {
				float r = 1.0f / distance;
				while (distance >= next) {
					float x = lastX + next * dx * r;
					float y = lastY + next * dy * r;
					result.lineTo(randomize(x), randomize(y));
					next += detail;
				}
			}
			next -= distance;
			lastX = thisX;
			lastY = thisY;
			break;
		}
		it.next();
	}

	return result;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:54,代碼來源:OutlineWobbleEffect.java


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