Java 8 AffineTransform - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AffineTransform class.

This code example shows how to use the following methods:getScaleX, getScaleY, getShearX, getShearY
    /** 
     * Check if the given AffineTransform is a translation 
     * (within thresholds -- see {@link #THRESH}. 
     */ 
    private static boolean isTranslation(AffineTransform at) {
        return ( Math.abs(at.getScaleX()-1.0) < THRESH &&
                 Math.abs(at.getScaleY()-1.0) < THRESH &&
                 Math.abs(at.getShearX())     < THRESH &&
                 Math.abs(at.getShearY())     < THRESH );
    } 
 
    /** 
     * Get an identity transform (creating it if necessary) 
     */ 
    private AffineTransform getIdentity() {
        if ( m_identity == null )
            m_identity = new AffineTransform();
        return m_identity;
    } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaleX, getScaleY, getShearX, getShearY, getTranslateX
     * 
     * @param expected The expected affine transform. 
     * @param actual   The actual affine transform. 
     */ 
    protected static void assertTransformEquals(AffineTransform expected, AffineTransform actual) {
        assertEquals("scaleX",     expected.getScaleX(),     actual.getScaleX(),     EPS);
        assertEquals("scaleY",     expected.getScaleY(),     actual.getScaleY(),     EPS);
        assertEquals("shearX",     expected.getShearX(),     actual.getShearX(),     EPS);
        assertEquals("shearY",     expected.getShearY(),     actual.getShearY(),     EPS);
        assertEquals("translateX", expected.getTranslateX(), actual.getTranslateX(), EPS);
        assertEquals("translateY", expected.getTranslateY(), actual.getTranslateY(), EPS);
    } 
 
    /** 
     * Compares the rendered view of two coverages for equality. 
     * 
     * @param expected The coverage containing the expected pixel values. 
     * @param actual   The coverage containing the actual pixel values. 
     */ 
    protected static void assertRasterEquals(final Coverage expected, final Coverage actual) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		// We multiply spread by the scale, so that changing scale will only affect accuracy 
		// and not spread in the output image. 
		generator.setSpread(scale * spread);
		BufferedImage distanceField = generator.generateDistanceField(input);
		 
		g.drawImage(distanceField, new AffineTransform(), null);
	} 
	 
	@Override 
	public String toString() {
		return "Distance field"; 
	} 
 
	@Override 
	public List getValues() {
		List values = new ArrayList();
		values.add(EffectUtil.colorValue("Color", color));
		values.add(EffectUtil.intValue("Scale", scale, "The distance field is computed from an image larger than the output glyph by this factor. Set this to a higher value for more accuracy, but slower font generation."));
		values.add(EffectUtil.floatValue("Spread", spread, 1.0f, Float.MAX_VALUE, "The maximum distance from edges where the effect of the distance field is seen. Set this to about half the width of lines in your output font."));
		return values;
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:concatenate, rotate, scale, translate
 
    public synchronized void run( IProgressMonitor monitor ) throws Exception {
        if (fixedPoint == null) {
            fixedPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
        } 
        AffineTransform t = new AffineTransform();
        t.translate(fixedPoint.getX(), fixedPoint.getY());
        t.rotate(rotation);
        t.scale(scaleFactorX, scaleFactorY);
        t.translate(-fixedPoint.getX(), -fixedPoint.getY());
        t.translate(translateX, translateY);
        t.concatenate(graphics.getTransform());
        graphics.setTransform(t);
    } 
 
    public synchronized void fixPoint( Point fixedPoint ) {
        this.fixedPoint = fixedPoint;
    } 
 
    public synchronized void zoom( double scaleFactorX, double scaleFactorY ) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaleX, getScaleY, getShearY, getTranslateX, getTranslateY
This code example shows how to use the following methods:getScaleX, getScaleY, getShearX, getShearY, getTranslateX
        writeByte(c.getRed());
        writeByte(c.getAlpha());
	} 
	 
    public void writeXFORM(AffineTransform t) throws IOException {
        writeFLOAT((float) t.getScaleX());
        writeFLOAT((float) t.getShearY());
        writeFLOAT((float) t.getShearX());
        writeFLOAT((float) t.getScaleY());
        writeFLOAT((float) t.getTranslateX());
        writeFLOAT((float) t.getTranslateY());
    } 
 
    // POINTS [] 
    public void writePOINTS(Point[] p) throws IOException {
        writePOINTS(p.length, p);
    } 
 
    public void writePOINTS(int n, Point[] p) throws IOException {
        for (int i = 0; i < n; i++) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:rotate, setToTranslation
This code example shows how to use the following methods:getScaleX, getScaleY, getShearX, getShearY, getTranslateX
     *        identity, {@code false} otherwise. 
     * 
     * @since 2.3.1 
     */ 
    public static boolean isIdentity(final AffineTransform tr, double tolerance) {
        if (tr.isIdentity()) {
            return true; 
        } 
        tolerance = Math.abs(tolerance);
        return Math.abs(tr.getScaleX() - 1) <= tolerance &&
               Math.abs(tr.getScaleY() - 1) <= tolerance &&
               Math.abs(tr.getShearX())     <= tolerance &&
               Math.abs(tr.getShearY())     <= tolerance &&
               Math.abs(tr.getTranslateX()) <= tolerance &&
               Math.abs(tr.getTranslateY()) <= tolerance;
    } 
 
    /** 
     * Transforms the given shape. This method is similar to 
     * {@link #createTransformedShape createTransformedShape} except that: 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaleX, getScaleY, getShearX, getShearY
     * @param at The affine transform applied to coordinates during iteration 
     */ 
    public PackedLineIterator(LineString ls, AffineTransform at, boolean generalize,
            float maxDistance) {
        if (at == null) {
            at = new AffineTransform();
        } 
 
        this.at = at;
        xScale = (float) Math.sqrt(
                (at.getScaleX() * at.getScaleX())
                + (at.getShearX() * at.getShearX()));
        yScale = (float) Math.sqrt(
                (at.getScaleY() * at.getScaleY())
                + (at.getShearY() * at.getShearY()));
 
        coordinates = (Double) ls.getCoordinateSequence();
        coordinateCount = coordinates.size();
        isClosed = ls instanceof LinearRing;
         
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:rotate, scale, translate
		return this.newAngle;
	} 
 
	public int[] makeSpritePixels() { 
		int angle = (int) newAngle;
		AffineTransform t = new AffineTransform();
		int width = bufferImage.getWidth();
		int height = bufferImage.getHeight();
		int dW = width;
		int dH = height;
		switch (angle) {
		case 90: { 
			t.translate(height, 0);
			t.rotate(Math.PI / 2);
			dW = height;
			dH = width;
			break; 
		} 
		case 180: { 
			t.translate(width, height);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 AffineTransform Methods: