java.awt.Graphics2D.scale()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(284)

本文整理了Java中java.awt.Graphics2D.scale()方法的一些代码示例,展示了Graphics2D.scale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.scale()方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:scale

Graphics2D.scale介绍

暂无

代码示例

代码示例来源:origin: plantuml/plantuml

public void apply(Graphics2D g) {
  g.translate(_x0, _y0);
  g.scale(_scale, -_scale);
  
}
}

代码示例来源:origin: plantuml/plantuml

destination = new BufferedImage((int) w, (int) h, BufferedImage.TYPE_INT_ARGB);
final Graphics2D gg = destination.createGraphics();
gg.scale(dpiFactor, dpiFactor);
gg.translate(deltaShadow - bounds.getMinX(), deltaShadow - bounds.getMinY());
final boolean isLine = shape instanceof Line2D.Double;
if (isLine) {
  gg.fill(shape);
gg.dispose();
g2d.scale(1 / dpiFactor, 1 / dpiFactor);
g2d.drawImage(destination, (int) (bounds.getMinX() * dpiFactor), (int) (bounds.getMinY() * dpiFactor), null);
g2d.setTransform(at);

代码示例来源:origin: org.apache.poi/poi-ooxml

graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.scale(scale, scale);
graphics.dispose();
img.flush();

代码示例来源:origin: org.apache.poi/poi-ooxml

graphics.translate(0, img.getHeight());
graphics.scale(scale, -scale);
page.getContent().visitShapes(renderer);
graphics.dispose();

代码示例来源:origin: haraldk/TwelveMonkeys

g.scale(image.getWidth(), image.getHeight());
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.fill(clip);
g.dispose();

代码示例来源:origin: org.apache.poi/poi

graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX(), -anchor.getY());
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());

代码示例来源:origin: MovingBlocks/Terasology

g.scale(1f / scale, 1f / scale);
g.translate(-offX, -offY);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawLine(0, worldArea.minY(), 0, worldArea.maxY());
g.dispose();

代码示例来源:origin: apache/pdfbox

g2d.scale(SCALE, SCALE);
g2d.dispose();

代码示例来源:origin: org.apache.poi/poi-ooxml

graphics.translate(bounds.x, bounds.y);
graphics.scale(1, -1);
graphics.translate(0, -bounds.height
    + graphics.getFontMetrics().getMaxCharBounds(graphics)
    .getHeight());
graphics.scale(-1, 1);
graphics.translate(-bounds.width, 0);

代码示例来源:origin: apache/pdfbox

private BufferedImage renderGlyph(GeneralPath path, Rectangle2D bounds2D, Rectangle cellRect)
  {
    BufferedImage bim = new BufferedImage((int) cellRect.getWidth(), (int) cellRect.getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics2D g = (Graphics2D) bim.getGraphics();
    g.setBackground(Color.white);
    g.clearRect(0, 0, bim.getWidth(), bim.getHeight());
    double scale = 1 / ((yBounds[1] - yBounds[0]) / cellRect.getHeight());
    // flip
    g.scale(1, -1);
    g.translate(0, -bim.getHeight());
    // horizontal center
    g.translate((cellRect.getWidth() - bounds2D.getWidth() * scale) / 2, 0);
    // scale from the glyph to the cell
    g.scale(scale, scale);
    // Adjust for negative y min bound
    g.translate(0, -yBounds[0]);
    g.setColor(Color.black);
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.fill(path);
    g.dispose();
    return bim;
  }
}

代码示例来源:origin: stackoverflow.com

outerPanel = new JPanel(){
  @Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();             
    g2.scale(scale, scale);
    super.paint(g);
    g2.dispose()
  }
}

代码示例来源:origin: org.apache.poi/poi

final double ax = anchor.getX();
final double ay = anchor.getY();
graphics.translate(ax + anchor.getWidth(), ay);
graphics.scale(-1, 1);
graphics.translate(-ax, -ay);
final double cx = anchor.getCenterX();
final double cy = anchor.getCenterY();
graphics.translate(cx, cy);
graphics.rotate(Math.toRadians(textRot));
graphics.translate(-cx, -cy);

代码示例来源:origin: apache/pdfbox

g.translate((cellRect.getWidth() - glyphImage.getWidth() * scale) / 2, 0);
g.scale(scale, scale);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);              
g.drawImage(glyphImage, 0, 0, null);
g.dispose();
return new JLabel(new ImageIcon(cellImage));

代码示例来源:origin: stackoverflow.com

public class MyExtendedClass extends ... {
  @Override
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();
    double scaleFactor = 1d;
    // Calculate the scaling factor to apply
    // based on the "default" size and the
    // current size...
    g2d.scale(scaleFactor, scaleFactor);
    super.paint(g2d);
    g2d.dispose();
  }
}

代码示例来源:origin: stackoverflow.com

Graphics2D g2 = (Graphics2D) g;
int w = // real width of canvas
int h = // real height of canvas
// Translate used to make sure scale is centered
g2.translate(w/2, h/2);
g2.scale(scale, scale);
g2.translate(-w/2, -h/2);

代码示例来源:origin: magefree/mage

g2.translate(xPos, yPos);
g2.scale(scale, scale);
g2.setColor(Color.white);
g2.fillPolygon(p);
int strW = g2.getFontMetrics().stringWidth(cstr);
g2.drawString(cstr, 5 - strW / 2, 8);
g2.dispose();
yPos += ((int) (0.30 * cardWidth));

代码示例来源:origin: stackoverflow.com

Graphics2D g2d = (Graphics2D) g.create();
AffineTransform at = g2d.getTransform();
at.translate(originX, originY);
g2d.setTransform(at);
g2d.scale(scale, scale);
g2d.rotate(Math.toRadians(angle), 0, 0);
g2d.fillRect(xOffset, yOffset, rectWidth, rectHeight);
g2d.dispose();

代码示例来源:origin: jbox2d/jbox2d

@Override
public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors,
  int count) {
 Graphics2D g = getGraphics();
 saveState(g);
 transformGraphics(g, zero);
 g.setStroke(stroke);
 for (int i = 0; i < count; i++) {
  Vec2 center = centers[i];
  Color color;
  // No alpha channel, it slows everything down way too much.
  if (colors == null) {
   color = pcolor;
  } else {
   ParticleColor c = colors[i];
   color = new Color(c.r * 1f / 127, c.g * 1f / 127, c.b * 1f / 127, 1);
  }
  AffineTransform old = g.getTransform();
  g.translate(center.x, center.y);
  g.scale(radius, radius);
  g.setColor(color);
  g.draw(circle);
  g.setTransform(old);
 }
 restoreState(g);
}

代码示例来源:origin: apache/pdfbox

graphics.translate(0, rasterHeight);
  graphics.scale(1, -1);
  graphics.translate(rasterWidth, 0);
  graphics.scale(-1, 1);
graphics.scale(xScale, yScale);
graphics.dispose();

代码示例来源:origin: stackoverflow.com

protected void paintComponent(Graphics g) {
     super.paintComponent(g);
     Graphics2D g2d = (Graphics2D) g.create();
     g2d.scale(scale, 1);
     FontMetrics fm = g2d.getFontMetrics();
     msgWidth = fm.stringWidth(msg);
     g2d.drawString(msg, xPos, 40);
     g2d.dispose();
   }

相关文章

Graphics2D类方法