If you think the Android project NineOldAndroids listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2010 The Android Open Source Project
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.jakewharton.nineoldandroids.sample.apidemos;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
/**
* A data structure that holds a Shape and various properties that can be used to define
* how the shape is drawn.
*/publicclass ShapeHolder {
privatefloat x = 0, y = 0;
private ShapeDrawable shape;
privateint color;
private RadialGradient gradient;
privatefloat alpha = 1f;
private Paint paint;
publicvoid setPaint(Paint value) {
paint = value;
}
public Paint getPaint() {
return paint;
}
publicvoid setX(float value) {
x = value;
}
publicfloat getX() {
return x;
}
publicvoid setY(float value) {
y = value;
}
publicfloat getY() {
return y;
}
publicvoid setShape(ShapeDrawable value) {
shape = value;
}
public ShapeDrawable getShape() {
return shape;
}
publicint getColor() {
return color;
}
publicvoid setColor(int value) {
shape.getPaint().setColor(value);
color = value;
}
publicvoid setGradient(RadialGradient value) {
gradient = value;
}
public RadialGradient getGradient() {
return gradient;
}
publicvoid setAlpha(float alpha) {
this.alpha = alpha;
shape.setAlpha((int)((alpha * 255f) + .5f));
}
publicfloat getWidth() {
return shape.getShape().getWidth();
}
publicvoid setWidth(float width) {
Shape s = shape.getShape();
s.resize(width, s.getHeight());
}
publicfloat getHeight() {
return shape.getShape().getHeight();
}
publicvoid setHeight(float height) {
Shape s = shape.getShape();
s.resize(s.getWidth(), height);
}
public ShapeHolder(ShapeDrawable s) {
shape = s;
}
}