diff options
author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-05-29 07:14:31 +0000 |
---|---|---|
committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-05-29 07:14:31 +0000 |
commit | e4bdb9cbf32f1c8ac328acae4e63b361e3f47092 (patch) | |
tree | 515f595cd9f0102d3187aec1d961dcb49fd46c68 /examples/gnu | |
parent | 0ef4c3a0d1c33e86e78100eb7d0d72093b88c077 (diff) | |
download | classpath-e4bdb9cbf32f1c8ac328acae4e63b361e3f47092.tar.gz |
2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java (translate):
Rewritten.
* examples/gnu/classpath/examples/swing/FillRect.java (paintComponent):
Optionally paint with translation. (createContent): Added option
to test painting with translation
Diffstat (limited to 'examples/gnu')
-rw-r--r-- | examples/gnu/classpath/examples/swing/FillRect.java | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/examples/gnu/classpath/examples/swing/FillRect.java b/examples/gnu/classpath/examples/swing/FillRect.java index 0c5566958..11e208d85 100644 --- a/examples/gnu/classpath/examples/swing/FillRect.java +++ b/examples/gnu/classpath/examples/swing/FillRect.java @@ -37,6 +37,7 @@ public class FillRect LCDCanvas lcd; Worker worker; JLabel label; + JCheckBox translate; int nx = 64; int ny = 64; @@ -48,6 +49,11 @@ public class FillRect long lastMillis = System.currentTimeMillis(); boolean enableRepaints = true; + + /** + * If true, test translation. + */ + boolean testTranslation = false; public void actionPerformed(ActionEvent e) { @@ -71,8 +77,22 @@ public class FillRect lcd = new LCDCanvas(); label = new JLabel(); label.setText("paintComponent took 00 msec. (00000 fillRect calls)"); + + translate = new JCheckBox("translate"); + translate.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent event) + { + testTranslation = translate.isSelected(); + } + }); + + JPanel bottom = new JPanel(); + bottom.add(label); + bottom.add(translate); + p.add(lcd, BorderLayout.CENTER); - p.add(label, BorderLayout.SOUTH); + p.add(bottom, BorderLayout.SOUTH); add(p); } @@ -123,6 +143,9 @@ public class FillRect g.fillRect(0, 0, sx, sy); Color pixelColor = null; + + int dx, dy; + for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) @@ -131,9 +154,19 @@ public class FillRect pixelColor = activePixel; else pixelColor = passivePixel; - + + dx = 4 * ix; + dy = 4 * iy; g.setColor(pixelColor); - g.fillRect(4 * ix, 4 * iy, 3, 3); + + if (testTranslation) + { + g.translate(dx, dy); + g.fillRect(0, 0, 3, 3); + g.translate(-dx, -dy); + } + else + g.fillRect(dx, dy, 3, 3); } } |