Examples of BoundedRangeModel


Examples of javax.swing.BoundedRangeModel

     */
    private void updateScrollBarValueFromMouseLocation(int mouseLocation) {
        // most of the below logic was lifted from BasicScrollBarUI. the logic here has been
        // greatly simplified here through the use of the ScrollBarOrientation.

        BoundedRangeModel model = scrollbar.getModel();
        Rectangle thumbBounds = getThumbBounds();
        Rectangle trackBounds = getTrackBounds();

        // calculate what the value of the scrollbar should be.
        int minimumPossibleThumbPosition = fOrientation.getPosition(trackBounds.getLocation());
        int maximumPossibleThumbPosition = getMaximumPossibleThumbPosition(trackBounds, thumbBounds);
        int actualThumbPosition = Math.min(maximumPossibleThumbPosition,
                Math.max(minimumPossibleThumbPosition, mouseLocation));

        // calculate the new value for the scroll bar (the top of the scroll thumb) based
        // on the dragged location.
        float valueMax = model.getMaximum() - model.getExtent();
        float valueRange = valueMax - model.getMinimum();
        float thumbValue = actualThumbPosition - minimumPossibleThumbPosition;
        float thumbRange = maximumPossibleThumbPosition - minimumPossibleThumbPosition;
        int value = (int) Math.ceil((thumbValue / thumbRange) * valueRange);

        scrollbar.setValue(value + model.getMinimum());
    }
View Full Code Here

Examples of javax.swing.BoundedRangeModel

     */
    @Override
    void scrollRectToVisible(Rectangle r) {
        int x = r.x;
        Insets insets = getTextFieldKit().getInsets();
        BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
        int oldValue = brm.getValue();
        int width = getModelRect().width;
        if (x > width - insets.right) {
            int newVal = oldValue + (x - width + insets.right) + 2;
            brm.setValue(newVal);
            repaint();
        }
        if (x < insets.left) {
            brm.setValue(oldValue - (insets.left - x) - 2);
            repaint();
        }
    }
View Full Code Here

Examples of javax.swing.BoundedRangeModel

        } else {
            offset = toLeft ? 0 : diff;
        }
        int extent = bounds.width - 1;
        int max = Math.max(extent, prefWidth);
        BoundedRangeModel brm = tfk.getHorizontalVisibility();
        int value = Math.min(brm.getValue(), max - extent);
        brm.setRangeProperties(value, extent, brm.getMinimum(), max, false);

        int x = (diff < 0 ? -value + tfk.getInsets().left : bounds.x + offset);
        int y = (bounds.height - height) / 2 + bounds.y;
        if (!toLeft) {
            x--;
View Full Code Here

Examples of javax.swing.BoundedRangeModel

        uninstallKeyboardActions();
    }

    public void layoutContainer(final Container c) {
        JScrollBar bar = ((JScrollBar)c);
        BoundedRangeModel model = bar.getModel();
        orientationStrategy.layoutScrollBar(bar);
        orientationStrategy.calculateTrackBounds(model);
        orientationStrategy.calculateThumbBounds(model);
    }
View Full Code Here

Examples of javax.swing.BoundedRangeModel

            String propertyName = e.getPropertyName();
            if (StringConstants.COMPONENT_ORIENTATION.equals(propertyName)) {
                uninstallKeyboardActions();
                installKeyboardActions();
            } else if (StringConstants.MODEL_PROPERTY_CHANGED.equals(propertyName)) {
                BoundedRangeModel oldValue = (BoundedRangeModel)e.getOldValue();
                if (oldValue != null) {
                    oldValue.removeChangeListener(modelListener);
                }

                BoundedRangeModel newValue = (BoundedRangeModel)e.getNewValue();
                if (newValue != null) {
                    newValue.addChangeListener(modelListener);
                }
            }

            scrollbar.revalidate();
            scrollbar.repaint();
View Full Code Here

Examples of javax.swing.BoundedRangeModel

                trackListener.offset = offset;
            }
        }

        void setValueOnDragging(final MouseEvent e, final int currentMouseX, final int currentMouseY, final int initialModelValue) {
            BoundedRangeModel model = scrollbar.getModel();
            int extent = model.getExtent();
            int viewSize = model.getMaximum() - model.getMinimum();
            int availableScrollingSize = viewSize - extent;
            int thumbSize = getThumbSize(Math.round(getTrackSize() * extent / viewSize));
            int availableTrackSize = getTrackSize() - thumbSize;
            int offset = getOffset(e, currentMouseX, currentMouseY);
            int modelIncrement = availableTrackSize != 0 ? offset * availableScrollingSize / availableTrackSize : 0;
            model.setValue(initialModelValue + modelIncrement);
        }
View Full Code Here

Examples of javax.swing.BoundedRangeModel

  public void encodeEnd(FacesContext facesContext,
      UIComponent uiComponent) throws IOException {

    UIOutput component = (UIOutput) uiComponent;

    BoundedRangeModel model = (BoundedRangeModel) component.getValue();

    if (model == null) {
      LOG.warn("'null' value found! Using dummy Model instead!");
      model = new DefaultBoundedRangeModel(4, 1, 0, 10);
    }

    ResponseWriter writer = facesContext.getResponseWriter();

    writer.startElement(HtmlConstants.TABLE, null);
    writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
    writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", null);
    writer.writeAttribute(HtmlAttributes.CELLPADDING, "0", null);
    writer.writeAttribute(HtmlAttributes.SUMMARY, "", null);

    writer.startElement(HtmlConstants.TR, null);

    writer.startElement(HtmlConstants.TD, null);
    writer.writeAttribute(HtmlAttributes.STYLE, "background-color: #aabbcc;", null);
    writer.writeAttribute(HtmlAttributes.WIDTH, Integer.toString(model.getValue()), null);
    writer.write("&nbsp;");
    writer.endElement(HtmlConstants.TD);

    writer.startElement(HtmlConstants.TD, null);
    writer.writeAttribute(HtmlAttributes.STYLE, "background-color: #ddeeff;", null);
    writer.writeAttribute(HtmlAttributes.WIDTH,
        Integer.toString(model.getMaximum() - model.getValue()), null);
    writer.write("&nbsp;");
    writer.endElement(HtmlConstants.TD);

    writer.endElement(HtmlConstants.TR);
    writer.endElement(HtmlConstants.TABLE);
View Full Code Here

Examples of javax.swing.BoundedRangeModel

  public void encodeEnd(FacesContext facesContext,
      UIComponent uiComponent) throws IOException {

    UIOutput component = (UIOutput) uiComponent;

    BoundedRangeModel model = (BoundedRangeModel) component.getValue();

    if (model == null) {
      LOG.warn("'null' value found! Using dummy Model instead!");
      model = new DefaultBoundedRangeModel(40, 1, 0, 100);
    }

    String image = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");

    String value1 = Integer.toString(model.getValue());
    String value2 = Integer.toString(
        model.getMaximum() - model.getValue());


    String title = (String) component.getAttributes().get(ATTR_TIP);
    if (title == null) {
      title = Integer.toString(100 * model.getValue()
          / (model.getMaximum() - model.getMinimum()))
          + " %";
    }

    TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();

View Full Code Here

Examples of javax.swing.BoundedRangeModel

    public TableScrollPane(JTable table, final TableUpdater tableUpdater) {
        this.scrollPane = new JScrollPane(table);
        ChangeListener changeListener = new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                BoundedRangeModel m = (BoundedRangeModel)(e.getSource());
                tableUpdater.setUpdatesEnabled(!(m.getValueIsAdjusting()));
            }
        };
        this.scrollPane.getVerticalScrollBar().getModel().addChangeListener(changeListener);
        this.scrollPane.getHorizontalScrollBar().getModel().addChangeListener(changeListener);
    }
View Full Code Here

Examples of javax.swing.BoundedRangeModel

                return;

            int val = ((isVertical)?vertical.getValue():
                       horizontal.getValue());

            BoundedRangeModel brm = (BoundedRangeModel)src;
            if (brm.getValueIsAdjusting()) {
                if (!inDrag) {
                    inDrag = true;
                    startValue = val;
                } else {
                    AffineTransform at;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.