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

项目: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;
}
项目:ermaster-k    文件:ERDiagramOutlinePage.java   
private void showThumbnail() {
    // RootEditPartのビューをソースとしてサムネイルを作成
    ScalableFreeformRootEditPart editPart = (ScalableFreeformRootEditPart) this.graphicalViewer
            .getRootEditPart();

    if (this.thumbnail != null) {
        this.thumbnail.deactivate();
    }

    this.thumbnail = new ScrollableThumbnail((Viewport) editPart
            .getFigure());
    this.thumbnail.setSource(editPart
            .getLayer(LayerConstants.PRINTABLE_LAYERS));

    this.lws.setContents(this.thumbnail);

}
项目: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;
}
项目:PDFReporter-Studio    文件:JDReportOutlineView.java   
/**
 * Initialize overview.
 */
protected void initializeOverview() {
    LightweightSystem lws = new J2DLightweightSystem(overview);

    RootEditPart rep = editor.getGraphicalViewer().getRootEditPart();
    if (rep instanceof MainDesignerRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
        thumbnail = new JSSScrollableThumbnail((Viewport) root.getFigure(), (MRoot)getViewer().getContents().getModel());
        thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
        lws.setContents(thumbnail);
        disposeListener = new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                if (thumbnail != null) {
                    thumbnail.deactivate();
                    thumbnail = null;
                }
            }
        };
        editor.getEditor().addDisposeListener(disposeListener);
    }
    lws.setControl(overview);
}
项目:OpenSPIFe    文件:TickIntervalsFigure.java   
protected void paintTickIntervals(Graphics g) {
    if (tickManager == null) {
        return;
    }
    Viewport viewport = TimelineUtils.getViewport(this);

    int scrollbarPosition = viewport.getHorizontalRangeModel().getValue();
    int optimizeClipLeft = scrollbarPosition - 100;
    int optimizeClipRight = scrollbarPosition + viewport.getBounds().width + 100;

    SortedSet<Tick> ticks = tickManager.getTicks(calendar, g);

    g.setLineStyle(SWT.LINE_DOT);
    g.setForegroundColor(ColorConstants.black);
    paintIntervals(g, ticks, optimizeClipLeft, optimizeClipRight);
}
项目:ermaster-nhit    文件:ERDiagramOutlinePage.java   
private void showThumbnail() {
    // RootEditPartのビューをソースとしてサムネイルを作成
    ScalableFreeformRootEditPart editPart = (ScalableFreeformRootEditPart) this.graphicalViewer
            .getRootEditPart();

    if (this.thumbnail != null) {
        this.thumbnail.deactivate();
    }

    this.thumbnail = new ScrollableThumbnail((Viewport) editPart
            .getFigure());
    this.thumbnail.setSource(editPart
            .getLayer(LayerConstants.PRINTABLE_LAYERS));

    this.lws.setContents(this.thumbnail);

}
项目:gef-gwt    文件:ViewportMouseWheelHelper.java   
/**
 * Finds the viewport of the given EditPart and scrolls it as requested. If
 * it can't be scrolled then leaves doit to be true so that the given
 * EditPart's ancestors might have a chance to scroll.
 * 
 * @see org.eclipse.gef.MouseWheelHelper#handleMouseWheelScrolled(org.eclipse.swt.widgets.Event)
 */
public void handleMouseWheelScrolled(Event event) {
    Viewport viewport = findViewport(owner);
    if (viewport == null || !viewport.isShowing())
        return;
    RangeModel rModel = viewport.getVerticalRangeModel();
    if (rModel.getExtent() < (rModel.getMaximum() - rModel.getMinimum())) {
        int currentPos = rModel.getValue();
        int scrollHeight = lineHeight;
        if (event.detail == SWT.SCROLL_PAGE)
            scrollHeight = pageHeight > lineHeight ? pageHeight
                    : Math.max(
                            lineHeight,
                            viewport.getClientArea(Rectangle.SINGLETON).height - 26);
        scrollHeight *= event.count;
        viewport.setVerticalLocation(currentPos - scrollHeight);
        if (rModel.getValue() != currentPos)
            event.doit = false;
    }
}
项目:gef-gwt    文件:ScrollableSelectionFeedbackEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.SelectionEditPolicy#activate()
 */
public void activate() {
    super.activate();
    // register listeners to all viewports in the host figure's path;
    // listeners
    // to the host figure itself will be registered within showFeedback()
    // and
    // unregistered within hideFeedback()
    for (Iterator iterator = ViewportUtilities.getViewportsPath(
            getHostFigureViewport(),
            ViewportUtilities.getRootViewport(getHostFigure())).iterator(); iterator
            .hasNext();) {
        Viewport viewport = (Viewport) iterator.next();
        viewport.addPropertyChangeListener(viewportViewLocationChangeListener);
    }
}
项目:gef-gwt    文件:ScrollableSelectionFeedbackEditPolicy.java   
private static Rectangle getAbsoluteViewportArea(Viewport viewport) {
    Rectangle viewportParentBounds = viewport.getParent().getBounds()
            .getCopy();

    int widthMax = viewport.getHorizontalRangeModel().getMaximum();
    int widthMin = viewport.getHorizontalRangeModel().getMinimum();
    int heightMax = viewport.getVerticalRangeModel().getMaximum();
    int heightMin = viewport.getVerticalRangeModel().getMinimum();

    viewportParentBounds
            .setSize(widthMax - widthMin, heightMax - heightMin);
    viewportParentBounds.translate(widthMin, heightMin);
    viewportParentBounds.translate(viewport.getViewLocation().getNegated());
    viewport.getParent().translateToAbsolute(viewportParentBounds);
    return viewportParentBounds;
}
项目: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();
}
项目:antlr4ide    文件:RailroadView.java   
public void reveal(final IFigure figure) {
  Viewport viewport = canvas.getViewport();
  Rectangle viewportBounds = viewport.getBounds().getCopy();
  viewportBounds.translate(viewport.getViewLocation());
  Rectangle figureBounds = figure.getBounds().getCopy();
  figure.translateToAbsolute(figureBounds);
  figureBounds.translate(viewport.getViewLocation());
  if (!viewportBounds.contains(figureBounds)) {
    int newX = viewportBounds.x;
    int newY = viewportBounds.y;
    if(viewportBounds.x > figureBounds.x) {
      newX = figureBounds.x;
    } else if(viewportBounds.x + viewportBounds.getRight().x < figureBounds.getRight().x) {
      newX = figureBounds.getRight().x - viewportBounds.width;
    }
    if(viewportBounds.y > figureBounds.y) {
      newY = figureBounds.y;
    } else if(viewportBounds.getBottom().y < figureBounds.getBottom().y) {
      newY = figureBounds.getBottom().y - viewportBounds.height;
    }
    canvas.scrollSmoothTo(newX, newY);
  }
}
项目: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( );
}
项目: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;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:BendpointPolicy.java   
@Override
protected Command getMoveBendpointCommand(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);
    BendpointMoveCommand cmd = new BendpointMoveCommand();
    cmd.setLink((Link) request.getSource().getModel());
    cmd.setIndex(request.getIndex());
    cmd.setNewLocation(p);
    return cmd;
}
项目:Hydrograph    文件:CustomPaletteViewer.java   
private void callHookRootFigure() {
    if (getFigureCanvas() == null)
        return;
    if (((GraphicalEditPart) getRootEditPart()).getFigure() instanceof Viewport) {
        getFigureCanvas().setViewport((Viewport) ((GraphicalEditPart) getRootEditPart()).getFigure());
    } else {
        getFigureCanvas().setContents(((GraphicalEditPart) getRootEditPart()).getFigure());
    }
}
项目:bdf2    文件:DbToolGefEditorOutlinePage.java   
public void createEyeViewControl(Composite parent) {
    Canvas canvas = new Canvas(parent, SWT.NONE);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    LightweightSystem liSystem = new LightweightSystem(canvas);
    ScalableFreeformRootEditPart rootEditPart = ((ScalableFreeformRootEditPart) dbToolGefEditor.getGraphicalViewer().getRootEditPart());
    ScrollableThumbnail thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setSource(rootEditPart.getLayer(LayerConstants.SCALABLE_LAYERS));
    liSystem.setContents(thumbnail);
}
项目:subclipse    文件:OverviewOutlinePage.java   
public void createControl(Composite parent) {
    // create canvas and lws
    overview = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(overview);
    // create thumbnail
    thumbnail =
        new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(
            rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
}
项目:subclipse    文件:GraphEditPart.java   
private void scrollTo(int ax, int ay) {
        Viewport viewport = ((FigureCanvas)viewer.getControl()).getViewport();
        Rectangle vbounds = viewport.getBounds();
        Point p = new Point(ax, ay);
//      target.translateToAbsolute(p); // TODO
        int x = p.x-vbounds.width/2;
        int y = p.y-vbounds.height/2;
        viewport.setHorizontalLocation(x);
        viewport.setVerticalLocation(y);
    }
项目:ForgedUI-Eclipse    文件:DiagramOutlinePage.java   
public void createControl(Composite parent) {
    // create canvas and lws
    overview = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(overview);
    // create thumbnail
    thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(rootEditPart
            .getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
}
项目:ForgedUI-Eclipse    文件:DiagramOutlinePage2.java   
protected void initializeOverview() {
    LightweightSystem lws = new LightweightSystem(overview);
    if (rep instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart)rep;
        thumbnail = new ScrollableThumbnail((Viewport)root.getFigure());
        thumbnail.setBorder(new MarginBorder(3));
        thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
        lws.setContents(thumbnail);
    }
}
项目:NEXCORE-UML-Modeler    文件:AbstractDiagramEditor.java   
public void createControl(Composite parent) {
    control = new SashForm(parent, SWT.NONE);

    getViewer().createControl(parent);

    getViewer().setEditDomain(getEditDomain());
    getSelectionSynchronizer().addViewer(getViewer());

    Canvas canvas = new Canvas(control, SWT.BORDER);
    LightweightSystem lws = new LightweightSystem(canvas);

    thumbnail = new ScrollableThumbnail((Viewport) ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getFigure());
    thumbnail.setSource(((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS));

    lws.setContents(thumbnail);

    disposeListener = new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (thumbnail != null) {
                thumbnail.deactivate();
                thumbnail = null;
            }
        }
    };
    getGraphicalViewer().getControl().addDisposeListener(disposeListener);

}
项目:NEXCORE-UML-Modeler    文件:SequenceDiagramEditPart.java   
/**
 * refreshNameHeaders
 * 
 * @param viewport
 *            void
 */
@SuppressWarnings("unchecked")
public void refreshNameHeaders() {
    try {
        Viewport viewport = ((FigureCanvas) getViewer().getControl()).getViewport();
        int verticalValue = viewport.getVerticalRangeModel().getValue();
        if (verticalValue > 30) {
            for (int i = 0; i < nameHeaderList.size(); i++) {
                nameHeader = nameHeaderList.get(i);
                nameHeader.setVisible(true);
            }
        } else {
            for (int i = 0; i < nameHeaderList.size(); i++) {
                nameHeader = nameHeaderList.get(i);
                nameHeader.setVisible(false);
            }
        }
        List<EditPart> ediPartList = getChildren();
        for (int i = 0; i < ediPartList.size(); i++) {
            if (ediPartList.get(i) instanceof LifeLineNameHeaderEditPart) {
                ((LifeLineNameHeaderEditPart) ediPartList.get(i)).refreshVisuals();
            }
        }
    } catch (Exception e) {
        Log.error(UMLMessage.LABEL_SEQUENCE_DIAGRAM_EDIT_PART_REFRESH_NAME_HEADERS_ERROR + e);
    }
}
项目:NEXCORE-UML-Modeler    文件:MessageBendpointEditPolicy.java   
/**
 * checkScroll
 * 
 * 스크롤바 범위 밖으로 메시지를 이동 시킬때 스크롤을 강제적으로 이동시켜줌
 * 
 * @param request
 *            void
 */
private void checkScroll(BendpointRequest request) {
    GraphicalViewer viewer = (GraphicalViewer) ((ScalableFreeformRootEditPart) request.getSource().getParent()).getViewer();
    FigureCanvas canvas = (FigureCanvas) viewer.getControl();
    ScrollBar verticalBar = canvas.getVerticalBar();
    Viewport viewport = canvas.getViewport();

    if (canvas.getSize().y < request.getLocation().y) {
        viewport.setVerticalLocation(request.getLocation().y - canvas.getSize().y + verticalBar.getSelection());
    } else if (request.getLocation().y < 0) {
        viewport.setVerticalLocation(request.getLocation().y + verticalBar.getSelection());
    }
}
项目:triquetrum    文件:DiagramEditorOutlinePage.java   
/**
 * Creates the graphical Thumbnail viewer.
 */
protected void createThumbnailViewer() {
  LightweightSystem lws = new LightweightSystem(_overview);
  ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) _graphicalViewer.getRootEditPart();
  _thumbnail = new FixedScrollableThumbnail((Viewport) rootEditPart.getFigure());
  _thumbnail.setBorder(new MarginBorder(3));
  _thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
  lws.setContents(_thumbnail);
}
项目:bts    文件:TextAnnotationsComposite.java   
public void reveal(IFigure target) {
    Viewport port = canvas.getViewport();
    Rectangle exposeRegion = target.getBounds().getCopy();
    target = target.getParent();
    while (target != null && target != port) {
        target.translateToParent(exposeRegion);
        target = target.getParent();
    }
    exposeRegion.expand(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));

    canvas.scrollSmoothTo(finalLocation.x, finalLocation.y);
}
项目:bts    文件:SignTextComposite.java   
public void reveal(IFigure target) {
    Viewport port = canvas.getViewport();
    Rectangle exposeRegion = target.getBounds().getCopy();
    target = target.getParent();
    while (target != null && target != port) {
        target.translateToParent(exposeRegion);
        target = target.getParent();
    }
    exposeRegion.expand(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));

    canvas.scrollSmoothTo(finalLocation.x, finalLocation.y);
}