androidx.annotation.Size Java Examples

The following examples show how to use androidx.annotation.Size. 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: ComplexColumn.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@NonNull
@CheckResult
public final Expr in(@NonNull @Size(min = 1) long... values) {
  final int length = values.length;
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(6 + (length << 1));
  sb.append(" IN (");
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = Long.toString(values[i]);
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #2
Source File: WindImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
public WindImplementor(@Size(2) int[] canvasSizes) {
    this.paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);

    backgroundColor = Color.rgb(233, 158, 60);
    int[] colors = new int[] {
            Color.rgb(240, 200, 148),
            Color.rgb(237, 178, 100),
            Color.rgb(209, 142, 54),};
    float[] scales = new float[] {0.6F, 0.8F, 1};

    this.winds = new Wind[51];
    for (int i = 0; i < winds.length; i ++) {
        winds[i] = new Wind(
                canvasSizes[0], canvasSizes[1],
                colors[i * 3 / winds.length], scales[i * 3 / winds.length]);
    }

    this.lastDisplayRate = 0;
    this.lastRotation3D = INITIAL_ROTATION_3D;
}
 
Example #3
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * OpenGL|ESの4x4行列を列優先で文字列化
 * @param transform
 * @return
 */
public static String toGLMatrixString(
	@NonNull @Size(min=16)final float[] transform) {

	return "GLMatrix[" +
		transform[0] + ", " +
		transform[1] + ", " +
		transform[2] + ", " +
		transform[3] +
		"][" +
		transform[4] + ", " +
		transform[5] + ", " +
		transform[6] + ", " +
		transform[7] +
		"][" +
		transform[8] + ", " +
		transform[9] + ", " +
		transform[10] + ", " +
		transform[11] +
		"][" +
		transform[12] + ", " +
		transform[13] + ", " +
		transform[14] + ", " +
		transform[15] +
		']';
}
 
Example #4
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * OpenGLの4x4(列優先)行列をandroid.graphics.Matrixの3x3行列に変換する
 * (アフィン変換のみ)
 * @param transform
 * @param result
 * @param aMatrix
 * @return
 */
public static Matrix toAndroidMatrix(
	@NonNull @Size(min=16)final float[] transform,
	@NonNull final Matrix result,
	@NonNull @Size(min=9) final float[] aMatrix) {

	aMatrix[Matrix.MSCALE_X] = transform[ 0];
	aMatrix[Matrix.MSKEW_Y] = transform[ 1];
	aMatrix[Matrix.MPERSP_0] = transform[ 3];
	aMatrix[Matrix.MSKEW_X] = transform[ 4];
	aMatrix[Matrix.MSCALE_Y] = transform[ 5];
	aMatrix[Matrix.MPERSP_1] = transform[ 7];
	aMatrix[Matrix.MTRANS_X] = transform[12];
	aMatrix[Matrix.MTRANS_Y] = transform[13];
	aMatrix[Matrix.MPERSP_2] = transform[15];
	result.setValues(aMatrix);

	return result;
}
 
Example #5
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * android.graphics.Matrixの3x3行列をOpenGLの4x4(列優先)行列に変換する
 * (アフィン変換のみ)
 * |a11 a12 a13|  |0 1 2|      |a11 a12   0 a13|   |0 4 8  12|
 * |a21 a22 a23|  |3 4 5|      |a21 a22   0 a23|   |1 5 9  13|
 * |a31 a32 a33|  |6 7 8| =>   |  0   0   1   0|   |2 6 10 14|
 *                             |a31 a32   0 a33|   |3 7 11 15|
 * @param transform
 * @param result
 * @return
 */
@NonNull
@Size(min=16)
public static float[] toGLMatrix(@NonNull final Matrix transform,
	@NonNull @Size(min=16) final float[] result,
	@NonNull @Size(min=9) final float[] aMatrix) {

	transform.getValues(aMatrix);
	result[ 0] = aMatrix[Matrix.MSCALE_X];
	result[ 1] = aMatrix[Matrix.MSKEW_Y];
	result[ 2] = 0;
	result[ 3] = aMatrix[Matrix.MPERSP_0];
	result[ 4] = aMatrix[Matrix.MSKEW_X];
	result[ 5] = aMatrix[Matrix.MSCALE_Y];
	result[ 6] = 0;
	result[ 7] = aMatrix[Matrix.MPERSP_1];
	result[ 8] = 0;
	result[ 9] = 0;
	result[10] = 1;
	result[11] = 0;
	result[12] = aMatrix[Matrix.MTRANS_X];
	result[13] = aMatrix[Matrix.MTRANS_Y];
	result[14] = 0;
	result[15] = aMatrix[Matrix.MPERSP_2];
	return result;
}
 
Example #6
Source File: Polygon.java    From mapbox-java with MIT License 6 votes vote down vote up
/**
 * Create a new instance of this class by passing in an outer {@link LineString} and optionally
 * one or more inner LineStrings contained within a list. Each of these LineStrings should follow
 * the linear ring rules.
 * <p>
 * Note that if a LineString breaks one of the linear ring rules, a {@link RuntimeException} will
 * be thrown.
 *
 * @param outer a LineString which defines the outer perimeter of the polygon
 * @param inner one or more LineStrings inside a list representing holes inside the outer
 *              perimeter
 * @return a new instance of this class defined by the values passed inside this static factory
 *   method
 * @since 3.0.0
 */
public static Polygon fromOuterInner(@NonNull LineString outer,
                                     @Nullable @Size(min = 1) List<LineString> inner) {
  isLinearRing(outer);
  List<List<Point>> coordinates = new ArrayList<>();
  coordinates.add(outer.coordinates());
  // If inner rings are set to null, return early.
  if (inner == null || inner.isEmpty()) {
    return new Polygon(TYPE, null, coordinates);
  }
  for (LineString lineString : inner) {
    isLinearRing(lineString);
    coordinates.add(lineString.coordinates());
  }
  return new Polygon(TYPE, null, coordinates);
}
 
Example #7
Source File: Column.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@SafeVarargs
@NonNull
@CheckResult
public final Expr in(@NonNull @Size(min = 1) T... values) {
  final int length = values.length;
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(6 + (length << 1));
  sb.append(" IN (");
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = toSqlArg(values[i]);
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #8
Source File: Column.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this NOT IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@NonNull
@CheckResult
public final Expr notIn(@NonNull @Size(min = 1) Collection<T> values) {
  final int length = values.size();
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(10 + (length << 1));
  sb.append(" NOT IN (");
  final Iterator<T> iterator = values.iterator();
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = toSqlArg(iterator.next());
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #9
Source File: Column.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this NOT IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@SafeVarargs
@NonNull
@CheckResult
public final Expr notIn(@NonNull @Size(min = 1) T... values) {
  final int length = values.length;
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(10 + (length << 1));
  sb.append(" NOT IN (");
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = toSqlArg(values[i]);
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #10
Source File: ComplexColumn.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this NOT IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@NonNull
@CheckResult
public final Expr notIn(@NonNull @Size(min = 1) long... values) {
  final int length = values.length;
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(10 + (length << 1));
  sb.append(" NOT IN (");
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = Long.toString(values[i]);
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #11
Source File: Column.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
/**
 * Create an expression to check this column against several values.
 * <p>
 * SQL: this IN (values...)
 *
 * @param values The values to test against this column
 * @return Expression
 */
@NonNull
@CheckResult
public final Expr in(@NonNull @Size(min = 1) Collection<T> values) {
  final int length = values.size();
  if (length == 0) {
    throw new SQLException("Empty IN clause values");
  }
  final String[] args = new String[length];
  final StringBuilder sb = new StringBuilder(6 + (length << 1));
  sb.append(" IN (");
  final Iterator<T> iterator = values.iterator();
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append('?');
    args[i] = toSqlArg(iterator.next());
  }
  sb.append(')');
  return new ExprN(this, sb.toString(), args);
}
 
Example #12
Source File: IconPackResourcesProvider.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@Size(3)
public Drawable[] getWeatherIcons(WeatherCode code, boolean dayTime) {
    if (config.hasWeatherIcons) {
        if (config.hasWeatherAnimators) {
            return new Drawable[] {
                    getDrawable(getWeatherIconName(code, dayTime, 1)),
                    getDrawable(getWeatherIconName(code, dayTime, 2)),
                    getDrawable(getWeatherIconName(code, dayTime, 3))
            };
        } else {
            return new Drawable[] {getWeatherIcon(code, dayTime), null, null};
        }
    }

    return defaultProvider.getWeatherIcons(code, dayTime);
}
 
Example #13
Source File: PermissionUtil.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
/**
 * TargetVersionSdk大于6.0时的权限检查方法
 *
 * @param context
 * @param perms
 * @return
 */
public static boolean hasPermissions(@NonNull Context context,
                                     @Size(min = 1) @NonNull String... perms) {
    // Always return true for SDK < M, let the system deal with the permissions
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        Log.w(TAG, "hasPermissions: API version < M, returning true by default");

        // DANGER ZONE!!! Changing this will break the library.
        return true;
    }

    // Null context may be passed if we have detected Low API (less than M) so getting
    // to this point with a null context should not be possible.
    if (context == null) {
        throw new IllegalArgumentException("Can't check permissions for null context");
    }

    for (String perm : perms) {
        if (ContextCompat.checkSelfPermission(context, perm)
                != PackageManager.PERMISSION_GRANTED) {
            return false;
        }
    }

    return true;
}
 
Example #14
Source File: Photo.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getUrl(@Size(2) int[] size) {
    return urls.raw
            + "?q=75&fm=jpg"
            + "&w=" + size[0]
            + "&h=" + size[1]
            + "&fit=crop";
}
 
Example #15
Source File: Photo.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Size(2)
private int[] getCropScaleSize(Context context, float scale) {
    float screenRatio = 1.f
            * context.getResources().getDisplayMetrics().widthPixels
            / context.getResources().getDisplayMetrics().heightPixels;
    float imageRatio = 1.f * width / height;

    if (imageRatio >= screenRatio) {
        int maxScaleHeight = (int) (context.getResources().getDisplayMetrics().heightPixels * scale);
        if (height <= maxScaleHeight) {
            return new int[] {width, height};
        } else {
            return new int[] {
                    (int) (1.f * maxScaleHeight * width / height),
                    maxScaleHeight
            };
        }
    } else {
        int maxScaleWidth = (int) (context.getResources().getDisplayMetrics().widthPixels * scale);
        if (width <= maxScaleWidth) {
            return new int[] {width, height};
        } else {
            return new int[] {
                    maxScaleWidth,
                    (int) (1.f * maxScaleWidth * height / width)
            };
        }
    }
}
 
Example #16
Source File: SfntTag.java    From Tehreer-Android with Apache License 2.0 5 votes vote down vote up
/**
    * Makes a four-byte integer, representing the passed-in tag as a string.
    *
    * @param tagStr The tag string to represent as an integer.
    * @return Integer representation of the tag.
    *
    * @throws IllegalArgumentException if <code>tagStr</code> is not four characters long, or any
    *         character is not a printing character represented by ASCII values 32-126.
    */
public static int make(@NonNull @Size(4) String tagStr) {
	if (tagStr.length() != 4) {
		throw new IllegalArgumentException("The length of tag string is not equal to four");
	}
	verifyChar(tagStr.charAt(0), "Index: 0");
	verifyChar(tagStr.charAt(1), "Index: 1");
	verifyChar(tagStr.charAt(2), "Index: 2");
	verifyChar(tagStr.charAt(3), "Index: 3");

	return makeNoVerify((byte) tagStr.charAt(0), (byte) tagStr.charAt(1),
				        (byte) tagStr.charAt(2), (byte) tagStr.charAt(3));
}
 
Example #17
Source File: TypeFamily.java    From Tehreer-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a type family object.
 *
 * @param familyName The name of family.
 * @param typefaces The list of typefaces belonging to family.
 */
public TypeFamily(@NonNull String familyName, @NonNull @Size(min = 1) List<Typeface> typefaces) {
    checkNotNull(familyName, "familyName");
    checkNotNull(typefaces, "typefaces");
    checkArgument(!typefaces.isEmpty(), "Typefaces list cannot be empty");

    this.familyName = familyName;
    this.typefaces = typefaces;
}
 
Example #18
Source File: LocaleUtils.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@NonNull
public static String getLanguage(@Size(min = 1) String... allow) {
    Locale lang = LocaleUtils.getLocale();
    Locale[] locales = new Locale[allow.length];
    for (int i = 0; i < allow.length; i++) {
        locales[i] = new Locale(allow[i]);
    }

    for (int i = 0; i < locales.length; i++) {
        if (lang.getLanguage().equals(locales[i].getLanguage()))
            return allow[i];
    }

    return allow[0];
}
 
Example #19
Source File: ComposedLine.java    From Tehreer-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an array of visual edges corresponding to the specified character range.
 * <p>
 * The resulting array will contain pairs of leading and trailing edges sorted from left to
 * right. There will be a separate pair for each glyph run occurred in the specified character
 * range. Each edge will be positioned relative to the start of the line assumed at zero.
 *
 * @param charStart The index to the first logical character in source text.
 * @param charEnd The index after the last logical character in source text.
 * @return An array of visual edges corresponding to the specified character range.
 *
 * @throws IllegalArgumentException if <code>charStart</code> is less than line start, or
 *         <code>charEnd</code> is greater than line end, or <code>charStart</code> is greater
 *         than <code>charEnd</code>.
 */
public @NonNull @Size(multiple = 2) float[] computeVisualEdges(int charStart, int charEnd) {
    checkSubRange(charStart, charEnd);

    int runCount = runList.size();

    float[] edgeList = new float[runCount * 2];
    int edgeIndex = 0;

    for (int i = 0; i < runCount; i++) {
        GlyphRun glyphRun = runList.get(i);
        int runStart = glyphRun.getCharStart();
        int runEnd = glyphRun.getCharEnd();

        if (runStart < charEnd && runEnd > charStart) {
            int selectionStart = Math.max(charStart, runStart);
            int selectionEnd = Math.min(charEnd, runEnd);

            float leadingEdge = glyphRun.computeCharDistance(selectionStart);
            float trailingEdge = glyphRun.computeCharDistance(selectionEnd);

            float relativeLeft = glyphRun.getOriginX();
            float selectionLeft = Math.min(leadingEdge, trailingEdge) + relativeLeft;
            float selectionRight = Math.max(leadingEdge, trailingEdge) + relativeLeft;

            edgeList[edgeIndex++] = selectionLeft;
            edgeList[edgeIndex++] = selectionRight;
        }
    }

    if (edgeIndex < edgeList.length) {
        edgeList = Arrays.copyOf(edgeList, edgeIndex);
    }

    return edgeList;
}
 
Example #20
Source File: NestedScrollingPhotoViewAttacher.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Helper method that simply checks the Matrix, and then displays the result
 */
@Size(2)
@Nullable
private float[] checkAndDisplayMatrix() {
    float[] delta = checkMatrixBounds();
    if (delta != null) {
        setImageViewMatrix(getDrawMatrix());
    }
    return delta;
}
 
Example #21
Source File: SunMoonView.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setTime(@Size(2) float[] startTimes, @Size(2) float[] endTimes, @Size(2) float[] currentTimes) {
    this.startTimes = startTimes;
    this.endTimes = endTimes;
    this.currentTimes = currentTimes;

    setIndicatorPosition(0);
    setIndicatorPosition(1);

    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example #22
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Bitmap loadBitmap(Context context, @DrawableRes int id, @Nullable @Size(2) int[] size)
        throws ExecutionException, InterruptedException {
    if (size == null) {
        size = new int[] {Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL};
    }
    return Glide.with(getValidContext(context))
            .load(id)
            .asBitmap()
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(size[0], size[1])
            .get();
}
 
Example #23
Source File: SnowImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void draw(@Size(2) int[] canvasSizes, Canvas canvas,
                 float displayRate, float scrollRate, float rotation2D, float rotation3D) {

    if (displayRate >= 1) {
        canvas.drawColor(backgroundColor);
    } else {
        canvas.drawColor(
                ColorUtils.setAlphaComponent(
                        backgroundColor,
                        (int) (displayRate * 255)));
    }

    if (scrollRate < 1) {
        canvas.rotate(
                rotation2D,
                canvasSizes[0] * 0.5F,
                canvasSizes[1] * 0.5F);
        for (Snow s : snows) {
            paint.setColor(s.color);
            if (displayRate < lastDisplayRate) {
                paint.setAlpha((int) (displayRate * (1 - scrollRate) * 255));
            } else {
                paint.setAlpha((int) ((1 - scrollRate) * 255));
            }
            canvas.drawCircle(s.centerX, s.centerY, s.radius, paint);
        }
    }

    lastDisplayRate = displayRate;
}
 
Example #24
Source File: SnowImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateData(@Size(2) int[] canvasSizes, long interval,
                       float rotation2D, float rotation3D) {
    for (Snow s : snows) {
        s.move(interval, lastRotation3D == INITIAL_ROTATION_3D ? 0 : rotation3D - lastRotation3D);
    }
    lastRotation3D = rotation3D;
}
 
Example #25
Source File: SnowImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SnowImplementor(@Size(2) int[] canvasSizes, @TypeRule int type) {
    this.paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);

    int[] colors = new int[3];
    switch (type) {
        case TYPE_SNOW_DAY:
            backgroundColor = Color.rgb(104, 186, 255);
            colors = new int[] {
                    Color.rgb(128, 197, 255),
                    Color.rgb(185, 222, 255),
                    Color.rgb(255, 255, 255)};
            break;

        case TYPE_SNOW_NIGHT:
            backgroundColor = Color.rgb(26, 91, 146);
            colors = new int[] {
                    Color.rgb(40, 102, 155),
                    Color.rgb(99, 144, 182),
                    Color.rgb(255, 255, 255)};
            break;
    }
    float[] scales = new float[] {0.6F, 0.8F, 1};

    this.snows = new Snow[51];
    for (int i = 0; i < snows.length; i ++) {
        snows[i] = new Snow(
                canvasSizes[0], canvasSizes[1],
                colors[i * 3 / snows.length], scales[i * 3 / snows.length]);
    }

    this.lastDisplayRate = 0;
    this.lastRotation3D = INITIAL_ROTATION_3D;
}
 
Example #26
Source File: SunImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void draw(@Size(2) int[] canvasSizes, Canvas canvas,
                 float displayRate, float scrollRate, float rotation2D, float rotation3D) {

    canvas.drawColor(Color.argb((int) (displayRate * 255), 253, 188, 76));

    if (scrollRate < 1) {
        float deltaX = (float) (Math.sin(rotation2D * Math.PI / 180.0) * 0.3 * canvasSizes[0]);
        float deltaY = (float) (Math.sin(rotation3D * Math.PI / 180.0) * -0.3 * canvasSizes[0]);

        canvas.translate(
                canvasSizes[0] + deltaX,
                (float) (0.0333 * canvasSizes[0] + deltaY));

        paint.setAlpha((int) (displayRate * (1 - scrollRate) * 255 * 0.40));
        canvas.rotate(angles[0]);
        for (int i = 0; i < 4; i ++) {
            canvas.drawRect(-unitSizes[0], -unitSizes[0], unitSizes[0], unitSizes[0], paint);
            canvas.rotate(22.5F);
        }
        canvas.rotate(-90 - angles[0]);

        paint.setAlpha((int) (displayRate * (1 - scrollRate) * 255 * 0.16));
        canvas.rotate(angles[1]);
        for (int i = 0; i < 4; i ++) {
            canvas.drawRect(-unitSizes[1], -unitSizes[1], unitSizes[1], unitSizes[1], paint);
            canvas.rotate(22.5F);
        }
        canvas.rotate(-90 - angles[1]);

        paint.setAlpha((int) (displayRate * (1 - scrollRate) * 255 * 0.08));
        canvas.rotate(angles[2]);
        for (int i = 0; i < 4; i ++) {
            canvas.drawRect(-unitSizes[2], -unitSizes[2], unitSizes[2], unitSizes[2], paint);
            canvas.rotate(22.5F);
        }
        canvas.rotate(-90 - angles[2]);
    }
}
 
Example #27
Source File: MeteorShowerImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateData(@Size(2) int[] canvasSizes, long interval,
                       float rotation2D, float rotation3D) {

    for (Meteor m : meteors) {
        m.move(interval, lastRotation3D == INITIAL_ROTATION_3D ? 0 : rotation3D - lastRotation3D);
    }
    for (Star s : stars) {
        s.shine(interval);
    }
    lastRotation3D = rotation3D;
}
 
Example #28
Source File: CloudImplementor.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void draw(@Size(2) int[] canvasSizes, Canvas canvas,
                 float displayRate, float scrollRate, float rotation2D, float rotation3D) {
    if (displayRate >=1) {
        canvas.drawColor(backgroundColor);
    } else {
        canvas.drawColor(
                ColorUtils.setAlphaComponent(
                        backgroundColor,
                        (int) (displayRate * 255)));
    }

    if (scrollRate < 1) {
        if (thunder != null) {
            canvas.drawColor(
                    Color.argb(
                            (int) (displayRate * (1 - scrollRate) * thunder.alpha * 255),
                            thunder.r,
                            thunder.g,
                            thunder.b));
        }
        for (Star s : stars) {
            paint.setColor(s.color);
            paint.setAlpha((int) (displayRate * (1 - scrollRate) * s.alpha * 255));
            canvas.drawCircle(s.centerX, s.centerY, s.radius, paint);
        }
        for (Cloud c : clouds) {
            paint.setColor(c.color);
            paint.setAlpha((int) (displayRate * (1 - scrollRate) * c.alpha * 255));
            canvas.drawCircle(c.centerX, c.centerY, c.radius, paint);
        }
    }
}
 
Example #29
Source File: AnimatableIconView.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setAnimatableIcon(@NonNull @Size(3) Drawable[] drawables,
                              @NonNull @Size(3) Animator[] animators) {
    endAnimators();
    for (int i = 0; i < drawables.length; i ++) {
        iconImageViews[i].setImageDrawable(drawables[i]);
        iconImageViews[i].setVisibility(drawables[i] == null ? GONE : VISIBLE);

        iconAnimators[i] = animators[i];
        if (iconAnimators[i] != null) {
            iconAnimators[i].setTarget(iconImageViews[i]);
        }
    }
}
 
Example #30
Source File: CoverImageView.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Size(2)
public static int[] getMeasureSize(int measureWidth, float w, float h) {
    return new int[] {
            measureWidth,
            (int) (measureWidth * h / w)
    };
}