<editor-fold defaultstate="collapsed" desc="Areas related">
195475
private void createAreas(final BufferedImage IMAGE) {
        final double ORIGIN_CORRECTION;
        final double ANGLE_STEP;

        switch (getOrientation()) {
            case NORTH:
                ORIGIN_CORRECTION = 135;
                break;
            case EAST:
                ORIGIN_CORRECTION = 135;
                break;
            case SOUTH:
                ORIGIN_CORRECTION = 135;
                break;
            case WEST:
                ORIGIN_CORRECTION = 225;
                break;
            default:
                ORIGIN_CORRECTION = 135;
                break;
        }

        if (bImage != null) {
            if (!isLogScale()) {
                ANGLE_STEP = Math.toDegrees(getModel().getAngleRange()) / (getMaxValue() - getMinValue());
            } else {
                ANGLE_STEP = Math.toDegrees(getModel().getAngleRange()) / UTIL.logOfBase(BASE, getMaxValue() - getMinValue());
            }

            if (bImage != null && !getAreas().isEmpty()) {
                final double OUTER_RADIUS = bImage.getWidth() * 0.44f;
                final double RADIUS;
                if (isSectionsVisible()) {
                    RADIUS = isExpandedSectionsEnabled() ? OUTER_RADIUS - bImage.getWidth() * 0.12f : OUTER_RADIUS - bImage.getWidth() * 0.04f;
                } else {
                    RADIUS = OUTER_RADIUS;
                }
                final double FREE_AREA = bImage.getWidth() / 2.0 - RADIUS;
                final Rectangle2D AREA_FRAME = new Rectangle2D.Double(bImage.getMinX() + FREE_AREA, bImage.getMinY() + FREE_AREA, 2 * RADIUS, 2 * RADIUS);

                for (Section area : getAreas()) {
                    if (!isLogScale()) {
                        area.setFilledArea(new Arc2D.Double(AREA_FRAME, ORIGIN_CORRECTION - (area.getStart() * ANGLE_STEP) + (getMinValue() * ANGLE_STEP), -(area.getStop() - area.getStart()) * ANGLE_STEP, Arc2D.PIE));
                    } else {
                        area.setFilledArea(new Arc2D.Double(AREA_FRAME, ORIGIN_CORRECTION - (UTIL.logOfBase(BASE, area.getStart()) * ANGLE_STEP) + (UTIL.logOfBase(BASE, getMinValue()) * ANGLE_STEP), -UTIL.logOfBase(BASE, area.getStop() - area.getStart()) * ANGLE_STEP, Arc2D.PIE));
                    }
                }
            }
            // Draw the areas
            if (isAreasVisible() && IMAGE != null) {
                final Graphics2D G2 = IMAGE.createGraphics();
                G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                switch (getOrientation()) {
                    case EAST:
                        break;
                    case SOUTH:
                        break;
                    case WEST:
                        G2.translate(CENTER.getX() / 2.2, 0);
                        break;
                    case NORTH:

                    default:
                        G2.translate(0, CENTER.getY() / 2.2);
                        break;
                }

                for (Section area : getAreas()) {
                    G2.setColor(isTransparentAreasEnabled() ? area.getTransparentColor() : area.getColor());
                    G2.fill(area.getFilledArea());
                }
                G2.dispose();
            }
        }
    }
522456
public void initKeyAreas(FieldTable table) throws DBException
    {
        if (m_VKeyList == null)
        {
            m_VKeyList = new Vector<PKeyArea>();
            // Now, copy the keys
            for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea <= table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA - 1; iKeyArea++)
            {
                this.makePKeyArea(table);
            }
        }
    }
413615
@Override
	protected void selectRectangle(Bbox selectedArea) {
		// we can clear here !
		if (!shiftOrCtrl) {
			MapModel mapModel = mapWidget.getMapModel();
			mapModel.clearSelectedFeatures();
		}
		GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
		SearchByLocationRequest request = new SearchByLocationRequest();
		request.setLayerIds(getSelectionLayerIds());
		for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
			if (layer.isShowing() && layer instanceof VectorLayer) {
				request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
			}
		}

		Polygon polygon = mapWidget.getMapModel().getGeometryFactory().createPolygon(selectedArea);
		request.setLocation(GeometryConverter.toDto(polygon));
		request.setCrs(mapWidget.getMapModel().getCrs());
		request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
		request.setRatio(coverageRatio);
		request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
		request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
		commandRequest.setCommandRequest(request);
		GwtCommandDispatcher.getInstance().execute(commandRequest,
				new AbstractCommandCallback<SearchByLocationResponse>() {

			public void execute(SearchByLocationResponse response) {
				Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
				for (String layerId : featureMap.keySet()) {
					selectFeatures(layerId, featureMap.get(layerId));
				}
			}
		});
	}
906694
public void setColor(TimeArea area, Color color) {
        // If null was supplied, then use the default color.
        if (color == null) {
            color = area.defaultColor;
        }
        // Save the color to the color map.
        colors.put(area, color);

        // Call any "updating functions" that are appropriate for the specified area.
        if (parent != null) {
            parent.zDrawTextFieldIndicators();
        }
    }
1335206
public void removeArea(final TimeSection AREA) {
        if (null == AREA) return;
        areas.remove(AREA);
        Collections.sort(areas, new TimeSectionComparator());
        fireUpdateEvent(SECTION_EVENT);
    }
799231
public static <S> PAreaBD<S> toPAreaBD(final AreaBD a)
  {
    Objects.requireNonNull(a, "area");
    return PAreaBD.of(a.minimumX(), a.maximumX(), a.minimumY(), a.maximumY());
  }
592479
public void setAreas(Section... AREAS_ARRAY) {
        areas.clear();
        for (Section area : AREAS_ARRAY) {
            areas.add(new Section(area.getStart(), area.getStop(), area.getColor()));
        }
        validate();
        fireStateChanged();
    }
495316
public void setAreasVisible(final boolean VISIBLE) {
        if (null == areasVisible) {
            _areasVisible = VISIBLE;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            areasVisible.set(VISIBLE);
        }
    }
1200614
private void obtainScrollableArea(@StyleRes final int themeResourceId) {
        TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
                new int[]{R.attr.materialDialogScrollableAreaTop,
                        R.attr.materialDialogScrollableAreaBottom});
        int topIndex = typedArray.getInt(0, -1);
        int bottomIndex = typedArray.getInt(1, -1);

        if (topIndex != -1) {
            Area top = Area.fromIndex(topIndex);

            if (bottomIndex != -1) {
                Area bottom = Area.fromIndex(bottomIndex);
                setScrollableArea(top, bottom);
            } else {
                setScrollableArea(top);
            }
        } else {
            setScrollableArea(null, null);
        }
    }
63528
public void markBoxArea(Context ctx, float[] bmin, float[] bmax, AreaModification areaMod, CompactHeightfield chf) {
        ctx.startTimer("MARK_BOX_AREA");

        int minx = (int) ((bmin[0] - chf.bmin[0]) / chf.cs);
        int miny = (int) ((bmin[1] - chf.bmin[1]) / chf.ch);
        int minz = (int) ((bmin[2] - chf.bmin[2]) / chf.cs);
        int maxx = (int) ((bmax[0] - chf.bmin[0]) / chf.cs);
        int maxy = (int) ((bmax[1] - chf.bmin[1]) / chf.ch);
        int maxz = (int) ((bmax[2] - chf.bmin[2]) / chf.cs);

        if (maxx < 0)
            return;
        if (minx >= chf.width)
            return;
        if (maxz < 0)
            return;
        if (minz >= chf.height)
            return;

        if (minx < 0)
            minx = 0;
        if (maxx >= chf.width)
            maxx = chf.width - 1;
        if (minz < 0)
            minz = 0;
        if (maxz >= chf.height)
            maxz = chf.height - 1;

        for (int z = minz; z <= maxz; ++z) {
            for (int x = minx; x <= maxx; ++x) {
                CompactCell c = chf.cells[x + z * chf.width];
                for (int i = c.index, ni = c.index + c.count; i < ni; ++i) {
                    CompactSpan s = chf.spans[i];
                    if (s.y >= miny && s.y <= maxy) {
                        if (chf.areas[i] != RC_NULL_AREA)
                            chf.areas[i] = areaMod.apply(chf.areas[i]);
                    }
                }
            }
        }

        ctx.stopTimer("MARK_BOX_AREA");

    }
997254
public void setAreas(final List<Section> AREAS) {
        areas.setAll(AREAS);
        Collections.sort(areas, new SectionComparator());
        fireUpdateEvent(SECTION_EVENT);
    }
106861
public void setScrollableArea (int x, int y, int width, int height)
    {
        Rectangle vb = _panel.getViewBounds();
        int hmax = x + width, vmax = y + height, value;

        if (width > vb.width) {
            value = MathUtil.bound(x, _hrange.getValue(), hmax - vb.width);
            _hrange.setRangeProperties(value, vb.width, x, hmax, false);
        } else {
            // Let's center it and lock it down.
            int newx = x - (vb.width - width)/2;
            _hrange.setRangeProperties(newx, 0, newx, newx, false);
        }
        if (height > vb.height) {
            value = MathUtil.bound(y, _vrange.getValue(), vmax - vb.height);
            _vrange.setRangeProperties(value, vb.height, y, vmax, false);
        } else {
            // Let's center it and lock it down.
            int newy = y - (vb.height - height)/2;
            _vrange.setRangeProperties(newy, 0, newy, newy, false);
        }
    }
492128
private void setAreaAreaPredicates_() {
        m_predicates_half_edge = Predicates.AreaAreaPredicates;

        m_max_dim[MatrixPredicate.InteriorInterior] = 2;
        m_max_dim[MatrixPredicate.InteriorBoundary] = 1;
        m_max_dim[MatrixPredicate.InteriorExterior] = 2;
        m_max_dim[MatrixPredicate.BoundaryInterior] = 1;
        m_max_dim[MatrixPredicate.BoundaryBoundary] = 1;
        m_max_dim[MatrixPredicate.BoundaryExterior] = 1;
        m_max_dim[MatrixPredicate.ExteriorInterior] = 2;
        m_max_dim[MatrixPredicate.ExteriorBoundary] = 1;
        m_max_dim[MatrixPredicate.ExteriorExterior] = 2;

        // set predicates that are always true/false
        if (m_perform_predicates[MatrixPredicate.ExteriorExterior])
        {
            m_matrix[MatrixPredicate.ExteriorExterior] = 2; // Always true
            m_perform_predicates[MatrixPredicate.ExteriorExterior] = false;
            m_predicate_count--;
        }
	}
233173
protected void recursiveSortLines(AreaImpl root)
    {
        sortChildLines(root);
        for (int i = 0; i < root.getChildCount(); i++)
            recursiveSortLines((AreaImpl) root.getChildAt(i));
    }
    
    /**
     * Goes through the grid of areas and sorts the adjacent visual areas that are not
     * separated by anything
     */
    protected void sortChildLines(AreaImpl root)
    {
        if (root.getChildCount() > 1)
        {
            List<Area> src = new Vector<Area>(root.getChildren());
            List<Area> dest = new Vector<Area>(src.size());
            while (!src.isEmpty())
            {
                final AreaImpl seed = (AreaImpl) src.get(0);
                List<Area> line = findAreasOnLine(root, seed, src);
                dest.addAll(line);
                src.removeAll(line);
            }
            
            root.removeAllChildren();
            root.appendChildren(dest);
        }
    }

    private List<Area> findAreasOnLine(AreaImpl parent, AreaImpl area, List<Area> candidates)
    {
        Vector<Area> ret = new Vector<Area>();
        ret.add(area);
        
        final int nx1 = area.getGridPosition().getX1();
        final int ny1 = area.getGridPosition().getY1();
        final int nx2 = area.getGridPosition().getX2();
        final int ny2 = area.getGridPosition().getY2();
        final AreaTopology t = parent.getTopology();
        
        //try to expand to the right
        int dist = 1;
        while (nx2 + dist < t.getTopologyWidth())
        {
            //try to find some node at the right in the given distance
            for (int y = ny1; y <= ny2; y++)
            {
                AreaImpl neigh = (AreaImpl) t.findAreaAt(nx2 + dist, y);
                if (neigh != null && candidates.contains(neigh)) //something found
                {
                    //the maximal Y difference to consider other areas to be on the same line
                    int threshold = (Math.min(area.getHeight(), neigh.getHeight()) / 2);
                    if (threshold < 0) threshold = 0;
                    //check if the nodes could be on the same line
                    if (AreaUtils.isOnSameLine(area, neigh, threshold))
                    {
                        ret.add(neigh);
                        break;
                    }
                }
            }
            dist++;
        }
        //try to expand to the left
        dist = 1;
        while (nx1 - dist >= 0)
        {
            //try to find some node at the right in the given distance
            for (int y = ny1; y <= ny2; y++)
            {
                AreaImpl neigh = (AreaImpl) t.findAreaAt(nx1 - dist, y);
                if (neigh != null && candidates.contains(neigh)) //something found
                {
                    //the maximal Y difference to consider other areas to be on the same line
                    int threshold = (Math.min(area.getHeight(), neigh.getHeight()) / 2);
                    if (threshold < 0) threshold = 0;
                    //check if the nodes could be on the same line
                    if (AreaUtils.isOnSameLine(area, neigh, threshold))
                    {
                        ret.insertElementAt(neigh, 0);
                        break;
                    }
                }
            }
            dist++;
        }
            
        return ret;
    }
    
}
125643
private function AddAreasField()
    {
        $name = 'Areas';
        $field = Input::Text($name, join(', ' , $this->areaNames));
        $this->AddField($field);
        if ($this->layout->Exists())
        {
            $field->SetHtmlAttribute('readonly', 'readonly');
        }
        else
        {
            $this->SetTransAttribute($name, 'placeholder');
            $this->SetRequired($name);
        }
    }
202582
public void setAreaIconsVisible(final boolean VISIBLE) {
        if (null == areaIconsVisible) {
            _areaIconsVisible = VISIBLE;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            areaIconsVisible.set(VISIBLE);
        }
    }
1124292
private void boundaryAreaBoundaryArea_(int half_edge, int id_a, int id_b) {
		if (m_matrix[MatrixPredicate.BoundaryBoundary] == 1)
			return;

		int parentage = m_topo_graph.getHalfEdgeParentage(half_edge);

		if ((parentage & id_a) != 0 && (parentage & id_b) != 0) {
			m_matrix[MatrixPredicate.BoundaryBoundary] = 1;
			return;
		}

		if (m_matrix[MatrixPredicate.BoundaryBoundary] != 0) {
			if (m_topo_graph.getHalfEdgeUserIndex(m_topo_graph
					.getHalfEdgePrev(m_topo_graph.getHalfEdgeTwin(half_edge)),
					m_visited_index) != 1) {
				int cluster = m_topo_graph.getHalfEdgeTo(half_edge);
				int clusterParentage = m_topo_graph
						.getClusterParentage(cluster);

				if ((clusterParentage & id_a) != 0
						&& (clusterParentage & id_b) != 0) {
					m_matrix[MatrixPredicate.BoundaryBoundary] = 0;
				}
			}
		}
	}