Java Code Examples for com.facebook.react.bridge.ReadableMap#getDouble()

The following examples show how to use com.facebook.react.bridge.ReadableMap#getDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNAGSMapView.java    From react-native-arcgis-mapview with MIT License 6 votes vote down vote up
public void centerMap(ReadableArray args) {
    final ArrayList<Point> points = new ArrayList<>();
    for (int i = 0; i <  args.size(); i++) {
        ReadableMap item = args.getMap(i);
        if (item == null) {
            continue;
        }
        Double latitude = item.getDouble("latitude");
        Double longitude = item.getDouble("longitude");
        if(latitude == 0 || longitude == 0) {
            continue;
        }
        points.add(new Point(longitude, latitude, SpatialReferences.getWgs84()));
    }
    // Perform the recentering
    if (points.size() == 1) {
        mapView.setViewpointCenterAsync(points.get(0),60000);
    } else if (points.size() > 1) {
        PointCollection pointCollection = new PointCollection(points);
        Polygon polygon = new Polygon(pointCollection);
        mapView.setViewpointGeometryAsync(polygon, 50);
    }

}
 
Example 2
Source File: RNAGSGraphicsOverlay.java    From react-native-arcgis-mapview with MIT License 6 votes vote down vote up
public static Point fromRawData(ReadableMap rawData) {
    // Convert map to attribute map
    Map<String, Object> map = null;
    if (rawData.hasKey("attributes")) {
        ReadableMap rawMap = rawData.getMap("attributes");
        map = RNAGSGraphicsOverlay.readableMapToMap(rawMap);
    }
    Double rotation = 0.0;
    if (rawData.hasKey("rotation")) {
        rotation = rawData.getDouble("rotation");
    }
    String graphicId = "";
    if (rawData.hasKey("graphicId")) {
        graphicId = rawData.getString("graphicId");
    }
    return new Point(
            rawData.getDouble("latitude"),
            rawData.getDouble("longitude"),
            rotation,
            rawData.getString("referenceId"),
            map,
            graphicId
    );
}
 
Example 3
Source File: ChartDataSetConfigUtils.java    From react-native-mp-android-chart with MIT License 6 votes vote down vote up
public static void commonLineRadarConfig(LineRadarDataSet dataSet, ReadableMap config) {
    if (BridgeUtils.validate(config, ReadableType.String, "fillColor")) {
        dataSet.setFillColor(Color.parseColor(config.getString("fillColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "fillAlpha")) {
        dataSet.setFillAlpha(config.getInt("fillAlpha"));
    }
    // TODO setFillDrawable android.graphics.drawable.Drawable
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawFilled")) {
        dataSet.setDrawFilled(config.getBoolean("drawFilled"));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "lineWidth")) {
        float lineWidth = (float) config.getDouble("lineWidth");
        if (lineWidth >= 0.2f && lineWidth < 10f) {
            dataSet.setLineWidth(lineWidth);
        }
    }
}
 
Example 4
Source File: CatalystNativeJSToJavaParametersTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void mapGetByType(ReadableMap map, String key, String typeToAskFor) {
  if (typeToAskFor.equals("double")) {
    map.getDouble(key);
  } else if (typeToAskFor.equals("int")) {
    map.getInt(key);
  } else if (typeToAskFor.equals("string")) {
    map.getString(key);
  } else if (typeToAskFor.equals("array")) {
    map.getArray(key);
  } else if (typeToAskFor.equals("map")) {
    map.getMap(key);
  } else if (typeToAskFor.equals("boolean")) {
    map.getBoolean(key);
  } else {
    throw new RuntimeException("Unknown type: " + typeToAskFor);
  }
}
 
Example 5
Source File: ConvertUtils.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
private static Object getValue(ReadableMap readableMa, Field field) {
    if (field.getType().equals(Integer.class)) {
        return readableMa.getInt(field.getName());
    }
    if (field.getType().equals(Double.class)) {
        return readableMa.getDouble(field.getName());
    }
    if (field.getType().equals(String.class)) {
        return readableMa.getString(field.getName());
    }
    if (field.getType().equals(Boolean.class)) {
        return readableMa.getBoolean(field.getName());
    }
    return null;
}
 
Example 6
Source File: OptionsHelper.java    From react-native-lock with MIT License 5 votes vote down vote up
public static  Map<String, Object> convertReadableMapToMap(ReadableMap reactMap) {
    Map<String, Object> map = new HashMap<>();
    ReadableMapKeySetIterator keySet = reactMap.keySetIterator();
    while (keySet.hasNextKey()) {
        String key = keySet.nextKey();
        Object object = null;
        switch (reactMap.getType(key)) {
            case Array:
                object = convertReadableArrayToArray(reactMap.getArray(key));
                break;
            case Boolean:
                object = reactMap.getBoolean(key);
                break;
            case Map:
                object = convertReadableMapToMap(reactMap.getMap(key));
                break;
            case Null:
                object = null;
                break;
            case Number:
                try {
                    object = reactMap.getDouble(key);
                } catch (java.lang.ClassCastException e) {
                    object = reactMap.getInt(key);
                }
                break;
            case String:
                object = reactMap.getString(key);
                break;
            default:
                Log.e(TAG, "Unknown type: " + reactMap.getType(key) + " for key: " + key);
        }
        map.put(key, object);
    }
    return map;
}
 
Example 7
Source File: MusicControlModule.java    From react-native-music-control with MIT License 5 votes vote down vote up
@ReactMethod
synchronized public void updatePlayback(ReadableMap info) {
    init();

    long updateTime;
    long elapsedTime;
    long bufferedTime = info.hasKey("bufferedTime") ? (long)(info.getDouble("bufferedTime") * 1000) : state.getBufferedPosition();
    float speed = info.hasKey("speed") ? (float)info.getDouble("speed") : state.getPlaybackSpeed();
    int pbState = info.hasKey("state") ? info.getInt("state") : state.getState();
    int maxVol = info.hasKey("maxVolume") ? info.getInt("maxVolume") : volume.getMaxVolume();
    int vol = info.hasKey("volume") ? info.getInt("volume") : volume.getCurrentVolume();
    ratingType = info.hasKey("rating") ? info.getInt("rating") : ratingType;

    if(info.hasKey("elapsedTime")) {
        elapsedTime = (long)(info.getDouble("elapsedTime") * 1000);
        updateTime = SystemClock.elapsedRealtime();
    } else {
        elapsedTime = state.getPosition();
        updateTime = state.getLastPositionUpdateTime();
    }

    pb.setState(pbState, elapsedTime, speed, updateTime);
    pb.setBufferedPosition(bufferedTime);
    pb.setActions(controls);

    isPlaying = pbState == PlaybackStateCompat.STATE_PLAYING || pbState == PlaybackStateCompat.STATE_BUFFERING;
    if(session.isActive()) notification.show(nb, isPlaying);

    state = pb.build();
    session.setPlaybackState(state);

    session.setRatingType(ratingType);

    if(remoteVolume) {
        session.setPlaybackToRemote(volume.create(null, maxVol, vol));
    } else {
        session.setPlaybackToLocal(AudioManager.STREAM_MUSIC);
    }
}
 
Example 8
Source File: NSTStreetView.java    From react-native-streetview with MIT License 5 votes vote down vote up
public void setCoordinate(ReadableMap coordinate) {

        if (coordinate == null ) return;
        Double lng = coordinate.getDouble("longitude");
        Double lat = coordinate.getDouble("latitude");

        // saving radius
        this.radius = coordinate.hasKey("radius") ? coordinate.getInt("radius") : 50;

        // Saving to local variable as panorama may not be ready yet (async)
        this.coordinate = new LatLng(lat, lng);
         if (this.coordinate != null && this.started  ) {
            this.panorama.setPosition(this.coordinate, this.radius);
         }
    }
 
Example 9
Source File: ImageEditingManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Crop an image. If all goes well, the success callback will be called with the file:// URI of
 * the new image as the only argument. This is a temporary file - consider using
 * CameraRollManager.saveImageWithTag to save it in the gallery.
 *
 * @param uri the MediaStore URI of the image to crop
 * @param options crop parameters specified as {@code {offset: {x, y}, size: {width, height}}}.
 *        Optionally this also contains  {@code {targetSize: {width, height}}}. If this is
 *        specified, the cropped image will be resized to that size.
 *        All units are in pixels (not DPs).
 * @param success callback to be invoked when the image has been cropped; the only argument that
 *        is passed to this callback is the file:// URI of the new image
 * @param error callback to be invoked when an error occurs (e.g. can't create file etc.)
 */
@ReactMethod
public void cropImage(
    String uri,
    ReadableMap options,
    final Callback success,
    final Callback error) {
  ReadableMap offset = options.hasKey("offset") ? options.getMap("offset") : null;
  ReadableMap size = options.hasKey("size") ? options.getMap("size") : null;
  if (offset == null || size == null ||
      !offset.hasKey("x") || !offset.hasKey("y") ||
      !size.hasKey("width") || !size.hasKey("height")) {
    throw new JSApplicationIllegalArgumentException("Please specify offset and size");
  }
  if (uri == null || uri.isEmpty()) {
    throw new JSApplicationIllegalArgumentException("Please specify a URI");
  }

  CropTask cropTask = new CropTask(
      getReactApplicationContext(),
      uri,
      (int) offset.getDouble("x"),
      (int) offset.getDouble("y"),
      (int) size.getDouble("width"),
      (int) size.getDouble("height"),
      success,
      error);
  if (options.hasKey("displaySize")) {
    ReadableMap targetSize = options.getMap("displaySize");
    cropTask.setTargetSize(
      (int) targetSize.getDouble("width"),
      (int) targetSize.getDouble("height"));
  }
  cropTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 10
Source File: ConversionUtil.java    From react-native-eval with MIT License 5 votes vote down vote up
/**
 * toObject extracts a value from a {@link ReadableMap} by its key,
 * and returns a POJO representing that object.
 *
 * @param readableMap The Map to containing the value to be converted
 * @param key The key for the value to be converted
 * @return The converted POJO
 */
public static Object toObject(@Nullable ReadableMap readableMap, String key) {
    if (readableMap == null) {
        return null;
    }

    Object result;

    ReadableType readableType = readableMap.getType(key);
    switch (readableType) {
        case Null:
            result = null;
            break;
        case Boolean:
            result = readableMap.getBoolean(key);
            break;
        case Number:
            // Can be int or double.
            double tmp = readableMap.getDouble(key);
            if (tmp == (int) tmp) {
                result = (int) tmp;
            } else {
                result = tmp;
            }
            break;
        case String:
            result = readableMap.getString(key);
            break;
        case Map:
            result = toMap(readableMap.getMap(key));
            break;
        case Array:
            result = toList(readableMap.getArray(key));
            break;
        default:
            throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
    }

    return result;
}
 
Example 11
Source File: ModulusAnimatedNode.java    From react-native-GPay with MIT License 5 votes vote down vote up
public ModulusAnimatedNode(
    ReadableMap config,
    NativeAnimatedNodesManager nativeAnimatedNodesManager) {
  mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
  mInputNode = config.getInt("input");
  mModulus = config.getDouble("modulus");
}
 
Example 12
Source File: RNAGSMapView.java    From react-native-arcgis-mapview with MIT License 5 votes vote down vote up
public void showCallout(ReadableMap args) {
    ReadableMap rawPoint = args.getMap("point");
    if (!rawPoint.hasKey("latitude") || !rawPoint.hasKey("longitude")) {
        return;
    }
    Double latitude = rawPoint.getDouble("latitude");
    Double longitude = rawPoint.getDouble("longitude");
    if (latitude == 0 || longitude == 0) {
        return;
    }
    String title = "";
    String text = "";
    Boolean shouldRecenter = false;

    if(args.hasKey("title")) {
        title = args.getString("title");
    }
    if(args.hasKey("text")) {
        text = args.getString("text");
    }
    if(args.hasKey("shouldRecenter")) {
        shouldRecenter = args.getBoolean("shouldRecenter");
    }

    // Displaying the callout
    Point agsPoint = new Point(longitude, latitude, SpatialReferences.getWgs84());

    // Set callout content
    View calloutContent = callout.getContent();
    ((TextView) calloutContent.findViewById(R.id.title)).setText(title);
    ((TextView) calloutContent.findViewById(R.id.text)).setText(text);
    callout.setLocation(agsPoint);
    callout.show();
    Log.i("AGS",callout.isShowing()+" " + calloutContent.getWidth() + " " + calloutContent.getHeight());
    if (shouldRecenter) {
        mapView.setViewpointCenterAsync(agsPoint);
    }
}
 
Example 13
Source File: RNFusedLocationModule.java    From react-native-geolocation-service with MIT License 4 votes vote down vote up
/**
 * Start listening for location updates. These will be emitted via the
 * {@link RCTDeviceEventEmitter} as {@code geolocationDidChange} events.
 *
 * @param options map containing optional arguments: highAccuracy (boolean), distanceFilter (double),
 *                interval (millis), fastestInterval (millis)
 */
@ReactMethod
public void startObserving(ReadableMap options) {
  ReactApplicationContext context = getContext();

  if (!LocationUtils.hasLocationPermission(context)) {
    invokeError(
      LocationError.PERMISSION_DENIED.getValue(),
      "Location permission not granted.",
      false
    );
    return;
  }

  if (!LocationUtils.isGooglePlayServicesAvailable(context)) {
    invokeError(
      LocationError.PLAY_SERVICE_NOT_AVAILABLE.getValue(),
      "Google play service is not available.",
      false
    );
    return;
  }

  boolean highAccuracy = options.hasKey("enableHighAccuracy")
    && options.getBoolean("enableHighAccuracy");

  // TODO: Make other PRIORITY_* constants available to the user
  mLocationPriority = highAccuracy ? LocationRequest.PRIORITY_HIGH_ACCURACY : DEFAULT_ACCURACY;
  mDistanceFilter = options.hasKey("distanceFilter")
    ? (float) options.getDouble("distanceFilter")
    : DEFAULT_DISTANCE_FILTER;
  mUpdateInterval = options.hasKey("interval")
    ? (long) options.getDouble("interval")
    : DEFAULT_INTERVAL;
  mFastestInterval = options.hasKey("fastestInterval")
    ? (long) options.getDouble("fastestInterval")
    : DEFAULT_INTERVAL;
  mShowLocationDialog = options.hasKey("showLocationDialog")
    ? options.getBoolean("showLocationDialog")
    : true;
  mForceRequestLocation = options.hasKey("forceRequestLocation")
    ? options.getBoolean("forceRequestLocation")
    : false;

  LocationSettingsRequest locationSettingsRequest = buildLocationSettingsRequest();

  if (mSettingsClient != null) {
    mSettingsClient.checkLocationSettings(locationSettingsRequest)
      .addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
        @Override
        public void onComplete(@NonNull Task<LocationSettingsResponse> task) {
          onLocationSettingsResponse(task, false);
        }
      });
  }
}
 
Example 14
Source File: RNFusedLocationModule.java    From react-native-geolocation-service with MIT License 4 votes vote down vote up
/**
 * Get the current position. This can return almost immediately if the location is cached or
 * request an update, which might take a while.
 *
 * @param options map containing optional arguments: timeout (millis), maximumAge (millis),
 *                highAccuracy (boolean), distanceFilter (double) and showLocationDialog (boolean)
 * @param success success callback
 * @param error   error callback
 */
@ReactMethod
public void getCurrentPosition(ReadableMap options, final Callback success, final Callback error) {
  ReactApplicationContext context = getContext();

  mSuccessCallback = success;
  mErrorCallback = error;

  if (!LocationUtils.hasLocationPermission(context)) {
    invokeError(
      LocationError.PERMISSION_DENIED.getValue(),
      "Location permission not granted.",
      true
    );
    return;
  }

  if (!LocationUtils.isGooglePlayServicesAvailable(context)) {
    invokeError(
      LocationError.PLAY_SERVICE_NOT_AVAILABLE.getValue(),
      "Google play service is not available.",
      true
    );
    return;
  }

  boolean highAccuracy = options.hasKey("enableHighAccuracy") &&
    options.getBoolean("enableHighAccuracy");

  // TODO: Make other PRIORITY_* constants available to the user
  mLocationPriority = highAccuracy ? LocationRequest.PRIORITY_HIGH_ACCURACY : DEFAULT_ACCURACY;

  mTimeout = options.hasKey("timeout") ? (long) options.getDouble("timeout") : Long.MAX_VALUE;
  mMaximumAge = options.hasKey("maximumAge")
    ? options.getDouble("maximumAge")
    : Double.POSITIVE_INFINITY;
  mDistanceFilter = options.hasKey("distanceFilter")
    ? (float) options.getDouble("distanceFilter")
    : 0;
  mShowLocationDialog = options.hasKey("showLocationDialog")
    ? options.getBoolean("showLocationDialog")
    : true;
  mForceRequestLocation = options.hasKey("forceRequestLocation")
    ? options.getBoolean("forceRequestLocation")
    : false;

  LocationSettingsRequest locationSettingsRequest = buildLocationSettingsRequest();

  if (mSettingsClient != null) {
    mSettingsClient.checkLocationSettings(locationSettingsRequest)
      .addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
        @Override
        public void onComplete(@NonNull Task<LocationSettingsResponse> task) {
          onLocationSettingsResponse(task, true);
        }
      });
  }
}
 
Example 15
Source File: HeartrateHistory.java    From react-native-google-fit with MIT License 4 votes vote down vote up
public boolean delete(ReadableMap sample) {
    long endTime = (long) sample.getDouble("endTime");
    long startTime = (long) sample.getDouble("startTime");
    new DeleteDataHelper(startTime, endTime, this.dataType, googleFitManager).execute();
    return true;
}
 
Example 16
Source File: SpringAnimation.java    From react-native-GPay with MIT License 4 votes vote down vote up
SpringAnimation(ReadableMap config) {
  mCurrentState.velocity = config.getDouble("initialVelocity");
  resetConfig(config);
}
 
Example 17
Source File: ARTTextShadowNode.java    From art with MIT License 4 votes vote down vote up
private void applyTextPropertiesToPaint(Paint paint) {
  int alignment = mTextAlignment;
  switch (alignment) {
    case TEXT_ALIGNMENT_LEFT:
      paint.setTextAlign(Paint.Align.LEFT);
      break;
    case TEXT_ALIGNMENT_RIGHT:
      paint.setTextAlign(Paint.Align.RIGHT);
      break;
    case TEXT_ALIGNMENT_CENTER:
      paint.setTextAlign(Paint.Align.CENTER);
      break;
  }
  if (mFrame != null) {
    if (mFrame.hasKey(PROP_FONT)) {
      ReadableMap font = mFrame.getMap(PROP_FONT);
      if (font != null) {
        float fontSize = DEFAULT_FONT_SIZE;
        if (font.hasKey(PROP_FONT_SIZE)) {
          fontSize = (float) font.getDouble(PROP_FONT_SIZE);
        }
        paint.setTextSize(fontSize * mScale);
        boolean isBold =
            font.hasKey(PROP_FONT_WEIGHT) && "bold".equals(font.getString(PROP_FONT_WEIGHT));
        boolean isItalic =
            font.hasKey(PROP_FONT_STYLE) && "italic".equals(font.getString(PROP_FONT_STYLE));
        int fontStyle;
        if (isBold && isItalic) {
          fontStyle = Typeface.BOLD_ITALIC;
        } else if (isBold) {
          fontStyle = Typeface.BOLD;
        } else if (isItalic) {
          fontStyle = Typeface.ITALIC;
        } else {
          fontStyle = Typeface.NORMAL;
        }
        // NB: if the font family is null / unsupported, the default one will be used
        paint.setTypeface(Typeface.create(font.getString(PROP_FONT_FAMILY), fontStyle));
      }
    }
  }
}
 
Example 18
Source File: ChartBaseManager.java    From react-native-mp-android-chart with MIT License 4 votes vote down vote up
/**
 * General axis config details: https://github.com/PhilJay/MPAndroidChart/wiki/The-Axis
 */
protected void setCommonAxisConfig(Chart chart, AxisBase axis, ReadableMap propMap) {
    // what is drawn
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "enabled")) {
        axis.setEnabled(propMap.getBoolean("enabled"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "drawLabels")) {
        axis.setDrawLabels(propMap.getBoolean("drawLabels"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "drawAxisLine")) {
        axis.setDrawAxisLine(propMap.getBoolean("drawAxisLine"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "drawGridLines")) {
        axis.setDrawGridLines(propMap.getBoolean("drawGridLines"));
    }

    // style
    if (BridgeUtils.validate(propMap, ReadableType.String, "textColor")) {
        axis.setTextColor(Color.parseColor(propMap.getString("textColor")));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "textSize")) {
        axis.setTextSize((float) propMap.getDouble("textSize"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "fontFamily") ||
            BridgeUtils.validate(propMap, ReadableType.Number, "fontStyle")) {
        axis.setTypeface(BridgeUtils.parseTypeface(chart.getContext(), propMap, "fontStyle", "fontFamily"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "gridColor")) {
        axis.setGridColor(Color.parseColor(propMap.getString("gridColor")));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "gridLineWidth")) {
        axis.setGridLineWidth((float) propMap.getDouble("gridLineWidth"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "axisLineColor")) {
        axis.setAxisLineColor(Color.parseColor(propMap.getString("axisLineColor")));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "axisLineWidth")) {
        axis.setAxisLineWidth((float) propMap.getDouble("axisLineWidth"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Map, "gridDashedLine")) {
        ReadableMap gridDashedLine = propMap.getMap("gridDashedLine");
        float lineLength = 0;
        float spaceLength = 0;
        float phase = 0;

        if (BridgeUtils.validate(gridDashedLine, ReadableType.Number, "lineLength")) {
            lineLength = (float) gridDashedLine.getDouble("lineLength");
        }
        if (BridgeUtils.validate(gridDashedLine, ReadableType.Number, "spaceLength")) {
            spaceLength = (float) gridDashedLine.getDouble("spaceLength");
        }
        if (BridgeUtils.validate(gridDashedLine, ReadableType.Number, "phase")) {
            phase = (float) gridDashedLine.getDouble("phase");
        }

        axis.enableGridDashedLine(lineLength, spaceLength, phase);
    }

    // limit lines
    if (BridgeUtils.validate(propMap, ReadableType.Array, "limitLines")) {
        ReadableArray limitLines = propMap.getArray("limitLines");

        for (int i = 0; i < limitLines.size(); i++) {
            if (!ReadableType.Map.equals(limitLines.getType(i))) {
                continue;
            }

            ReadableMap limitLineMap = limitLines.getMap(i);
            if (BridgeUtils.validate(limitLineMap, ReadableType.Number, "limit")) {
                LimitLine limitLine = new LimitLine((float) limitLineMap.getDouble("limit"));

                if (BridgeUtils.validate(limitLineMap, ReadableType.String, "label")) {
                    limitLine.setLabel(limitLineMap.getString("label"));
                }
                if (BridgeUtils.validate(limitLineMap, ReadableType.String, "lineColor")) {
                    limitLine.setLineColor(Color.parseColor(limitLineMap.getString("lineColor")));
                }
                if (BridgeUtils.validate(limitLineMap, ReadableType.Number, "lineWidth")) {
                    limitLine.setLineWidth((float) limitLineMap.getDouble("lineWidth"));
                }

                axis.addLimitLine(limitLine);
            }

        }
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "drawLimitLinesBehindData")) {
        axis.setDrawLimitLinesBehindData(propMap.getBoolean("drawLimitLinesBehindData"));
    }
}
 
Example 19
Source File: RNAGSGraphicsOverlay.java    From react-native-arcgis-mapview with MIT License 4 votes vote down vote up
private void updateGraphicLoop(ReadableMap args) {
    // Establish variables
    com.esri.arcgisruntime.geometry.Point agsPoint = null;
    // Get references
    String referenceId = args.getString("referenceId");
    Map<String, Object> attributes = null;
    Double rotation = 0.0;

    // Once we have all the required values, we change them
    Graphic graphic = ArrayHelper.graphicViaReferenceId(graphicsOverlay, referenceId);
    if (graphic == null) {
        return;
    }

    if (args.hasKey("attributes")) {
        attributes = RNAGSGraphicsOverlay.readableMapToMap(args.getMap("attributes"));
        graphic.getAttributes().putAll(attributes);

    }
    if (args.hasKey("graphicsId")) {
        String graphicsId = args.getString("graphicsId");
        String graphicUri = pointImageDictionary.get(graphicsId);
        if (graphicUri != null) {
            PictureMarkerSymbol symbol = new PictureMarkerSymbol(graphicUri);
            graphic.setSymbol(symbol);
        }
    }
    if (args.hasKey("latitude") && args.hasKey("longitude")) {
        Double latitude = args.getDouble("latitude");
        Double longitude = args.getDouble("longitude");
        agsPoint = new com.esri.arcgisruntime.geometry.Point(longitude, latitude, SpatialReferences.getWgs84());
    }
    if (args.hasKey("rotation")) {
        rotation = args.getDouble("rotation");
    }
    if (shouldAnimateUpdate) {
        Float initialRotation = (graphic.getSymbol() != null && graphic.getSymbol() instanceof PictureMarkerSymbol) ?
                ((PictureMarkerSymbol) graphic.getSymbol()).getAngle() : 0;
        animateUpdate(graphic, ((com.esri.arcgisruntime.geometry.Point) graphic.getGeometry()), agsPoint, initialRotation, rotation.floatValue());

    } else {
        graphic.setGeometry(agsPoint);
        ((PictureMarkerSymbol) graphic.getSymbol()).setAngle(rotation.floatValue());
    }
    // End of updates

}
 
Example 20
Source File: LineChartManager.java    From react-native-mp-android-chart with MIT License 4 votes vote down vote up
@Override
void dataSetConfig(IDataSet<Entry> dataSet, ReadableMap config) {
    LineDataSet lineDataSet = (LineDataSet) dataSet;

    ChartDataSetConfigUtils.commonConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonLineScatterCandleRadarConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonLineRadarConfig(lineDataSet, config);

    // LineDataSet only config
    if (BridgeUtils.validate(config, ReadableType.Number, "circleRadius")) {
        lineDataSet.setCircleRadius((float) config.getDouble("circleRadius"));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCircles")) {
        lineDataSet.setDrawCircles(config.getBoolean("drawCircles"));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCubic")) {
        lineDataSet.setDrawCubic(config.getBoolean("drawCubic"));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "drawCubicIntensity")) {
        lineDataSet.setCubicIntensity((float) config.getDouble("drawCubicIntensity"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "circleColor")) {
        lineDataSet.setCircleColor(Color.parseColor(config.getString("circleColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Array, "circleColors")) {
        lineDataSet.setCircleColors(BridgeUtils.parseColors(config.getArray("circleColors")));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "circleColorHole")) {
        lineDataSet.setCircleColorHole(Color.parseColor(config.getString("circleColorHole")));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCircleHole")) {
        lineDataSet.setDrawCircleHole(config.getBoolean("drawCircleHole"));
    }
    if (BridgeUtils.validate(config, ReadableType.Map, "dashedLine")) {
        ReadableMap dashedLine = config.getMap("dashedLine");
        float lineLength = 0;
        float spaceLength = 0;
        float phase = 0;

        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "lineLength")) {
            lineLength = (float) dashedLine.getDouble("lineLength");
        }
        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "spaceLength")) {
            spaceLength = (float) dashedLine.getDouble("spaceLength");
        }
        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "phase")) {
            phase = (float) dashedLine.getDouble("phase");
        }

        lineDataSet.enableDashedLine(lineLength, spaceLength, phase);
    }
}