If you think the Android project android-maps-utils 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 2013 Google Inc.//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.google.maps.android.ui;
import android.content.res.Resources;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import com.google.maps.android.R;
/**
* Draws a bubble with a shadow, filled with any color.
*/class BubbleDrawable extends Drawable {
privatefinal Drawable mShadow;
privatefinal Drawable mMask;
privateint mColor = Color.WHITE;
public BubbleDrawable(Resources res) {
mMask = res.getDrawable(R.drawable.bubble_mask);
mShadow = res.getDrawable(R.drawable.bubble_shadow);
}
publicvoid setColor(int color) {
mColor = color;
}
@Override
publicvoid draw(Canvas canvas) {
mMask.draw(canvas);
canvas.drawColor(mColor, PorterDuff.Mode.SRC_IN);
mShadow.draw(canvas);
}
@Override
publicvoid setAlpha(int alpha) {
thrownew UnsupportedOperationException();
}
@Override
publicvoid setColorFilter(ColorFilter cf) {
thrownew UnsupportedOperationException();
}
@Override
publicint getOpacity() {
return PixelFormat.TRANSLUCENT;
}
@Override
publicvoid setBounds(int left, int top, int right, int bottom) {
mMask.setBounds(left, top, right, bottom);
mShadow.setBounds(left, top, right, bottom);
}
@Override
publicvoid setBounds(Rect bounds) {
mMask.setBounds(bounds);
mShadow.setBounds(bounds);
}
@Override
publicboolean getPadding(Rect padding) {
return mMask.getPadding(padding);
}
}