Android examples for Graphics:Rectangle
union Rectangles
//package com.java2s; import android.support.annotation.NonNull; import java.util.ArrayList; import java.util.List; public class Main { public static List<int[]> unionRectangles(@NonNull List<int[]> underlines) { int count = underlines.size(); if (count == 0) { return underlines; }/*from ww w .j a v a2s. co m*/ List<int[]> newLines = new ArrayList<>(); int[] temp = underlines.get(0); for (int i = 1; i < count; i++) { int[] next = underlines.get(i); if (isLineIntersect(temp, next)) { temp[4] = Math.max(temp[4], next[4]); } else { newLines.add(temp); temp = next; } } return newLines; } static boolean isLineIntersect(int[] a, int[] b) { return a[4] <= b[3]; } }