本文整理汇总了Java中java.awt.geom.Point2D类的典型用法代码示例。如果您正苦于以下问题:Java Point2D类的具体用法?Java Point2D怎么用?Java Point2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2D类属于java.awt.geom包,在下文中一共展示了Point2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateIcons
import java.awt.geom.Point2D; //导入依赖的package包/类
public static void updateIcons(JTree tree) {
Font defaultFont = UIManager.getFont("Tree.font");
Font currentFont = tree.getFont();
double newScale = (double)
currentFont.getSize2D() / defaultFont.getSize2D();
DefaultTreeCellRenderer renderer =
(DefaultTreeCellRenderer) tree.getCellRenderer();
renderer.setOpenIcon(
scale(UIManager.getIcon("Tree.openIcon"), newScale, tree));
renderer.setClosedIcon(
scale(UIManager.getIcon("Tree.closedIcon"), newScale, tree));
renderer.setLeafIcon(
scale(UIManager.getIcon("Tree.leafIcon"), newScale, tree));
Collection<Integer> iconSizes = Arrays.asList(
renderer.getOpenIcon().getIconHeight(),
renderer.getClosedIcon().getIconHeight(),
renderer.getLeafIcon().getIconHeight());
// Convert points to pixels
Point2D p = new Point2D.Float(0, currentFont.getSize2D());
FontRenderContext context =
tree.getFontMetrics(currentFont).getFontRenderContext();
context.getTransform().transform(p, p);
int fontSizeInPixels = (int) Math.ceil(p.getY());
tree.setRowHeight(
Math.max(fontSizeInPixels, Collections.max(iconSizes) + 2));
}
示例2: temp
import java.awt.geom.Point2D; //导入依赖的package包/类
public static float temp( int yr, int day, Point2D point) {
if(yr<79 || yr>98) return 999f; //Float.NaN;
Point2D p = getMapXY(point);
int x = (int)Math.floor(p.getX());
if(x<0 || x>=46) return 998f; //Float.NaN;
int y = (int)Math.floor(p.getY());
if(y<0 || y>=40) return 997f; //Float.NaN;
if(year!=yr) try {
readGrids(yr);
} catch (IOException ex) {
return 996f; //Float.NaN;
}
if( t==null ) return 995f; //Float.NaN;
double dx = p.getX()-x;
double dy = p.getY()-y;
double dxy = dx*dy;
int d = day-1;
float T = .01f * (float) ( (double)t[d][y][x]*(1d-dx-dy+dxy)
+ (double)t[d][y][x+1]*(dx-dxy)
+ (double)t[d][y+1][x]*(dy-dxy)
+ (double)t[d][y+1][x+1]*(dxy) );
return T;
}
示例3: advancePositions
import java.awt.geom.Point2D; //导入依赖的package包/类
private void advancePositions() {
double c = 0;
int nodeCount = graph.getNodeCount();
for (int iter = 0; iter < updatesPerFrame; ++iter) {
for (Node n : graph.getNodes()) {
Point2D.Float f = getForceforNode(n);
double log = Math.log10(nodeCount) == 0 ? 1 : Math
.log10(nodeCount);
double delta = graph.getDegree(n) > 1 ? (deltaT / log)
/ Math.pow(graph.getDegree(n), 0.4) : (deltaT / log);
f.setLocation(f.getX() * delta, f.getY() * delta);
n.getNodeData().setX(
n.getNodeData().x() + (float) (f.getX() / sensitivity));
n.getNodeData().setY(
n.getNodeData().y() + (float) (f.getY() / sensitivity));
c += Math.abs(f.getX()) + Math.abs(f.getY());
}
}
setChange(c);
align(100, 100);
}
示例4: asvConfigToCfg
import java.awt.geom.Point2D; //导入依赖的package包/类
/**
* convert a state from workspace to c space
*/
private static Config asvConfigToCfg(ASVConfig initialState, Test tester) {
List<Point2D> positions = initialState.asvPositions;
//length
double [] pts = new double [initialState.getASVCount()+1];
Point2D p0= positions.get(0);
pts[0]=p0.getX();
pts[1]=p0.getY();
double prevAngle=0;
for (int i=1;i<positions.size();i++){
Point2D p1 = positions.get(i);
double currentAngle = Math.atan2(p1.getY() - p0.getY(),
p1.getX() - p0.getX());
pts[i+1]=tester.normaliseAngle(PI+prevAngle-currentAngle);
prevAngle=currentAngle;
p0=p1;
}
Config cfg = new Config(pts);
return cfg;
}
示例5: handleZoomable
import java.awt.geom.Point2D; //导入依赖的package包/类
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable,
ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (canvas.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (canvas.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
plot.setNotify(notifyState); // this generates the change event too
}
}
示例6: 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);
}
示例7: loadTrackFromFile
import java.awt.geom.Point2D; //导入依赖的package包/类
private void loadTrackFromFile(File file) throws HeadlessException, IOException, ClassNotFoundException {
Object old = extractedTrack;
if (file == null) {
throw new IOException("null filename, can't load track from file - track needs to be saved first");
}
log.info("loading track data from " + file);
extractedTrack = SlotcarTrack.loadFromFile(file);
// extractPoints = (LinkedList<Point2D.Float>) ois.readObject(); // unchecked cast exception
extractPoints = new LinkedList<Point2D.Float>();
for (Object o : extractedTrack.trackPoints) {
extractPoints.add((Point2D.Float) o);
}
extractedTrack.getSupport().addPropertyChangeListener(this);
extractedTrack.updateTrack(); // update other internal vars of track
setTrackName(extractedTrack.getTrackName());
}
示例8: getTriangle
import java.awt.geom.Point2D; //导入依赖的package包/类
protected int getTriangle(final FloatPoint point) {
int res = -1;
FloatPoint l = getLocation();
for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
GeneralPath gp = getTrianglePath(type);
double y = point.getY() + l.getY();
double x = point.getX() + l.getX();
if (gp.contains(new Point2D.Double(x, y))) {
res = type;
break;
}
}
return res;
}
示例9: intersectionPoint
import java.awt.geom.Point2D; //导入依赖的package包/类
public Point2D intersectionPoint(Ruling other) {
Ruling this_l = this.expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT);
Ruling other_l = other.expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT);
Ruling horizontal, vertical;
if (!this_l.intersectsLine(other_l)) {
return null;
}
if (this_l.horizontal() && other_l.vertical()) {
horizontal = this_l; vertical = other_l;
}
else if (this_l.vertical() && other_l.horizontal()) {
vertical = this_l; horizontal = other_l;
}
else {
throw new IllegalArgumentException("lines must be orthogonal, vertical and horizontal");
}
return new Point2D.Float(vertical.getLeft(), horizontal.getTop());
}
示例10: pickContainedVertices
import java.awt.geom.Point2D; //导入依赖的package包/类
@Override
protected void pickContainedVertices(VisualizationViewer<GraphNode, GraphEdge> vv, Point2D down,Point2D out, boolean clear) {
super.pickContainedVertices(vv, down, out, clear);
NetworkModelAdapter netAdapter = this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter();
// --- Get the selected nodes ----------------
Set<GraphNode> nodesSelected = this.getVisViewer().getPickedVertexState().getPicked();
// --- Get the related NetworkComponent's ----
HashSet<NetworkComponent> components = netAdapter.getNetworkComponentsFullySelected(nodesSelected);
if (components!=null) {
// --- Run through NetworkComponents -----
for (NetworkComponent networkComponent : components) {
Vector<GraphElement> elements = netAdapter.getGraphElementsFromNetworkComponent(networkComponent);
for (GraphElement graphElement : elements) {
if (graphElement instanceof GraphEdge) {
this.getVisViewer().getPickedEdgeState().pick((GraphEdge) graphElement, true);
}
}
}
}
}
示例11: pixellate
import java.awt.geom.Point2D; //导入依赖的package包/类
/**
* !!! not used currently, but might be by getPixelbounds?
*/
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
if (renderFRC == null) {
renderFRC = frc;
}
// it is a total pain that you have to copy the transform.
AffineTransform at = renderFRC.getTransform();
at.transform(loc, loc);
pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
pxResult.y = (int)loc.getY();
loc.setLocation(pxResult.x, pxResult.y);
try {
at.inverseTransform(loc, loc);
}
catch (NoninvertibleTransformException e) {
throw new IllegalArgumentException("must be able to invert frc transform");
}
}
示例12: initPositions
import java.awt.geom.Point2D; //导入依赖的package包/类
/**
* Ensure that the positions array exists and holds position data.
* If the array is null, this allocates it and sets default positions.
*/
private void initPositions() {
if (positions == null) {
setFRCTX();
positions = new float[glyphs.length * 2 + 2];
Point2D.Float trackPt = null;
float track = getTracking(font);
if (track != 0) {
track *= font.getSize2D();
trackPt = new Point2D.Float(track, 0); // advance delta
}
Point2D.Float pt = new Point2D.Float(0, 0);
if (font.isTransformed()) {
AffineTransform at = font.getTransform();
at.transform(pt, pt);
positions[0] = pt.x;
positions[1] = pt.y;
if (trackPt != null) {
at.deltaTransform(trackPt, trackPt);
}
}
for (int i = 0, n = 2; i < glyphs.length; ++i, n += 2) {
getGlyphStrike(i).addDefaultGlyphAdvance(glyphs[i], pt);
if (trackPt != null) {
pt.x += trackPt.x;
pt.y += trackPt.y;
}
positions[n] = pt.x;
positions[n+1] = pt.y;
}
}
}
示例13: findDirectPath
import java.awt.geom.Point2D; //导入依赖的package包/类
public Path findDirectPath(final Point2D start, final Point2D target) {
final Path2D path2D = new GeneralPath(Path2D.WIND_NON_ZERO);
path2D.moveTo(start.getX(), start.getY());
path2D.lineTo(target.getX(), target.getY());
final List<Point2D> points = new ArrayList<>();
points.add(start);
points.add(target);
return new Path(start, target, path2D, points);
}
示例14: translateJava2DToScreen
import java.awt.geom.Point2D; //导入依赖的package包/类
/**
* Translates a Java2D point on the chart to a screen location.
*
* @param java2DPoint
* the Java2D point.
*
* @return The screen location.
*/
@Override
public Point translateJava2DToScreen(Point2D java2DPoint) {
Insets insets = getInsets();
int x = (int) (java2DPoint.getX() * this.scaleX + insets.left);
int y = (int) (java2DPoint.getY() * this.scaleY + insets.top);
return new Point(x, y);
}
示例15: setLocation
import java.awt.geom.Point2D; //导入依赖的package包/类
@Override
public void setLocation(V v, Point2D p) {
// Update own storage.
v.setCoordinateX(p.getX());
v.setCoordinateY(p.getY());
super.setLocation(v, p);
}