<?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</id>
		<title>Java Tutorial/SWT 2D Graphics - История изменений</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"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics&amp;action=history"/>
		<updated>2026-04-21T20:09:18Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT_2D_Graphics&amp;diff=2829&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&amp;diff=2829&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&amp;diff=2830&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&amp;diff=2830&amp;oldid=prev"/>
				<updated>2010-05-31T15:18:19Z</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;* [[Java Tutorial/SWT 2D Graphics/Animation | Animation]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Arc | Arc]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Color | Color]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Draw Focus | Draw Focus]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Draw String | Draw String]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/GC | GC]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Image | Image]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Line | Line]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Oval | Oval]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/PNG GIF | PNG GIF]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Path | Path]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Polygon | Polygon]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Rectangle | Rectangle]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/SWT Paint | SWT Paint]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Sine | Sine]]&lt;br /&gt;
* [[Java Tutorial/SWT 2D Graphics/Transform | Transform]]&lt;br /&gt;
&lt;br /&gt;
==  Changing Fonts ==&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.PaintEvent;&lt;br /&gt;
import org.eclipse.swt.events.PaintListener;&lt;br /&gt;
import org.eclipse.swt.graphics.Font;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Canvas;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FontChangeSWT {&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;Canvas Example&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Canvas canvas = new Canvas(shell, SWT.NONE);&lt;br /&gt;
    canvas.addPaintListener(new PaintListener() {&lt;br /&gt;
      public void paintControl(PaintEvent e) {&lt;br /&gt;
        &lt;br /&gt;
        Font font = new Font(shell.getDisplay(), &amp;quot;Helvetica&amp;quot;, 18, SWT.NORMAL);&lt;br /&gt;
        e.gc.setFont(font);&lt;br /&gt;
        e.gc.drawText(&amp;quot;My Text&amp;quot;, 0, 0);&lt;br /&gt;
        font.dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&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;
    }&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;
==  Creating Fonts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ConstructorDescriptionpublic Font(Device device, FontData fd)Creates a font using the specified device and font data.public Font(Device device, FontData[] fds)Creates a font using the specified device and array of font data.public Font(Device device, String name, int height, int style)Creates a font using the specified device, name, height (in points), and style. Style constants are SWT.NORMAL, SWT.BOLD, and SWT.ITALIC.&lt;br /&gt;
&amp;lt;p&amp;gt;Font Styles&amp;lt;/p&amp;gt;&lt;br /&gt;
StyleDescriptionSWT.NORMALCreates a normal fontSWT.BOLDCreates a bold fontSWT.ITALICCreates an italic font&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Font Terminology ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TermMeaningbaselineThe imaginary line the font sits onascentThe number of pixels that characters reach above the baseline to the top of typical lowercase charactersdescentThe number of pixels that characters reach below the baselineheightThe total height of characters in pixels, equal to the ascent plus the descent plus the leading arealeading areaThe number of pixels above the top of typical lowercase characters&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.PaintEvent;&lt;br /&gt;
import org.eclipse.swt.events.PaintListener;&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.FontMetrics;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Canvas;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FontMetricsPaintSWT {&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;Canvas Example&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Canvas canvas = new Canvas(shell, SWT.NONE);&lt;br /&gt;
    canvas.addPaintListener(new PaintListener() {&lt;br /&gt;
      public void paintControl(PaintEvent e) {&lt;br /&gt;
        &lt;br /&gt;
        Font font = new Font(shell.getDisplay(), new FontData(&amp;quot;Helvetica&amp;quot;, 18, SWT.NORMAL));&lt;br /&gt;
        e.gc.setFont(font);&lt;br /&gt;
        e.gc.drawText(&amp;quot;My Text&amp;quot;, 0, 0);&lt;br /&gt;
        &lt;br /&gt;
        FontMetrics fm = e.gc.getFontMetrics();&lt;br /&gt;
        int bHeight = fm.getLeading() + fm.getAscent();&lt;br /&gt;
        int oHeight = fm.getAscent();&lt;br /&gt;
        int yHeight = fm.getAscent() + fm.getDescent();&lt;br /&gt;
        int totalHeight = fm.getHeight(); // Equals fm.getLeading() + fm.getAscent()&lt;br /&gt;
                                          // + fm.getDescent();&lt;br /&gt;
        &lt;br /&gt;
        e.gc.drawLine(10,bHeight,100,bHeight);&lt;br /&gt;
        e.gc.drawLine(10,oHeight,100,oHeight);&lt;br /&gt;
        e.gc.drawLine(10,yHeight,100,yHeight);&lt;br /&gt;
        e.gc.drawLine(10,totalHeight,100,totalHeight);&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        font.dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&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;
    }&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;
==  Get system default font ==&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.PaintEvent;&lt;br /&gt;
import org.eclipse.swt.events.PaintListener;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Canvas;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FontSystemGettingSWT {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Canvas Example&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Canvas canvas = new Canvas(shell, SWT.NONE);&lt;br /&gt;
    canvas.addPaintListener(new PaintListener() {&lt;br /&gt;
      public void paintControl(PaintEvent e) {&lt;br /&gt;
        &lt;br /&gt;
        e.gc.setFont(display.getSystemFont());&lt;br /&gt;
        &lt;br /&gt;
        e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5);&lt;br /&gt;
      }&lt;br /&gt;
    });&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;
    }&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;
==  Using FontMetrics to get char width ==&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.graphics.FontMetrics;&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.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class FontMetricsCharWidth {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    Text text = new Text(shell, SWT.NONE);&lt;br /&gt;
    GC gc = new GC(text);&lt;br /&gt;
    FontMetrics fm = gc.getFontMetrics();&lt;br /&gt;
    int charWidth = fm.getAverageCharWidth();&lt;br /&gt;
    int width = text.ruputeSize(charWidth * 8, SWT.DEFAULT).x;&lt;br /&gt;
    gc.dispose();&lt;br /&gt;
    &lt;br /&gt;
    System.out.println(width);&lt;br /&gt;
    shell.isDisposed();&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>