当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransform.scale方法代码示例

本文整理汇总了Java中java.awt.geom.AffineTransform.scale方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform.scale方法的具体用法?Java AffineTransform.scale怎么用?Java AffineTransform.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStrike

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public FontStrike getStrike(Font font, FontRenderContext frc) {

        AffineTransform at = frc.getTransform();
        double ptSize = font.getSize2D();
        at.scale(ptSize, ptSize);
        if (font.isTransformed()) {
            at.concatenate(font.getTransform());
            if (at.getTranslateX() != 0 || at.getTranslateY() != 0) {
                at.setTransform(at.getScaleX(),
                                at.getShearY(),
                                at.getShearX(),
                                at.getScaleY(),
                                0.0, 0.0);
            }
        }
        int aa = FontStrikeDesc.getAAHintIntVal(this, font, frc);
        int fm = FontStrikeDesc.getFMHintIntVal(frc.getFractionalMetricsHint());
        FontStrikeDesc desc = new FontStrikeDesc(frc.getTransform(),
                                                 at, font.getStyle(),
                                                 aa, fm);
        return getStrike(desc, false);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Font2D.java

示例2: transformEdgeShape

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private void transformEdgeShape( Point2D down, Point2D out ) {
    float x1 = (float) down.getX();
    float y1 = (float) down.getY();
    float x2 = (float) out.getX();
    float y2 = (float) out.getY();

    AffineTransform xform = AffineTransform.getTranslateInstance( x1, y1 );

    float dx = x2 - x1;
    float dy = y2 - y1;
    float thetaRadians = (float) Math.atan2( dy, dx );
    xform.rotate( thetaRadians );
    float dist = (float) Math.sqrt( dx * dx + dy * dy );
    xform.scale( dist / rawEdge.getBounds().getWidth(), 1.0 );
    edgeShape = xform.createTransformedShape( rawEdge );
}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:17,代码来源:MapperEditingGraphMousePlugin.java

示例3: makeRandomTransform

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static AffineTransform makeRandomTransform(int numops) {
    AffineTransform at = new AffineTransform();
    while (--numops >= 0) {
        switch (rand.nextInt(4)) {
        case 0:
            at.scale(rand.nextDouble() * 5 - 2.5,
                     rand.nextDouble() * 5 - 2.5);
            break;
        case 1:
            at.shear(rand.nextDouble() * 5 - 2.5,
                     rand.nextDouble() * 5 - 2.5);
            break;
        case 2:
            at.rotate(rand.nextDouble() * Math.PI * 2);
            break;
        case 3:
            at.translate(rand.nextDouble() * 50 - 25,
                         rand.nextDouble() * 50 - 25);
            break;
        default:
            throw new InternalError("bad case!");
        }
    }
    return at;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:GetTypeOptimization.java

示例4: generateIdenticon

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Code taken from: <a href="https://stackoverflow.com/a/40699460">Stackoverflow answer from Kevin G. based on code from davidhampgonsalves.com/Identicons</a>
 * Comments and slight modifications added.
 */
public static javafx.scene.image.Image generateIdenticon(String text, int image_width, int image_height) throws IOException {
	// If the input name/text is null or empty no image can be created.
	if (text == null || text.length() < 3) {
		return null;
	}

	int width = 5, height = 5;

	byte[] hash = text.getBytes();

	BufferedImage identicon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
	WritableRaster raster = identicon.getRaster();

	int [] background = new int [] {255,255,255, 0};
	int [] foreground = new int [] {hash[0] & 255, hash[1] & 255, hash[2] & 255, 255};

	for(int x=0 ; x < width ; x++) {
		//Enforce horizontal symmetry
		int i = x < 3 ? x : 4 - x;
		for(int y=0 ; y < height; y++) {
			int [] pixelColor;
			//toggle pixels based on bit being on/off
			if((hash[i] >> y & 1) == 1)
				pixelColor = foreground;
			else
				pixelColor = background;
			raster.setPixel(x, y, pixelColor);
		}
	}

	BufferedImage finalImage = new BufferedImage(image_width, image_height, BufferedImage.TYPE_INT_ARGB);

	//Scale image to the size you want
	AffineTransform at = new AffineTransform();
	at.scale(image_width / width, image_height / height);
	AffineTransformOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
	finalImage = op.filter(identicon, finalImage);

	// Convert BufferedImage to javafx image
	return createImage(finalImage);
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:46,代码来源:Util.java

示例5: draw

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
@Override
public void draw(Graphics2D graphics) {
	graphics.setStroke(JSpaceSettlersComponent.THIN_STROKE);
	
       final AffineTransform transform =
               AffineTransform.getTranslateInstance(drawLocation.getX(), drawLocation.getY());
       transform.rotate(-Math.PI / 2.0);

   	transform.scale(scale, scale);

       Shape newFlagShape = transform.createTransformedShape(FLAG_SHAPE);

       // color the flag to match the team
       graphics.setPaint(flagColor);
       graphics.fill(newFlagShape);
}
 
开发者ID:CatherineHa,项目名称:Proj4,代码行数:17,代码来源:FlagGraphics.java

示例6: applyTexturePaint

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private void applyTexturePaint(TexturePaint texturePaint) throws IOException {
	Rectangle2D anchorRect = texturePaint.getAnchorRect();
	PDTilingPattern pattern = new PDTilingPattern();
	pattern.setPaintType(PDTilingPattern.PAINT_COLORED);
	pattern.setTilingType(PDTilingPattern.TILING_CONSTANT_SPACING_FASTER_TILING);

	pattern.setBBox(new PDRectangle((float) anchorRect.getX(), (float) anchorRect.getY(),
			(float) anchorRect.getWidth(), (float) anchorRect.getHeight()));
	pattern.setXStep((float) anchorRect.getWidth());
	pattern.setYStep((float) anchorRect.getHeight());

	AffineTransform patternTransform = new AffineTransform();
	patternTransform.translate(0, anchorRect.getHeight());
	patternTransform.scale(1f, -1f);
	pattern.setMatrix(patternTransform);

	PDAppearanceStream appearance = new PDAppearanceStream(document);
	appearance.setResources(pattern.getResources());
	appearance.setBBox(pattern.getBBox());

	PDPageContentStream imageContentStream = new PDPageContentStream(document, appearance,
			((COSStream) pattern.getCOSObject()).createOutputStream());
	BufferedImage texturePaintImage = texturePaint.getImage();
	PDImageXObject imageXObject = imageEncoder.encodeImage(document, imageContentStream, texturePaintImage);

	float ratioW = (float) ((anchorRect.getWidth()) / texturePaintImage.getWidth());
	float ratioH = (float) ((anchorRect.getHeight()) / texturePaintImage.getHeight());
	float paintHeight = (texturePaintImage.getHeight()) * ratioH;
	imageContentStream.drawImage(imageXObject, (float) anchorRect.getX(), (float) (paintHeight + anchorRect.getY()),
			texturePaintImage.getWidth() * ratioW, -paintHeight);
	imageContentStream.close();

	PDColorSpace patternCS1 = new PDPattern(null, imageXObject.getColorSpace());
	COSName tilingPatternName = resources.add(pattern);
	PDColor patternColor = new PDColor(tilingPatternName, patternCS1);

	contentStream.setNonStrokingColor(patternColor);
	contentStream.setStrokingColor(patternColor);
}
 
开发者ID:rototor,项目名称:pdfbox-graphics2d,代码行数:40,代码来源:PdfBoxGraphics2DPaintApplier.java

示例7: createGradientTransform

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private static AffineTransform createGradientTransform(Rectangle2D r) {
    double cx = r.getCenterX();
    double cy = r.getCenterY();
    AffineTransform xform = AffineTransform.getTranslateInstance(cx, cy);
    xform.scale(r.getWidth()/2, r.getHeight()/2);
    xform.translate(-cx, -cy);
    return xform;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:RadialGradientPaint.java

示例8: resizeImage

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static BufferedImage resizeImage(BufferedImage image, int wantedWidth, int wantedHeight) {
    int w = image.getWidth();
    int h = image.getHeight();
    AffineTransform at = new AffineTransform();
    at.scale((double) wantedWidth / (double) w, (double) wantedHeight / (double) h);
    AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);

    BufferedImage rescaledImage = new BufferedImage(wantedWidth, wantedHeight, BufferedImage.TYPE_INT_ARGB);
    rescaledImage = scaleOp.filter(image, rescaledImage);

    return rescaledImage;
}
 
开发者ID:trebonius0,项目名称:Photato,代码行数:13,代码来源:ImageHelper.java

示例9: scaleSmooth

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private static BufferedImage scaleSmooth(BufferedImage im, double newWidth, double newHeigth)
{
    int w = im.getWidth();
    int h = im.getHeight();
    BufferedImage result = new BufferedImage((int)newWidth, (int)newHeigth, BufferedImage.TYPE_INT_ARGB);
    AffineTransform at = new AffineTransform();
    at.scale(newWidth / w, newHeigth / h);
    AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
    result = scaleOp.filter(im, result);
    return result;
}
 
开发者ID:mirkoruether,项目名称:DigitRecognizer,代码行数:12,代码来源:DigitManipulator.java

示例10: paintTextFieldBackground

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Paints the background of a text field.
 *
 * @param context SynthContext identifying the <code>JComponent</code> and
 *        <code>Region</code> to paint to
 * @param g <code>Graphics</code> to paint to
 * @param x X coordinate of the area to paint to
 * @param y Y coordinate of the area to paint to
 * @param w Width of the area to paint to
 * @param h Height of the area to paint to
 */
public void paintTextFieldBackground(SynthContext context,
                                      Graphics g, int x, int y,
                                      int w, int h) {
    if (context.getComponent().getComponentOrientation().isLeftToRight()){
        paintBackground(context, g, x, y, w, h, null);
    } else {
        AffineTransform transform = new AffineTransform();
        transform.translate(x,y);
        transform.scale(-1, 1);
        transform.translate(-w,0);
        paintBackground(context, g, 0, 0, w, h, transform);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:SynthPainterImpl.java

示例11: test

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void test(AffineTransform init, Tester next, boolean full) {
    double scales[] = (full ? fullvals : abbrevvals);
    for (int i = 0; i < scales.length; i += 2) {
        AffineTransform at2 = new AffineTransform(init);
        at2.scale(scales[i], scales[i+1]);
        if (verbose) System.out.println("*Scale("+scales[i]+", "+
                                        scales[i+1]+") = "+at2);
        next.test(at2, full);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TestInvertMethods.java

示例12: paintFormattedTextFieldBorder

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Paints the border of a formatted text field.
 *
 * @param context SynthContext identifying the <code>JComponent</code> and
 *        <code>Region</code> to paint to
 * @param g <code>Graphics</code> to paint to
 * @param x X coordinate of the area to paint to
 * @param y Y coordinate of the area to paint to
 * @param w Width of the area to paint to
 * @param h Height of the area to paint to
 */
public void paintFormattedTextFieldBorder(SynthContext context,
                                  Graphics g, int x, int y,
                                  int w, int h) {
    if (context.getComponent().getComponentOrientation().isLeftToRight()){
        paintBorder(context, g, x, y, w, h, null);
    } else {
        AffineTransform transform = new AffineTransform();
        transform.translate(x,y);
        transform.scale(-1, 1);
        transform.translate(-w,0);
        paintBorder(context, g, 0, 0, w, h, transform);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SynthPainterImpl.java

示例13: paintComboBoxBackground

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Paints the background of a combo box.
 *
 * @param context SynthContext identifying the <code>JComponent</code> and
 *        <code>Region</code> to paint to
 * @param g <code>Graphics</code> to paint to
 * @param x X coordinate of the area to paint to
 * @param y Y coordinate of the area to paint to
 * @param w Width of the area to paint to
 * @param h Height of the area to paint to
 */
public void paintComboBoxBackground(SynthContext context,
                                    Graphics g, int x, int y,
                                    int w, int h) {
    if (context.getComponent().getComponentOrientation().isLeftToRight()){
        paintBackground(context, g, x, y, w, h, null);
    } else {
        AffineTransform transform = new AffineTransform();
        transform.translate(x,y);
        transform.scale(-1, 1);
        transform.translate(-w,0);
        paintBackground(context, g, 0, 0, w, h, transform);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SynthPainterImpl.java

示例14: getNativePointSize

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private int getNativePointSize() {
    /* Make a copy of the glyphTX in which we will store the
     * font transform, inverting the devTx if necessary
     */
    double[] mat = new double[4];
    desc.glyphTx.getMatrix(mat);
    fontTx = new AffineTransform(mat);

    /* Now work backwards to get the font transform */
    if (!desc.devTx.isIdentity() &&
        desc.devTx.getType() != AffineTransform.TYPE_TRANSLATION) {
        try {
            invertDevTx = desc.devTx.createInverse();
            fontTx.concatenate(invertDevTx);
        } catch (NoninvertibleTransformException e) {
            e.printStackTrace();
        }
    }

    /* At this point the fontTx may be a simple +ve scale, or it
     * may be something more complex.
     */
    Point2D.Float pt = new Point2D.Float(1f,1f);
    fontTx.deltaTransform(pt, pt);
    double ptSize = Math.abs(pt.y);
    int ttype = fontTx.getType();
    if ((ttype & ~AffineTransform.TYPE_UNIFORM_SCALE) != 0 ||
        fontTx.getScaleY() <= 0) {
        /* We need to create an inverse transform that doesn't
         * include the point size (strictly the uniform scale)
         */
        fontTx.scale(1/ptSize, 1/ptSize);
    } else {
        fontTx = null; // no need
    }
    return (int)ptSize;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:NativeStrike.java

示例15: makeComplexAT

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static AffineTransform makeComplexAT() {
    AffineTransform at = new AffineTransform();
    at.scale(2.5, -3.0);
    at.rotate(Math.PI / 4.0);
    at.shear(1.0, -3.0);
    at.translate(25.0, 12.5);
    return at;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TestSerialization.java


注:本文中的java.awt.geom.AffineTransform.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。