blob: 9e04ecbf907d9d563f7739770b60470a64d61ccd [file] [log] [blame]
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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.android.browser.view;
import android.view.View;
import com.android.browser.view.PieMenu.PieView;
import java.util.ArrayList;
import java.util.List;
/**
* Pie menu item
*/
public class PieItem {
private View mView;
private PieView mPieView;
private int level;
private float start;
private float sweep;
private float animate;
private int inner;
private int outer;
private boolean mSelected;
private boolean mEnabled;
private List<PieItem> mItems;
public PieItem(View view, int level) {
mView = view;
this.level = level;
mEnabled = true;
setAnimationAngle(getAnimationAngle());
setAlpha(getAlpha());
}
public PieItem(View view, int level, PieView sym) {
mView = view;
this.level = level;
mPieView = sym;
mEnabled = false;
}
public boolean hasItems() {
return mItems != null;
}
public List<PieItem> getItems() {
return mItems;
}
public void addItem(PieItem item) {
if (mItems == null) {
mItems = new ArrayList<PieItem>();
}
mItems.add(item);
}
public void setAlpha(float alpha) {
if (mView != null) {
mView.setAlpha(alpha);
}
}
public float getAlpha() {
if (mView != null) {
return mView.getAlpha();
}
return 1;
}
public void setAnimationAngle(float a) {
animate = a;
}
public float getAnimationAngle() {
return animate;
}
public void setEnabled(boolean enabled) {
mEnabled = enabled;
}
public void setSelected(boolean s) {
mSelected = s;
if (mView != null) {
mView.setSelected(s);
}
}
public boolean isSelected() {
return mSelected;
}
public int getLevel() {
return level;
}
public void setGeometry(float st, float sw, int inside, int outside) {
start = st;
sweep = sw;
inner = inside;
outer = outside;
}
public float getStart() {
return start;
}
public float getStartAngle() {
return start + animate;
}
public float getSweep() {
return sweep;
}
public int getInnerRadius() {
return inner;
}
public int getOuterRadius() {
return outer;
}
public boolean isPieView() {
return (mPieView != null);
}
public View getView() {
return mView;
}
public void setPieView(PieView sym) {
mPieView = sym;
}
public PieView getPieView() {
if (mEnabled) {
return mPieView;
}
return null;
}
}