Пример #1
0
            public static MultiRectArea getResult(MultiRectArea src1, MultiRectArea src2)
            {
                if (src1 == null || src2 == null || src1.isEmpty() || src2.isEmpty())
                {
                    return(new MultiRectArea());
                }

                MultiRectArea.RectCash dst = new MultiRectArea.RectCash();

                if (!src1.sorted || !src2.sorted ||
                    src1.getRectCount() <= MAX_SIMPLE || src2.getRectCount() <= MAX_SIMPLE)
                {
                    dst.setRect(simpleIntersect(src1, src2), false);
                }
                else
                {
                    java.awt.Rectangle bounds1 = src1.getBounds();
                    java.awt.Rectangle bounds2 = src2.getBounds();
                    java.awt.Rectangle bounds3 = bounds1.intersection(bounds2);
                    if (bounds3.width > 0 && bounds3.height > 0)
                    {
                        intersectRegions(src1.rect, src2.rect, dst, bounds1.height + 2, bounds2.height + 2);
                    }
                }

                return(dst);
            }
Пример #2
0
            internal MultiRectArea getResult(MultiRectArea src1, MultiRectArea src2)
            {
                if (src1 == null || src1.isEmpty())
                {
                    return(new MultiRectArea(src2));
                }

                if (src2 == null || src2.isEmpty())
                {
                    return(new MultiRectArea(src1));
                }

                dst = new MultiRectArea.RectCash();

                if (!src1.sorted || !src2.sorted ||
                    src1.getRectCount() <= MAX_SIMPLE || src2.getRectCount() <= MAX_SIMPLE)
                {
                    simpleUnion(src1, src2, dst);
                }
                else
                {
                    java.awt.Rectangle bounds1 = src1.getBounds();
                    java.awt.Rectangle bounds2 = src2.getBounds();
                    java.awt.Rectangle bounds3 = bounds1.intersection(bounds2);

                    if (bounds3.width < 0 || bounds3.height < 0)
                    {
                        if (bounds1.y + bounds1.height < bounds2.y)
                        {
                            dst.setRect(addVerRegion(src1.rect, src2.rect), false);
                        }
                        else
                        if (bounds2.y + bounds2.height < bounds1.y)
                        {
                            dst.setRect(addVerRegion(src2.rect, src1.rect), false);
                        }
                        else
                        if (bounds1.x < bounds2.x)
                        {
                            dst.setRect(addHorRegion(src1.rect, src2.rect), false);
                        }
                        else
                        {
                            dst.setRect(addHorRegion(src2.rect, src1.rect), false);
                        }
                    }
                    else
                    {
                        unionRegions(src1.rect, src2.rect, bounds1.height + 2, bounds2.height + 2);
                    }
                }

                return(dst);
            }