Package org.pushingpixels.flamingo.api.common.model

Examples of org.pushingpixels.flamingo.api.common.model.PopupButtonModel


   * thing as if the user had pressed and released the popup area of the
   * button.
   */
  public void doPopupClick() {
    Dimension size = getSize();
    PopupButtonModel popupModel = this.getPopupModel();
    popupModel.setArmed(true);
    popupModel.setPressed(true);
    paintImmediately(new Rectangle(0, 0, size.width, size.height));
    try {
      Thread.sleep(100);
    } catch (InterruptedException ie) {
    }
    popupModel.setPressed(false);
    popupModel.setArmed(false);
    popupModel.setPopupShowing(true);
    paintImmediately(new Rectangle(0, 0, size.width, size.height));
  }
View Full Code Here


    // + (e.isTemporary() ? "temporary" : "permanent")
    // + " focus to \n\t" + e.getOppositeComponent());
    b.getActionModel().setArmed(false);
    b.getActionModel().setPressed(false);
    if (b instanceof JCommandButton) {
      PopupButtonModel popupModel = ((JCommandButton) b).getPopupModel();
      popupModel.setPressed(false);
      popupModel.setArmed(false);
    }
  }
View Full Code Here

            actionModel.setArmed(true);
            actionModel.setPressed(true);
          }
        } else {
          if ((popupRect != null) && popupRect.contains(e.getPoint())) {
            PopupButtonModel popupModel = ((JCommandButton) b)
                .getPopupModel();
            if (popupModel.isEnabled()) {
              popupModel.setArmed(true);
              popupModel.setPressed(true);
            }
          }
        }

        // System.err.println(b.getText() + " - hasFocus():"
View Full Code Here

   *            Mouse event for the model synchronization.
   */
  private void syncMouseMovement(MouseEvent e) {
    AbstractCommandButton b = (AbstractCommandButton) e.getSource();
    ButtonModel actionModel = b.getActionModel();
    PopupButtonModel popupModel = (b instanceof JCommandButton) ? ((JCommandButton) b)
        .getPopupModel()
        : null;
    CommandButtonUI ui = b.getUI();
    Rectangle actionRect = ui.getLayoutInfo().actionClickArea;
    Rectangle popupRect = ui.getLayoutInfo().popupClickArea;

    if ((actionRect != null) && actionRect.contains(e.getPoint())) {
      if (actionModel.isEnabled()) {
        if (!SwingUtilities.isLeftMouseButton(e))
          actionModel.setRollover(true);
        if (actionModel.isPressed())
          actionModel.setArmed(true);
      }
      if (popupModel != null && !SwingUtilities.isLeftMouseButton(e))
        popupModel.setRollover(false);
    } else {
      if ((popupRect != null) && popupRect.contains(e.getPoint())) {
        if ((popupModel != null) && popupModel.isEnabled()) {
          if (!SwingUtilities.isLeftMouseButton(e))
            popupModel.setRollover(true);
          if (popupModel.isPressed())
            popupModel.setArmed(true);
        }
        if (!SwingUtilities.isLeftMouseButton(e))
          actionModel.setRollover(false);
      }
    }
View Full Code Here

   */
  @Override
    public void mouseExited(MouseEvent e) {
    AbstractCommandButton b = (AbstractCommandButton) e.getSource();
    ButtonModel actionModel = b.getActionModel();
    PopupButtonModel popupModel = (b instanceof JCommandButton) ? ((JCommandButton) b)
        .getPopupModel()
        : null;
    actionModel.setRollover(false);
    actionModel.setArmed(false);
    if (popupModel != null) {
      popupModel.setRollover(false);
      popupModel.setArmed(false);
    }
  };
View Full Code Here

        .setPopupOrientationKind(CommandButtonPopupOrientationKind.SIDEWARD);
    button.setHGapScaleFactor(0.75);
    button.getPopupModel().addChangeListener(new ChangeListener() {
      @Override
      public void stateChanged(ChangeEvent e) {
        PopupButtonModel model = button.getPopupModel();
        boolean displayDownwards = model.isRollover()
            || model.isPopupShowing();
        CommandButtonPopupOrientationKind popupOrientationKind = displayDownwards ? CommandButtonPopupOrientationKind.DOWNWARD
            : CommandButtonPopupOrientationKind.SIDEWARD;
        button.setPopupOrientationKind(popupOrientationKind);
      }
    });
View Full Code Here

          updateBorder();
        }

        if ("popupModel".equals(evt.getPropertyName())) {
          // rewire the popup action listener on the new popup model
          PopupButtonModel oldModel = (PopupButtonModel) evt
              .getOldValue();
          PopupButtonModel newModel = (PopupButtonModel) evt
              .getNewValue();

          if (oldModel != null) {
            oldModel.removePopupActionListener(popupActionListener);
            popupActionListener = null;
          }

          if (newModel != null) {
            popupActionListener = createPopupActionListener();
            newModel.addPopupActionListener(popupActionListener);
          }
        }
        if ("displayState".equals(evt.getPropertyName()) || ("enabled".equals(evt.getPropertyName()) && !((Boolean) evt.getNewValue()))) {
          syncIconDimension();
          syncDisabledIcon();
View Full Code Here

   * @param toFill
   *            Rectangle for the background.
   */
  protected void paintButtonBackground(Graphics graphics, Rectangle toFill) {
    ButtonModel actionModel = this.commandButton.getActionModel();
    PopupButtonModel popupModel = (this.commandButton instanceof JCommandButton) ? ((JCommandButton) this.commandButton)
        .getPopupModel()
        : null;

    // first time - paint the full background passing both models
    this.paintButtonBackground(graphics, toFill, actionModel, popupModel);

    Rectangle actionArea = this.getLayoutInfo().actionClickArea;
    Rectangle popupArea = this.getLayoutInfo().popupClickArea;
    if ((actionArea != null) && !actionArea.isEmpty()) {
      // now overlay the action area with the background matching action
      // model
      Graphics2D graphicsAction = (Graphics2D) graphics.create();
      // System.out.println(actionArea);
      graphicsAction.clip(actionArea);
      float actionAlpha = 0.4f;
      if ((popupModel != null) && !popupModel.isEnabled())
        actionAlpha = 1.0f;
      graphicsAction.setComposite(AlphaComposite.SrcOver
          .derive(actionAlpha));
      // System.out.println(graphicsAction.getClipBounds());
      this.paintButtonBackground(graphicsAction, toFill, actionModel);
View Full Code Here

   * Returns indication whether the action-popup areas separator is painted.
   *
   * @return <code>true</code> if the action-popup areas separator is painted.
   */
  protected boolean isPaintingSeparators() {
    PopupButtonModel popupModel = (this.commandButton instanceof JCommandButton) ? ((JCommandButton) this.commandButton)
        .getPopupModel()
        : null;
    boolean isActionRollover = this.commandButton.getActionModel()
        .isRollover();
    boolean isPopupRollover = (popupModel != null)
        && popupModel.isRollover();
    // Rectangle actionArea = this.getActionClickArea();
    // Rectangle popupArea = this.getPopupClickArea();
    // boolean hasNonEmptyAreas = (actionArea.width * actionArea.height
    // * popupArea.width * popupArea.height > 0);
    return // hasNonEmptyAreas &&
View Full Code Here

   * Returns indication whether the button background is painted.
   *
   * @return <code>true</code> if the button background is painted.
   */
  protected boolean isPaintingBackground() {
    PopupButtonModel popupModel = (this.commandButton instanceof JCommandButton) ? ((JCommandButton) this.commandButton)
        .getPopupModel()
        : null;
    boolean isActionSelected = this.commandButton.getActionModel()
        .isSelected();
    boolean isPopupSelected = (popupModel != null)
        && popupModel.isSelected();
    boolean isActionRollover = this.commandButton.getActionModel()
        .isRollover();
    boolean isPopupRollover = (popupModel != null)
        && popupModel.isRollover();
    boolean isPopupShowing = (popupModel != null)
        && (popupModel.isPopupShowing());
    boolean isActionArmed = this.commandButton.getActionModel().isArmed();
    boolean isPopupArmed = (popupModel != null) && (popupModel.isArmed());

    return (isActionSelected || isPopupSelected || isActionRollover
        || isPopupRollover || isPopupShowing || isActionArmed
        || isPopupArmed || !this.commandButton.isFlat());
  }
View Full Code Here

TOP

Related Classes of org.pushingpixels.flamingo.api.common.model.PopupButtonModel

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.