[ZEST]Zoom to a rectangle area [message #247851] |
Fri, 20 March 2009 22:35  |
Eclipse User |
|
|
|
Originally posted by: zzhangh.cn.ibm.com
Hi,
What I'm trying to achieve is to display a large graph.
Does zest supports letting user select an area on the canvas and zoom to that area? and thumbnail as well?
If not, can you shed some lights on how best to implement this, thanks!
Regards,
Hao
|
|
|
Re: [ZEST]Zoom to a rectangle area [message #248814 is a reply to message #247851] |
Tue, 05 May 2009 20:42  |
Eclipse User |
|
|
|
I have a code for implementing a thumbnail directly in a view... to use,
uou can extend ThumbnailView in the following way:
public class DummieView extends ThumbnailView{
/** */
//private Graph graph;
int level = 0;
/* (non-Javadoc)
* @see
edu.uci.lighthouse.ui.views.ThumbnailView#createPartControl( org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
final Graph graph = new Graph(parent, SWT.None);
graph.setLayoutAlgorithm(new
SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
// Set the parameters for the thumbnail view
setViewport(graph.getViewport());
setSource(graph.getContents());
setMainComposite(graph);
}
}
xx-------------------------------------------xx
public class ThumbnailView extends ViewPart{
/** */
Composite composite;
/** */
FigureCanvas thumbnail;
/** */
ScrollableThumbnail tb;
/* (non-Javadoc)
* @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.ecli pse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
FormData data;
parent.setLayout(new FormLayout());
data = new FormData();
data.top = new FormAttachment(100,-130);
data.left = new FormAttachment(100,-130);
data.right = new FormAttachment(100,-30);
data.bottom = new FormAttachment(100,-30);
thumbnail = new FigureCanvas(parent, SWT.NONE);
thumbnail.setBackground(ColorConstants.white);
thumbnail.setLayoutData(data);
tb = new ScrollableThumbnail();
tb.setBorder(new LineBorder(1));
thumbnail.setContents(tb);
}
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
@Override
public void setFocus() {
if (composite != null){
composite.setFocus();
}
}
/**
* @param port
*/
protected void setViewport(Viewport port){
if (tb != null) {
tb.setViewport(port);
}
}
/**
* @param fig
*/
protected void setSource(IFigure fig){
if (tb != null){
tb.setSource(fig);
}
}
/**
* @param composite
*/
protected void setMainComposite(Composite composite){
FormData data = new FormData();
data.top = new FormAttachment(0,0);
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(100,0);
data.bottom = new FormAttachment(100,0);
composite.setLayoutData(data);
this.composite = composite;
}
}
Hao Zhang wrote:
> Hi,
> What I'm trying to achieve is to display a large graph.
> Does zest supports letting user select an area on the canvas and zoom to that area? and thumbnail as well?
> If not, can you shed some lights on how best to implement this, thanks!
>
> Regards,
> Hao
|
|
|
Powered by
FUDForum. Page generated in 0.03702 seconds