Java Code Examples for android.graphics.RectF#union()
The following examples show how to use
android.graphics.RectF#union() .
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: UserLocationOverlay.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 7 votes |
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; }
Example 2
Source File: AnimatorProxy.java From android-apps with MIT License | 6 votes |
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)); }
Example 3
Source File: AnimatorProxy.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
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)); }
Example 4
Source File: OC_MoreNumbers_S1.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: UEAnimatorProxy.java From Auie with GNU General Public License v2.0 | 6 votes |
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)); }
Example 6
Source File: UserLocationOverlay.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } }); }
Example 7
Source File: AnimatorProxy.java From UltimateAndroid with Apache License 2.0 | 6 votes |
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)); }
Example 8
Source File: AnimatorProxy.java From Libraries-for-Android-Developers with MIT License | 6 votes |
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)); }
Example 9
Source File: ElementGroup.java From cidrawing with Apache License 2.0 | 5 votes |
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(); }
Example 10
Source File: GroupElement.java From cidrawing with Apache License 2.0 | 5 votes |
@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; }
Example 11
Source File: VirtualElement.java From cidrawing with Apache License 2.0 | 5 votes |
@Override public RectF getOuterBoundingBox() { RectF box = new RectF(); for (DrawElement element : elements) { box.union(element.getOuterBoundingBox()); } return box; }
Example 12
Source File: OC_LTrace.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public RectF pathsBounds() { RectF r = new RectF(); for(OBPath p : paths) r.union(p.frame()); return r; }
Example 13
Source File: AnimatorProxy.java From KJFrameForAndroid with Apache License 2.0 | 5 votes |
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)); }
Example 14
Source File: AnimatorProxy.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
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)); }
Example 15
Source File: OC_Onset.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
static RectF AllLabelsFrame(List<OBLabel> labs) { RectF f = new RectF(); for(OBControl l : labs) { f.union(l.frame()); } return f; }
Example 16
Source File: OBReadingPara.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public RectF frame() { RectF f = new RectF(); for (OBReadingWord word : words) { if (word.label != null) f.union(word.label.frame()); } return f; }
Example 17
Source File: AnimatorProxy.java From timecat with Apache License 2.0 | 5 votes |
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)); }
Example 18
Source File: AnnotationMediator.java From Reader with Apache License 2.0 | 5 votes |
/** * 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); }
Example 19
Source File: OC_Count100_S2j.java From GLEXP-Team-onebillion with Apache License 2.0 | 4 votes |
@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; }
Example 20
Source File: SelectionActionModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * 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)); }