You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by MSafiri <zs...@gmail.com> on 2010/11/19 15:46:00 UTC

Data for "trend" is not an instance of org.apache.pivot.wtk.media.Image

Dear All,

In our application we are trying to use icons (up and down arrows) to
display trends. The icons are displayed correctly, but every time we receive
the following error message:

Data for "trend" is not an instance of org.apache.pivot.wtk.media.Image

Can you please let me know whether we have to follow some specific methods
to add icons to cell? We followed the example on the PIVOT site.

Your help is appreciated,

Regards,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1930922.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Will send some on Monday. Have a good weekend.

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1931511.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by Greg Brown <gk...@mac.com>.
For some reason, we aren't allowed to post Java source attachments to the list. Can you attach a zip file containing a screen shot and any relevant source code? Thanks.

On Nov 22, 2010, at 4:20 AM, MSafiri wrote:

> 
> Dear Greg,
> 
> I am uploading the .java file, which is causing the problem.
> 
> This is the way we declare the Image:
> 
> 		Image flagGreen = Image.load(new URL("file:///C:/green.png"));
> 		Image flagRed = Image.load(new URL("file:///C:/red.png"));
> 
> This part is putting the flag to the column, based on the calculation:
> 
> 	
> if(isDateOutOfThresoldRange(dateFormat.format(currentValues.get(MessageDataDef.progress_start))
> + "", 
> 				dateFormat.format(newValues.get(MessageDataDef.progress_start)) + "")){
> 			mapStartDate.put("trend", flagRed);
> 		}else{
> 			mapStartDate.put("trend", flagGreen);
> 		}
> 
> You can see all the code in the attached file.
> 
> Thanks alot for your help,
> 
> MSafiri
> http://apache-pivot-users.399431.n3.nabble.com/file/n1944528/DialogProgressUpdateConfirmation.java
> DialogProgressUpdateConfirmation.java 
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1944528.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by Greg Brown <gk...@mac.com>.
That's great! Good luck with the rest of your port. Do consider moving to 2.0 if it is a possibility - you will most likely find it even easier to work with than 1.5.x.
G

On Nov 23, 2010, at 8:41 AM, MSafiri wrote:

> 
> Hi Greg,
> 
> Thanks for the reply. We are on version 1.5.2, using the one from the
> official web site. Well, as you can see from the questions, we are still
> learning. Pivot works really well for us. So far 70% of the old, swing based
> GUI is replaced, nicer, cleaner, easier to extend..great work. 
> 
> Tomorrow we start the most complicated element and if we complete that in 2
> weeks, we are on the way...
> 
> Cheers,
> 
> MSafiri
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1953357.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Hi Greg,

Thanks for the reply. We are on version 1.5.2, using the one from the
official web site. Well, as you can see from the questions, we are still
learning. Pivot works really well for us. So far 70% of the old, swing based
GUI is replaced, nicer, cleaner, easier to extend..great work. 

Tomorrow we start the most complicated element and if we complete that in 2
weeks, we are on the way...

Cheers,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1953357.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by Greg Brown <gk...@mac.com>.
Is the cell value null in those cases? Null values should be allowed by TableViewImageCellRenderer. I have fixed this in the trunk - if you are using Pivot 2.0, you can sync to get this fix. No need to use a transparent image.
G

On Nov 23, 2010, at 7:57 AM, MSafiri wrote:

> 
> Greg,
> 
> Ignore the previous mail. Cause found and we are fixing it. What happened is
> that the 1st 3 rows are without any image in the Trend column and it caused
> the problem. 
> 
> Tried to create an empty image, no luck, so we created a 'dirty' solution
> via a 16x16 transparent icon. Once we were able to demo the application, we
> are going back to fix it properly.
> 
> Thanks for the help,
> 
> Regards,
> 
> MSafiri
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1953158.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Greg,

Ignore the previous mail. Cause found and we are fixing it. What happened is
that the 1st 3 rows are without any image in the Trend column and it caused
the problem. 

Tried to create an empty image, no luck, so we created a 'dirty' solution
via a 16x16 transparent icon. Once we were able to demo the application, we
are going back to fix it properly.

Thanks for the help,

Regards,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1953158.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Dear Greg,

The Trend cells holds the images, the image is selected based on the result
of a calculation. Indeed, the 1st three cells are empty as for such data no
calculation is performed. However we are receiving the same error for all
the lines. You can see the images displayed on the screenshot attached to
the previous mail. All of them are displayed properly, although the message
appears.

Regards,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1951909.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by Greg Brown <gk...@mac.com>.
It looks like some of the Trend cells are blank. They probably don't contain an image and could be generating this warning. What is the value of those cells?

On Nov 22, 2010, at 9:17 AM, MSafiri wrote:

> 
> Dear Greg,
> 
> Sorry, i took the message wrong. I have sent the file (Java) this morning as
> an attachment to one of my message. Sending it again with this mail. Also
> loading a screenshot.
> 
> http://apache-pivot-users.399431.n3.nabble.com/file/n1945952/2010-11-22_151522.png 
> 
> http://apache-pivot-users.399431.n3.nabble.com/file/n1945952/DialogProgressUpdateConfirmation.java
> DialogProgressUpdateConfirmation.java 
> 
> Regards,
> 
> MSafiri
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1945952.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Dear Greg,

Sorry, i took the message wrong. I have sent the file (Java) this morning as
an attachment to one of my message. Sending it again with this mail. Also
loading a screenshot.

http://apache-pivot-users.399431.n3.nabble.com/file/n1945952/2010-11-22_151522.png 

http://apache-pivot-users.399431.n3.nabble.com/file/n1945952/DialogProgressUpdateConfirmation.java
DialogProgressUpdateConfirmation.java 

Regards,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1945952.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by Greg Brown <gk...@mac.com>.
That suggestion wasn't meant to resolve the problem - I was just pointing out what might be considered bad programming practice. 

Still not sure what the actual problem might be - can you post a zip file containing a screen shot and source, as requested in my earlier message?

G 

On Nov 22, 2010, at 8:27 AM, MSafiri wrote:

> 
> Dear Greg,
> 
> Thanks for the tip. We tried the solution you mentioned, but we are
> receiving the same message. We are using Pivot 1.5.2.
> 
> Regards,
> 
> MSafiri
> 
> 
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1945669.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Dear Greg,

Thanks for the tip. We tried the solution you mentioned, but we are
receiving the same message. We are using Pivot 1.5.2.

Regards,

MSafiri


-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1945669.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for

Posted by Greg Brown <gk...@mac.com>.
FYI, it is generally not a good idea to use file system paths in your application code, since this can easily change from system to system. You should include the image resources in your JAR and load them from the classpath. For example:

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Image flagGreen = Image.load(classLoader.getResource("images/green.png"));

On Nov 22, 2010, at 4:20 AM, MSafiri wrote:

> 
> Dear Greg,
> 
> I am uploading the .java file, which is causing the problem.
> 
> This is the way we declare the Image:
> 
> 		Image flagGreen = Image.load(new URL("file:///C:/green.png"));
> 		Image flagRed = Image.load(new URL("file:///C:/red.png"));
> 
> This part is putting the flag to the column, based on the calculation:
> 
> 	
> if(isDateOutOfThresoldRange(dateFormat.format(currentValues.get(MessageDataDef.progress_start))
> + "", 
> 				dateFormat.format(newValues.get(MessageDataDef.progress_start)) + "")){
> 			mapStartDate.put("trend", flagRed);
> 		}else{
> 			mapStartDate.put("trend", flagGreen);
> 		}
> 
> You can see all the code in the attached file.
> 
> Thanks alot for your help,
> 
> MSafiri
> http://apache-pivot-users.399431.n3.nabble.com/file/n1944528/DialogProgressUpdateConfirmation.java
> DialogProgressUpdateConfirmation.java 
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1944528.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Data for

Posted by MSafiri <zs...@gmail.com>.
Dear Greg,

I am uploading the .java file, which is causing the problem.

This is the way we declare the Image:

		Image flagGreen = Image.load(new URL("file:///C:/green.png"));
		Image flagRed = Image.load(new URL("file:///C:/red.png"));

This part is putting the flag to the column, based on the calculation:

	
if(isDateOutOfThresoldRange(dateFormat.format(currentValues.get(MessageDataDef.progress_start))
+ "", 
				dateFormat.format(newValues.get(MessageDataDef.progress_start)) + "")){
			mapStartDate.put("trend", flagRed);
		}else{
			mapStartDate.put("trend", flagGreen);
		}

You can see all the code in the attached file.

Thanks alot for your help,

MSafiri
http://apache-pivot-users.399431.n3.nabble.com/file/n1944528/DialogProgressUpdateConfirmation.java
DialogProgressUpdateConfirmation.java 
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Data-for-trend-is-not-an-instance-of-org-apache-pivot-wtk-media-Image-tp1930922p1944528.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Data for "trend" is not an instance of org.apache.pivot.wtk.media.Image

Posted by Greg Brown <gk...@mac.com>.
Not sure how the icons are being displayed if the content isn't an Image. Some source code might help identify the problem.

On Nov 19, 2010, at 9:46 AM, MSafiri wrote:

> Dear All, In our application we are trying to use icons (up and down arrows) to display trends. The icons are displayed correctly, but every time we receive the following error message: Data for "trend" is not an instance of org.apache.pivot.wtk.media.Image Can you please let me know whether we have to follow some specific methods to add icons to cell? We followed the example on the PIVOT site. Your help is appreciated, Regards, MSafiri 
> View this message in context: Data for "trend" is not an instance of org.apache.pivot.wtk.media.Image
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.