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

项目:PDFReporter-Studio    文件:JDRulerRootEditPart.java   
/**
 * Constructor
 */
public RulerViewport() {
    super(true);
    setLayoutManager(null);
    // The range model that's not shared is initialized such that it can't scroll
    // anymore (otherwise, CTRL + SHIFT + ARROW scrolls it).
    RangeModel bogusRangeModel;
    if (horizontal)
        bogusRangeModel = getVerticalRangeModel();
    else
        bogusRangeModel = getHorizontalRangeModel();
    bogusRangeModel.setMinimum(0);
    bogusRangeModel.setMaximum(100);
    bogusRangeModel.setValue(0);
    bogusRangeModel.setExtent(100);
}
项目:OpenSPIFe    文件:Timeline.java   
/**
 * This method can be used to determine the center location (x) of the timeline relative to the user on the screen. Results of this operation can be passed to the timeline.centerOnTime(..) method
 * to re-center the timeline after a destabilizing operation. Of course first the location would first have to be converted to a Date object, in which case you could just call the
 * getCurrentScreenCenterDate() method.
 * 
 * @return the x location of the center of the screen
 */
public int getCurrentScreenCenterLocation() {
    int screenPosition = -1;

    int viewportWidth = this.getTimelineViewers().get(1).getTimelineEditPart().getDataScrollPane().getViewport().getBounds().width;

    RangeModel horzRangeModel = this.getHorizontalRangeModel();
    int currentScrollPosition = horzRangeModel.getValue();
    int vLeft = currentScrollPosition;
    int vCenter = vLeft + (viewportWidth / 2);
    screenPosition = vCenter;

    if (screenPosition == -1) {
        LogUtil.warn("couldn't get center screen position");
    }

    return screenPosition;
}
项目:OpenSPIFe    文件:Timeline.java   
/**
 * This method can be used to retrieve the right most visible location of the timeline visible to the user through the current viewport.
 * 
 * @return the x location of the right most part of the timeline visible to the user.
 */
public int getCurrentScreenRightLocation() {
    int screenPosition = -1;

    int viewportWidth = this.getTimelineViewers().get(1).getTimelineEditPart().getDataScrollPane().getViewport().getBounds().width;

    RangeModel horzRangeModel = this.getHorizontalRangeModel();
    int currentScrollPosition = horzRangeModel.getValue();
    int vLeft = currentScrollPosition;
    int vRight = vLeft + viewportWidth;
    screenPosition = vRight;

    if (screenPosition == -1) {
        LogUtil.warn("couldn't get right screen position");
    }

    return screenPosition;
}
项目: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    文件:DrawerEditPart.java   
/**
 * @see org.eclipse.gef.ui.palette.editparts.PaletteEditPart#restoreState(org.eclipse.ui.IMemento)
 */
public void restoreState(IMemento memento) {
    setExpanded(new Boolean(memento.getString(PROPERTY_EXPANSION_STATE))
            .booleanValue());
    setPinnedOpen(new Boolean(memento.getString(PROPERTY_PINNED_STATE))
            .booleanValue());
    RangeModel rModel = getDrawerFigure().getScrollpane().getViewport()
            .getVerticalRangeModel();
    rModel.setMinimum(memento.getInteger(RangeModel.PROPERTY_MINIMUM)
            .intValue());
    rModel.setMaximum(memento.getInteger(RangeModel.PROPERTY_MAXIMUM)
            .intValue());
    rModel.setExtent(memento.getInteger(RangeModel.PROPERTY_EXTENT)
            .intValue());
    rModel.setValue(memento.getInteger(RangeModel.PROPERTY_VALUE)
            .intValue());
    super.restoreState(memento);
}
项目:gef-gwt    文件:RulerRootEditPart.java   
/**
 * Constructor
 */
public RulerViewport() {
    super(true);
    setLayoutManager(null);
    // The range model that's not shared is initialized such that it
    // can't scroll
    // anymore (otherwise, CTRL + SHIFT + ARROW scrolls it).
    RangeModel bogusRangeModel;
    if (horizontal)
        bogusRangeModel = getVerticalRangeModel();
    else
        bogusRangeModel = getHorizontalRangeModel();
    bogusRangeModel.setMinimum(0);
    bogusRangeModel.setMaximum(100);
    bogusRangeModel.setValue(0);
    bogusRangeModel.setExtent(100);
}
项目: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();
}
项目: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    文件:EditorRulerRootEditPart.java   
/**
 * Constructor
 */
public RulerViewport( )
{
    super( true );
    setLayoutManager( null );
    // The range model that's not shared is initialized such that it
    // can't scroll
    // anymore (otherwise, CTRL + SHIFT + ARROW scrolls it).
    RangeModel bogusRangeModel;
    if ( horizontal )
        bogusRangeModel = getVerticalRangeModel( );
    else
        bogusRangeModel = getHorizontalRangeModel( );
    bogusRangeModel.setMinimum( 0 );
    bogusRangeModel.setMaximum( 100 );
    bogusRangeModel.setValue( 0 );
    bogusRangeModel.setExtent( 100 );
}
项目:PDFReporter-Studio    文件:JDRulerComposite.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(rModel);
    port.setVerticalRangeModel(rModel);
    rulerEditDomain.removeViewer(viewer);
    viewer.getControl().dispose();
}
项目:PDFReporter-Studio    文件:JDRulerRootEditPart.java   
/**
 * This is the method that does the actual layout. We don't want a layout to occur when layout() is invoked, rather
 * when something changes in the shared RangeModel.
 * 
 * @param force
 *          if <code>true</code>, the contents will be resized and revalidated; otherwise, just a repaint will
 *          occur.
 */
protected void doLayout(boolean force) {
    repaint();
    /*
     * @TODO:Pratik It seems you don't really need this force argument. Those that invoke doLayout(false) can invoke
     * repaint() themselves. doLayout() should just layout.
     */
    if (force) {
        RangeModel rModel;
        if (horizontal)
            rModel = getHorizontalRangeModel();
        else
            rModel = getVerticalRangeModel();
        Rectangle contentBounds = Rectangle.SINGLETON;
        if (horizontal) {
            contentBounds.y = 0;
            contentBounds.x = rModel.getMinimum();
            contentBounds.height = this.getContents().getPreferredSize().height;
            contentBounds.width = rModel.getMaximum() - rModel.getMinimum();
        } else {
            contentBounds.y = rModel.getMinimum();
            contentBounds.x = 0;
            contentBounds.height = rModel.getMaximum() - rModel.getMinimum();
            contentBounds.width = this.getContents().getPreferredSize().width;
        }
        if (!this.getContents().getBounds().equals(contentBounds)) {
            this.getContents().setBounds(contentBounds);
            this.getContents().revalidate();
        }
    }
}
项目:PDFReporter-Studio    文件:JDRulerRootEditPart.java   
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent event) {
    if (this.getContents() != null && event.getSource() instanceof RangeModel) {
        String property = event.getPropertyName();
        doLayout(RangeModel.PROPERTY_MAXIMUM.equals(property) || RangeModel.PROPERTY_MINIMUM.equals(property)
                || RangeModel.PROPERTY_VALUE.equals(property));
    }
}
项目: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    文件:Timeline.java   
private Control createTimelineRegion(Composite parent) {
    Composite timelineRegion = new EnsembleComposite(parent, SWT.NONE);
    timelineRegion.setData("debug", Timeline.class.getSimpleName() + ".timelineRegion");
    timelineRegion.setLayout(new BorderLayout());

    // create the range model first
    final RangeModel rangeModel = new DefaultRangeModel();
    setHorizontalRangeModel(rangeModel);

    // frozen top timeline contents
    // date/time ruler (scale)
    Composite timelineTopComposite = buildTopTimeline(timelineRegion);
    timelineTopComposite.setLayoutData(SWT.TOP);

    // timeline contents
    ScrolledComposite scroller = buildTimelineContents(timelineRegion);
    scroller.setLayoutData(SWT.CENTER);

    // scroller
    TimelineViewer timelineHScroller = buildTimeline(timelineRegion, getTimelineModel(), new SplitScrollEditPartFactory<T>());
    timelineHScroller.getControl().setLayoutData(SWT.BOTTOM);

    scroller.getContent().addListener(SWT.MouseHorizontalWheel, new Listener() {
        @Override
        public void handleEvent(Event event) {
            int value = rangeModel.getValue();
            value -= 5 * event.count;
            rangeModel.setValue(value);
        }
    });

    return timelineRegion;
}
项目:OpenSPIFe    文件:Timeline.java   
private void setHorizontalRangeModel(RangeModel rm) {
    if (horzRangeModel != null) {
        horzRangeModel.removePropertyChangeListener(horizontalRangeModelListener);
    }
    if (rm != null) {
        rm.addPropertyChangeListener(horizontalRangeModelListener);
    }
    this.horzRangeModel = rm;
}
项目:OpenSPIFe    文件:Timeline.java   
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final int newPosition = ((Integer) evt.getNewValue()).intValue();
    if (RangeModel.PROPERTY_VALUE.equals(evt.getPropertyName())) {
        if (newPosition == x) {
            // success
            x = -1;
        }
        horzintalPosition = newPosition;
    } else {
        if (x >= 0 && x <= newPosition) {
            // try and set the value
            horzRangeModel.setValue(x);
        }
    }

    boolean optimizeScrolling = true;
    if (optimizeScrolling) {
        setScrolling(true);
        if (scrollingThread != null) {
            scrollingThread.interrupt();
            scrollingThread = null;
        }
        scrollingThread = new Thread("Scrolling Thread") {

            @Override
            public void run() {
                try {
                    sleep(SCROLL_REFRESH_DELAY);
                    setScrolling(false);
                } catch (InterruptedException e) {
                    // usually will be interrupted
                }
            }

        };
        scrollingThread.start();
    }
}
项目:OpenSPIFe    文件:Timeline.java   
/**
 * This method can be used to retrieve the left most visible location of the timeline visible to the user through the current viewport.
 * 
 * @return the x location of the left most part of the timeline visible to the user.
 */
public int getCurrentScreenLeftLocation() {
    int screenPosition = -1;

    RangeModel horzRangeModel = this.getHorizontalRangeModel();
    int currentScrollPosition = horzRangeModel.getValue();
    int vLeft = currentScrollPosition;
    screenPosition = vLeft;

    if (screenPosition == -1) {
        LogUtil.warn("couldn't get left screen position");
    }

    return screenPosition;
}
项目:gef-gwt    文件:RulerComposite.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(rModel);
    port.setVerticalRangeModel(rModel);
    rulerEditDomain.removeViewer(viewer);
    viewer.getControl().dispose();
}
项目:gef-gwt    文件:DrawerEditPart.java   
/**
 * @see org.eclipse.gef.ui.palette.editparts.PaletteEditPart#saveState(org.eclipse.ui.IMemento)
 */
public void saveState(IMemento memento) {
    memento.putString(PROPERTY_EXPANSION_STATE,
            new Boolean(isExpanded()).toString());
    memento.putString(PROPERTY_PINNED_STATE,
            new Boolean(isPinnedOpen()).toString());
    RangeModel rModel = getDrawerFigure().getScrollpane().getViewport()
            .getVerticalRangeModel();
    memento.putInteger(RangeModel.PROPERTY_MINIMUM, rModel.getMinimum());
    memento.putInteger(RangeModel.PROPERTY_MAXIMUM, rModel.getMaximum());
    memento.putInteger(RangeModel.PROPERTY_EXTENT, rModel.getExtent());
    memento.putInteger(RangeModel.PROPERTY_VALUE, rModel.getValue());
    super.saveState(memento);
}
项目:gef-gwt    文件:PaletteScrollBar.java   
protected void initialize() {
    super.initialize();
    setLayoutManager(new ScrollBarLayout(transposer) {
        protected Rectangle layoutButtons(ScrollBar scrollBar) {
            Rectangle bounds = transposer.t(scrollBar.getClientArea());
            Dimension buttonSize = new Dimension(BUTTON_WIDTH,
                    BUTTON_HEIGHT);

            getButtonUp().setBounds(
                    transposer.t(new Rectangle(bounds.getTop()
                            .getTranslated(-(buttonSize.width / 2), 0),
                            buttonSize)));
            Rectangle r = new Rectangle(bounds.getBottom().getTranslated(
                    -(buttonSize.width / 2), -buttonSize.height),
                    buttonSize);
            getButtonDown().setBounds(transposer.t(r));
            Rectangle trackBounds = bounds.getCropped(new Insets(
                    buttonSize.height, 0, buttonSize.height, 0));
            RangeModel model = scrollBar.getRangeModel();
            getButtonUp()
                    .setVisible(model.getValue() != model.getMinimum());
            getButtonDown().setVisible(
                    model.getValue() != model.getMaximum()
                            - model.getExtent());
            return trackBounds;
        }
    });
    setPageUp(null);
    setPageDown(null);
    setThumb(null);
    setOpaque(false);
}
项目:gef-gwt    文件:RulerRootEditPart.java   
/**
 * This is the method that does the actual layout. We don't want a
 * layout to occur when layout() is invoked, rather when something
 * changes in the shared RangeModel.
 * 
 * @param force
 *            if <code>true</code>, the contents will be resized and
 *            revalidated; otherwise, just a repaint will occur.
 */
protected void doLayout(boolean force) {
    repaint();
    /*
     * @TODO:Pratik It seems you don't really need this force argument.
     * Those that invoke doLayout(false) can invoke repaint()
     * themselves. doLayout() should just layout.
     */
    if (force) {
        RangeModel rModel;
        if (horizontal)
            rModel = getHorizontalRangeModel();
        else
            rModel = getVerticalRangeModel();
        Rectangle contentBounds = Rectangle.SINGLETON;
        if (horizontal) {
            contentBounds.y = 0;
            contentBounds.x = rModel.getMinimum();
            contentBounds.height = this.getContents()
                    .getPreferredSize().height;
            contentBounds.width = rModel.getMaximum()
                    - rModel.getMinimum();
        } else {
            contentBounds.y = rModel.getMinimum();
            contentBounds.x = 0;
            contentBounds.height = rModel.getMaximum()
                    - rModel.getMinimum();
            contentBounds.width = this.getContents().getPreferredSize().width;
        }
        if (!this.getContents().getBounds().equals(contentBounds)) {
            this.getContents().setBounds(contentBounds);
            this.getContents().revalidate();
        }
    }
}
项目:gef-gwt    文件:RulerRootEditPart.java   
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent event) {
    if (this.getContents() != null
            && event.getSource() instanceof RangeModel) {
        String property = event.getPropertyName();
        doLayout(RangeModel.PROPERTY_MAXIMUM.equals(property)
                || RangeModel.PROPERTY_MINIMUM.equals(property)
                || RangeModel.PROPERTY_VALUE.equals(property));
    }
}
项目:birt    文件:EditorRulerRootEditPart.java   
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public void propertyChange( PropertyChangeEvent event )
{
    if ( this.getContents( ) != null
            && event.getSource( ) instanceof RangeModel )
    {
        String property = event.getPropertyName( );
        doLayout( RangeModel.PROPERTY_MAXIMUM.equals( property )
                || RangeModel.PROPERTY_MINIMUM.equals( property )
                || RangeModel.PROPERTY_VALUE.equals( property ) );
    }
}
项目:birt    文件:RulerDefaultRangeModel.java   
/**
 * @param model
 */
public RulerDefaultRangeModel( RangeModel model )
{
    assert model != null;
    this.delegate = model;
    delegate.addPropertyChangeListener( this );
}
项目:OpenSPIFe    文件:SecondaryRangeModel.java   
public SecondaryRangeModel(RangeModel primaryRangeModel) {
    this.primaryRangeModel = primaryRangeModel;
}
项目:OpenSPIFe    文件:Timeline.java   
private RangeModel getHorizontalRangeModel() {
    return horzRangeModel;
}
项目:birt    文件:EditorRulerRootEditPart.java   
/**
 * This is the method that does the actual layout. We don't want a
 * layout to occur when layout() is invoked, rather when something
 * changes in the shared RangeModel.
 * 
 * @param force
 *            if <code>true</code>, the contents will be resized and
 *            revalidated; otherwise, just a repaint will occur.
 */
protected void doLayout( boolean force )
{
    repaint( );
    /*
     * @TODO:Pratik It seems you don't really need this force argument.
     * Those that invoke doLayout(false) can invoke repaint()
     * themselves. doLayout() should just layout.
     */
    if ( force )
    {
        RangeModel rModel;
        if ( horizontal )
            rModel = getHorizontalRangeModel( );
        else
            rModel = getVerticalRangeModel( );
        Rectangle contentBounds = Rectangle.SINGLETON;
        if ( horizontal )
        {
            contentBounds.y = 0;
            contentBounds.x = rModel.getMinimum( );
            contentBounds.height = this.getContents( )
                    .getPreferredSize( ).height;
            contentBounds.width = rModel.getMaximum( )
                    - rModel.getMinimum( );
        }
        else
        {
            contentBounds.y = rModel.getMinimum( );
            contentBounds.x = 0;
            contentBounds.height = rModel.getMaximum( )
                    - rModel.getMinimum( );
            contentBounds.width = this.getContents( )
                    .getPreferredSize( ).width;
        }
        if ( !this.getContents( ).getBounds( ).equals( contentBounds ) )
        {
            this.getContents( ).setBounds( contentBounds );
            this.getContents( ).revalidate( );
        }
    }
}