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


Java Point2D.getX方法代码示例

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


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

示例1: mouseDragged

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
	Point2D p = e.getPoint();
	Point2D s = renderer.screenToWorld(p);

	if (isPanning && mouseInMode(Mode.TRANSFORMING)) {
		dx = p.getX() - panStart.getX();
		dy = p.getY() - panStart.getY();
		renderer.translate(dx, dy);
		panStart.setLocation(p);
	}

	if (isMoving) {

		if (oldPosition == null)
			oldPosition = grabbed.getPosition();
		grabbed.setPosition(s);
	}

	if (isCreatingEdge) {
		renderer.getEdgeRenderer()
				.drawEdgeToPoint(grabbed.getPosition(), s);
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:24,代码来源:GraphMouseImpl.java

示例2: centerVisualization

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void centerVisualization(V vertex, final boolean immediate) {
    if (vertex != null) {
        Layout<V,E> layout = this.getGraphLayout();
        Point2D q = layout.transform(vertex);
        Point2D lvc = this.getRenderContext().getMultiLayerTransformer().inverseTransform(this.getCenter());
        final int steps = (immediate ? 1 : 10);
        final double dx = (lvc.getX() - q.getX()) / steps;
        final double dy = (lvc.getY() - q.getY()) / steps;

        new Thread() {
            public void run() {
                MutableTransformer transformer = GraphVisualizationPanel.this.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT); 
                for (int i = 0; i < steps; i++) {
                    transformer.translate(dx, dy);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    }
                }
            }
        }.start();
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:24,代码来源:GraphVisualizationPanel.java

示例3: containsPoint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public static boolean containsPoint(Edge edge, Point2D p, double scaleFactor) {
	Shape edgeShape = null;

	if (edge.getShape().equalsIgnoreCase(Constants.LINE_STRAIGHT)) {
		edgeShape = new Line2D.Double(edge.getSource().getPosition(), edge
				.getTarget().getPosition());

	} else if (edge.getShape().equalsIgnoreCase(Constants.LINE_CURVED)) {
		Point2D from = edge.getSource().getPosition();
		Point2D to = edge.getTarget().getPosition();
		double fx = from.getX();
		double fy = from.getY();
		double tx = to.getX();
		double ty = to.getY();
		double a = Utilities.calculateAngle(from, to);
		double h = EdgeRenderer.QUADCURVE_CTRL_POINT.getY() / scaleFactor;

		// Calculate Control Point
		double cx = (fx + tx) / 2 - h * Math.sin(a);
		double cy = (fy + ty) / 2 + h * Math.cos(a);

		edgeShape = new QuadCurve2D.Double(fx, fy, cx, cy, tx, ty);

	} else if (edge.getShape().equalsIgnoreCase(Constants.LINE_LOOP)) {
		// TODO: Calculate shape for loop to enable picking of loop edges
	}

	// Create a small rectangular area around point, and use it
	// to check for intersection with the line of the edge
	double pickRadius = 1;
	double px = p.getX();
	double py = p.getY();
	Rectangle2D pickArea = new Rectangle2D.Double(px - pickRadius, py
			- pickRadius, 2 * pickRadius, 2 * pickRadius);

	return edgeShape.intersects(pickArea);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:38,代码来源:IntersectingShapePickSupport.java

示例4: drawMultipleEllipse

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Draws two dots to represent the average value of more than one outlier.
 * 
 * @param point  the location
 * @param boxWidth  the box width.
 * @param oRadius  the radius.
 * @param g2  the graphics device.
 */
private void drawMultipleEllipse(Point2D point, double boxWidth, 
                                 double oRadius, Graphics2D g2)  {
                                     
    Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) 
            + oRadius, point.getY(), oRadius, oRadius);
    Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), 
            point.getY(), oRadius, oRadius);
    g2.draw(dot1);
    g2.draw(dot2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:BoxAndWhiskerRenderer.java

示例5: getTranslatedLinearGradientPaint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private static LinearGradientPaint getTranslatedLinearGradientPaint(LinearGradientPaint gradient, Point2D startPoint,
		Point2D endPoint, boolean vertical) {
	if (vertical) {
		return new LinearGradientPaint(0f, (float) startPoint.getY(), 0f, (float) endPoint.getY(),
				gradient.getFractions(), gradient.getColors());
	} else {
		return new LinearGradientPaint((float) startPoint.getX(), 0f, (float) endPoint.getX(), 0f,
				gradient.getFractions(), gradient.getColors());
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:CustomLegendGraphic.java

示例6: besselTangent

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private static Point2D besselTangent(double delta_ib, double delta_i, Point2D p0, Point2D p1 , Point2D p2){
    double alpha_i = delta_ib/(delta_ib+delta_i);
    
    double x = (1-alpha_i)/delta_ib * (p1.getX() - p0.getX())
            + alpha_i/delta_i * (p2.getX()-p1.getX());
    double y = (1-alpha_i)/delta_ib * (p1.getY() - p0.getY())
            + alpha_i/delta_i * (p2.getY()-p1.getY());
   
    return new Point2D.Double(x,y);
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:11,代码来源:SplineConnectionWidget.java

示例7: PathOrderBox

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public PathOrderBox(GraphNode parent, GraphNode child, int index, Point2D middle, Graphics2D g2d, int displayIndex) {
    parentGraphNode = parent;
    childGraphNode = child;
    this.index = index;
    this.displayIndex = displayIndex;
    Rectangle2D bounds = g2d.getFont().getStringBounds(Integer.toString(index), g2d.getFontRenderContext());
    rect = new RoundRectangle2D.Double(middle.getX() - bounds.getWidth() / 2 - 5, middle.getY() - bounds.getHeight() / 2, bounds.getWidth() + 10, bounds.getHeight(), bounds.getHeight() - 1, bounds.getHeight() - 1);
}
 
开发者ID:radsimu,项目名称:UaicNlpToolkit,代码行数:9,代码来源:PathOrderBox.java

示例8: drawLabel

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private void drawLabel(Vertex v) {
	String text = v.getLabel();
	float[] c = v.getBorderColor().getColorComponents(null);
	Point2D pos = v.getPosition();
	double x = pos.getX() + v.getSize() / scaleFactor;
	double y = pos.getY() + (v.getSize() + VERTEX_LABEL_OFFSET)
			/ scaleFactor;
	pos.setLocation(x, y);

	gl.glColor3f(c[0], c[1], c[2]);
	renderText(text, pos);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:13,代码来源:LabelRenderer.java

示例9: pointToPath

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public boolean pointToPath(Point2D pt, Point2D result) {
    result.setLocation(pt);
    if (tx != null) {
        try {
            tx.inverseTransform(pt, result);
        }
        catch (NoninvertibleTransformException ex) {
        }
    }
    return result.getX() > 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:LayoutPathImpl.java

示例10: coArcTo

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private static void coArcTo(GeneralPath p, double x2, double y2, double x3, double y3) {
	Point2D p1 = p.getCurrentPoint();
	double x1 = p1.getX();
	double y1 = p1.getY();
	boolean xe = (x1 == x2 && x2 == x3);
	boolean ye = (y1 == y2 && y2 == y3);
	if (xe && ye) return;
	if (xe || ye) { p.lineTo(x3, y3); return; }
	double d = arcHK(x1, y1, x2, y2, x3, y3);
	double h = arcH(x1, y1, x2, y2, x3, y3) / d;
	double k = arcK(x1, y1, x2, y2, x3, y3) / d;
	if (Double.isNaN(h) || Double.isInfinite(h)) { p.lineTo(x3, y3); return; }
	if (Double.isNaN(k) || Double.isInfinite(k)) { p.lineTo(x3, y3); return; }
	double r = Math.hypot(k - y1, x1 - h);
	double a1 = Math.toDegrees(Math.atan2(k - y1, x1 - h));
	double a2 = Math.toDegrees(Math.atan2(k - y2, x2 - h));
	double a3 = Math.toDegrees(Math.atan2(k - y3, x3 - h));
	Arc2D.Double arc = new Arc2D.Double();
	arc.x = h - r;
	arc.y = k - r;
	arc.width = r + r;
	arc.height = r + r;
	arc.start = a1;
	if ((a1 <= a2 && a2 <= a3) || (a3 <= a2 && a2 <= a1)) {
		arc.extent = a3 - a1;
	} else if (a3 <= a1) {
		arc.extent = a3 - a1 + 360;
	} else {
		arc.extent = a3 - a1 - 360;
	}
	p.append(arc, true);
}
 
开发者ID:kreativekorp,项目名称:vexillo,代码行数:33,代码来源:Symbol.java

示例11: getXAt

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public double getXAt( Point2D p ) {
	Insets insets = axes.getInsets();
	Rectangle r = getVisibleRect();
	double w = (double)(r.width - insets.left - insets.right);
	if( tracksWidth  || scPane==null) {
		return xRange[0] + (xRange[1]-xRange[0])*(p.getX()-(double)insets.left)/w;
	} else {
		return xRange[0] + (p.getX()-(double)insets.left) / (xScale*zoom);
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:11,代码来源:XYGraph.java

示例12: getMidPoint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public static Point2D getMidPoint(final Point2D p1, final Point2D p2) {
  final Point2D mid = new Point2D.Double();
  final double x = (p1.getX() + p2.getX()) / 2;
  final double y = (p1.getY() + p2.getY()) / 2;
  mid.setLocation(x, y);
  return mid;

}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:9,代码来源:GeometricUtilities.java

示例13: setTranslate

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void setTranslate(Point2D translate, List<Side> dragSides,
                         Diagram diagram) {
    if (dragSides.size() == 0)
        this.translate = translate;
    else {
        Rectangle2D rect = getRectangle();

        Component component = diagram.getComponent(bounds[0]);

        double minWidth = component.getMinWidth();
        double minHieght = component.getMinHeight();

        if (dragSides.indexOf(Side.RIGHT) >= 0) {
            if (rect.getWidth() + translate.getX() > minWidth)
                addSize.setWidth(translate.getX());
        }
        if (dragSides.indexOf(Side.BOTTOM) >= 0)
            if (rect.getHeight() + translate.getY() > minHieght)
                addSize.setHeight(translate.getY());
        if (dragSides.indexOf(Side.TOP) >= 0) {
            if (rect.getHeight() - translate.getY() > minHieght) {
                addSize.setHeight(-translate.getY());
                this.translate.setLocation(this.translate.getX(), translate
                        .getY());
            }
        }
        if (dragSides.indexOf(Side.LEFT) >= 0) {
            if (rect.getWidth() - translate.getX() > minWidth) {
                addSize.setWidth(-translate.getX());
                this.translate.setLocation(translate.getX(), this.translate
                        .getY());
            }
        }
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:36,代码来源:Group.java

示例14: JMTPoint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Builds a new JMTPoint from a given point
 * @param point point for coordinates
 * @param rotate true if station is rotated
 */
public JMTPoint(Point2D point, boolean rotate) {
	this.x = point.getX();
	this.y = point.getY();
	this.rotate = rotate;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:11,代码来源:JMTPoint.java

示例15: getCursorPosition

import java.awt.geom.Point2D; //导入方法依赖的package包/类
@Override
protected Point getCursorPosition() {
    final Point2D nativePosition = nativeGetCursorPosition();
    return new Point((int)nativePosition.getX(), (int)nativePosition.getY());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:CCursorManager.java


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