<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT_2D_Graphics%2FAnimation</id>
		<title>Java Tutorial/SWT 2D Graphics/Animation - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT_2D_Graphics%2FAnimation"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/Animation&amp;action=history"/>
		<updated>2026-04-21T18:45:11Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/Animation&amp;diff=2797&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/Animation&amp;diff=2797&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/Animation&amp;diff=2798&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/Animation&amp;diff=2798&amp;oldid=prev"/>
				<updated>2010-05-31T15:18:10Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Animate a bouncing ball with Double Buffering ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.events.*;&lt;br /&gt;
import org.eclipse.swt.graphics.*;&lt;br /&gt;
import org.eclipse.swt.layout.*;&lt;br /&gt;
import org.eclipse.swt.widgets.*;&lt;br /&gt;
public class AnimationDoubleBuffering {&lt;br /&gt;
  private static final int IMAGE_WIDTH = 100;&lt;br /&gt;
  private static final int TIMER_INTERVAL = 10;&lt;br /&gt;
  private static int x = 0;&lt;br /&gt;
  private static int y = 0;&lt;br /&gt;
  private static int directionX = 1;&lt;br /&gt;
  private static int directionY = 1;&lt;br /&gt;
  private static Canvas canvas;&lt;br /&gt;
  public static void animate() {&lt;br /&gt;
    x += directionX;&lt;br /&gt;
    y += directionY;&lt;br /&gt;
    // Determine out of bounds&lt;br /&gt;
    Rectangle rect = canvas.getClientArea();&lt;br /&gt;
    if (x &amp;lt; 0) {&lt;br /&gt;
      x = 0;&lt;br /&gt;
      directionX = 1;&lt;br /&gt;
    } else if (x &amp;gt; rect.width - IMAGE_WIDTH) {&lt;br /&gt;
      x = rect.width - IMAGE_WIDTH;&lt;br /&gt;
      directionX = -1;&lt;br /&gt;
    }&lt;br /&gt;
    if (y &amp;lt; 0) {&lt;br /&gt;
      y = 0;&lt;br /&gt;
      directionY = 1;&lt;br /&gt;
    } else if (y &amp;gt; rect.height - IMAGE_WIDTH) {&lt;br /&gt;
      y = rect.height - IMAGE_WIDTH;&lt;br /&gt;
      directionY = -1;&lt;br /&gt;
    }&lt;br /&gt;
    // Force a redraw&lt;br /&gt;
    canvas.redraw();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Animator&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    canvas = new Canvas(shell, SWT.NO_BACKGROUND);&lt;br /&gt;
    canvas.addPaintListener(new PaintListener() {&lt;br /&gt;
      public void paintControl(PaintEvent event) {&lt;br /&gt;
        // Create the image to fill the canvas&lt;br /&gt;
        Image image = new Image(shell.getDisplay(), canvas.getBounds());&lt;br /&gt;
        // Set up the offscreen gc&lt;br /&gt;
        GC gcImage = new GC(image);&lt;br /&gt;
        gcImage.setBackground(event.gc.getBackground());&lt;br /&gt;
        gcImage.fillRectangle(image.getBounds());&lt;br /&gt;
        gcImage.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
        gcImage.fillOval(x, y, IMAGE_WIDTH, IMAGE_WIDTH);&lt;br /&gt;
        // Draw the offscreen buffer to the screen&lt;br /&gt;
        event.gc.drawImage(image, 0, 0);&lt;br /&gt;
        image.dispose();&lt;br /&gt;
        gcImage.dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    &lt;br /&gt;
    shell.open();&lt;br /&gt;
    Runnable runnable = new Runnable() {&lt;br /&gt;
      public void run() {&lt;br /&gt;
        animate();&lt;br /&gt;
        display.timerExec(TIMER_INTERVAL, this);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    display.timerExec(TIMER_INTERVAL, runnable);&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Kill the timer&lt;br /&gt;
    display.timerExec(-1, runnable);&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Animation a bounce ball with flicker ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.events.*;&lt;br /&gt;
import org.eclipse.swt.graphics.*;&lt;br /&gt;
import org.eclipse.swt.layout.*;&lt;br /&gt;
import org.eclipse.swt.widgets.*;&lt;br /&gt;
public class AnimationBounce {&lt;br /&gt;
  private static final int IMAGE_WIDTH = 100;&lt;br /&gt;
  private static final int TIMER_INTERVAL = 10;&lt;br /&gt;
  private static int x = 0;&lt;br /&gt;
  private static int y = 0;&lt;br /&gt;
  private static int directionX = 1;&lt;br /&gt;
  private static int directionY = 1;&lt;br /&gt;
  private static Canvas canvas;&lt;br /&gt;
  public static void animate() {&lt;br /&gt;
    x += directionX;&lt;br /&gt;
    y += directionY;&lt;br /&gt;
    // Determine out of bounds&lt;br /&gt;
    Rectangle rect = canvas.getClientArea();&lt;br /&gt;
    if (x &amp;lt; 0) {&lt;br /&gt;
      x = 0;&lt;br /&gt;
      directionX = 1;&lt;br /&gt;
    } else if (x &amp;gt; rect.width - IMAGE_WIDTH) {&lt;br /&gt;
      x = rect.width - IMAGE_WIDTH;&lt;br /&gt;
      directionX = -1;&lt;br /&gt;
    }&lt;br /&gt;
    if (y &amp;lt; 0) {&lt;br /&gt;
      y = 0;&lt;br /&gt;
      directionY = 1;&lt;br /&gt;
    } else if (y &amp;gt; rect.height - IMAGE_WIDTH) {&lt;br /&gt;
      y = rect.height - IMAGE_WIDTH;&lt;br /&gt;
      directionY = -1;&lt;br /&gt;
    }&lt;br /&gt;
    // Force a redraw&lt;br /&gt;
    canvas.redraw();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Animator&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    canvas = new Canvas(shell, SWT.NO_BACKGROUND);&lt;br /&gt;
    canvas.addPaintListener(new PaintListener() {&lt;br /&gt;
      public void paintControl(PaintEvent event) {&lt;br /&gt;
        // Draw the background&lt;br /&gt;
        event.gc.fillRectangle(canvas.getBounds());&lt;br /&gt;
        event.gc.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
        event.gc.fillOval(x, y, IMAGE_WIDTH, IMAGE_WIDTH);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    &lt;br /&gt;
    shell.open();&lt;br /&gt;
    Runnable runnable = new Runnable() {&lt;br /&gt;
      public void run() {&lt;br /&gt;
        animate();&lt;br /&gt;
        display.timerExec(TIMER_INTERVAL, this);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    display.timerExec(TIMER_INTERVAL, runnable);&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Kill the timer&lt;br /&gt;
    display.timerExec(-1, runnable);&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>