Search in sources :

Example 86 with Pair

use of net.imglib2.util.Pair in project Osmand by osmandapp.

the class PagerSlidingTabStrip method getIndicatorCoordinates.

private Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();
    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();
        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }
    return new Pair<Float, Float>(lineLeft, lineRight);
}
Also used : HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) Pair(android.support.v4.util.Pair)

Example 87 with Pair

use of net.imglib2.util.Pair in project Osmand by osmandapp.

the class MapSourceAction method execute.

@Override
public void execute(MapActivity activity) {
    if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
        OsmandSettings settings = activity.getMyApplication().getSettings();
        List<Pair<String, String>> sources = loadListFromParams();
        Pair<String, String> currentSource = settings.MAP_ONLINE_DATA.get() ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get()) : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data));
        Pair<String, String> nextSource = sources.get(0);
        int index = sources.indexOf(currentSource);
        if (index >= 0 && index + 1 < sources.size()) {
            nextSource = sources.get(index + 1);
        }
        if (nextSource.first.equals(LAYER_OSM_VECTOR)) {
            settings.MAP_ONLINE_DATA.set(false);
            activity.getMapLayers().updateMapSource(activity.getMapView(), null);
        } else {
            settings.MAP_TILE_SOURCES.set(nextSource.first);
            settings.MAP_ONLINE_DATA.set(true);
            activity.getMapLayers().updateMapSource(activity.getMapView(), settings.MAP_TILE_SOURCES);
        }
        Toast.makeText(activity, activity.getString(R.string.quick_action_map_source_switch, nextSource.second), Toast.LENGTH_SHORT).show();
    }
}
Also used : OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin) OsmandSettings(net.osmand.plus.OsmandSettings) Pair(android.support.v4.util.Pair)

Example 88 with Pair

use of net.imglib2.util.Pair in project streamline by hortonworks.

the class KafkaServiceRegistrar method createKafkaBrokerComponent.

private Pair<Component, List<ComponentProcess>> createKafkaBrokerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_LISTENERS)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_LISTENERS + " not present.");
    }
    Map<String, String> confMap = new HashMap<>();
    confMap.put(PARAM_LISTENERS, config.getString(PARAM_LISTENERS));
    Component kafkaBroker = new Component();
    kafkaBroker.setName(COMPONENT_KAFKA_BROKER);
    List<KafkaBrokerListeners.ListenersPropEntry> parsedProps = new KafkaBrokerListeners.ListenersPropParsed(confMap).getParsedProps();
    List<ComponentProcess> componentProcesses = parsedProps.stream().map(propEntry -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(propEntry.getHost());
        cp.setPort(propEntry.getPort());
        cp.setProtocol(propEntry.getProtocol().name());
        return cp;
    }).collect(toList());
    return new Pair<>(kafkaBroker, componentProcesses);
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Pair(org.apache.commons.math3.util.Pair) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Lists(com.google.common.collect.Lists) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) KafkaBrokerListeners(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaBrokerListeners) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) KafkaBrokerListeners(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaBrokerListeners) Pair(org.apache.commons.math3.util.Pair)

Example 89 with Pair

use of net.imglib2.util.Pair in project streamline by hortonworks.

the class StormServiceRegistrar method createNimbusComponent.

private Pair<Component, List<ComponentProcess>> createNimbusComponent(Config config, Map<String, String> flatConfigMap) {
    if (!config.contains(PARAM_NIMBUS_SEEDS)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " not present.");
    }
    if (!config.contains(PARAM_NIMBUS_THRIFT_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_THRIFT_PORT + " not present.");
    }
    String nimbusSeeds;
    try {
        nimbusSeeds = config.getString(PARAM_NIMBUS_SEEDS);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " should be a string.");
    }
    Number nimbusThriftPort = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_PORT);
    Component nimbus = new Component();
    nimbus.setName(COMPONENT_NIMBUS);
    List<ComponentProcess> componentProcesses = Arrays.stream(nimbusSeeds.split(",")).map(nimbusHost -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(nimbusHost);
        cp.setPort(nimbusThriftPort.intValue());
        return cp;
    }).collect(toList());
    return new Pair<>(nimbus, componentProcesses);
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Arrays(java.util.Arrays) Pair(org.apache.commons.math3.util.Pair) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Lists(com.google.common.collect.Lists) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Collections(java.util.Collections) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Pair(org.apache.commons.math3.util.Pair)

Example 90 with Pair

use of net.imglib2.util.Pair in project streamline by hortonworks.

the class StormServiceRegistrar method createStormUIServerComponent.

private Pair<Component, List<ComponentProcess>> createStormUIServerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_UI_HOST)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " not present.");
    }
    if (!config.contains(PARAM_UI_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_PORT + " not present.");
    }
    String stormUiServerHost;
    try {
        stormUiServerHost = config.getString(PARAM_UI_HOST);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " should be a string.");
    }
    Number stormUiServerPort = readNumberFromConfig(config, PARAM_UI_PORT);
    Component stormUiServer = new Component();
    stormUiServer.setName(COMPONENT_STORM_UI_SERVER);
    ComponentProcess uiProcess = new ComponentProcess();
    uiProcess.setHost(stormUiServerHost);
    uiProcess.setPort(stormUiServerPort.intValue());
    return new Pair<>(stormUiServer, Collections.singletonList(uiProcess));
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Pair(org.apache.commons.math3.util.Pair)

Aggregations

Pair (android.support.v4.util.Pair)79 ArrayList (java.util.ArrayList)49 Pair (org.apache.commons.math3.util.Pair)38 View (android.view.View)28 List (java.util.List)22 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)19 Intent (android.content.Intent)18 TextView (android.widget.TextView)15 HashMap (java.util.HashMap)15 Map (java.util.Map)15 Arrays (java.util.Arrays)13 Test (org.junit.Test)12 ImageView (android.widget.ImageView)11 RecyclerView (android.support.v7.widget.RecyclerView)9 Collections (java.util.Collections)9 Person (org.drools.modelcompiler.domain.Person)9 KieSession (org.kie.api.runtime.KieSession)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Assertions (org.assertj.core.api.Assertions)7 Cursor (android.database.Cursor)4