本文整理汇总了Java中java.awt.geom.Point2D.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.setLocation方法的具体用法?Java Point2D.setLocation怎么用?Java Point2D.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Point2D
的用法示例。
在下文中一共展示了Point2D.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: advancePositions
import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void advancePositions() {
for (int i = 0; i < updatesPerFrame; i++) {
for (Vertex v : graph.getVertices()) {
if (!isFixed(v)) {
Point2D c = transform( v);
if (c != null) {
Point2D f = getForceforNode(v);
double deltaIndividual = 0;
try {
double log = Math.log10(getGraph().getVertexCount()) == 0 ? 1 : Math.log10(getGraph().getVertexCount());
deltaIndividual = getGraph().degree(v) > 1 ? (deltaT/log) / Math.pow(getGraph().degree(v), 0.4) : (deltaT/log);
} catch (java.lang.IllegalArgumentException ex) {
this.reset();
}
f.setLocation(f.getX() * deltaIndividual, f.getY() * deltaIndividual);
c.setLocation(c.getX() + f.getX(), c.getY() + f.getY());
new_change += Math.abs(f.getX()) + Math.abs(f.getY());
}
}
}
}
change = new_change;
new_change = 0;
align(100, 100);
}
示例2: calcoffset
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Return the location of the point passed in result as mapped to the
* line indicated by index. If doExtend is true, extend the
* x value without pinning to the ends of the line.
* this assumes that index is valid and references a line that has
* non-zero length.
*/
private void calcoffset(int index, boolean doExtend, Point2D result) {
double bx = data[index-3];
double by = data[index-2];
double px = result.getX() - bx;
double py = result.getY() - by;
double dx = data[index] - bx;
double dy = data[index+1] - by;
double l = data[index+2] - data[index - 1];
// rx = A dot B / |B|
// ry = A dot invB / |B|
double rx = (px * dx + py * dy) / l;
double ry = (px * -dy + py * dx) / l;
if (!doExtend) {
if (rx < 0) rx = 0;
else if (rx > l) rx = l;
}
rx += data[index-1];
result.setLocation(rx, ry);
}
示例3: assignPositionToVertex
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Assign position p to the vertex
* @param vertex
* @param p
* @return the newly assigned position
*/
@SuppressWarnings("unchecked")
public Point2D assignPositionToVertex(Vertex vertex, Point2D p) {
Point2D c = transform((V)vertex);
//if(c == null){
// c = getRandomPoint();
// vertex.addUserDatum(getBaseKey(), c , UserData.CLONE);
//}
c.setLocation(p);
locations.put((V) vertex, c);
return p;
}
示例4: mouseClicked
import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
if (e.isConsumed() || e.isControlDown())
return;
if (e.getButton() == MouseEvent.BUTTON3 || (System.getProperty("os.name").toLowerCase().contains("mac") && e.isControlDown()) ) {
System.out.println("Loading Contributed Grid");
loadSelection();
return;
}
Point2D point = map.getScaledPoint( e.getPoint() );
double wrap = map.getWrap();
if (wrap > 0)
while (point.getX() > wrap)
point.setLocation(point.getX() - wrap, point.getY());
if (!select(selectedIndex, point))
selectedIndex = -1;
int i;
for (i = selectedIndex + 1; i < names.length; i++) {
if (select(i, point)) {
selectedIndex = i;
map.repaint();
return;
}
}
for (i = 0; i < selectedIndex + 1; i++) {
if (select(i, point)) {
selectedIndex = i;
map.repaint();
return;
}
}
selectedIndex = -1;
map.repaint();
}
示例5: toString
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns a string representation of this topology. The output of this
* method can be subsequently used to reconstruct a topology with the
* <tt>fromString</tt> method. Only the nodes and wired links are exported
* here (not the topology's properties).
*/
public String toString() {
StringBuffer res = new StringBuffer();
res.append("cR " + communicationRange + "\n");
res.append("sR " + sensingRange + "\n");
for (Node n : nodes) {
Point2D p2d = new Point2D.Double();
p2d.setLocation(n.coords.getX(), n.coords.getY());
res.append(n.toString() + " " + p2d.toString().substring(14) + "\n");
}
for (Link l : getLinks())
if (!l.isWireless())
res.append(l.toString() + "\n");
return res.toString();
}
示例6: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the corresponding destination point for a given source point.
*
* This Op will return the source point unchanged.
*
* @param src The source point.
* @param dst The destination point.
*/
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null)
return (Point2D) src.clone();
dst.setLocation(src);
return dst;
}
示例7: pathToPoint
import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void pathToPoint(Point2D location, boolean preceding, Point2D point) {
if (tx != null) {
tx.transform(location, point);
} else {
point.setLocation(location);
}
}
示例8: advancePositions
import java.awt.geom.Point2D; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void advancePositions() {
try{
for (int i = 0; i < updatesPerFrame; i++) {
for (Object o : graph.getVertices()) {
Vertex v = (Vertex) o;
if(!isFixed(v)){
Point2D c = transform((V) v);
if(c != null){
Point2D f = getForceforNode(v);
double deltaIndividual = getGraph().degree((V)v) > 1 ? deltaT / Math.pow(getGraph().degree((V)v), 0.4) : deltaT;
f.setLocation(f.getX()*deltaIndividual, f.getY()*deltaIndividual);
c.setLocation(c.getX() + f.getX(), c.getY() + f.getY());
}
}
}
}
}catch(Exception e){
System.err.println(e);
e.printStackTrace();
}
align(100,100);
}
示例9: map
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Map a location based on the provided segment, returning in pt.
* Seg must be a valid 'lineto' segment. Note: if the path is
* closed, x must be within the start and end of the path.
*/
private void map(int seg, double a, double o, Point2D pt) {
double dx = data[seg] - data[seg-3];
double dy = data[seg+1] - data[seg-2];
double dl = data[seg+2] - data[seg-1];
double ux = dx/dl; // could cache these, but is it worth it?
double uy = dy/dl;
a -= data[seg-1];
pt.setLocation(data[seg-3] + a * ux - o * uy,
data[seg-2] + a * uy + o * ux);
}
示例10: getPositionAndOrientation
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the position and orientation of the spline at the given position
* @param T Spline parameter
* @param idx Index of the segment of the track
* @param pos Point in which to store the position
* @param orient Point in which to store the normalized orientation vector
* @return 0 if successful, -1 if not.
*/
public int getPositionAndOrientation(float T, int idx, Point2D pos, Point2D orient) {
if ((pos==null) || (orient == null))
return -1;
if (idx > numXY) {
// T not in parameter range
return -1;
}
pos.setLocation(evaluateX(T,idx), evaluateY(T,idx));
float oX = orientationX(T, idx);
float oY = orientationY(T, idx);
float norm = (float)Math.sqrt(oX*oX+oY*oY);
orient.setLocation(oX/norm, oY/norm);
return 1;
}
示例11: correctSubGraphMapping
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* @param parent parent of central node of collection to correct
* @param center central node of set to correct
* @param upper parent node neighbors
* @param lower central node neighbors, nodes to correct
*/
protected void correctSubGraphMapping(ViwnNode parent, ViwnNode center,
Collection<ViwnNode> upper, Collection<ViwnNode> lower) {
// calculate direction vector from parent to center
Point2D par = locations.get(parent);
Point2D cen = locations.get(center);
Point2D dir = new Point2D.Double((cen.getX() - par.getX()),
(cen.getY() - par.getY()));
double dist = dir.distance(0, 0);
dir.setLocation(dir.getX() / dist, dir.getY() / dist);
boolean end = false;
int[] dim;
Set<ViwnNode> ad = new HashSet<>(upper);
ad.removeAll(lower);
// calculate boundaries of subgraph
dim = findMappedGraphBoundaries(center, lower);
// check for conflicts
end = !isAnyInsideBounds(ad, dim);
while (!end) {
// move subgraph
correctNode2PointMapping(lower, (int) (100 * dir.getX()),
(int) (100 * dir.getY()));
// calculate boundaries of subgraph
dim = findMappedGraphBoundaries(center, lower);
// check for conflicts
end = !isAnyInsideBounds(ad, dim);
}
}
示例12: 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;
}
示例13: drawCurve
import java.awt.geom.Point2D; //导入方法依赖的package包/类
private void drawCurve(Edge e) {
Point2D from = e.getSource().getPosition();
Point2D to = e.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 = 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);
float t = 0;
double x = 0, y = 0;
Point2D c = new Point2D.Double(cx, cy);
gl.glBegin(GL.GL_LINE_STRIP);
while (t <= 1) {
t += 0.01;
double c1x = fx + (cx - fx) * t;
double c1y = fy + (cy - fy) * t;
double c2x = cx + (tx - cx) * t;
double c2y = cy + (ty - cy) * t;
x = c1x + (c2x - c1x) * t;
y = c1y + (c2y - c1y) * t;
gl.glVertex2d(x, y);
if (renderer.getNetwork().isDirected()) {
// store the point to direct the arrow
if (0.495 < t && t < 0.505)
c.setLocation(x, y);
if (IntersectingShapePickSupport.containsPoint(e.getTarget(),
new Point2D.Double(x, y), scaleFactor)) {
// hit border!
break;
}
}
}
gl.glEnd();
if (renderer.getNetwork().isDirected()) {
// draw arrow
Point2D b = new Point2D.Double(x, y);
double arrowAngle = Utilities.calculateAngle(c, b);
gl.glPushMatrix();
gl.glTranslated(x, y, 0);
gl.glRotated(Math.toDegrees(arrowAngle), 0, 0, 1);
gl.glScaled(1 / scaleFactor, 1 / scaleFactor, 1);
gl.glCallList(DLIST_ARROW);
gl.glPopMatrix();
}
}
示例14: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the location of the corresponding destination point given a
* point in the source <CODE>Raster</CODE>. If <CODE>dstPt</CODE> is
* specified, it is used to hold the return value.
* Since this is not a geometric operation, the point returned
* is the same as the specified <CODE>srcPt</CODE>.
*
* @param srcPt The <code>Point2D</code> that represents the point in
* the source <code>Raster</code>
* @param dstPt The <CODE>Point2D</CODE> in which to store the result.
*
* @return The <CODE>Point2D</CODE> in the destination image that
* corresponds to the specified point in the source image.
*/
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
if (dstPt == null) {
dstPt = new Point2D.Float();
}
dstPt.setLocation(srcPt.getX(), srcPt.getY());
return dstPt;
}
示例15: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the location of the destination point given a
* point in the source. If {@code dstPt} is not
* {@code null}, it will be used to hold the return value.
* Since this is not a geometric operation, the {@code srcPt}
* will equal the {@code dstPt}.
* @param srcPt a {@code Point2D} that represents a point
* in the source image
* @param dstPt a {@code Point2D} that represents the location
* in the destination
* @return the {@code Point2D} in the destination that
* corresponds to the specified point in the source.
*/
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
if (dstPt == null) {
dstPt = new Point2D.Float();
}
dstPt.setLocation(srcPt.getX(), srcPt.getY());
return dstPt;
}