Java 类org.eclipse.draw2d.FigureCanvas 实例源码

项目:neoscada    文件:TextController.java   
public TextController ( final FigureCanvas canvas, final SymbolController controller, final Text element, final ResourceManager manager )
{
    super ( controller, manager );
    this.canvas = canvas;
    this.figure = new Label ( element.getText ()) {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        protected void paintFigure ( final Graphics graphics )
        {
            final Double alpha = getAlpha ();
            if ( alpha != null )
            {
                graphics.setAlpha ( (int) ( Math.max ( 0.0, Math.min ( 1.0, alpha ) ) * 255.0 ) );
            }
            super.paintFigure ( graphics );
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ( );
        }
    };
    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ModuleInstanceLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ModuleInstancePropertyNode.class) && getHost().getModel() instanceof ModuleInstanceNode) {
        ModuleInstancePropertyCreateCommand cmd = new ModuleInstancePropertyCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 2);
        cmd.setNode((ModuleInstancePropertyNode) node);
        cmd.setParent((ModuleInstanceNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ModuleInstancePropertyNode.DEF_WIDTH, ModuleInstancePropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ModuleOperationLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ModuleOperationParameterNode.class) && (getHost().getModel() instanceof ModuleOperationNode)) {
        ModuleOperationNode par = (ModuleOperationNode) getHost().getModel();
        if (!(par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_READ.name()) || par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_WRITE.name()))) {
            ModuleOperationParameterCreateCommand cmd = new ModuleOperationParameterCreateCommand();
            Node node = (Node) request.getNewObject();
            node.setParent((Node) getHost().getModel());
            Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
            Point viewSize = vp.getViewLocation();
            Point p = request.getLocation();
            p.setX(p.x + viewSize.x);
            p.setY(p.y + viewSize.y);
            p = node.getAnchor(p, 2);
            cmd.setNode((ModuleOperationParameterNode) node);
            cmd.setParent((ModuleOperationNode) node.getParent());
            cmd.setLocation(new Rectangle(p.x, p.y, ModuleOperationParameterNode.DEF_WIDTH, ModuleOperationParameterNode.DEF_HEIGHT));
            ret = cmd;
        }
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getMoveBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointMoveCommand cmd = new BendpointMoveCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setIndex(request.getIndex());
    cmd.setNewLocation(p);
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:PlatformConfigurationLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComputingNodeConfigurationNode.class) && (getHost().getModel() instanceof PlatformConfigurationNode)) {
        ComputingNodeConfigurationCreateCommand cmd = new ComputingNodeConfigurationCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComputingNodeConfigurationNode) node);
        cmd.setParent((PlatformConfigurationNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComputingNodeConfigurationNode.DEF_WIDTH, ComputingNodeConfigurationNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalSystemLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalComputingPlatformNode.class) && (getHost().getModel() instanceof LogicalSystemNode)) {
        LogicalComputingPlatformCreateCommand cmd = new LogicalComputingPlatformCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        cmd.setNode((LogicalComputingPlatformNode) node);
        cmd.setParent((LogicalSystemNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingPlatformNode.DEF_WIDTH, LogicalComputingPlatformNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalComputingLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalProcessorsNode.class) && (getHost().getModel() instanceof LogicalComputingNode)) {
        LogicalProcessorsCreateCommand cmd = new LogicalProcessorsCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 2);
        cmd.setNode((LogicalProcessorsNode) node);
        cmd.setParent((LogicalComputingNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalProcessorsNode.DEF_WIDTH, LogicalProcessorsNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalComputingPlatformLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalComputingNode.class) && (getHost().getModel() instanceof LogicalComputingPlatformNode)) {
        LogicalComputingCreateCommand cmd = new LogicalComputingCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((LogicalComputingNode) node);
        cmd.setParent((LogicalComputingPlatformNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingNode.DEF_WIDTH, LogicalComputingNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ComponentNodeLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) {
        ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComponentPropertyNode) node);
        cmd.setParent((ComponentNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ComponentNodeLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) {
        ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComponentPropertyNode) node);
        cmd.setParent((ComponentNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntLogicalSysEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntFinalAssemblyEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntDeploymentEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompImplEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new RefreshAction(this, inp.getFile().getProject().getFullPath(), inp.getFile()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:InitAssemblyEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    EditPartFactory factory = new EditPartFactory();
    FileEditorInput inp = (FileEditorInput) getEditorInput();
    factory.setContainerName(inp.getFile().getProject().getFullPath().toOSString());
    getGraphicalViewer().setEditPartFactory(factory);
    ((FigureCanvas) getGraphicalControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(new ExportImageAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ExportAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateAPIAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateINTAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new GenerateUIDAction(this, inp.getFile().getProject().getFullPath()));
    getActionRegistry().registerAction(new ClearTargetAction(this, inp.getFile().getProject().getFullPath()));
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
}
项目:NEXCORE-UML-Modeler    文件:MessageEditPart.java   
/**
 * @param lnEditparts
 * @return
 */
private boolean isMessageOnLifeLineName() {

    Viewport viewport = ((FigureCanvas) getViewer().getControl()).getViewport();
    int verticalValue = viewport.getVerticalRangeModel().getValue();

    // System.out.println(verticalValue);

    if (verticalValue < getFigure().getBounds().y && verticalValue + 75 > getFigure().getBounds().y) {
        // System.out.println("Figure Location false : " +
        // getFigure().getBounds().y);
        return false;
    } else if (getFigure().getBounds().y < verticalValue) {
        return false;
    }
    // System.out.println("Figure Location true : " +
    // getFigure().getBounds().y);
    return true;
}
项目:NEXCORE-UML-Modeler    文件:SequenceDiagramDropTargetListener.java   
/**
 * @see nexcore.tool.uml.ui.core.diagram.editor.DiagramDropTargetListener#dropCommandForNode(org.eclipse.swt.dnd.DropTargetEvent,
 *      org.eclipse.gef.commands.CompoundCommand,
 *      nexcore.tool.uml.ui.core.project.ITreeNode, int)
 */
@Override
protected void dropCommandForNode(DropTargetEvent event, CompoundCommand commpoundCommand, ITreeNode next, int count) {

    Element treeElement = (Element) next.getEObject();
    int horizontalScrollPoint = 0;
    int verticalScrollPoint = 0;
    Point eventPoint = null;
    Command command = null;
    org.eclipse.draw2d.geometry.Point where = null;

    horizontalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getHorizontalBar()
        .getSelection();
    verticalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getVerticalBar()
        .getSelection();
    eventPoint = diagramEditor.getDiagramGraphicalViewer().getControl().toControl(event.x + horizontalScrollPoint,
        event.y + verticalScrollPoint);

    // y좌표에 +100은 여러개를 Dorp했을때 대각선 아래로 위치하도록 한다.
    where = new org.eclipse.draw2d.geometry.Point(eventPoint.x + (count * 160), eventPoint.y);//20);
    command = new DropLifeLineNotationCommand(UMLMessage.LABEL_ADD_DROP, diagramEditor, treeElement, where);
    ((DropLifeLineNotationCommand) command).setDiagram(this.diagramEditor.getDiagram());
    commpoundCommand.add(command);

}
项目:erflute    文件:PlaceTableAction.java   
@Override
public void execute(Event event) throws Exception {
    final ERDiagram diagram = getDiagram();

    final List<ERTable> input = new ArrayList<>();
    input.addAll(diagram.getDiagramContents().getDiagramWalkers().getTableSet().getList());

    final NodeSelectionDialog dialog =
            new NodeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), diagram);

    final FigureCanvas canvas = (FigureCanvas) oneEditor.getGraphicalViewer().getControl();
    final Point point =
            new Point(canvas.getHorizontalBar().getSelection() + canvas.getClientArea().width / 2, canvas.getVerticalBar()
                    .getSelection() + canvas.getClientArea().height / 2);

    if (dialog.open() == IDialogConstants.OK_ID) {
        final Object[] results = dialog.getResult();
        for (final Object result : results) {
            final ERTable curTable = (ERTable) result;
            final ERVirtualTable virtualTable = new ERVirtualTable(oneEditor.getVirtualDiagram(), curTable);
            virtualTable.setPoint(point.x, point.y);
            getDiagram().addWalkerPlainly(virtualTable);
        }
    }
}
项目:gef-gwt    文件:GwtRulerComposite.java   
private void disposeRulerViewer(GraphicalViewer viewer) {
    if (viewer == null)
        return;
    /*
     * There's a tie from the editor's range model to the RulerViewport (via
     * a listener) to the RulerRootEditPart to the RulerViewer. Break this
     * tie so that the viewer doesn't leak and can be garbage collected.
     */

    dockLayoutPanel.remove(northPanel);
    dockLayoutPanel.remove(westPanel);
    dockLayoutPanel.forceLayout();

    RangeModel rModel = new DefaultRangeModel();
    Viewport port = ((FigureCanvas) viewer.getControl()).getViewport();
    port.setHorizontalRangeModel(rModel);
    port.setVerticalRangeModel(rModel);
    rulerEditDomain.removeViewer(viewer);
    viewer.getRootEditPart().deactivate();
    // viewer.getControl().dispose();
}
项目:snaker-designer    文件:SnakerFormDesignerEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();

    viewer.setRootEditPart(new ScalableFreeformRootEditPart());
    viewer.setEditPartFactory(new FormDesignerEditPartFactory(this));
    ContextMenuProvider provider = new FormContextMenuProvider(viewer,
            actionIds, getActionRegistry());
    viewer.setContextMenu(provider);

    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));

    ((FigureCanvas) viewer.getControl())
            .setScrollBarVisibility(FigureCanvas.ALWAYS);
}
项目:snaker-designer    文件:ProcessDesignerEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();

    GraphicalViewer viewer = getGraphicalViewer();
    viewer.setRootEditPart(rootEditPart);
    getGraphicalViewer().setEditPartFactory(
            new DesignerEditPartFactory(getParentEditor()));
    configureEditPartViewer(viewer);
    ((FigureCanvas) viewer.getControl())
            .setScrollBarVisibility(FigureCanvas.ALWAYS);
    getActionRegistry().registerAction(
            new ToggleGridAction(getGraphicalViewer()));
    getActionRegistry().registerAction(
            new ToggleSnapToGeometryAction(getGraphicalViewer()));
}
项目:snaker-designer    文件:TaskFieldDesignerEditor.java   
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();

    viewer.setRootEditPart(new ScalableFreeformRootEditPart());
    viewer.setEditPartFactory(new TaskFieldEditPartFactory(
            getParentEditor()));
    ContextMenuProvider provider = new FormContextMenuProvider(viewer,
            getParentEditor().getEditActionList(), getParentEditor()
                    .getActionRegistry());
    viewer.setContextMenu(provider);

    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));

    ((FigureCanvas) viewer.getControl())
            .setScrollBarVisibility(FigureCanvas.ALWAYS);
}
项目:birt    文件:ReportViewerKeyHandler.java   
private boolean scrollPageIncrement( GraphicalEditPart part, int code )
{
    if ( !( part.getViewer( ) instanceof DeferredGraphicalViewer ) )
    {
        return false;
    }
    DeferredGraphicalViewer viewer = (DeferredGraphicalViewer) part.getViewer( );
    FigureCanvas canvas = viewer.getFigureCanvas( );

    int increment = 0;
    if ( code == SWT.PAGE_DOWN )
    {
        increment = canvas.getVerticalBar( ).getSelection( )
                + canvas.getVerticalBar( ).getPageIncrement( );
    }
    else if ( code == SWT.PAGE_UP )
    {
        increment = canvas.getVerticalBar( ).getSelection( )
                - canvas.getVerticalBar( ).getPageIncrement( );
    }
    canvas.scrollToY( increment );
    return true;
}
项目:birt    文件:TableCellKeyDelegate.java   
void scrollViewer( KeyEvent event )
{
    if ( !( getViewer( ).getControl( ) instanceof FigureCanvas ) )
        return;
    FigureCanvas figCanvas = (FigureCanvas) getViewer( ).getControl( );
    Point loc = figCanvas.getViewport( ).getViewLocation( );
    Rectangle area = figCanvas.getViewport( )
            .getClientArea( Rectangle.SINGLETON )
            .scale( .1 );
    switch ( event.keyCode )
    {
        case SWT.ARROW_DOWN :
            figCanvas.scrollToY( loc.y + area.height );
            break;
        case SWT.ARROW_UP :
            figCanvas.scrollToY( loc.y - area.height );
            break;
        case SWT.ARROW_LEFT :
            figCanvas.scrollToX( loc.x - area.width );
            break;
        case SWT.ARROW_RIGHT :
            figCanvas.scrollToX( loc.x + area.width );
    }
}
项目:birt    文件:EditorRulerComposite.java   
private void disposeRulerViewer( GraphicalViewer viewer )
{
    if ( viewer == null )
        return;
    /*
     * There's a tie from the editor's range model to the RulerViewport (via
     * a listener) to the RulerRootEditPart to the RulerViewer. Break this
     * tie so that the viewer doesn't leak and can be garbage collected.
     */

    RangeModel rModel = new DefaultRangeModel( );
    Viewport port = ( (FigureCanvas) viewer.getControl( ) ).getViewport( );
    port.setHorizontalRangeModel( new RulerDefaultRangeModel( rModel ) );
    port.setVerticalRangeModel( new RulerDefaultRangeModel( rModel ) );
    rulerEditDomain.removeViewer( viewer );
    viewer.getControl( ).dispose( );
}
项目:birt    文件:EditorDragGuidePolicy.java   
private Dimension getDistance( )
    {
//      Point p = getStartLocation( );
//      
//      Control canvas = getGuideEditPart( ).getViewer( ).getControl( );
//      org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds( );
//  
//      Dimension retValue = new Dimension(rect.width - p.x, p.y);
//      
//      return retValue;

        Point p = getStartLocation( );

        FigureCanvas canvas = ((DeferredGraphicalViewer)getGuideEditPart().getViewer( ).getProperty( GraphicalViewer.class.toString( ))).getFigureCanvas( );
        org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds( );

        Dimension retValue = new Dimension(rect.width - p.x, p.y);
        if (canvas.getVerticalBar( ).isVisible( ))
        {
            retValue.width = retValue.width - canvas.getVerticalBar( ).getSize( ).x;
        }
        return retValue;
    }
项目:seg.jUCMNav    文件:UrnOutlinePage.java   
/**
 * Initialize the graphical overview.
 * 
 */
protected void initializeOverview() {
    if (multieditor.getCurrentPage() == null) {
        overview.setVisible(false);
        thumbnail.deactivate();
        thumbnail = null;
        return;
    }

    RootEditPart rep = multieditor.getCurrentPage().getGraphicalViewer().getRootEditPart();
    if (rep instanceof ScalableFreeformRootEditPart) {
        refreshThumbnail((ScalableFreeformRootEditPart) rep);

        disposeListener = new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                if (thumbnail != null) {
                    thumbnail.deactivate();
                    thumbnail = null;
                }
            }
        };
        ((FigureCanvas) multieditor.getCurrentPage().getGraphicalViewer().getControl()).addDisposeListener(disposeListener);
    }
}
项目:d-case_editor    文件:ModuleUtil.java   
/**
 * Returns the current cursor location for Diagram.
 * 
 * @param argumentEditPart
 *            the argument edit part.
 * @return the current point.
 */
public static Point getCurrentLocation(ArgumentEditPart argumentEditPart) {
    IDiagramGraphicalViewer viewer = DcaseEditorUtil
            .getCurrentDcaseEditor().getDiagramGraphicalViewer();
    FigureCanvas canvas = (FigureCanvas) viewer.getControl();
    // the position of scrollable diagram.
    Point viewPoint = canvas.getViewport().getViewLocation();
    Tool tool = argumentEditPart.getViewer().getEditDomain()
            .getActiveTool();
    AbstractTool aTool = (AbstractTool) tool;
    Point toolLocation = null;
    try {
        Method method = AbstractTool.class.getDeclaredMethod("getLocation"); //$NON-NLS-1$
        method.setAccessible(true);
        toolLocation = ((org.eclipse.draw2d.geometry.Point) method
                .invoke(aTool)).getCopy();
    } catch (Exception e) {
        MessageWriter.writeMessageToConsole(
                Messages.AddPatternContributionItem_0,
                MessageTypeImpl.CREATE_PATTERN_FAILED);
        return new Point(0, 0);
    }
    return new Point(viewPoint.x + toolLocation.x, viewPoint.y
            + toolLocation.y);
}
项目:neoscada    文件:AbstractBaseDraw2DDetailsPart.java   
@Override
public void createPart ( final Composite parent )
{
    super.createPart ( parent );

    this.canvas = new FigureCanvas ( parent );
    this.canvas.setBackground ( Display.getDefault ().getSystemColor ( SWT.COLOR_LIST_BACKGROUND ) );

    this.canvas.setContents ( createRoot () );
}
项目:neoscada    文件:VisualInterfaceViewer.java   
protected FigureCanvas createCanvas ()
{
    final FigureCanvas canvas = new FigureCanvas ( this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE );

    addControlListener ( new ControlAdapter () {
        @Override
        public void controlResized ( final ControlEvent e )
        {
            handleResize ( getBounds () );
        }
    } );

    return canvas;
}
项目:neoscada    文件:ImageController.java   
public ImageController ( final FigureCanvas canvas, final SymbolController controller, final Image element, final SymbolLoader symbolLoader, final ResourceManager manager, final FactoryContext factoryContext )
{
    super ( controller, manager );
    this.factoryContext = factoryContext;

    this.symbolLoader = symbolLoader;

    this.figure = new Label () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };
    controller.addElement ( element, this );

    applyCommon ( element );
    setImage ( element.getUri () );
}
项目:neoscada    文件:BasicViewElementFactory.java   
public BasicViewElementFactory ( final FigureCanvas canvas, final ResourceManager manager, final SymbolLoader symbolLoader, final FactoryContext factoryContext )
{
    this.manager = manager;
    this.canvas = canvas;
    this.symbolLoader = symbolLoader;
    this.symbolCache = new HashMap<URI, XMISymbolLoader> ();

    this.factoryContext = factoryContext == null ? FactoryContext.DEFAULT : factoryContext;
}
项目:neoscada    文件:BasicViewElementFactory.java   
public BasicViewElementFactory ( final FigureCanvas canvas, final ResourceManager manager, final SymbolLoader symbolLoader, final FactoryContext factoryContext, final Map<URI, XMISymbolLoader> symbolCache )
{
    this.manager = manager;
    this.canvas = canvas;
    this.symbolLoader = symbolLoader;
    this.symbolCache = symbolCache;

    this.factoryContext = factoryContext == null ? FactoryContext.DEFAULT : factoryContext;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointCreateCommand cmd = new BendpointCreateCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getDeleteBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointDeleteCommand cmd = new BendpointDeleteCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointCreateCommand cmd = new BendpointCreateCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getDeleteBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointDeleteCommand cmd = new BendpointDeleteCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getMoveBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointMoveCommand cmd = new BendpointMoveCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setIndex(request.getIndex());
    cmd.setNewLocation(p);
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) request.getSource().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointCreateCommand cmd = new BendpointCreateCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getDeleteBendpointCommand(BendpointRequest request) {
    Viewport vp = ((FigureCanvas) request.getSource().getViewer().getControl()).getViewport();
    Point viewSize = vp.getViewLocation();
    Point p = request.getLocation();
    p.setX(p.x + viewSize.x);
    p.setY(p.y + viewSize.y);
    BendpointDeleteCommand cmd = new BendpointDeleteCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setLocation(p);
    cmd.setIndex(request.getIndex());
    return cmd;
}