Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » A few questions on Zest
A few questions on Zest [message #246567] Sun, 14 December 2008 12:32 Go to next message
Eclipse UserFriend
Originally posted by: zzhangh.cn.ibm.com

Hi all,
I got a few questions while using Zest as below,
1. How to use custom figure for GraphNodes (not tooltips, but the nodes themselves)
2. After a graph has been created, how to show/hide texts on the nodes (I tried GraphNode#setNodeStyle(), but the graph
was not updated)

Thanks in advance!

Regards,
Hao
Re: A few questions on Zest [message #246572 is a reply to message #246567] Mon, 15 December 2008 03:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Hao Zhang wrote:
> Hi all,
> I got a few questions while using Zest as below,
> 1. How to use custom figure for GraphNodes (not tooltips, but the nodes themselves)
> 2. After a graph has been created, how to show/hide texts on the nodes (I tried GraphNode#setNodeStyle(), but the graph
> was not updated)
>
> Thanks in advance!
>
> Regards,
> Hao
1. Every GraphNode has a GraphLabel as its figure, so if you use Zest
Viewer(JFace style), specify a image in the viewer's labelprovider or
directly set the image for GrahpNode through invoking its method
*setImage* (SWT style)

viewer = new GraphViewer(shell, SWT.NONE);
viewer.setContentProvider(new MyContentProvider());
viewer.setLabelProvider(new MyLabelProvider(){
public Image getImage(Object element) {
return custom_image;
});


Graph g = new Graph(shell, SWT.NONE);
GraphNode n = new GraphNode(g, SWT.NONE, "David");
n.setImage(image);
2 Because figure is GraphLabel, you can simply do it like below:

Hide:

node.setText("");
//update node style
node.setNodeStyle(n.getNodeStyle() | ZestStyles.NODES_HIDE_TEXT);

Show:
node.setText("New Text");
node.setNodeStyle(n.getNodeStyle() & ~ZestStyles.NODES_HIDE_TEXT);

Hope this help you!

BTW: are you the famous IBM CSDL fellow Zhang Hao?
Re: A few questions on Zest [message #246577 is a reply to message #246572] Mon, 15 December 2008 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zzhangh.cn.ibm.com

Hi David,
For the show/hide question your suggestion worked, thanks!
However, for the other one, what I wanted is to use a custom IFigure other than an Image, is there any solution? Do I
have to write my own GraphNode?

P.S. I'm not the fellow...

Regards,
Hao

David BY Chan wrote:
> Hao Zhang wrote:
>> Hi all,
>> I got a few questions while using Zest as below,
>> 1. How to use custom figure for GraphNodes (not tooltips, but the nodes themselves)
>> 2. After a graph has been created, how to show/hide texts on the nodes (I tried GraphNode#setNodeStyle(), but the graph
>> was not updated)
>>
>> Thanks in advance!
>>
>> Regards,
>> Hao
> 1. Every GraphNode has a GraphLabel as its figure, so if you use Zest
> Viewer(JFace style), specify a image in the viewer's labelprovider or
> directly set the image for GrahpNode through invoking its method
> *setImage* (SWT style)
>
> viewer = new GraphViewer(shell, SWT.NONE);
> viewer.setContentProvider(new MyContentProvider());
> viewer.setLabelProvider(new MyLabelProvider(){
> public Image getImage(Object element) {
> return custom_image;
> });
>
>
> Graph g = new Graph(shell, SWT.NONE);
> GraphNode n = new GraphNode(g, SWT.NONE, "David");
> n.setImage(image);
> 2 Because figure is GraphLabel, you can simply do it like below:
>
> Hide:
>
> node.setText("");
> //update node style
> node.setNodeStyle(n.getNodeStyle() | ZestStyles.NODES_HIDE_TEXT);
>
> Show:
> node.setText("New Text");
> node.setNodeStyle(n.getNodeStyle() & ~ZestStyles.NODES_HIDE_TEXT);
>
> Hope this help you!
>
> BTW: are you the famous IBM CSDL fellow Zhang Hao?
Re: A few questions on Zest [message #246582 is a reply to message #246577] Tue, 16 December 2008 03:21 Go to previous message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

yes, write an extended GraphNode and override its method
createFigureForModel, where substitute your figure for GraphLabel.

More details you'd better read the source code of Zest.
Hao Zhang wrote:
> Hi David,
> For the show/hide question your suggestion worked, thanks!
> However, for the other one, what I wanted is to use a custom IFigure other than an Image, is there any solution? Do I
> have to write my own GraphNode?
>
> P.S. I'm not the fellow...
>
> Regards,
> Hao
>
> David BY Chan wrote:
>> Hao Zhang wrote:
>>> Hi all,
>>> I got a few questions while using Zest as below,
>>> 1. How to use custom figure for GraphNodes (not tooltips, but the nodes themselves)
>>> 2. After a graph has been created, how to show/hide texts on the nodes (I tried GraphNode#setNodeStyle(), but the graph
>>> was not updated)
>>>
>>> Thanks in advance!
>>>
>>> Regards,
>>> Hao
>> 1. Every GraphNode has a GraphLabel as its figure, so if you use Zest
>> Viewer(JFace style), specify a image in the viewer's labelprovider or
>> directly set the image for GrahpNode through invoking its method
>> *setImage* (SWT style)
>>
>> viewer = new GraphViewer(shell, SWT.NONE);
>> viewer.setContentProvider(new MyContentProvider());
>> viewer.setLabelProvider(new MyLabelProvider(){
>> public Image getImage(Object element) {
>> return custom_image;
>> });
>>
>>
>> Graph g = new Graph(shell, SWT.NONE);
>> GraphNode n = new GraphNode(g, SWT.NONE, "David");
>> n.setImage(image);
>> 2 Because figure is GraphLabel, you can simply do it like below:
>>
>> Hide:
>>
>> node.setText("");
>> //update node style
>> node.setNodeStyle(n.getNodeStyle() | ZestStyles.NODES_HIDE_TEXT);
>>
>> Show:
>> node.setText("New Text");
>> node.setNodeStyle(n.getNodeStyle() & ~ZestStyles.NODES_HIDE_TEXT);
>>
>> Hope this help you!
>>
>> BTW: are you the famous IBM CSDL fellow Zhang Hao?
Previous Topic:Question about creating a new Plug-in
Next Topic:Layer question
Goto Forum:
  


Current Time: Fri Apr 26 19:19:12 GMT 2024

Powered by FUDForum. Page generated in 0.03297 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top