/** Set the OMGraphicList within this OMGraphicHandler. Works if canSetGraphicList == true. */ public synchronized void setList(OMGraphicList omgl) { if (DEBUG) { Debug.output( "FilterSupport.setList() with " + (omgl != null ? omgl.size() + " graphics." : "null list.")); } list = omgl; }
/** * Return the graphic list currently being used by the OMGraphicHandler. If filters have been * applied, then the OMGraphics that have made it through the filter are visible. List may be * null, if it hasn't been set. * * @see OMGraphic#isVisible(). */ public synchronized OMGraphicList getList() { if (DEBUG) { Debug.output( "FilterSupport.getList() with " + (list != null ? list.size() + " graphics." : "null list.")); } return list; }
/** * Method that provides a recursive mechanism to go through OMGraphicsLists to filter out areas, * inside or outside another. */ protected OMGraphicList filterList(OMGraphicList omgl, Area area, boolean getInsideArea) { OMGraphicList ret = new OMGraphicList(); boolean DEBUG_DETAIL = Debug.debugging("filtersupportdetail"); boolean DEBUG = Debug.debugging("filtersupport") || DEBUG_DETAIL; if (DEBUG) { Debug.output("FilterSupport.filterList"); } int count = 0; // for debugging if (area != null && omgl != null) { // just checking for (OMGraphic omg : omgl) { if (DEBUG) { Debug.output("FilterSupport.filterList evaluating " + (count++) + " OMGraphic, " + omg); } boolean outsideFilter = true; // If not visible, automatically fails... if (!omg.isVisible()) { if (DEBUG) { Debug.output(" OMGraphic not visible, ignoring"); } continue; } if (omg instanceof OMGraphicList) { if (omg == omgl) { Debug.output(" OMGraphic is parent list (points to itself), ignoring..."); continue; } if (DEBUG) { Debug.output(" (filterList recursiving handing OMGraphicList)"); } OMGraphicList subList = filterList((OMGraphicList) omg, area, getInsideArea); if (!subList.isEmpty()) { if (DEBUG) { Debug.output( " +++ OMGraphicList's contents (" + subList.size() + ") pass filter, adding..."); } if (((OMGraphicList) omg).isVague()) { passedFilter(omg); omg.setVisible(true); ret.add(omg); } else { passedFilter(subList); ret.add(subList); } } else { if (DEBUG) { Debug.output(" --- OMGraphicList's contents fail filter, ignoring..."); } failedFilter(omg); } continue; } else { Shape omgShape = omg.getShape(); if (omgShape != null) { if (omgShape.getBounds2D().getWidth() == 0 && omgShape.getBounds2D().getHeight() == 0) { if (area.contains(omgShape.getBounds2D().getX(), omgShape.getBounds2D().getY())) { if (DEBUG_DETAIL) { Debug.output(" +++ omg contains position"); } outsideFilter = false; } } else if (area.intersects(omgShape.getBounds2D())) { if (DEBUG_DETAIL) { Debug.output(" +++ omg intersects bounds"); } // The area.interects() method above is a // general case. If you care about // preciseness, set the precise flag. // Depending on the performance cost, we might // want to make it permanent. if (precise) { Area omgArea = new Area(omgShape); if (!omgArea.isSingular()) { Area clone = (Area) area.clone(); clone.intersect(omgArea); if (!clone.isEmpty()) { outsideFilter = false; } } else { outsideFilter = false; } } else { outsideFilter = false; } } } // decide what to do depending on filteredOut and // getInsideArea if ((outsideFilter && !getInsideArea) || (!outsideFilter && getInsideArea)) { if (DEBUG) { Debug.output(" +++ OMGraphic passes filter, adding..."); } passedFilter(omg); ret.add(omg); } else { if (DEBUG) { Debug.output(" --- OMGraphic fails filter, hiding..."); } failedFilter(omg); } } } } return ret; }