本文整理汇总了Java中org.eclipse.draw2d.Locator.relocate方法的典型用法代码示例。如果您正苦于以下问题:Java Locator.relocate方法的具体用法?Java Locator.relocate怎么用?Java Locator.relocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Locator
的用法示例。
在下文中一共展示了Locator.relocate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshNodeConnection
import org.eclipse.draw2d.Locator; //导入方法依赖的package包/类
/**
* Refresh this node SplineConnection's children (its decorations). Calling the locator's relocate() moves these decorations.
*
* @param conn
* the node connection
* @param force
* force a refresh that might cause infinite loops
* @return true if we could refresh (edit part and figure exist)
*/
public boolean refreshNodeConnection(NodeConnection conn, boolean force) {
NodeConnectionEditPart nc = (NodeConnectionEditPart) getViewer().getEditPartRegistry().get(conn);
if (nc != null) {
// seems to cause infinite loops with connection router.
if (force)
nc.refreshVisuals();
for (Iterator iter = nc.getFigure().getChildren().iterator(); iter.hasNext();) {
IFigure fig = (IFigure) iter.next();
if (fig instanceof TimeoutPathFigure || fig instanceof Label) {
Locator loc = (Locator) ((SplineConnection) nc.getFigure()).getLayoutManager().getConstraint(fig);
// don't know why isn't refreshing stub/timer labels
// probably has to do with implementation of locator
// Seems to be useful when moving the node connection
// indirectly.
loc.relocate(fig);
}
}
return true;
}
return false;
}
示例2: reveal
import org.eclipse.draw2d.Locator; //导入方法依赖的package包/类
public void reveal( EditPart part )
{
// In some case, the editor control is not created, but get the sync selection event.
// Fix this problem temporary.
if(getFigureCanvas( )==null || getFigureCanvas( ).isDisposed( ))
{
return;
}
Viewport port = getFigureCanvas( ).getViewport( );
IFigure target = ( (GraphicalEditPart) part ).getFigure( );
Rectangle exposeRegion = target.getBounds( ).getCopy( );
// Get the primary editpolicy
EditPolicy policy = part.getEditPolicy( EditPolicy.PRIMARY_DRAG_ROLE );
// If the policy let us access the handles, proceed, otherwise
// default to original behaviour
if ( !( policy instanceof ISelectionHandlesEditPolicy ) )
{
super.reveal( part );
return;
}
// First translate exposeRegion to the root level
target = target.getParent( );
while ( target != null && target != port )
{
target.translateToParent( exposeRegion );
target = target.getParent( );
}
// Merge selection handles if any to the exposeRegion
List handles = ( (ISelectionHandlesEditPolicy) policy ).getHandles( );
for ( Iterator iter = handles.iterator( ); iter.hasNext( ); )
{
AbstractHandle handle = (AbstractHandle) iter.next( );
Locator locator = handle.getLocator( );
locator.relocate( handle );
exposeRegion.union( handle.getBounds( ).getCopy( ) );
}
exposeRegion.getExpanded( 5, 5 );
Dimension viewportSize = port.getClientArea( ).getSize( );
Point topLeft = exposeRegion.getTopLeft( );
Point bottomRight = exposeRegion.getBottomRight( )
.translate( viewportSize.getNegated( ) );
Point finalLocation = new Point( );
if ( viewportSize.width < exposeRegion.width )
finalLocation.x = Math.min( bottomRight.x, Math.max( topLeft.x,
port.getViewLocation( ).x ) );
else
finalLocation.x = Math.min( topLeft.x, Math.max( bottomRight.x,
port.getViewLocation( ).x ) );
if ( viewportSize.height < exposeRegion.height )
finalLocation.y = Math.min( bottomRight.y, Math.max( topLeft.y,
port.getViewLocation( ).y ) );
else
finalLocation.y = Math.min( topLeft.y, Math.max( bottomRight.y,
port.getViewLocation( ).y ) );
getFigureCanvas( ).scrollSmoothTo( finalLocation.x, finalLocation.y );
}