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

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/SWT_Paint&amp;diff=2803&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/SWT_Paint&amp;diff=2803&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://jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/SWT_Paint&amp;diff=2804&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics/SWT_Paint&amp;diff=2804&amp;oldid=prev"/>
				<updated>2010-05-31T15:18:12Z</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;==  A dynamic gradient ==&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;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
/*&lt;br /&gt;
 * Control example snippet: a dynamic gradient&lt;br /&gt;
 * &lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class GradientDynamic {&lt;br /&gt;
  static Image oldImage;&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.setBackgroundMode(SWT.INHERIT_DEFAULT);&lt;br /&gt;
    shell.addListener(SWT.Resize, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        Rectangle rect = shell.getClientArea();&lt;br /&gt;
        Image newImage = new Image(display, Math.max(1, rect.width), 1);&lt;br /&gt;
        GC gc = new GC(newImage);&lt;br /&gt;
        gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));&lt;br /&gt;
        gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));&lt;br /&gt;
        gc.fillGradientRectangle(rect.x, rect.y, rect.width, 1, false);&lt;br /&gt;
        gc.dispose();&lt;br /&gt;
        shell.setBackgroundImage(newImage);&lt;br /&gt;
        if (oldImage != null){&lt;br /&gt;
          oldImage.dispose();&lt;br /&gt;
        }&lt;br /&gt;
        oldImage = newImage;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    if (oldImage != null)&lt;br /&gt;
      oldImage.dispose();&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;
==  Alpha blending ==&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;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
/* &lt;br /&gt;
 * Drawing with transformations, paths and alpha blending&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.1&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Font;&lt;br /&gt;
import org.eclipse.swt.graphics.FontData;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Path;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FillDrawPath {&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;
    FontData fd = shell.getFont().getFontData()[0];&lt;br /&gt;
    final Font font = new Font(display, fd.getName(), 60, SWT.BOLD | SWT.ITALIC);&lt;br /&gt;
    final Image image = new Image(display, 640, 480);&lt;br /&gt;
    final Rectangle rect = image.getBounds();&lt;br /&gt;
    GC gc = new GC(image);&lt;br /&gt;
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
    gc.fillOval(rect.x, rect.y, rect.width, rect.height);&lt;br /&gt;
    gc.dispose();&lt;br /&gt;
    shell.addListener(SWT.Paint, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        GC gc = event.gc;&lt;br /&gt;
        gc.drawImage(image, 0, 0, rect.width, rect.height, 0, 0, rect.width / 2, rect.height / 2);&lt;br /&gt;
        gc.setAlpha(100);&lt;br /&gt;
        Path path = new Path(display);&lt;br /&gt;
        path.addString(&amp;quot;SWT&amp;quot;, 0, 0, font);&lt;br /&gt;
        gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));&lt;br /&gt;
        gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));&lt;br /&gt;
        gc.fillPath(path);&lt;br /&gt;
        gc.drawPath(path);&lt;br /&gt;
        path.dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.setSize(shell.ruputeSize(rect.width / 2, rect.height / 2));&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    image.dispose();&lt;br /&gt;
    font.dispose();&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;
==  A paint canvas. ==&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;
/* &lt;br /&gt;
 * JFreeChart : a free chart library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jfreechart/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it &lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by &lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or &lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but &lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY &lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public &lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, &lt;br /&gt;
 * USA.  &lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. &lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * SwtPaintCanvas.java&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * (C) Copyright 2000-2007, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  Henry Proudhon (henry.proudhon AT ensmp.fr);&lt;br /&gt;
 * Contributor(s):   David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 *&lt;br /&gt;
 * Changes&lt;br /&gt;
 * -------&lt;br /&gt;
 * 04-Aug-2006 : New class (HP);&lt;br /&gt;
 * 25-Oct-2007 : Fixed Eclipse warnings (DG);&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.events.PaintEvent;&lt;br /&gt;
import org.eclipse.swt.events.PaintListener;&lt;br /&gt;
import org.eclipse.swt.graphics.Color;&lt;br /&gt;
import org.eclipse.swt.widgets.Canvas;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
/**&lt;br /&gt;
 * A paint canvas.&lt;br /&gt;
 */&lt;br /&gt;
public class SWTPaintCanvas extends Canvas {&lt;br /&gt;
    private Color myColor;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a new instance.&lt;br /&gt;
     * &lt;br /&gt;
     * @param parent  the parent.&lt;br /&gt;
     * @param style  the style.&lt;br /&gt;
     * @param color  the color.&lt;br /&gt;
     */&lt;br /&gt;
    public SWTPaintCanvas(Composite parent, int style, Color color) {&lt;br /&gt;
        this(parent, style);&lt;br /&gt;
        setColor(color);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a new instance.&lt;br /&gt;
     * &lt;br /&gt;
     * @param parent  the parent.&lt;br /&gt;
     * @param style  the style.&lt;br /&gt;
     */&lt;br /&gt;
    public SWTPaintCanvas(Composite parent, int style) {&lt;br /&gt;
        super(parent, style);&lt;br /&gt;
        addPaintListener(new PaintListener() {&lt;br /&gt;
            public void paintControl(PaintEvent e) {&lt;br /&gt;
                e.gc.setForeground(e.gc.getDevice().getSystemColor(&lt;br /&gt;
                        SWT.COLOR_BLACK));&lt;br /&gt;
                e.gc.setBackground(SWTPaintCanvas.this.myColor);&lt;br /&gt;
                e.gc.fillRectangle(getClientArea());&lt;br /&gt;
                e.gc.drawRectangle(getClientArea().x, getClientArea().y, &lt;br /&gt;
                        getClientArea().width - 1, getClientArea().height - 1);&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the color.&lt;br /&gt;
     * &lt;br /&gt;
     * @param color  the color.&lt;br /&gt;
     */&lt;br /&gt;
    public void setColor(Color color) {&lt;br /&gt;
        if (this.myColor != null) {&lt;br /&gt;
            this.myColor.dispose();&lt;br /&gt;
        }&lt;br /&gt;
        //this.myColor = new Color(getDisplay(), color.getRGB());&lt;br /&gt;
        this.myColor = color;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the color.&lt;br /&gt;
     * &lt;br /&gt;
     * @return The color.&lt;br /&gt;
     */&lt;br /&gt;
    public Color getColor() {&lt;br /&gt;
        return this.myColor;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Overridden to do nothing.&lt;br /&gt;
     * &lt;br /&gt;
     * @param c  the color.&lt;br /&gt;
     */&lt;br /&gt;
    public void setBackground(Color c) {&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Overridden to do nothing.&lt;br /&gt;
     * &lt;br /&gt;
     * @param c  the color.&lt;br /&gt;
     */&lt;br /&gt;
    public void setForeground(Color c) {&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Frees resources.&lt;br /&gt;
     */&lt;br /&gt;
    public void dispose() {&lt;br /&gt;
        this.myColor.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;
==  Implement a simple scribble program ==&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;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class ScribbleProgram {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    Listener listener = new Listener() {&lt;br /&gt;
      int lastX = 0, lastY = 0;&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        switch (event.type) {&lt;br /&gt;
        case SWT.MouseMove:&lt;br /&gt;
          if ((event.stateMask &amp;amp; SWT.BUTTON1) == 0)&lt;br /&gt;
            break;&lt;br /&gt;
          GC gc = new GC(shell);&lt;br /&gt;
          gc.drawLine(lastX, lastY, event.x, event.y);&lt;br /&gt;
          gc.dispose();&lt;br /&gt;
        case SWT.MouseDown:&lt;br /&gt;
          lastX = event.x;&lt;br /&gt;
          lastY = event.y;&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    shell.addListener(SWT.MouseDown, listener);&lt;br /&gt;
    shell.addListener(SWT.MouseMove, listener);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&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>