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


Java AffineTransform.setToScale方法代码示例

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


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

示例1: getAffineTransform

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private AffineTransform getAffineTransform( int transform ) {
        /// ABP
        AffineTransform at = new AffineTransform();
        switch ( transform )
        {
        case SCALE:
          at.setToScale( 1.5f, 1.5f ); break;
        case ROTATE:
          at.setToRotation( Math.PI / 6 ); break;
        case SHEAR:
          at.setToShear( 0.4f, 0 ); break;
        case NONE:
          break;
        default:
          //System.err.println( "Illegal G2 Transform Arg: " + transform);
          break;
        }

        return at;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:FontPanel.java

示例2: TexturePaintContext

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
TexturePaintContext(ColorModel cm, AffineTransform xform,
                    int bWidth, int bHeight, int maxw) {
    this.colorModel = getInternedColorModel(cm);
    this.bWidth = bWidth;
    this.bHeight = bHeight;
    this.maxWidth = maxw;

    try {
        xform = xform.createInverse();
    } catch (NoninvertibleTransformException e) {
        xform.setToScale(0, 0);
    }
    this.incXAcross = mod(xform.getScaleX(), bWidth);
    this.incYAcross = mod(xform.getShearY(), bHeight);
    this.incXDown = mod(xform.getShearX(), bWidth);
    this.incYDown = mod(xform.getScaleY(), bHeight);
    this.xOrg = xform.getTranslateX();
    this.yOrg = xform.getTranslateY();
    this.colincx = (int) incXAcross;
    this.colincy = (int) incYAcross;
    this.colincxerr = fractAsInt(incXAcross);
    this.colincyerr = fractAsInt(incYAcross);
    this.rowincx = (int) incXDown;
    this.rowincy = (int) incYDown;
    this.rowincxerr = fractAsInt(incXDown);
    this.rowincyerr = fractAsInt(incYDown);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:TexturePaintContext.java

示例3: SunGraphics2D

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;

    transform = new AffineTransform();
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;
    resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    validateColor();

    devScale = sd.getDefaultScale();
    if (devScale != 1) {
        transform.setToScale(devScale, devScale);
        invalidateTransform();
    }

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:SunGraphics2D.java

示例4: setRadialGradientPaint

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * This method calculates six m** values and a focusX value that
 * are used by the native fragment shader.  These techniques are
 * based on a whitepaper by Daniel Rice on radial gradient performance
 * (attached to the bug report for 6521533).  One can refer to that
 * document for the complete set of formulas and calculations, but
 * the basic goal is to compose a transform that will convert an
 * (x,y) position in device space into a "u" value that represents
 * the relative distance to the gradient focus point.  The resulting
 * value can be used to look up the appropriate color by linearly
 * interpolating between the two nearest colors in the gradient.
 */
private static void setRadialGradientPaint(RenderQueue rq,
                                           SunGraphics2D sg2d,
                                           RadialGradientPaint paint,
                                           boolean useMask)
{
    boolean linear =
        (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB);
    int cycleMethod = paint.getCycleMethod().ordinal();
    float[] fractions = paint.getFractions();
    Color[] colors = paint.getColors();
    int numStops = colors.length;
    int[] pixels = convertToIntArgbPrePixels(colors, linear);
    Point2D center = paint.getCenterPoint();
    Point2D focus = paint.getFocusPoint();
    float radius = paint.getRadius();

    // save original (untransformed) center and focus points
    double cx = center.getX();
    double cy = center.getY();
    double fx = focus.getX();
    double fy = focus.getY();

    // transform from gradient coords to device coords
    AffineTransform at = paint.getTransform();
    at.preConcatenate(sg2d.transform);
    focus = at.transform(focus, focus);

    // transform unit circle to gradient coords; we start with the
    // unit circle (center=(0,0), focus on positive x-axis, radius=1)
    // and then transform into gradient space
    at.translate(cx, cy);
    at.rotate(fx - cx, fy - cy);
    at.scale(radius, radius);

    // invert to get mapping from device coords to unit circle
    try {
        at.invert();
    } catch (Exception e) {
        at.setToScale(0.0, 0.0);
    }
    focus = at.transform(focus, focus);

    // clamp the focus point so that it does not rest on, or outside
    // of, the circumference of the gradient circle
    fx = Math.min(focus.getX(), 0.99);

    // assert rq.lock.isHeldByCurrentThread();
    rq.ensureCapacity(20 + 28 + (numStops*4*2));
    RenderBuffer buf = rq.getBuffer();
    buf.putInt(SET_RADIAL_GRADIENT_PAINT);
    buf.putInt(useMask ? 1 : 0);
    buf.putInt(linear  ? 1 : 0);
    buf.putInt(numStops);
    buf.putInt(cycleMethod);
    buf.putFloat((float)at.getScaleX());
    buf.putFloat((float)at.getShearX());
    buf.putFloat((float)at.getTranslateX());
    buf.putFloat((float)at.getShearY());
    buf.putFloat((float)at.getScaleY());
    buf.putFloat((float)at.getTranslateY());
    buf.putFloat((float)fx);
    buf.put(fractions);
    buf.put(pixels);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:77,代码来源:BufferedPaints.java


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