You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Clint Gilbert <cl...@hms.harvard.edu> on 2011/01/14 06:17:46 UTC

Programmatic drawing in Pivot 2.0?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- From the sound of things on

https://cwiki.apache.org/PIVOT/major-feature-changes-between-15x-and-20.html

I was one of the few people who used the "shape DOM" classes from
org.apache.pivot.wtk.media.drawing.  I found the new Drawing and
SVGDiagramSerializer classes but those seem (at a glance) to require
loading up an SVG file from a stream.  Is that so?  Is there a way in
Pivot 2.0 to draw simple shapes programatically, as was possible in
Pivot 1.5?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk0v3HUACgkQ0GFaTS4nYxsX6gCfZVjizYvYcAN/3/lqM3zgtLXu
pusAn1NtKAvQhI4FM1bw6M+hxLM1ghMh
=4LtI
-----END PGP SIGNATURE-----

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Actually i fell dumb for the last question..maybe I need to get some
sleep...jjeje well...resolved the last isue i end up withs a new a "working"
bxml, a simple laucnher class (atached below) and my modified clases of wtk
module :D now im getting this porblem...

org.apache.pivot.serialization.SerializationException: class
org.apache.pivot.wtk.media.Drawing is not a sequence.

and I just don't get it...:S any help will be reaaaaaaaaaaaaally
apreciated!!! :D

<Drawing xmlns:bxml="http://pivot.apache.org/wtkx" 
	xmlns:freedrawing="org.apache.pivot.wtk.media.drawing"
	xmlns="org.apache.pivot.wtk.media">


	<freedrawing:Canvas bxml:id="canvas">
		<freedrawing:Ellipse width="320" height="320" stroke="" fill="#eeeeee" />
		
	</freedrawing:Canvas>


</Drawing>

and a simple class like this...

package co.com.adv.salarixexternal.ui.controller.localcanvas;

import org.apache.pivot.beans.BXML;
import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.ImageView;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtk.media.Drawing;
import org.apache.pivot.wtk.media.drawing.Canvas;
import org.apache.pivot.wtk.media.drawing.Line;
import org.apache.pivot.wtk.media.drawing.Shape;

import co.com.adv.salarixexternal.BXMLauncher;

public class RotateLine implements Application {

	private Drawing drawing = null;
	@BXML
    private Shape.Rotate rotation = null;
	
	private Window window = null;
	@BXML
    private Canvas canvas;

	@Override
	public void startup(Display display, Map&lt;String, String&gt; properties)
			throws Exception {
		BXMLSerializer bxmlSerializer = new BXMLSerializer();
		drawing = (Drawing)bxmlSerializer.readObject(BXMLauncher.class,
"/co/com/adv/salarixexternal/ui/bxml/RotateLine.bxml");
		//now we try to paint a line by hand
        Line line = new Line();
        line.setEndpoints(0, 0, 300, 300);
        line.setStroke("#000000");
        //line.setFill("#000000");
        canvas.add(line);
        ApplicationContext.scheduleRecurringCallback(new Runnable() {
            @Override
            public void run() {
                int angle = (int)rotation.getAngle();
                angle = (angle + 6) % 360;
                rotation.setAngle(angle);
            }
        }, 1000);

        window = new Window(new ImageView(drawing));
        window.setMaximized(true);
        window.open(display);
	}

	@Override
	public boolean shutdown(boolean optional) throws Exception {
		if (window != null) {
            window.close();
        }

        return false;
	}

	@Override
	public void suspend() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() throws Exception {
		// TODO Auto-generated method stub
		
	}

}


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3284577.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Hi there,..i fot stuck again...i got this bxml...

<Drawing xmlns:wtkx="http://pivot.apache.org/wtkx"
    xmlns="org.apache.pivot.wtk.media">
    <canvas>
        <Canvas xmlns="org.apache.pivot.wtk.media.drawing" bxml:id="canvas">
            <Ellipse width="320" height="320" stroke="" fill="#eeeeee"/>
            <Line x1="0" y1="0" x2="0" y2="-160" strokeThickness="4">
                <transforms>
                    <Shape.Translate x="160" y="160"/>
                    <Shape.Rotate bxml:id="rotation"/>
                </transforms>
            </Line>
        </Canvas>
    </canvas>
</Drawing>

and already movend the clases...corrected the
heritage....debuged...corrected issues...and now im triying to run mi first
example... but im geting this error.

Message:
http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?Canvas&bxml:id&bxml

I also triyed

&lt;Drawing xmlns:wtkx=&quot;http://pivot.apache.org/wtkx&quot;
    xmlns=&quot;org.apache.pivot.wtk.media&quot;
    xmlns=&quot;org.apache.pivot.wtk.media.drawing&quot;&gt;
    <canvas>
        <Canvas bxml:id="canvas">
            <Ellipse width="320" height="320" stroke="" fill="#eeeeee"/>
            <Line x1="0" y1="0" x2="0" y2="-160" strokeThickness="4">
                <transforms>
                    <Shape.Translate x="160" y="160"/>
                    <Shape.Rotate bxml:id="rotation"/>
                </transforms>
            </Line>
        </Canvas>
    </canvas>
</Drawing>

but got this error...

Message: Attribute "xmlns" was already specified for element "Drawing".

and ifi remove and just use xml tags to show th system how to get into the
packages toresolve the classes  i got back to Message:
http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?Canvas&bxml:id&bxml

any ideas???

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3284555.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Sandro Martini <sa...@gmail.com>.
Oh yes,
in development environment you have to add even plugin.jar (and maybe
even javaws.jar, both from jre/lib folder under the jdk folder), for
example in the jdk definition inside eclipse, so all compile without
problems.

I have to write something on this in our wiki (since many time, but I
never find time ... and now it's on my infinite todo list).
Greg wrote something like this in the wiki, but for Mac.

Bye

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
sorry for the dumb question...I have got this porblem many times...and alway
forget that tis references the plugin lib in jre... :s

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3284106.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Hi there...I started working in the wtk module, but I can't manage to resolve
the dependency for netscape.javascript.JSObject, already checked in al the
pom files and haven't found that dependency :( 

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3284096.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Sandro Martini <sa...@gmail.com>.
Uh sorry

>(when I got it functional i'll send it to you...maybe it can help
Yes, this would be useful, so i can publish somewhere under our
apache-extras ...

Bye

Re: Programmatic drawing in Pivot 2.0?

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
you can find something here:
http://pivot.apache.org/tutorials/platform-overview.html
(and the same file is inside our distributions, so even in 1.5.2 you
should find it), but I understand that could not help so much (it
hasn't much detail for what you are searching).

Bye

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Hi there...i finally decided to use the old settings and add them to my
porject (when I got it functional i'll send it to you...maybe it can help),
but now im a little stuck...i was wondering where can I find some class
diagramas for both versions???

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3283708.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Sandro Martini <sa...@gmail.com>.
Yes, we support SVG using SVGSalamander , maybe there you can find some more
info on drawing in Svg (if it's good for your case).
Or you can try to look at old classes in Pivot-1.5.2 and replicate/adapt
what you need.
Sorry but I can't help you more on this.

We are thinking to re-enable some old/dropped features adapting for the
current Pivot version, and moving them in one of our apache-extras project
related to Pivot.
But it's not on top of our priorities, and help/contributions are welcome
...

Bye
 Il giorno 24/ago/2011 23:04, "camicas" <ca...@adv.com.co> ha
scritto:
> Just to be sure (at this point i'm totally lost! jajajaja) you men
> http://www.kitfox.com/ ????
>
> --
> View this message in context:
http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3282150.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Just to be sure (at this point i'm totally lost! jajajaja) you men
http://www.kitfox.com/ ???? 

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3282150.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Sandro Martini <sa...@gmail.com>.
Hi, sorry at the moment I can tell you only a quick info:
Try to look at svg functions.
There was the old drawing package (with a clock demo) but if I remember well
should have been removed in 2.0 .

So good tests with SVG.

Bye
 Il giorno 24/ago/2011 22:29, "camicas" <ca...@adv.com.co> ha
scritto:
> Sorry to take this back to life....but im stuck...im been triying to draw
a
> simple line for the last 3 hours...and my head is really starting to
> hurt...jajajaja any indications?? I triyed overwriting the paint method in
a
> class that exteds panel..
> @Override
> public void paint(Graphics2D graphics) {
> // TODO Auto-generated method stub
> System.out.println("canvas controller painted!!!");
> Line2D line = new Line2D.Float(new Point2D.Double(0d, 0d),
> new Point2D.Double(100d, 100d));
> graphics.draw(line);
> super.paint(graphics);
> }
>
> but the bloody method never get called!!! :( pleeease help! i ned to draw
a
> simple line....:D
>
> --
> View this message in context:
http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3282030.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
I don't know what i have been doing bad.....but i just added the repaint
method...and both methos..paint and repaint are called now..:D thanks
everyone for your help :D now I just have to make repaint the full lines
when I move the componetes...because now it looks horrible...jajajajaa

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3293753.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
HI there...the sysout is never shown in console :(

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3292730.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Greg Brown <gk...@verizon.net>.
> im been triying to draw a
> simple line for the last 3 hours...and my head is really starting to
> hurt...jajajaja any indications?? I triyed overwriting the paint method in a
> class that exteds panel..
> @Override
>        public void paint(Graphics2D graphics) {
>                // TODO Auto-generated method stub
>                System.out.println("canvas controller painted!!!");
>                Line2D line = new Line2D.Float(new Point2D.Double(0d, 0d),
>                                new Point2D.Double(100d, 100d));
>                graphics.draw(line);
>                super.paint(graphics);
>        }
> 
> but the bloody method never get called!!!

This should work. Are you sure the method isn't getting called? Perhaps you should place the call to super.paint() at the beginning of the method? Otherwise, your line may be painted over by the base class.




Re: Programmatic drawing in Pivot 2.0?

Posted by camicas <ca...@adv.com.co>.
Sorry to take this back to life....but im stuck...im been triying to draw a
simple line for the last 3 hours...and my head is really starting to
hurt...jajajaja any indications?? I triyed overwriting the paint method in a
class that exteds panel..
@Override
        public void paint(Graphics2D graphics) {
                // TODO Auto-generated method stub
                System.out.println("canvas controller painted!!!");
                Line2D line = new Line2D.Float(new Point2D.Double(0d, 0d),
                                new Point2D.Double(100d, 100d));
                graphics.draw(line);
                super.paint(graphics);
        }

but the bloody method never get called!!! :( pleeease help! i ned to draw a
simple line....:D 

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Programmatic-drawing-in-Pivot-2-0-tp2253493p3282030.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Programmatic drawing in Pivot 2.0?

Posted by Clint Gilbert <cl...@hms.harvard.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No worries at all, thank you for the tips.  My project is a
graphics-heavy adaptation of a board game, which I imagine is far from
the most common Pivot use case.  I'll look into making my own classes,
or maybe adapting and re-using the old classes from Pivot < 2.0.
Congrats on the new version!

On 01/14/2011 07:53 AM, Greg Brown wrote:
> Oh no! Sorry about that.
> 
> Pivot 2.0 still supports "immediate mode" drawing. You can do this in a couple of ways, but the easiest is to create a class that extends Panel and overrides paint(). Then you can use the drawing operations on the Graphics2D object passed to the method to draw your shapes. Pivot's "shape DOM" classes were mostly just wrappers around the drawing primitives in java.awt.geom anyways.
> 
> Hope this helps.
> 
> Greg
> 
> On Jan 14, 2011, at 12:17 AM, Clint Gilbert wrote:
> 
> From the sound of things on
> 
> https://cwiki.apache.org/PIVOT/major-feature-changes-between-15x-and-20.html
> 
> I was one of the few people who used the "shape DOM" classes from
> org.apache.pivot.wtk.media.drawing.  I found the new Drawing and
> SVGDiagramSerializer classes but those seem (at a glance) to require
> loading up an SVG file from a stream.  Is that so?  Is there a way in
> Pivot 2.0 to draw simple shapes programatically, as was possible in
> Pivot 1.5?
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk0yKysACgkQ0GFaTS4nYxtN9gCcChWt/Xtnfw0kBnc+1xVf6fYc
1J8AoM0Umua33fgSXlgMSQPXoUcUItZm
=9vjJ
-----END PGP SIGNATURE-----

Re: Programmatic drawing in Pivot 2.0?

Posted by Greg Brown <gk...@verizon.net>.
Oh no! Sorry about that.

Pivot 2.0 still supports "immediate mode" drawing. You can do this in a couple of ways, but the easiest is to create a class that extends Panel and overrides paint(). Then you can use the drawing operations on the Graphics2D object passed to the method to draw your shapes. Pivot's "shape DOM" classes were mostly just wrappers around the drawing primitives in java.awt.geom anyways.

Hope this helps.

Greg

On Jan 14, 2011, at 12:17 AM, Clint Gilbert wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> - From the sound of things on
> 
> https://cwiki.apache.org/PIVOT/major-feature-changes-between-15x-and-20.html
> 
> I was one of the few people who used the "shape DOM" classes from
> org.apache.pivot.wtk.media.drawing.  I found the new Drawing and
> SVGDiagramSerializer classes but those seem (at a glance) to require
> loading up an SVG file from a stream.  Is that so?  Is there a way in
> Pivot 2.0 to draw simple shapes programatically, as was possible in
> Pivot 1.5?
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> 
> iEYEARECAAYFAk0v3HUACgkQ0GFaTS4nYxsX6gCfZVjizYvYcAN/3/lqM3zgtLXu
> pusAn1NtKAvQhI4FM1bw6M+hxLM1ghMh
> =4LtI
> -----END PGP SIGNATURE-----