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


Java Graphics2D.scale方法代码示例

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


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

示例1: main

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final int[] arrEmpty = {};
    final int[] arr1elem = {150};
    final BufferedImage bi = new BufferedImage(300, 300,
                                               BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = (Graphics2D) bi.getGraphics();
    test(g, arrEmpty);
    test(g, arr1elem);
    g.translate(2.0, 2.0);
    test(g, arrEmpty);
    test(g, arr1elem);
    g.scale(2.0, 2.0);
    test(g, arrEmpty);
    test(g, arr1elem);
    g.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Test8004821.java

示例2: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** This method is called by Swing to draw this component. */
@Override
public void paintComponent(final Graphics gr) {
	super.paintComponent(gr);
	Graphics2D g2 = (Graphics2D) gr;
	AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g2.scale(scale, scale);
	Object sel = (selected != null ? selected : highlight);
	GraphNode c = null;
	if (sel instanceof GraphNode && ((GraphNode) sel).shape() == null) {
		c = (GraphNode) sel;
		sel = c.ins.get(0);
	}
	graph.draw(new Artist(g2), scale, sel, true);
	if (c != null) {
		gr.setColor(((GraphEdge) sel).color());
		gr.fillArc(c.x() - 5 - graph.getLeft(), c.y() - 5 - graph.getTop(), 10, 10, 0, 360);
	}
	g2.setTransform(oldAF);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:GraphViewer.java

示例3: TurnAnalyzer

import java.awt.Graphics2D; //导入方法依赖的package包/类
@SuppressWarnings("serial")
public TurnAnalyzer(JFrame frame) {
	super(frame,"Turn analysis");
	menuPainter = new JPanel() {
		public void paint(Graphics g) {
			if (refImg == null) {
				return;
			}
			Graphics2D g2 = (Graphics2D) g;
			g2.scale(2, 2);

			g2.drawImage(refImg, 0, 0, null);
		}
	};
	menuPainter.setPreferredSize(MENU_SIZE_X2);
	menuPainter.setMinimumSize(MENU_SIZE_X2);
	menuPainter.setSize(MENU_SIZE_X2);
	initialize();
}
 
开发者ID:fatmanspanda,项目名称:ALTTPMenuPractice,代码行数:20,代码来源:TurnAnalyzer.java

示例4: paintGraph

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Paints the graph outline.
 */
public void paintGraph(Graphics g) {
  if (graphComponent != null) {
    Graphics2D g2 = (Graphics2D) g;
    AffineTransform tx = g2.getTransform();

    try {
      Point tr = graphComponent.getGraphControl().getTranslate();
      g2.translate(translate.x + tr.getX() * scale, translate.y + tr.getY() * scale);
      g2.scale(scale, scale);

      // Draws the scaled graph
      graphComponent.getGraphControl().drawGraph(g2, drawLabels);
    } finally {
      g2.setTransform(tx);
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:mxGraphOutline.java

示例5: paintGraph

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintGraph(Graphics graphics, int pixWidth, int pixHeight) {
	Graphics2D g = (Graphics2D) graphics;
	Graphics2D scaled = (Graphics2D) g.create();

	scaled.translate(0, pixHeight + 1 + this.updatePanelHeight + 50);
	// prepare data
	prepareData();

	scaled.scale(1, -1);
	g.setColor(Color.black);
	drawPoints(scaled, pixWidth, pixHeight);

	scaled.dispose();

	// x-axis label
	String xAxisLabel = "sorted k-distances";
	Rectangle2D stringBounds = SCALED_LABEL_FONT.getStringBounds(xAxisLabel, g.getFontRenderContext());
	g.drawString(xAxisLabel, MARGIN + (float) (pixWidth / 2.0d - stringBounds.getWidth() / 2.0d), MARGIN
			+ (float) (pixHeight - 2.0d * stringBounds.getHeight()) + 3);

	// y-axis label
	String yAxisLabel = "k-distance value";
	stringBounds = LABEL_FONT.getStringBounds(yAxisLabel, g.getFontRenderContext());
	g.drawString(yAxisLabel, MARGIN, (int) (MARGIN + stringBounds.getHeight() + 6));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:SimilarityKDistanceVisualization.java

示例6: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draw every sprite
 */
public void paint(Graphics g) {
	Graphics2D g2 = (Graphics2D) g;
	g2.scale(zoom, zoom); // zoom in
	int xOffset = offset(posX);
	int yOffset = offset(posY);
	g2.translate(xOffset, yOffset);

	// draw background
	g2.drawImage(bg.getImage(), 0, 0, null);

	// Catch null steps; but they shouldn't happen
	if (steps == null || steps[step] == null) { return; }

	// catch other errors
	try {
		Anime t = steps[step];
		t.draw(g2, posX, posY);
	} catch (Exception e) {
		e.printStackTrace(); // thread conflicts cause errors? idk
	}
}
 
开发者ID:fatmanspanda,项目名称:SpriteAnimator,代码行数:25,代码来源:SpriteAnimator.java

示例7: createTestImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static Image createTestImage(int w, int h,
        double scaleX, double scaleY, Color color) {

    int width = (int) Math.ceil(scaleX * w);
    int height = (int) Math.ceil(scaleY * h);
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    Graphics2D g = img.createGraphics();
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, width, height);
    g.scale(scaleX, scaleY);
    g.setColor(color);
    int d = 1;
    int d2 = 2 * d;
    g.drawLine(d, h / 2, w - d2, h / 2);
    g.drawLine(w / 2, d, w / 2, h - d2);
    g.drawRect(d, d, w - d2, h - d2);
    g.dispose();

    return img;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RepaintManagerFPUIScaleTest.java

示例8: main

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final BufferedImage bi = new BufferedImage(100, 300,
                                               BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = bi.createGraphics();
    g.scale(2, 2);
    g.setColor(Color.RED);
    g.fillRect(0, 0, 100, 300);
    g.setColor(Color.GREEN);
    g.fillRect(0, 100, 100, 100);
    g.copyArea(0, 100, 100, 100, 0, -100);
    g.dispose();
    for (int x = 0; x < 100; ++x) {
        for (int y = 0; y < 100; ++y) {
            final int actual = bi.getRGB(x, y);
            final int exp = Color.GREEN.getRGB();
            if (actual != exp) {
                System.err.println("Expected:" + Integer.toHexString(exp));
                System.err.println("Actual:" + Integer.toHexString(actual));
                throw new RuntimeException("Test " + "failed");
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:ScaledCopyArea.java

示例9: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    AffineTransform previousTransform = g2D.getTransform();
    g2D.scale(zoom, zoom);
    g2D.drawImage(buff, 0, 0, null);
    g2D.setTransform(previousTransform);
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:9,代码来源:ImageViewerPanel.java

示例10: write

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static int write(Graphics2D g2, String text, int line, int x, double kx, double ky,
    int initY) {
    g2.scale(kx, ky);
    final int y = (int) Math
        .round((initY + line * WelcomeParams.getInstance().lineHeigth) / ky);
    g2.drawString(text, x, y);
    g2.scale(1 / kx, 1 / ky);
    return y;
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:10,代码来源:FWelcome.java

示例11: main

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice()
                                 .getDefaultConfiguration();
    VolatileImage vi = gc.createCompatibleVolatileImage(100, 100);

    Graphics2D g2d = vi.createGraphics();
    g2d.scale(2, 2);
    BufferedImage img = new BufferedImage(50, 50,
                                          BufferedImage.TYPE_INT_ARGB);

    g2d.drawImage(img, 10, 25, Color.blue, null);
    g2d.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DrawCachedImageAndTransform.java

示例12: drawSinxDX

import java.awt.Graphics2D; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void drawSinxDX(GeneralPath gp, Graphics2D g) {
	for (double i = 0.000001; i <= 8 * Math.PI; i += 0.0001 * Math.PI) {
		gp.lineTo(20 * i, 100 * -Math.sin(i) / i);
	}
	g.draw(gp);
	g.scale(-1, 1);
	g.draw(gp);
}
 
开发者ID:followwwind,项目名称:javase,代码行数:10,代码来源:Sinx.java

示例13: step1

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws standard JMenuBar.
 */
private BufferedImage step1(final JMenuBar menubar) {
    final BufferedImage bi1 = new BufferedImage(W, H, TYPE_INT_ARGB_PRE);
    final Graphics2D g2d = bi1.createGraphics();
    g2d.scale(2, 2);
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, W, H);
    menubar.paintAll(g2d);
    g2d.dispose();
    return bi1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:MisplacedBorder.java

示例14: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** This method is called by Swing to draw this component. */
@Override public void paintComponent(final Graphics gr) {
    super.paintComponent(gr);
    Graphics2D g2 = (Graphics2D)gr;
    AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.scale(scale, scale);
    Object sel=(selected!=null ? selected : highlight);
    GraphNode c=null;
    if (sel instanceof GraphNode && ((GraphNode)sel).shape()==null) { c = (GraphNode)sel; sel = c.ins.get(0); }
    graph.draw(new Artist(g2), scale, sel, true);
    if (c!=null) { gr.setColor(((GraphEdge)sel).color()); gr.fillArc(c.x()-5-graph.getLeft(), c.y()-5-graph.getTop(), 10, 10, 0, 360); }
    g2.setTransform(oldAF);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:GraphViewer.java

示例15: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
if( image==null ) return;
		Graphics2D g2 = (Graphics2D)g;
		g2.scale(zoom, zoom);
		g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION,
								RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		g.drawImage( image, 0, 0, this);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:9,代码来源:SCSImage.java


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