Package javax.swing

Examples of javax.swing.BoundedRangeModel


    JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar()
        : getVerticalScrollBar();

    if (scrollBar != null)
    {
      BoundedRangeModel model = scrollBar.getModel();
      int newValue = (int) Math.round(model.getValue() * factor)
          + (int) Math.round((center) ? (model.getExtent()
              * (factor - 1) / 2) : 0);
      model.setValue(newValue);
    }
  }
View Full Code Here


    JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar()
        : getVerticalScrollBar();

    if (scrollBar != null)
    {
      final BoundedRangeModel model = scrollBar.getModel();
      final int newValue = ((model.getMaximum()) / 2) - model.getExtent()
          / 2;
      model.setValue(newValue);
    }
  }
View Full Code Here

        public void adjustmentValueChanged(final AdjustmentEvent e) {
            // LCMC fix
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JScrollBar sb = (JScrollBar)e.getSource();
                    BoundedRangeModel m = sb.getModel();
                    int vval = m.getValue();
                    float dv = previous - vval;
                    previous = vval;
                    if(dv != 0 && scrollBarsMayControlAdjusting) {
                   
                        // get the uniform scale of all transforms
View Full Code Here

        public void mouseDragged(MouseEvent e) {
            if (p == null) {
                //do nothing
            } else {
                BoundedRangeModel hModel = scrollPane.getHorizontalModel();
                BoundedRangeModel vModel = scrollPane.getVerticalModel();
                hModel.setValue(hModel.getValue() + (p.x - e.getX()));
                vModel.setValue(vModel.getValue() + (p.y - e.getY()));
            }
        }
View Full Code Here

        if (p>100) p=100;
        set(Caller.PROGRESS, new Integer(p));
    }

    public float getProgress() {
        BoundedRangeModel model = progressBar.getModel();
        float progress = (float) (model.getValue() - model.getMinimum());
        float limit = (float) model.getMaximum();
       
        return progress / limit;
    }
View Full Code Here

        /**
         * Run the task.
         */
        public void run() {
            final BoundedRangeModel model = progressBar.getModel();
            switch (task) {
                case -LABEL: {
                    value = description.getText();
                    return;
                }
                case +LABEL: {
                    description.setText((String) value);
                    return;
                }
                case PROGRESS: {
                    model.setValue(((Integer) value).intValue());
                    progressBar.setIndeterminate(false);
                    return;
                }
                case STARTED: {
                    model.setRangeProperties(0, 1, 0, 100, false);
                    window.setVisible(true);
                    break; // Need further action below.
                }
                case COMPLETE: {
                    model.setRangeProperties(100, 1, 0, 100, false);
                    window.setVisible(warningArea != null);
                    cancel.setEnabled(false);
                    break; // Need further action below.
                }
            }
View Full Code Here

   * Method stateChanged
   */
  public void stateChanged(ChangeEvent e) {

    Object source = e.getSource();
    BoundedRangeModel rangeModel = null;
    if (source instanceof BoundedRangeModel) {
      rangeModel = (BoundedRangeModel) source;
      if ((CONTINUOUS_UPDATE) || (rangeModel.getValueIsAdjusting() == false)) {
        graphComponent.setPointGap(rangeModel.getValue() + 1);
      }
    }
  }
View Full Code Here

    for (int i = 0; i < targets.length; i++) {
      LOG.info("scanning " + targets[i] + "...");
      scan(targets[i], fileSet);
    }
    File[] files = (File[]) fileSet.toArray(new File[fileSet.size()]);
    BoundedRangeModel rangeModel = view.getRangeModel();
    LOG.info("done scanning : " + files.length + " file(s) found");
    rangeModel.setMaximum(files.length);
    for (int i = 0; i < files.length; i++) {
      File file = files[i];
      try {
        LOG.info("inject : " + file);
        injector.inject(file);
        rangeModel.setValue(i + 1);
      } catch (Exception e) {
        throw new NestedRuntimeException("Error injecting file : " + file, e);
      }
    }
  }
View Full Code Here

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

    UIProgress component = (UIProgress) 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);
    }

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);

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

    Integer width = LayoutUtil.getLayoutWidth(component);

    String width1 = value1;
    String width2 = value2;

    if (width != null) {
      int value = (width -1) * model.getValue()
          / (model.getMaximum() - model.getMinimum());
      width1 = Integer.toString(value);
      width2 = Integer.toString((width - 2) - value);
    }


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

    writer.startElement(HtmlConstants.TR, null);

    writer.startElement(HtmlConstants.TD, null);
    writer.writeStyleAttribute("background-color: #aabbcc;");
    writer.writeAttribute(HtmlAttributes.WIDTH, width1, false);
    writer.writeText(TobagoConstants.CHAR_NON_BEAKING_SPACE);
    writer.endElement(HtmlConstants.TD);

    writer.startElement(HtmlConstants.TD, null);
    writer.writeStyleAttribute("background-color: #ddeeff;");
    writer.writeAttribute(HtmlAttributes.WIDTH, width2, false);
    writer.writeText(TobagoConstants.CHAR_NON_BEAKING_SPACE);
    writer.endElement(HtmlConstants.TD);

    writer.endElement(HtmlConstants.TR);
    writer.endElement(HtmlConstants.TABLE);
    UIComponent facet = component.getFacet("complete");
    if (model.getValue() == model.getMaximum() && facet != null
        && facet instanceof UICommand) {
      UICommand command = (UICommand) facet;
      writer.writeJavascript("Tobago.submitAction2(this, '" + command.getClientId(facesContext) + "', null, null);");
    }
  }
View Full Code Here

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

    UIProgress component = (UIProgress) 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());

    final int diff = model.getMaximum() - model.getMinimum();
    Object title = component.getAttributes().get(ATTR_TIP);
    if (title == null && diff > 0) {
      title = Integer.toString(100 * model.getValue() / diff) + " %";
    }

    Integer width = LayoutUtil.getLayoutWidth(component);

    String width1 = value1;
    String width2 = value2;

    if (width != null) {
      int value = diff > 0 ? (width - 1) * model.getValue() / diff : width;
      width1 = Integer.toString(value);
      width2 = Integer.toString((width - 2) - value);
    }

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlConstants.SPAN, component);
    writer.writeClassAttribute();
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, String.valueOf(title), true);
    }

    writer.startElement(HtmlConstants.IMG, null);
    StyleClasses color1Classes = new StyleClasses();
    color1Classes.addClass("progress", "color1");
    color1Classes.addMarkupClass(component, "progress", "color1");
    writer.writeClassAttribute(color1Classes);
    writer.writeAttribute(HtmlAttributes.SRC, image, false);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.ALT, String.valueOf(title), true);
    }
    writer.writeAttribute(HtmlAttributes.STYLE, "width:" + width1 + "px", false);
    writer.writeAttribute(HtmlAttributes.BORDER, 0);
    writer.endElement(HtmlConstants.IMG);

    writer.startElement(HtmlConstants.IMG, null);
    StyleClasses color2Classes = new StyleClasses();
    color2Classes.addClass("progress", "color2");
    color2Classes.addMarkupClass(component, "progress", "color2");
    writer.writeClassAttribute(color2Classes);
    writer.writeAttribute(HtmlAttributes.SRC, image, false);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.ALT, String.valueOf(title), true);
    }
    writer.writeAttribute(HtmlAttributes.STYLE, "width:" + width2 + "px", false);
    writer.writeAttribute(HtmlAttributes.BORDER, 0);
    writer.endElement(HtmlConstants.IMG);

    writer.endElement(HtmlConstants.SPAN);
    UIComponent facet = component.getFacet("complete");
    if (model.getValue() == model.getMaximum() && facet != null
        && facet instanceof UICommand) {
      UICommand command = (UICommand) facet;
      writer.writeJavascript("Tobago.submitAction2(this, '" + command.getClientId(facesContext) + "', null, null);");
    }
  }
View Full Code Here

TOP

Related Classes of javax.swing.BoundedRangeModel

Copyright © 2018 www.massapicom. 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.