Coverage details for edu.uci.ics.jung.visualization.Coordinates

LineHitsSource
1 /*
2 * Copyright (c) 2003, the JUNG Project and the Regents of the University
3 * of California
4 * All rights reserved.
5 *
6 * This software is open-source under the BSD license; see either
7 * "license.txt" or
8 * http://jung.sourceforge.net/license.txt for a description.
9 */
10 package edu.uci.ics.jung.visualization;
11  
12 import java.awt.geom.Point2D;
13  
14 /**
15  *
16  * Stores coordinates (X,Y) for vertices being visualized.
17  *
18  * @author Scott White
19  */
20 public class Coordinates extends Point2D.Float {
21  
22      public Coordinates() {
23900         super();
24900    }
25  
26     public Coordinates(double x, double y) {
270        super((float)x,(float)y);
280    }
29  
30     /**
31      * Initializes this coordinate to the value of the passed-in
32      * coordinate.
33      * @param coordinates
34      */
35     public Coordinates(Coordinates coordinates) {
360        this(coordinates.getX(), coordinates.getY());
370    }
38  
39     /**
40      * Sets the x value to be d;
41      * @param d
42      */
43     public void setX(double d) {
4421507        setLocation(d, getY());
4521507    }
46  
47     /**
48      * Sets the y value to be d;
49      * @param d
50      */
51     public void setY(double d) {
5221524        setLocation(getX(), d);
5321524    }
54  
55     /**
56      * Increases the x and y values of this
57      * scalar by (x, y).
58      * @param x
59      * @param y
60      */
61     public void add(double x, double y) {
62100        addX(x);
63100        addY(y);
64100    }
65  
66     /**
67      * Increases the x value by d.
68      * @param d
69      */
70     public void addX(double d) {
7111720        setX(getX()+d);
7211720    }
73  
74     /**
75      * Increases the y value by d.
76      * @param d
77      */
78     public void addY(double d) {
7911720        setY(getY()+d);
8011720    }
81  
82     /**
83      * Multiplies a coordinate by scalar x and y values.
84      * @param x A scalar to multiple x by
85      * @param y A scalar to multiply y by
86      */
87     public void mult(double x, double y) {
880        multX(x);
890        multY(y);
900    }
91  
92     /**
93      * Multiplies the X coordinate by a scalar value.
94      * <P>
95      * For example, (3, 10) x-scaled by 2 returns (6, 10).
96      * @param d the scalar value by which x will be multiplied
97      */
98     public void multX(double d) {
990        setX(getX()*d);
1000    }
101  
102     /**
103      * Multiplies the Y coordinate by a scalar value.
104      * <P>
105      * For example, (3, 10) y-scaled by 2 returns (3, 20).
106      * @param d the scalar value by which y will be multiplied
107      */
108     public void multY(double d) {
1090        setY(getY()*d);
1100    }
111  
112     /**
113      * Computes the euclidean distance between two coordinates
114      * @param o another coordinates
115      * @return the euclidean distance
116      */
117     public double distance(Coordinates o) {
1180        return super.distance(o);
119     }
120  
121     /**
122      * Computes the midpoint between the two coordinates
123      * @param o another coordinates
124      * @return the midpoint
125      */
126     public Coordinates midpoint(Coordinates o) {
1270        double midX = (this.getX() + o.getX()) / 2.0;
1280        double midY = (this.getY() + o.getY()) / 2.0;
1290        Coordinates midpoint = new Coordinates(midX, midY);
1300        return midpoint;
131     }
132  
133 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.