Java Code Examples for java.awt.geom.Point2D.Float

The following are Jave code examples for showing how to use Float of the java.awt.geom.Point2D class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MFM   File: SwingUtils.java   View Source Code Vote up 8 votes
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));
}
 
Example 2
Project: WordnetLoom   File: ViwnVertexRenderer.java   View Source Code Vote up 6 votes
private void drawFrame(GraphicsDecorator g, Shape shape, Color color, Point2D.Float pos) {
    Shape old_clip = g.getClip();
    AffineTransform old = g.getTransform();
    AffineTransform t = g.getTransform();
    t.concatenate(AffineTransform.getTranslateInstance(pos.x, pos.y));
    g.setTransform(t);
    g.setColor(color);
    Stroke old_stroke = g.getStroke();
    g.setStroke(new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    Area a = new Area(g.getClip());
    a.subtract(new Area(shape));
    g.setClip(a);
    g.draw(shape);
    g.setTransform(old);
    g.setStroke(old_stroke);
    g.setClip(old_clip);
}
 
Example 3
Project: VASSAL-src   File: Pivot.java   View Source Code Vote up 5 votes
/**
 * Pivot the given point around the pivot point from oldAngle to newAngle
 * @param oldAngle
 * @param newAngle
 */
private void pivotPoint(Point p, double oldAngle, double newAngle) {
  Point2D pivot2D = new Point2D.Double(pivotX, pivotY);
  AffineTransform t = AffineTransform.getRotateInstance(oldAngle);
  t.transform(pivot2D, pivot2D);
  t = AffineTransform.getRotateInstance(newAngle - oldAngle, pivot2D.getX(), pivot2D.getY());
  Point2D newPos2D = new Point2D.Float(0, 0);
  t.transform(newPos2D, newPos2D);
  p.x += (int) Math.round(newPos2D.getX());
  p.y += (int) Math.round(newPos2D.getY());
}
 
Example 4
Project: jaer   File: KalmanEventFilter.java   View Source Code Vote up 5 votes
public Point2D.Float getBallVelocity() {
	Point2D.Float position = new Point2D.Float();
	if ( currentBestFilter != null ) {
		final double[] mu = currentBestFilter.getMu();
		position.setLocation(mu[2], mu[3]);
	}
	return position;
}
 
Example 5
Project: MicroSim   File: Organism.java   View Source Code Vote up 5 votes
Organism(Micro_Sim processing, Point2D.Float startingPosition) {
    super(processing);
    position = startingPosition;
    moveTo = position;
    rotation = 20;
    mRates = new MutationRates();
}
 
Example 6
Project: MicroSim   File: Driver.java   View Source Code Vote up 5 votes
public void Start() {
    if (Helper.PercentageChance(80)) {
        triggers.add(new EyeTrigger(this, processing));
    } else {
        triggers.add(new ChronoTrigger(this, processing));
    }

    size = new Point2D.Float(5, 5);
    tag = "Driver";

    if (distance == 0) {
        distance = ThreadLocalRandom.current().nextInt(10, 120);
    }
}
 
Example 7
Project: jaer   File: StereoCalibrationDualViewFilter.java   View Source Code Vote up 5 votes
private void generateCalibrationString() {
	if ((cameraMatrix == null) || cameraMatrix.isNull() || cameraMatrix.empty()) {
		calibrationString = SINGLE_CAMERA_CALIBRATION_UNCALIBRATED;
		calibrated = false;
		return;
	}

	DoubleBufferIndexer cameraMatrixIndexer = cameraMatrix.createIndexer();

	// Average focal lengths for X and Y axis (fx, fy).
	focalLengthPixels = (float) (cameraMatrixIndexer.get(0, 0) + cameraMatrixIndexer.get(1, 1)) / 2;

	// Go from pixels to millimeters, by multiplying by pixel size (in mm).
	focalLengthMm = chip.getPixelWidthUm() * 1e-3f * focalLengthPixels;

	principlePoint = new Point2D.Float((float) cameraMatrixIndexer.get(0, 2), (float) cameraMatrixIndexer.get(1, 2));
	StringBuilder sb = new StringBuilder();
	if (imageCounter > 0) {
		sb.append(String.format("Using %d images", imageCounter));
		if (!saved) {
			sb.append("; not yet saved\n");
		} else {
			sb.append("; saved\n");
		}
	} else {
		sb.append(String.format("Path:%s\n", shortenDirPath(dirPath)));
	}
	sb.append(String.format("focal length avg=%.1f pixels=%.2f mm\nPrincipal point (green cross)=%.1f,%.1f, Chip size/2=%.0f,%.0f\n",
		focalLengthPixels, focalLengthMm,
		principlePoint.x, principlePoint.y,
		(float) chip.getSizeX() / 2, (float) chip.getSizeY() / 2));
	calibrationString = sb.toString();
	calibrated = true;
	textRendererScaleSet = false;
}
 
Example 8
Project: cuttlefish   File: Utilities.java   View Source Code Vote up 5 votes
public static Point2D getBorderPoint(Vertex v, double angrad, double scale) {
	double x, y;
	Point2D b = null;

	if (v.getShape().equalsIgnoreCase(Constants.SHAPE_DISK)) {
		x = v.getPosition().getX() - v.getSize() * Math.cos(angrad) / scale;
		y = v.getPosition().getY() - v.getSize() * Math.sin(angrad) / scale;

		b = new Point2D.Float();
		b.setLocation(x, y);

	} else if (v.getShape().equalsIgnoreCase(Constants.SHAPE_SQUARE)) {
		double size = v.getSize();
		double r = size;
		double pi = Math.PI;

		if (rangeContains(angrad, 0, 0.25 * pi)
				|| rangeContains(angrad, 1.75 * pi, 2 * pi)) {
			r = size / Math.cos(angrad);
		} else if (rangeContains(angrad, 0.25 * pi, 0.75 * pi)) {
			r = size / Math.sin(angrad);
		} else if (rangeContains(angrad, 0.75 * pi, 1.25 * pi)) {
			r = -size / Math.cos(angrad);
		} else {
			r = -size / Math.sin(angrad);
		}

		r /= scale;

		x = v.getPosition().getX() - r * Math.cos(angrad);
		y = v.getPosition().getY() - r * Math.sin(angrad);

		b = new Point2D.Float();
		b.setLocation(x, y);
	}

	return b;
}
 
Example 9
Project: jaer   File: BasicCluster.java   View Source Code Vote up 4 votes
/** Returns birth location of cluster: initially the first event and later, after cluster
 * becomes visible, it is the location when it becomes visible, which is presumably less noisy.
 * @return x,y location. */
public Point2D.Float getBirthLocation() {
    return birthLocation;
}
 
Example 10
Project: OpenJSharp   File: PhysicalStrike.java   View Source Code Vote up 4 votes
protected void adjustPoint(Point2D.Float pt) {
}
 
Example 11
Project: openjdk-jdk10   File: DelegateStrike.java   View Source Code Vote up 4 votes
Point2D.Float getCharMetrics(char ch) {
    return delegateStrike.getCharMetrics(ch);
}
 
Example 12
Project: jdk8u-jdk   File: NativeStrike.java   View Source Code Vote up 4 votes
void getGlyphImageBounds(int glyphcode, Point2D.Float pt,
                         Rectangle result) {
}
 
Example 13
Project: connection-scan   File: Data.java   View Source Code Vote up 4 votes
public static Point2D coordinate(float x, float y) {
	return new Point2D.Float(x, y);
}
 
Example 14
Project: jaer   File: SlotcarTrack.java   View Source Code Vote up 4 votes
/**
 * Returns the list of smooth points with given step size
 */
public LinkedList<Point2D.Float> getSmoothPoints(float stepSize) {
    return smoothTrack.allPoints(stepSize);
}
 
Example 15
Project: jdk8u-jdk   File: NativeStrike.java   View Source Code Vote up 4 votes
Point2D.Float getGlyphMetrics(int glyphCode) {
    return null;
}
 
Example 16
Project: jaer   File: ApsDvsMotionOrientationEvent.java   View Source Code Vote up 4 votes
@Override
public void setVelocity(Point2D.Float velocity) {
    this.velocity.setLocation(velocity.x, velocity.y);
}
 
Example 17
Project: OpenJSharp   File: FontStrike.java   View Source Code Vote up 4 votes
abstract void getGlyphImageBounds(int glyphcode,
Point2D.Float pt,
Rectangle result);
 
Example 18
Project: jdk8u-jdk   File: DelegateStrike.java   View Source Code Vote up 4 votes
Point2D.Float getCharMetrics(char ch) {
    return delegateStrike.getCharMetrics(ch);
}
 
Example 19
Project: jaer   File: Vector2D.java   View Source Code Vote up 4 votes
public Vector2D(Point2D.Float point){
    super(point.x,point.y);
}
 
Example 20
Project: CarSharing   File: IPassenger.java   View Source Code Vote up 2 votes
/**
 * Setter of the destination.
 * @param destination the destination to set
 */
void setDestination(Point2D.Float destination);