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; }
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); } }
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); }
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); }
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); }
/** * 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); }
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); } } } } }
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()); }
@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(); } }); } }
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; }
@Override protected IFigure createFigure() { ScrollPane scrollPane = new ScrollPane(); scrollPane.setOpaque(false); scrollPane.setBackgroundColor(ColorConstants.white); return scrollPane; }
@Override protected ScrollPane getTargetScrollPane(TimelineViewer viewer) { if (viewer != null && viewer.getTimelineEditPart() != null) { return viewer.getTimelineEditPart().getHeaderScrollPane(); } return null; }
@Override protected ScrollPane getTargetScrollPane(TimelineViewer viewer) { if (viewer != null && viewer.getTimelineEditPart() != null) { return viewer.getTimelineEditPart().getDataScrollPane(); } return null; }
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; }
/** * {@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); }
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); }
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; } } }
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()); }
public ScrollPane getScrollPane(){ return scrollpane; }
private int getScrollVisibility(Boolean h){ return h == null ? ScrollPane.AUTOMATIC : (h ? ScrollPane.ALWAYS : ScrollPane.NEVER); }
/** * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getContentPane() */ @Override public IFigure getContentPane() { return ((ScrollPane) this.getFigure()).getContents(); }
public void centerCursorTimeOnHorzLocation(int x) { ScrollPane dataScrollPane = getTimelineEditPart().getDataScrollPane(); int local = x - dataScrollPane.getBounds().x + dataScrollPane.getViewport().getHorizontalRangeModel().getValue(); getTimeline().scrollTo(getTimeline().getCursorTime(), local); }
@Override protected int getHorizontalScrollBarVisibility() { return ScrollPane.AUTOMATIC; }
protected int getHorizontalScrollBarVisibility() { return ScrollPane.NEVER; }
public ScrollPane getHeaderScrollPane() { return scrollingHeaderEditPart == null ? null : (ScrollPane) scrollingHeaderEditPart.getFigure(); }
public ScrollPane getDataScrollPane() { return scrollingDataEditPart == null ? null : (ScrollPane) scrollingDataEditPart.getFigure(); }
@Override protected void addChildVisual(EditPart childEditPart, int index) { IFigure child = ((GraphicalEditPart)childEditPart).getFigure(); ((ScrollPane)getFigure()).setContents(child); }
@Override public Rectangle getClientArea(Rectangle rect) { TimelineViewer viewer = (TimelineViewer) getViewer(); ScrollPane figure = getTargetScrollPane(viewer); return figure == null ? Rectangle.SINGLETON : figure.getClientArea(); }
@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); } } }
/** {@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); }
/** * Returns the ScrollPane associated with this DrawerFigure * * @return the ScrollPane */ public ScrollPane getScrollpane() { return scrollpane; }
protected abstract ScrollPane getTargetScrollPane(TimelineViewer viewer);