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

项目:OpenSPIFe    文件:TimelineNodeMoveEditPolicy.java   
private Rectangle getClipBounds() {
    final GraphicalEditPart owner = getOwner();
    Rectangle r = null;
    IFigure f = owner.getFigure();
    while (f != null) {
        if (f instanceof ScrollPane) {
            if (r == null) {
                r = new Rectangle(f.getClientArea());
            } else {
                r = r.intersect(f.getClientArea());
            }
        }
        f = f.getParent();
    }
    return r;
}
项目:OpenSPIFe    文件:Timeline.java   
public void doHorizontalScroll(GraphicalEditPart ep) {
    IFigure figure = ep.getFigure();
    final Rectangle bounds = figure.getBounds().getCopy();
    IFigure parent = figure.getParent();

    int currentScrollPosition = horzRangeModel.getValue();
    TimelineViewer timelineViewer = (TimelineViewer) ep.getViewer();
    ScrollPane dataScrollPane = timelineViewer.getTimelineEditPart().getDataScrollPane();
    Rectangle viewportBounds = dataScrollPane.getViewport().getBounds();
    int viewportWidth = viewportBounds.width;

    int vLeft = currentScrollPosition;
    int vRight = vLeft + viewportWidth;

    int pLeft = parent.getBounds().x;
    int left = bounds.x - pLeft;
    int right = left + bounds.width;

    if (left < vLeft) {
        horzRangeModel.setValue(left);
    } else if (right > vRight) {
        horzRangeModel.setValue(right - viewportWidth);
    }
}
项目:wt-studio    文件:TableModelFigure.java   
public TableModelFigure()
{
    ToolbarLayout layout = new ToolbarLayout();
    layout.setHorizontal(true);
    layout.setSpacing(10);
    layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);

    setLayoutManager(new FillLayout());
    setOpaque(true);
    setBackgroundColor(ColorConstants.white);
    border = new FrameBorder("列表");
    border.setLabel("Block");
    this.setBorder(border);
    ScrollPane scrollpane = new ScrollPane();
    scrollpane.setHorizontalScrollBarVisibility(1);
    scrollpane.setVerticalScrollBarVisibility(0);
    headerFigure = new FreeformLayer();
    headerFigure.setLayoutManager(new ScrollAreaLayout());
    headerFigure.setBackgroundColor(ColorConstants.white);
    add(scrollpane);
    scrollpane.setViewport(new FreeformViewport());
    scrollpane.setContents(headerFigure);
}
项目:ForgedUI-Eclipse    文件:PickerColumnFigure.java   
public PickerColumnFigure() {
    pane = new FreeformLayer();
    pane.setLayoutManager(new FreeformLayout());
    setLayoutManager(new StackLayout());
    container = new TitaniumFigure();
    container.setLayoutManager(new FreeformLayout());
    pane.add(container);

    scrollpane = new ScrollPane();
    scrollpane.setHorizontalScrollBarVisibility(ScrollPane.NEVER);
    scrollpane.setVerticalScrollBarVisibility(ScrollPane.NEVER);
    scrollpane.setViewport(new FreeformViewport());
    scrollpane.setContents(pane);
    add(scrollpane);
}
项目:ForgedUI-Eclipse    文件:ScrollViewFigure.java   
public ScrollViewFigure() {
    pane = new FreeformLayer();
    pane.setLayoutManager(new FreeformLayout());
    setLayoutManager(new StackLayout());
    container = new TitaniumFigure();
    container.setLayoutManager(new FreeformLayout());
    pane.add(container);

    scrollpane = new ScrollPane();
    scrollpane.setScrollBarVisibility(ScrollPane.AUTOMATIC);
    scrollpane.setViewport(new FreeformViewport());
    scrollpane.setContents(pane);
    add(scrollpane);
}
项目:OpenSPIFe    文件:TimelineViewer.java   
/**
 * Replace the range model for this viewer
 * 
 * @param rangeModel
 */
public void setHorizontalRangeModel(RangeModel rangeModel) {
    AbstractTimelineEditPart timelineEditPart = getTimelineEditPart();
    ScrollPane dataScrollPane = timelineEditPart.getDataScrollPane();
    Viewport viewport = dataScrollPane.getViewport();
    viewport.setHorizontalRangeModel(rangeModel);
}
项目:OpenSPIFe    文件:TimelineViewer.java   
public void scrollToEditPart(final EditPart editPart) {
        EditPart parentEditPart = editPart;
        while (parentEditPart != null && !(parentEditPart instanceof ScrollingGraphicalEditPart)) {
            parentEditPart = parentEditPart.getParent();
        }

        if(!TimelineUtils.isScrollable(editPart)) {
            return;
        }

        if (parentEditPart != null) {
            ScrollingGraphicalEditPart scrollingEP = (ScrollingGraphicalEditPart) parentEditPart;
            final IFigure figure = ((GraphicalEditPart)editPart).getFigure();
            final ScrollPane scrollPane = (ScrollPane) scrollingEP.getFigure();
            SELECTION_MODE selectionMode = getTimeline().getSelectionMode();
            if (selectionMode == SELECTION_MODE.SCROLL_TO_CENTER) {
                doScrollCenterToEditPart(scrollPane, figure, 0.5f, 0.5f);
                timeline.doVerticalScroll(TimelineViewer.this, (GraphicalEditPart) editPart);
            } else {
                Rectangle bounds = figure.getBounds();
                Rectangle clientArea = scrollPane.getClientArea();
                boolean outOfBounds = bounds.height != 0 && bounds.width != 0
//                      && (bounds.x < clientArea.x || (bounds.x + bounds.width > clientArea.x + clientArea.width));
                        && (bounds.x >= clientArea.x + clientArea.width || (bounds.x + bounds.width <= clientArea.x));
                if (outOfBounds) {
                    if (selectionMode == SELECTION_MODE.SCROLL_TO_VISIBLE) {
                        doScrollToEditPart(scrollPane, figure);
                    } else if (selectionMode == SELECTION_MODE.SCROLL_TO_LEFT_JUSTIFY) {
                        doScrollCenterToEditPart(scrollPane, figure, 0f, 0.5f);
                    }
                }
            }
        }
    }
项目:OpenSPIFe    文件:TimelineViewer.java   
public static void doScrollCenterToEditPart(final ScrollPane scrollPane, final IFigure figure, float percentFromLeft, float percentFromTop) {
    Rectangle bounds = figure.getBounds().getCopy();
    // because GEF is in absolute coords, we need to adjust for that
    if (figure.getParent() != null) {
        Rectangle parentBounds = figure.getParent().getBounds();
        Rectangle clientArea = scrollPane.getClientArea();

        int x = (int) (bounds.x - parentBounds.x - clientArea.width * percentFromLeft + bounds.width*percentFromLeft);
        int y = (int) (bounds.y - parentBounds.y - clientArea.height * percentFromTop + bounds.height*percentFromTop);

        bounds.x = x;
        bounds.y = y;
    }
    scrollPane.scrollTo(bounds.getLocation());
}
项目:OpenSPIFe    文件:SplitScrollEditPartFactory.java   
@Override
public void notifyChanged(Notification notification) {
    Object f = notification.getFeature();
    if (TimelinePackage.Literals.PAGE__ZOOM_OPTION == f) {
        final TimelineViewer viewer = getViewer();
        // get the location we are zooming to
        int x = viewer.getZoomManager().getZoomLocation().x;
        int width = viewer.getTimelineEditPart().getDataScrollPane().getBounds().width;
        final float split[] = { 0.5f };
        if (x > -1 && width > x) {
            split[0] = ((float)x)/width;
        }
        // set up a listener to scroll to location after layout is complete
        final ScrollPane dataScrollPane = viewer.getTimelineEditPart().getDataScrollPane();
        ScrollBar hbar = dataScrollPane.getHorizontalScrollBar();
        final int oldCenter = hbar.getValue() + ((int)(hbar.getExtent()*split[0]));
        ZoomOption oval = (ZoomOption)notification.getOldValue();
        ZoomOption nval = (ZoomOption)notification.getNewValue();
        final double d = ((double)oval.getMsInterval()) / nval.getMsInterval();
        GEFUtils.runLaterInDisplayThread(ScrollPaneEditPart.this, new Runnable() {
            @Override
            public void run() {
                HbarUpdater updater = new HbarUpdater(viewer.getTimeline(), dataScrollPane, (int)(d * oldCenter)
                        , split[0], viewer.getZoomManager().getZoomDate());
                dataScrollPane.addLayoutListener(updater);
                refresh();
            }
        });
    } else if (TimelinePackage.Literals.PAGE__CURRENT_PAGE_EXTENT == f
                || TimelinePackage.Literals.PAGE__START_TIME == f
                || TimelinePackage.Literals.PAGE__DURATION == f) {
        GEFUtils.runLaterInDisplayThread(ScrollPaneEditPart.this, new Runnable() {
            @Override
            public void run() {
                refresh();
            }
        });
    }
}
项目:OpenSPIFe    文件:SplitScrollEditPartFactory.java   
public HbarUpdater(Timeline timeline, ScrollPane sp, int newCenter, float split, Date centerDate) {
    this.timeline = timeline;
    this.sp = sp;
    this.newCenter = newCenter;
    this.split = split;
    this.centerDate = centerDate;
}
项目:OpenSPIFe    文件:AbstractTimelineEditPart.java   
@Override
protected IFigure createFigure() {
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setOpaque(false);
    scrollPane.setBackgroundColor(ColorConstants.white);
    return scrollPane;
}
项目:OpenSPIFe    文件:TimelineRootEditPart.java   
@Override
protected ScrollPane getTargetScrollPane(TimelineViewer viewer) {
    if (viewer != null && viewer.getTimelineEditPart() != null) {
        return viewer.getTimelineEditPart().getHeaderScrollPane();
    }
    return null;
}
项目:OpenSPIFe    文件:TimelineRootEditPart.java   
@Override
protected ScrollPane getTargetScrollPane(TimelineViewer viewer) {
    if (viewer != null && viewer.getTimelineEditPart() != null) {
        return viewer.getTimelineEditPart().getDataScrollPane();
    }
    return null;
}
项目:OpenSPIFe    文件:SplitFigureLayout.java   
private static IFigure getContents(IFigure figure) {
    if (figure == null) {
        return null;
    }

    if (figure instanceof ScrollPane) {
        IFigure contents = ((ScrollPane)figure).getContents();
        if (contents != null) {
            return contents;
        }
    }
    return figure;
}
项目:gef-gwt    文件:OverlayScrollPaneLayout.java   
/**
 * {@inheritDoc} In OverlayScrollPane, scrollbars are overlayed on top of
 * the Viewport, so the preferred size is just the Viewports preferred size.
 * 
 * @since 2.0
 */
protected Dimension calculatePreferredSize(IFigure container, int wHint,
        int hHint) {
    ScrollPane scrollpane = (ScrollPane) container;
    Insets insets = scrollpane.getInsets();

    int excludedWidth = insets.getWidth();
    int excludedHeight = insets.getHeight();

    return scrollpane
            .getViewport()
            .getPreferredSize(wHint - excludedWidth, hHint - excludedHeight)
            .getExpanded(excludedWidth, excludedHeight);
}
项目:gef-gwt    文件:DrawerFigure.java   
private void createScrollpane() {
    scrollpane = new ScrollPane();
    scrollpane.getViewport().setContentsTracksWidth(true);
    scrollpane.setMinimumSize(new Dimension(0, 0));
    scrollpane.setHorizontalScrollBarVisibility(ScrollPane.NEVER);
    scrollpane.setVerticalScrollBar(new PaletteScrollBar());
    scrollpane.getVerticalScrollBar().setStepIncrement(20);
    scrollpane.setLayoutManager(new OverlayScrollPaneLayout());
    scrollpane.setContents(new Figure());
    scrollpane.getContents().setOpaque(true);
    scrollpane.getContents().setBackgroundColor(
            PaletteColorUtil.WIDGET_LIST_BACKGROUND);
}
项目:gef-gwt    文件:DrawerFigure.java   
public void setAnimating(boolean isAnimating) {
    if (isAnimating) {
        if (scrollpane.getParent() != this) {
            addedScrollpane = true;
            add(scrollpane);
        }
        scrollpane.setVerticalScrollBarVisibility(ScrollPane.NEVER);
    } else {
        scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC);
        if (addedScrollpane) {
            remove(scrollpane);
            addedScrollpane = false;
        }
    }
}
项目:wt-studio    文件:ITableModelFigure.java   
public ITableModelFigure()
{
    ToolbarLayout layout = new ToolbarLayout();
    //layout.setSpacing(10);
    layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
    setLayoutManager(layout);
    setOpaque(true);
    setBackgroundColor(ColorConstants.white);
    border = new  IFrameBorder();
    setBorder(border);
    this.add(new ScrollPane());
}
项目:ForgedUI-Eclipse    文件:PickerColumnFigure.java   
public ScrollPane getScrollPane(){
    return scrollpane;
}
项目:ForgedUI-Eclipse    文件:ScrollViewFigure.java   
private int getScrollVisibility(Boolean h){
    return h == null ? ScrollPane.AUTOMATIC :
        (h ? ScrollPane.ALWAYS : ScrollPane.NEVER);
}
项目:NEXCORE-UML-Modeler    文件:ScrollableEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getContentPane()
 */
@Override
public IFigure getContentPane() {
    return ((ScrollPane) this.getFigure()).getContents();
}
项目:OpenSPIFe    文件:TimelineViewer.java   
public void centerCursorTimeOnHorzLocation(int x) {
    ScrollPane dataScrollPane = getTimelineEditPart().getDataScrollPane();
    int local = x - dataScrollPane.getBounds().x + dataScrollPane.getViewport().getHorizontalRangeModel().getValue();
    getTimeline().scrollTo(getTimeline().getCursorTime(), local);
}
项目:OpenSPIFe    文件:SplitScrollEditPartFactory.java   
@Override
protected int getHorizontalScrollBarVisibility() {
    return ScrollPane.AUTOMATIC;
}
项目:OpenSPIFe    文件:AbstractTimelineEditPart.java   
protected int getHorizontalScrollBarVisibility() {
    return ScrollPane.NEVER;
}
项目:OpenSPIFe    文件:AbstractTimelineEditPart.java   
public ScrollPane getHeaderScrollPane() {
    return scrollingHeaderEditPart == null ? null : (ScrollPane) scrollingHeaderEditPart.getFigure();
}
项目:OpenSPIFe    文件:AbstractTimelineEditPart.java   
public ScrollPane getDataScrollPane() {
    return  scrollingDataEditPart == null ? null : (ScrollPane) scrollingDataEditPart.getFigure();
}
项目:OpenSPIFe    文件:AbstractTimelineEditPart.java   
@Override
protected void addChildVisual(EditPart childEditPart, int index) {
    IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
    ((ScrollPane)getFigure()).setContents(child);
}
项目:OpenSPIFe    文件:TimelineRootEditPart.java   
@Override
public Rectangle getClientArea(Rectangle rect) {
    TimelineViewer viewer = (TimelineViewer) getViewer();
    ScrollPane figure = getTargetScrollPane(viewer);
    return figure == null ? Rectangle.SINGLETON : figure.getClientArea();
}
项目:OpenSPIFe    文件:SplitFigureLayout.java   
@Override
    public void layout(IFigure container) {
        Rectangle area = container.getClientArea();
//      Dimension minSize = getMinimumSize(container, -1, -1);
        Rectangle bounds = new Rectangle();

        Point sashLocation = dividerFigure.getBounds().getLocation();

        if(((SplitFigure)container).getOrientation() == SplitConstants.HORIZONTAL_SPLIT) {
            int sashX = 0;
            if (sashLocation.x < 0) {
                sashX = 0;
//          } else if (area.width > minSize.width && sashLocation.x  - dividerFigure.getPreferredSize().width > area.width) {
//              sashX = area.width  - dividerFigure.getPreferredSize().width;
            } else {
                sashX = sashLocation.x;
            }

            bounds.y = area.y;
            bounds.height = area.height;//Math.max(leftFigure.getPreferredSize().height, rightFigure.getPreferredSize().height));

            if (leftFigure != null) {
                bounds.x = 0;
                bounds.width = sashX;
                leftFigure.setBounds(bounds);
            }

            if (dividerFigure != null) {
                bounds.x += sashX;
                bounds.width = dividerFigure.getPreferredSize().width;
                dividerFigure.setBounds(bounds);
            }

            if (rightFigure != null) {
                bounds.x += dividerFigure.getPreferredSize().width;
                if (rightFigure instanceof ScrollPane) {
                    bounds.width = area.width - bounds.x;
                } else {
                    bounds.width = rightFigure.getPreferredSize().width;
                    bounds.width = area.width - bounds.x;
                }
                rightFigure.setBounds(bounds);
            }
        } else {
            int sashY = 0;
            if (sashLocation.y < 0) {
                sashY = 0;
//          } else if (sashLocation.y  - dividerFigure.getPreferredSize().height > area.height) {
//              sashY = area.height  - dividerFigure.getPreferredSize().height;
            } else {
                sashY = sashLocation.y;
            }

            bounds.x = area.x;
            bounds.width = area.width;

            if (leftFigure != null) { // top figure
                bounds.y = 0;
                bounds.height = sashY;
                leftFigure.setBounds(bounds);
            }

            if (dividerFigure != null) {
                bounds.y += sashY;
                bounds.height = dividerFigure.getPreferredSize().height;
                dividerFigure.setBounds(bounds);
            }

            if (rightFigure != null) { // bottom figure
                bounds.y += dividerFigure.getPreferredSize().height;
                if (rightFigure instanceof ScrollPane) {
                    bounds.height = area.height - bounds.y;
                } else {
                    bounds.height = rightFigure.getPreferredSize().height;
                }
                rightFigure.setBounds(bounds);
            }
        }


    }
项目:gef-gwt    文件:OverlayScrollPaneLayout.java   
/** {@inheritDoc} */
public void layout(IFigure parent) {
    ScrollPane scrollpane = (ScrollPane) parent;
    Rectangle clientArea = parent.getClientArea();

    ScrollBar hBar = scrollpane.getHorizontalScrollBar(), vBar = scrollpane
            .getVerticalScrollBar();
    Viewport viewport = scrollpane.getViewport();

    Insets insets = new Insets();
    insets.bottom = hBar.getPreferredSize(clientArea.width,
            clientArea.height).height;
    insets.right = vBar.getPreferredSize(clientArea.width,
            clientArea.height).width;

    int hVis = scrollpane.getHorizontalScrollBarVisibility(), vVis = scrollpane
            .getVerticalScrollBarVisibility();

    Dimension available = clientArea.getSize(), preferred = viewport
            .getPreferredSize(available.width, available.height).getCopy();

    boolean none = available.contains(preferred), both = !none
            && vVis != NEVER && hVis != NEVER
            && preferred.contains(available), showV = both
            || preferred.height > available.height, showH = both
            || preferred.width > available.width;

    // Adjust for visibility override flags
    showV = !(vVis == NEVER) && (showV || vVis == ALWAYS);
    showH = !(hVis == NEVER) && (showH || hVis == ALWAYS);

    if (!showV)
        insets.right = 0;
    if (!showH)
        insets.bottom = 0;
    Rectangle bounds, viewportArea = clientArea;

    if (showV) {
        bounds = new Rectangle(viewportArea.right() - insets.right,
                viewportArea.y, insets.right, viewportArea.height);
        vBar.setBounds(bounds);
        // vBar.setMaximum(preferred.height);
    }
    if (showH) {
        bounds = new Rectangle(viewportArea.x, viewportArea.bottom()
                - insets.bottom, viewportArea.width, insets.bottom);
        hBar.setBounds(bounds);
        // hBar.setMaximum(preferred.width);
    }
    vBar.setVisible(showV);
    hBar.setVisible(showH);
    viewport.setBounds(viewportArea);
}
项目:gef-gwt    文件:DrawerFigure.java   
/**
 * Returns the ScrollPane associated with this DrawerFigure
 * 
 * @return the ScrollPane
 */
public ScrollPane getScrollpane() {
    return scrollpane;
}
项目:OpenSPIFe    文件:TimelineRootEditPart.java   
protected abstract ScrollPane getTargetScrollPane(TimelineViewer viewer);