diff options
author | Darrell Anderson <[email protected]> | 2014-01-08 20:06:00 +0100 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2014-01-08 20:06:00 +0100 |
commit | 636f509299122d02087c6fd62e1e4a46dbd22026 (patch) | |
tree | 70e43efceeb5b00e7f19cdac8da44928bd2fb459 /tdejava/koala/test/kblend/KBlendTest.java | |
parent | 719b61750c08343f530068ed4127623aeac71cf0 (diff) | |
download | tdebindings-636f509299122d02087c6fd62e1e4a46dbd22026.tar.gz tdebindings-636f509299122d02087c6fd62e1e4a46dbd22026.zip |
Rename many classes to avoid conflicts with KDE
Diffstat (limited to 'tdejava/koala/test/kblend/KBlendTest.java')
-rw-r--r-- | tdejava/koala/test/kblend/KBlendTest.java | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/tdejava/koala/test/kblend/KBlendTest.java b/tdejava/koala/test/kblend/KBlendTest.java new file mode 100644 index 00000000..65e2d025 --- /dev/null +++ b/tdejava/koala/test/kblend/KBlendTest.java @@ -0,0 +1,130 @@ +import org.trinitydesktop.qt.*; +import org.trinitydesktop.koala.*; + +// +// Simple little hack to show off blending effects. +// +// (C) KDE Artistic Cristian Tibirna <[email protected]> +// + +/** + * Class to test KImageEffect blending effects. + * + * This is a translation to java from kblendtest.cpp in the tests library + * of tdeui source. + * + * @see TDEApplication + * @see KImageEffect + * + * @author Cristian Tibirna <[email protected]>, java translation Kenneth J. Pouncey, [email protected] + * @version 0.1 + */ + +public class KBlendTest { + + public static void main(String[] args) { + TDECmdLineArgs.init(args, "kblendtest", "KBlendTest", "It blends!", "0.1"); + TDEApplication app = new TDEApplication(); + KBlendWidget w = new KBlendWidget(null,"KBlendTest"); + w.setCaption(app.name()); + app.setMainWidget(w); + w.show(); + app.exec(); + return; + } + + + public static class KBlendWidget extends TQWidget { + + TQImage image; + TQColor bgnd; + + String testImage = "testimage.png"; + + public KBlendWidget (TQWidget parent, String name) { + + // change the colors to see the effects. +// bgnd = new TQColor(TQColor.qRgb(255, 255, 255)); + bgnd = Qt.blue(); +// bgnd = Qt.red(); + + image = new TQImage(testImage); + + resize(image.width()*2+60, image.height()*3+80); + setBackgroundColor(bgnd); + } + + protected void paintEvent(TQPaintEvent pe ) { + + long it, ft; + String say = ""; + + image = new TQImage(testImage); + + TQPainter p = new TQPainter(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 TQImage(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 TQImage(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 TQImage(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 TQImage(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 TQImage(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(); + tdejava.initialize(); + } + +} |