下面列出了android.graphics.RectF#union ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null) {
return;
}
View parent = (View)view.getParent();
if (parent == null) {
return;
}
view.setAnimation(this);
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
parent.invalidate(
(int) FloatMath.floor(after.left),
(int) FloatMath.floor(after.top),
(int) FloatMath.ceil(after.right),
(int) FloatMath.ceil(after.bottom));
}
protected RectF getMyLocationMapDrawingBounds(MapView mv, Location lastFix, RectF reuse) {
mv.getProjection().toMapPixels(mLatLng, mMapCoords);
reuse = getDrawingBounds(mMapCoords, lastFix, reuse);
// Add in the accuracy circle if enabled
if (mDrawAccuracyEnabled) {
final float radius = (float) Math.ceil(
lastFix.getAccuracy() / (float) Projection.groundResolution(
lastFix.getLatitude(), mMapView.getZoomLevel())
);
RectF accuracyRect =
new RectF(mMapCoords.x - radius, mMapCoords.y - radius, mMapCoords.x + radius,
mMapCoords.y + radius);
final float strokeWidth = (float) Math.ceil(
mCirclePaint.getStrokeWidth() == 0 ? 1 : mCirclePaint.getStrokeWidth());
accuracyRect.inset(-strokeWidth, -strokeWidth);
reuse.union(accuracyRect);
}
return reuse;
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null || view.getParent() == null) {
return;
}
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
((View)view.getParent()).invalidate(
(int) Math.floor(after.left),
(int) Math.floor(after.top),
(int) Math.ceil(after.right),
(int) Math.ceil(after.bottom));
}
private void invalidate() {
if (mMapView == null) {
return; //not on map yet
}
// Get new drawing bounds
mMyLocationPreviousRect.set(mMyLocationRect);
updateDrawingPositionRect();
final RectF newRect = new RectF(mMyLocationRect);
// If we had a previous location, merge in those bounds too
newRect.union(mMyLocationPreviousRect);
// Invalidate the bounds
mMapView.post(new Runnable() {
@Override
public void run() {
mMapView.invalidateMapCoordinates(newRect);
}
});
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null) {
return;
}
View parent = (View)view.getParent();
if (parent == null) {
return;
}
view.setAnimation(this);
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
parent.invalidate(
(int) FloatMath.floor(after.left),
(int) FloatMath.floor(after.top),
(int) FloatMath.ceil(after.right),
(int) FloatMath.ceil(after.bottom));
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null || view.getParent() == null) {
return;
}
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
((View)view.getParent()).invalidate(
(int) Math.floor(after.left),
(int) Math.floor(after.top),
(int) Math.ceil(after.right),
(int) Math.ceil(after.bottom));
}
public void hiliteColumn(int column) throws Exception
{
lockScreen();
RectF rect = new RectF(objectDict.get(String.format("box_%d", column)).getWorldFrame());
rect.union(objectDict.get(String.format("box_%d", 90+column)).getWorldFrame());
rowBorder.setFrame(rect);
rowBorder.show();
for(int i=0; i<10; i++)
{
markLastNum((OBLabel)objectDict.get(String.format("num_%d", i*10 + column)));
objectDict.get(String.format("box_%d", i*10 + column)).setBackgroundColor(hilitecolour);
}
unlockScreen();
playSfxAudio("num_mark",true);
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null) {
return;
}
View parent = (View)view.getParent();
if (parent == null) {
return;
}
view.setAnimation(this);
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
parent.invalidate(
(int) Math.floor(after.left),
(int) Math.floor(after.top),
(int) Math.ceil(after.right),
(int) Math.ceil(after.bottom));
}
/**
* 1.存储一块高亮区域中每行文字的rect
* 2.存储当前整个高亮区域对应的rect(即以后的删除区域)
*
* @param annLists 一块区域由多行文字构成,annLists存储了多行文字对应的真实文档中对应Rect
* @param curPage
* @param type 类型(高亮,删除线,下划线)
*/
public void saveDocAnnPoints(ArrayList<RectF> annLists, int curPage, BaseAnnotation.Type type) {
LogUtils.d(TAG, "saveDocAnnPoints:curPage=" + curPage + " type=" + type.ordinal());
AnnotationPointsBean textBean = new AnnotationPointsBean(annLists);
String annResult = mGson.toJson(textBean);
RectF deleteRect = new RectF();
for (int i = 0; i < annLists.size(); i++) {
RectF rectF = annLists.get(i);
deleteRect.union(rectF);
}
String deleteResult = mGson.toJson(deleteRect);
mDbManager.setCurrDocAnnPoints(curPage, type, annResult, deleteResult);
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null || view.getParent() == null) {
return;
}
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
((View) view.getParent()).invalidate((int) Math.floor(after.left), (int) Math.floor(after.top), (int) Math.ceil(after.right), (int) Math.ceil(after.bottom));
}
public RectF frame()
{
RectF f = new RectF();
for (OBReadingWord word : words)
{
if (word.label != null)
f.union(word.label.frame());
}
return f;
}
static RectF AllLabelsFrame(List<OBLabel> labs)
{
RectF f = new RectF();
for(OBControl l : labs)
{
f.union(l.frame());
}
return f;
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null || view.getParent() == null) {
return;
}
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
((View) view.getParent()).invalidate((int) Math.floor(after.left), (int) Math.floor(after.top), (int) Math.ceil(after.right),
(int) Math.ceil(after.bottom));
}
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null || view.getParent() == null) {
return;
}
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
((View) view.getParent()).invalidate((int) Math.floor(after.left),
(int) Math.floor(after.top), (int) Math.ceil(after.right),
(int) Math.ceil(after.bottom));
}
public RectF pathsBounds()
{
RectF r = new RectF();
for(OBPath p : paths)
r.union(p.frame());
return r;
}
@Override
public RectF getOuterBoundingBox() {
RectF box = new RectF();
for (DrawElement element : elements) {
box.union(element.getOuterBoundingBox());
}
return box;
}
@Override
public RectF getOuterBoundingBox() {
RectF box = new RectF();
for (DrawElement element : elements) {
DrawElement temp = (DrawElement) element.clone();
temp.getDisplayMatrix().postConcat(getDisplayMatrix());
box.union(temp.getOuterBoundingBox());
}
return box;
}
protected void recalculateBoundingBox() {
RectF box = new RectF();
for (DrawElement element : elements) {
box.union(element.getOuterBoundingBox());
}
initBoundingBox = new RectF(box);
boundingPath = new Path();
boundingPath.addRect(box, Path.Direction.CW);
updateBoundingBox();
}
/**
* Merges a {@link RectF} into an existing list of any objects which contain a rectangle.
* While merging, this method makes sure that:
*
* <ol>
* <li>No rectangle is redundant (contained within a bigger rectangle)</li>
* <li>Rectangles of the same height and vertical position that intersect get merged</li>
* </ol>
*
* @param list the list of rectangles (or other rectangle containers) to merge the new
* rectangle into
* @param candidate the {@link RectF} to merge into the list
* @param extractor a function that can extract a {@link RectF} from an element of the given
* list
* @param packer a function that can wrap the resulting {@link RectF} into an element that
* the list contains
* @hide
*/
@VisibleForTesting
public static <T> void mergeRectangleIntoList(final List<T> list,
final RectF candidate, final Function<T, RectF> extractor,
final Function<RectF, T> packer) {
if (candidate.isEmpty()) {
return;
}
final int elementCount = list.size();
for (int index = 0; index < elementCount; ++index) {
final RectF existingRectangle = extractor.apply(list.get(index));
if (existingRectangle.contains(candidate)) {
return;
}
if (candidate.contains(existingRectangle)) {
existingRectangle.setEmpty();
continue;
}
final boolean rectanglesContinueEachOther = candidate.left == existingRectangle.right
|| candidate.right == existingRectangle.left;
final boolean canMerge = candidate.top == existingRectangle.top
&& candidate.bottom == existingRectangle.bottom
&& (RectF.intersects(candidate, existingRectangle)
|| rectanglesContinueEachOther);
if (canMerge) {
candidate.union(existingRectangle);
existingRectangle.setEmpty();
}
}
for (int index = elementCount - 1; index >= 0; --index) {
final RectF rectangle = extractor.apply(list.get(index));
if (rectangle.isEmpty()) {
list.remove(index);
}
}
list.add(packer.apply(candidate));
}
@Override
public void setSceneXX(String scene)
{
deleteControls("cover.*");
if(eventAttributes.get("counting") == null)
{
lockScreen();
super.setSceneXX(scene);
for(OBControl control : filterControls("cover.*"))
{
String[] nums = ((String)control.attributes().get("num")).split(",");
OBControl firstBox = objectDict.get(String.format("box_%s",nums[0]));
OBControl lastBox = objectDict.get(String.format("box_%s",nums[nums.length-1]));
RectF frm = new RectF(firstBox.getWorldFrame());
frm.union(lastBox.getWorldFrame());
control.setWidth(frm.width());
control.setHeight(frm.height());
control.setFrame(frm);
control.show();
OBGroup gr = new OBGroup(Collections.singletonList(control));
frm.inset(firstBox.borderWidth/2.0f, firstBox.borderWidth/2.0f);
gr.setFrame(frm);
control.setTop(-firstBox.borderWidth/2.0f);
control.setLeft(-firstBox.borderWidth/2.0f);
gr.setMasksToBounds(true);
gr.setZPosition(10);
gr.settings = control.settings;
objectDict.put((String)control.attributes().get("id"),gr);
attachControl(gr);
gr.hide();
}
unlockScreen();
}
currentIndex = 1;
}