summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/test/kblend
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kdejava/koala/test/kblend
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdejava/koala/test/kblend')
-rw-r--r--kdejava/koala/test/kblend/KBlendTest.java130
-rw-r--r--kdejava/koala/test/kblend/testimage.pngbin0 -> 35951 bytes
2 files changed, 130 insertions, 0 deletions
diff --git a/kdejava/koala/test/kblend/KBlendTest.java b/kdejava/koala/test/kblend/KBlendTest.java
new file mode 100644
index 00000000..6e4e4109
--- /dev/null
+++ b/kdejava/koala/test/kblend/KBlendTest.java
@@ -0,0 +1,130 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+//
+// Simple little hack to show off blending effects.
+//
+// (C) KDE Artistic Cristian Tibirna <tibirna@kde.org>
+//
+
+/**
+ * Class to test KImageEffect blending effects.
+ *
+ * This is a translation to java from kblendtest.cpp in the tests library
+ * of kdeui source.
+ *
+ * @see KApplication
+ * @see KImageEffect
+ *
+ * @author Cristian Tibirna <tibirna@kde.org>, java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class KBlendTest {
+
+ public static void main(String[] args) {
+ KCmdLineArgs.init(args, "kblendtest", "KBlendTest", "It blends!", "0.1");
+ KApplication app = new KApplication();
+ KBlendWidget w = new KBlendWidget(null,"KBlendTest");
+ w.setCaption(app.name());
+ app.setMainWidget(w);
+ w.show();
+ app.exec();
+ return;
+ }
+
+
+ public static class KBlendWidget extends QWidget {
+
+ QImage image;
+ QColor bgnd;
+
+ String testImage = "testimage.png";
+
+ public KBlendWidget (QWidget parent, String name) {
+
+ // change the colors to see the effects.
+// bgnd = new QColor(QColor.qRgb(255, 255, 255));
+ bgnd = Qt.blue();
+// bgnd = Qt.red();
+
+ image = new QImage(testImage);
+
+ resize(image.width()*2+60, image.height()*3+80);
+ setBackgroundColor(bgnd);
+ }
+
+ protected void paintEvent(QPaintEvent pe ) {
+
+ long it, ft;
+ String say = "";
+
+ image = new QImage(testImage);
+
+ QPainter p = new QPainter(this);
+
+ p.setPen(Qt.black());
+
+ // you see here use of anti_dir param (blend from down to up, here)
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.VerticalGradient,true);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Vertical";
+ p.drawImage(20, 20, image);
+ p.drawText(5 , 15, say);
+
+ image = new QImage(testImage);
+
+ // here a negative initial intensity is used (1/2 of image is unaffected)
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, -0.5f, bgnd, KImageEffect.HorizontalGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Horizontal";
+ p.drawImage(40+image.width(), 20, image);
+ p.drawText(15+image.width() , 15, say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.0f, bgnd, KImageEffect.DiagonalGradient,true);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Diagonal";
+ p.drawImage(20, 40+image.height(), image);
+ p.drawText(5 , 35+image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.1f, bgnd, KImageEffect.CrossDiagonalGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, CrossDiagonal";
+ p.drawImage(40+image.width(), 40+image.height(), image);
+ p.drawText(25+image.width() , 35 + image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, -0.6f, bgnd, KImageEffect.RectangleGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Rectangle";
+ p.drawImage(20, 60+2*image.height(), image);
+ p.drawText(5 , 55+2*image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.EllipticGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Elliptic";
+ p.drawImage(40+image.width(), 60+2*image.height(), image);
+ p.drawText(25+image.width(), 55+2*image.height(), say);
+ p.end();
+ }
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kblend/testimage.png b/kdejava/koala/test/kblend/testimage.png
new file mode 100644
index 00000000..2f591d8e
--- /dev/null
+++ b/kdejava/koala/test/kblend/testimage.png
Binary files differ