Example usage for java.lang Number intValue

List of usage examples for java.lang Number intValue

Introduction

In this page you can find the example usage for java.lang Number intValue.

Prototype

public abstract int intValue();

Source Link

Document

Returns the value of the specified number as an int .

Usage

From source file:mavn.network.view.JUNGPanelAdapter.java

public void fireNodes(final double[] result) {
    Transformer<Number, Paint> vertexPaint = new Transformer<Number, Paint>() {

        private final Color[] palette = { new Color(51, 181, 229), Color.BLACK, new Color(255, 68, 68) };

        @Override/*from w  ww  . j ava 2 s .c  o m*/
        public Paint transform(Number i) {
            if (i.doubleValue() == inputX || i.doubleValue() == inputY) {
                if (result[inputX] == 1) {
                    return palette[0];
                }
                if (result[inputY] == -1) {
                    return palette[0];
                }
            }
            if (i.doubleValue() >= andMin && i.doubleValue() <= andMax) {
                if (result[i.intValue()] == 1) {
                    return palette[0];
                }
                if (result[i.intValue()] == -1) {
                    return palette[1];
                }
            }
            if (i.doubleValue() >= orMin && i.doubleValue() <= orMax) {
                if (result[i.intValue()] == 1) {
                    return palette[0];
                }
                if (result[i.intValue()] == -1) {
                    return palette[1];
                }
            }
            if (i.doubleValue() == output) {
                if (result[output] == 1) {
                    return palette[0];
                }
                if (result[output] == -1) {
                    return palette[1];
                }
            }
            return palette[2];
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
}

From source file:io.fabric8.mq.autoscaler.MQAutoScaler.java

private BrokerVitalSigns getBrokerVitalSigns(J4pClient client) {
    BrokerVitalSigns brokerVitalSigns = null;
    ObjectName root = null;//from  www. j a va2 s  . c o  m
    String attribute = "";
    if (client != null) {

        try {
            root = getBrokerJMXRoot(client);
            attribute = "BrokerName";
            Object brokerName = getAttribute(client, root, attribute);

            attribute = "BrokerId";
            Object brokerId = getAttribute(client, root, attribute);

            brokerVitalSigns = new BrokerVitalSigns(brokerName.toString(), brokerId.toString(), client, root);

            attribute = "TotalConnectionsCount";
            Number result = (Number) getAttribute(client, root, attribute);
            brokerVitalSigns.setTotalConnections(result.intValue());
            populateDestinations(brokerVitalSigns);

        } catch (Throwable e) {
            LOG.error("Unable able to get BrokerVitalSigns from type=" + root + ",attribute: " + attribute, e);
        }
    }
    return brokerVitalSigns;
}

From source file:es.logongas.ix3.dao.impl.GenericDAOImplHibernate.java

/**
 * Pone los parmetros en una Query/*from w  w  w  .  j  a v a 2s.  c  om*/
 *
 * @param query La Query a la que se le pone los parmetros.
 * @param parameters El map debe ser del tipo Map<String,Object> o Map<Integer,Object>. Y se pondrn los parmetros por nombre o por posicin.
 */
private void setParameters(Query query, Map<Object, Object> parameters) {
    if (parameters != null) {
        for (Map.Entry<Object, Object> entry : parameters.entrySet()) {
            Object value = entry.getValue();
            Object parameterKey = entry.getKey();

            if (parameterKey == null) {
                throw new NullPointerException("El nombre de un parmetro no puede ser null");
            }

            if (parameterKey instanceof Number) {
                Number parameterIndex = (Number) parameterKey;
                query.setParameter(parameterIndex.intValue(), value);
            } else if (parameterKey instanceof String) {
                String parameterName = (String) parameterKey;
                if (value instanceof Object[]) {
                    query.setParameterList(parameterName, (Object[]) value);
                } else if (value instanceof Collection) {
                    query.setParameterList(parameterName, (Collection) value);
                } else {
                    query.setParameter(parameterName, value);
                }
            } else {
                throw new RuntimeException("La clave debe ser de tipo String o Number");
            }
        }
    }
}

From source file:com.prowidesoftware.swift.model.field.Field257.java

/**
 * Set the component5 from a Number object.
 * <br />/*w  ww.ja v a2 s.  co m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent5(String) 
 * method.
 * 
 * @see #setComponent5(String)
 *
 * @param component5 the Number with the component5 content to set
 */
public Field257 setComponent5(java.lang.Number component5) {
    if (component5 != null) {
        setComponent(5, "" + component5.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field260.java

/**
 * Set the component5 from a Number object.
 * <br />//from  w  ww .j av  a 2  s.  com
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent5(String) 
 * method.
 * 
 * @see #setComponent5(String)
 *
 * @param component5 the Number with the component5 content to set
 */
public Field260 setComponent5(java.lang.Number component5) {
    if (component5 != null) {
        setComponent(5, "" + component5.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field263.java

/**
 * Set the component5 from a Number object.
 * <br />/*from   w w  w .ja  v  a 2  s.co  m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent5(String) 
 * method.
 * 
 * @see #setComponent5(String)
 *
 * @param component5 the Number with the component5 content to set
 */
public Field263 setComponent5(java.lang.Number component5) {
    if (component5 != null) {
        setComponent(5, "" + component5.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field264.java

/**
 * Set the component5 from a Number object.
 * <br />//www. j a v a  2s  .c o m
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent5(String) 
 * method.
 * 
 * @see #setComponent5(String)
 *
 * @param component5 the Number with the component5 content to set
 */
public Field264 setComponent5(java.lang.Number component5) {
    if (component5 != null) {
        setComponent(5, "" + component5.intValue());
    }
    return this;
}

From source file:com.example.app.profile.ui.user.ProfileMembershipManagement.java

@Override
public void init() {
    super.init();
    setValidator(CompositeValidator.of((component, notifiable) -> validateSupporters(notifiable),
            (component, notifiable) -> {
                if (_requiredMembershipTypes.isEmpty())
                    return true;
                final HashSet<MembershipType> toCheck = new HashSet<>(_requiredMembershipTypes);
                getProfile().getMembershipSet()
                        .forEach(membership -> toCheck.remove(membership.getMembershipType()));
                toCheck.forEach(mt -> {
                    NotificationImpl notification = new NotificationImpl(NotificationType.ERROR,
                            createText(CommonValidationText.ARG0_IS_REQUIRED, mt.getName()));
                    notification.setSource(this);
                    notifiable.sendNotification(notification);
                });//from   w  w  w  .  j a  v  a2s.c  o  m
                return toCheck.isEmpty();
            }));

    User currentUser = _userDAO.getAssertedCurrentUser();
    Hibernate.initialize(currentUser);
    Hibernate.initialize(currentUser.getPrincipal());
    Hibernate.initialize(currentUser.getPrincipal().getContact());
    final Profile adminProfile = getProfile();
    final TimeZone timeZone = getSession().getTimeZone();
    boolean isAdminish = _profileDAO.canOperate(currentUser, adminProfile, timeZone, _mop.modifyCompany());
    if (!_profileDAO.canOperate(currentUser, adminProfile, timeZone, _mop.modifyUserRoles())) {
        Label label = new Label(INSUFFICIENT_PERMISSIONS(MEMBERSHIP())).withHTMLElement(HTMLElement.h3);
        setDefaultComponent(label);
        return;
    }
    final SimpleDateFormat dateFormat = getDateFormat(getLocaleContext().getLocale());
    dateFormat.setTimeZone(getSession().getTimeZone());
    final DateFormatLabel dateRenderer = new DateFormatLabel(dateFormat) {
        @Override
        public Component getTableCellRendererComponent(Table table, Object cellValue, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Date value = (Date) cellValue;
            value = toDate(convertFromPersisted(value, getSession().getTimeZone()));
            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    };
    final NamedObjectComparator nocComparator = new NamedObjectComparator(getLocaleContext());
    FixedValueColumn actionColumn = new FixedValueColumn();
    actionColumn.setColumnName(CommonColumnText.ACTIONS);
    PropertyColumn userColumn = new PropertyColumn(Membership.class, Membership.USER_PROP);
    userColumn.setColumnName(CommonColumnText.USER);
    userColumn.setComparator(nocComparator);
    PropertyColumn membershipTypeColumn = new PropertyColumn(Membership.class, Membership.MEMBERSHIP_TYPE_PROP);
    membershipTypeColumn.setColumnName(MEMBERSHIP_TYPE());
    membershipTypeColumn.setComparator(nocComparator);
    PropertyColumn membershipDStartColumn = new PropertyColumn(Membership.class, Membership.START_DATE_PROP);
    membershipDStartColumn.setColumnName(START_DATE());
    membershipDStartColumn.setComparator(ComparableComparator.getInstance());
    PropertyColumn membershipDEndColumn = new PropertyColumn(Membership.class, Membership.END_DATE_PROP);
    membershipDEndColumn.setComparator(ComparableComparator.getInstance());
    membershipDEndColumn.setColumnName(END_DATE());

    _membershipTable = isAllowEditActive()
            ? new DataColumnTable<>(actionColumn, userColumn, membershipTypeColumn, membershipDStartColumn,
                    membershipDEndColumn)
            : new DataColumnTable<>(actionColumn, userColumn, membershipTypeColumn);
    _membershipTable.setTableCellRenderer(dateRenderer, Date.class);
    _membershipTable.getDefaultModel().setAutoReattachEntities(false);
    _membershipTable.setRowModel(new RowModelImpl() {
        @Override
        public Row getRow(Table table, int row) {
            final Row r = super.getRow(table, row);
            final Membership membership = _membershipTable.getDefaultModel().getRow(row);
            if (membership.isActive()) {
                r.removeClassName("member-inactive");
                r.addClassName("member-active");
            } else {
                r.addClassName("member-inactive");
                r.removeClassName("member-active");
            }
            return r;
        }
    });

    QLResolverOptions resolverOptions = new QLResolverOptions();
    resolverOptions.setFetchSize(1);
    resolverOptions.setCacheRegion(ProjectCacheRegions.MEMBER_QUERY);

    PushButton editOperationsBtn = new PushButton(BUTTON_TEXT_MODIFY()) {
        @Override
        public Component getTableCellRendererComponent(Table table, @Nullable Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Membership mem = (Membership) value;
            boolean hasOperations = false;
            if (mem != null) {
                final QLBuilderImpl qb = new QLBuilderImpl(ProfileType.class, "ptAlias");
                qb.setQLResolverOptions(resolverOptions);
                qb.appendCriteria("id", PropertyConstraint.Operator.eq,
                        mem.getProfile().getProfileType().getId());
                final JoinedQLBuilder mtQB = qb.createInnerJoin(ProfileType.MEMBERSHIP_TYPES_PROP);
                final JoinedQLBuilder opQB = mtQB.createInnerJoin(MembershipType.DEFAULT_OPERATIONS_PROP);
                qb.setProjection("COUNT(DISTINCT %s)", opQB.getAlias());

                try (CloseableIterator<?> it = qb.getQueryResolver().iterate()) {
                    if (it.hasNext()) {
                        final Number next = (Number) it.next();
                        hasOperations = next.intValue() > 0;
                    }
                }
            }
            setVisible(hasOperations && isAdminish);

            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    };
    editOperationsBtn.addActionListener(eev -> doOperationEdit(_membershipTable.getLeadSelection()));
    PushButton editActivationDatesBtn = new PushButton(ACTION_EDIT_DATES());
    editActivationDatesBtn.setTooltip(TOOLTIP_EDIT_DATES(MEMBERSHIP()));
    editActivationDatesBtn.addActionListener(eev -> doDatesEdit(_membershipTable.getLeadSelection()));

    PushButton deactivateBtn = new PushButton(ACTION_DEACTIVATE()) {
        @Override
        public Component getTableCellRendererComponent(Table table, @Nullable Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Membership m = (Membership) value;
            assert m != null;
            setVisible(m.getEndDate() == null);

            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    };
    deactivateBtn.setTooltip(TOOLTIP_DEACTIVATE());
    deactivateBtn.addActionListener(ev -> {
        final Membership membership = _membershipTable.getLeadSelection();
        assert membership != null;
        final Date now = convertForPersistence(
                getZonedDateTimeForComparison(timeZone).minus(1, ChronoUnit.DAYS));
        membership.setEndDate(now);
        showHideConstraints();
    });

    PushButton deleteBtn = CommonActions.DELETE.push();
    deleteBtn.getButtonDisplay().setConfirmText(DELETE_CONFIRM_TEXT_FMT(MEMBERSHIP()));
    deleteBtn.addActionListener(dev -> {
        final Membership membership = _membershipTable.getLeadSelection();
        assert membership != null;
        membership.getProfile().getMembershipSet().remove(membership);
        reloadTableData();
    });
    Container actions = of("actions", editOperationsBtn);
    if (isAllowEditActive()) {
        actions.add(editActivationDatesBtn);
        actions.add(deactivateBtn);
    }
    if (isAdminish)
        actions.add(deleteBtn);
    final Column uiColumn = _membershipTable.getUIColumn(actionColumn);
    assert uiColumn != null;
    uiColumn.setDisplayClass("action-column");
    _membershipTable.setUICellRenderer(actionColumn, actions);

    Menu menu = new Menu(CommonButtonText.ADD);
    menu.setTooltip(ConcatTextSource.create(CommonButtonText.ADD, MEMBERSHIP_TYPE()).withSpaceSeparator());
    enableTooltip(menu);
    menu.addClassName("entity-action");
    LocaleContext lc = getLocaleContext();
    getProfile().getProfileType().getMembershipTypeSet().stream()
            .filter(membershipType -> !_excludedMembershipTypes.contains(membershipType))
            .sorted(new NamedObjectComparator(lc)).forEach(mt -> {
                TextSource menuItemText = mt.getName();
                MenuItem mi = new MenuItem(menuItemText);
                mi.addActionListener(ev -> doSelectUserAndCreateMembership(mt));
                menu.add(mi);
            });

    _activeConstraint.setSelectedObject(ACTIVE());
    _activeConstraint.addActionListener(this::reloadTableData);

    setDefaultComponent(of("search-wrapper profile-role-search", of("entity-actions actions", menu),
            of("search-bar", _activeConstraint), new Pager(_membershipTable.addClassName("search-results"))));

    reloadTableData();
}

From source file:com.prowidesoftware.swift.model.field.Field98D.java

/**
 * Set the component3 from a Number object.
 * <br />/*w w w  . j a va2s  .  c  o  m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent3(String) 
 * method.
 * 
 * @see #setComponent3(String)
 *
 * @param component3 the Number with the component3 content to set
 */
public Field98D setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field98G.java

/**
 * Set the component3 from a Number object.
 * <br />/*ww w.  j  av a2  s  .c o  m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent3(String) 
 * method.
 * 
 * @see #setComponent3(String)
 *
 * @param component3 the Number with the component3 content to set
 */
public Field98G setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}