Search in sources :

Example 1 with AbstractBounded

use of org.cytoscape.work.util.AbstractBounded in project cytoscape-impl by cytoscape.

the class BoundedHandler method update.

@Override
public void update() {
    isUpdating = true;
    try {
        final T bounded = getBounded();
        if (lastBounded != bounded) {
            lastBounded = bounded;
            // Make sure we're the only handler for this Tunable that's listening
            // for changes.  If we're in the middle of a refresh, we can sometimes
            // be in a state where there are two...
            BoundedChangeListener<N> found = null;
            List<BoundedChangeListener<N>> listeners = ((AbstractBounded) lastBounded).getListeners();
            for (BoundedChangeListener<N> listener : listeners) {
                if (listener instanceof AbstractGUITunableHandler && ((AbstractGUITunableHandler) listener).getQualifiedName().equals(this.getQualifiedName()))
                    found = listener;
            }
            if (found != null)
                lastBounded.removeListener(found);
            lastBounded.addListener(this);
            panel.removeAll();
            initPanel(bounded);
        } else {
            if (useSlider) {
                Number n = (Number) bounded.getValue();
                slider.setValue(n);
            } else {
                boundedField = new TunableBoundedField((Number) bounded.getValue(), (Number) bounded.getLowerBound(), (Number) bounded.getUpperBound(), bounded.isLowerBoundStrict(), bounded.isUpperBoundStrict());
            }
        }
    } catch (Exception e) {
        logger.error("Could not update bounded value", e);
    }
    isUpdating = false;
}
Also used : BoundedChangeListener(org.cytoscape.work.util.BoundedChangeListener) TunableBoundedField(org.cytoscape.work.internal.tunables.utils.TunableBoundedField) AbstractBounded(org.cytoscape.work.util.AbstractBounded) AbstractGUITunableHandler(org.cytoscape.work.swing.AbstractGUITunableHandler)

Example 2 with AbstractBounded

use of org.cytoscape.work.util.AbstractBounded in project cytoscape-impl by cytoscape.

the class BoundedPropertyHandler method parseAndSetValue.

@SuppressWarnings("unchecked")
@Override
public void parseAndSetValue(String propertyValue) {
    AbstractBounded container = getContainer();
    Class<?> elementType = getElementType();
    Object value = BasicTypePropertyHandler.parseValue(getName(), propertyValue, elementType);
    container.setValue((Comparable) value);
}
Also used : AbstractBounded(org.cytoscape.work.util.AbstractBounded)

Example 3 with AbstractBounded

use of org.cytoscape.work.util.AbstractBounded in project cytoscape-impl by cytoscape.

the class HelpGenerator method boundedTypeString.

private String boundedTypeString(Class<?> type, Object object) {
    if (object instanceof AbstractBounded) {
        AbstractBounded ab = (AbstractBounded) object;
        String str = "&lt;" + classString(type.getSimpleName()) + "&nbsp;(";
        str += ab.getLowerBound().toString() + "&lt;";
        if (!ab.isLowerBoundStrict())
            str += "=";
        if (ab.getValue() != null) {
            str += ab.getValue().toString();
        } else {
            str += classString(ab.getLowerBound().getClass().getSimpleName());
        }
        str += "&lt;";
        if (!ab.isUpperBoundStrict())
            str += "=";
        str += ab.getUpperBound().toString() + ")&gt;";
        return fixedSpan(str);
    } else {
        return fixedSpan("&lt;" + classString(type.getSimpleName()) + "&gt;");
    }
}
Also used : AbstractBounded(org.cytoscape.work.util.AbstractBounded)

Aggregations

AbstractBounded (org.cytoscape.work.util.AbstractBounded)3 TunableBoundedField (org.cytoscape.work.internal.tunables.utils.TunableBoundedField)1 AbstractGUITunableHandler (org.cytoscape.work.swing.AbstractGUITunableHandler)1 BoundedChangeListener (org.cytoscape.work.util.BoundedChangeListener)1