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


Java Point2D類代碼示例

本文整理匯總了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));
}
 
開發者ID:phweda,項目名稱:MFM,代碼行數:32,代碼來源:SwingUtils.java

示例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;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:24,代碼來源:TGrid.java

示例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);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:27,代碼來源:ARFLayout.java

示例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;
}
 
開發者ID:moment-of-peace,項目名稱:AI-RRT-Motion-Planning,代碼行數:25,代碼來源:Main.java

示例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
    } 
}
 
開發者ID:jfree,項目名稱:jfreechart-fx,代碼行數:32,代碼來源:ScrollHandlerFX.java

示例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);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:26,代碼來源:WeightedARF2Layout.java

示例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());
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:17,代碼來源:TrackDefineFilter.java

示例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;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:18,代碼來源:DFDFunction.java

示例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());        
}
 
開發者ID:redmyers,項目名稱:484_P7_1-Java,代碼行數:21,代碼來源:Ruling.java

示例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);
				}
			}
		}
	}
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:24,代碼來源:GraphEnvironmentMousePlugin.java

示例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");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:StandardGlyphVector.java

示例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;
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:40,代碼來源:StandardGlyphVector.java

示例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);
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:11,代碼來源:PathFinder.java

示例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);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:17,代碼來源:AbstractChartPanel.java

示例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);
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:9,代碼來源:MyGraphLayout.java


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