/* RegionObserver implementation
962390
@Override
  public void start(CoprocessorEnvironment e) throws IOException {
    if (e instanceof RegionCoprocessorEnvironment) {
      RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
      Supplier<TransactionStateCache> cacheSupplier = getTransactionStateCacheSupplier(env);
      this.cache = cacheSupplier.get();

      HTableDescriptor tableDesc = env.getRegion().getTableDesc();
      for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) {
        String columnTTL = columnDesc.getValue(TxConstants.PROPERTY_TTL);
        long ttl = 0;
        if (columnTTL != null) {
          try {
            ttl = Long.parseLong(columnTTL);
            LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + columnTTL);
          } catch (NumberFormatException nfe) {
            LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() +
                       ", value = " + columnTTL);
          }
        }
        ttlByFamily.put(columnDesc.getName(), ttl);
      }

      this.allowEmptyValues = env.getConfiguration().getBoolean(TxConstants.ALLOW_EMPTY_VALUES_KEY,
                                                                TxConstants.ALLOW_EMPTY_VALUES_DEFAULT);
      this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA));
      if (readNonTxnData) {
        LOG.info("Reading pre-existing data enabled for table " + tableDesc.getNameAsString());
      }
    }
  }
1105080
public void show(int itemIndex, Bounds region) {
      navigator.showLengthRegion(itemIndex, orientation.minY(region), orientation.maxY(region));
      showBreadthRegion(orientation.minX(region), orientation.maxX(region));
    }
430370
public void formatRegion(XtextResource resource, int offset, int length) {
		assert resource != null;
		assert offset >= 0;
		assert length >= 0;
		final String result = formatResourceRegion(resource, offset, length);
		// Write back to the resource
		try (StringInputStream stringInputStream = new StringInputStream(result)) {
			resource.load(stringInputStream, Collections.emptyMap());
		} catch (Exception exception) {
			throw Exceptions.sneakyThrow(exception);
		}
	}
241239
private void doGetRegional() throws PageException {
	Struct sct = new StructImpl();
	pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
	sct.set("locale", Caster.toString(config.getLocale()));
	sct.set("timezone", toStringTimeZone(config.getTimeZone()));
	sct.set("timeserver", config.getTimeServer());
	sct.set("usetimeserver", config.getUseTimeServer());
	// replaced with encoding outputsct.set("defaultencoding", config.get DefaultEncoding());
    }
1321417
protected void addObserver (Object obs)
    {
        if (_observers == null) {
            _observers = ObserverList.newFastUnsafe();
        }
        _observers.add(obs);
    }
1015941
private Region insert(Region x, Region t) {
    if (t == NULL_NODE) {
      t = x;
    } else if (x.orderRelativeTo(t) < 0) {
      t.left(insert(x, t.left));
    } else if (x.orderRelativeTo(t) > 0) {
      t.right(insert(x, t.right));
    } else {
      throw new AssertionError("Cannot insert " + x + " into " + this);
    }
    t = skew(t);
    t = split(t);
    return t;
  }
677574
public void addRegion(InfinispanBaseRegion region) {
		allRegions.put(ByteString.fromString(region.getCache().getName()), region);
	}
339123
function(){
    this._regionManager = new Marionette.RegionManager();

    this.listenTo(this._regionManager, "region:add", function(name, region){
      this[name] = region;
    });

    this.listenTo(this._regionManager, "region:remove", function(name, region){
      delete this[name];
    });
  }
912601
public static void regionsColor( GrayS32 pixelToRegion ,
									 FastQueue<float[]> segmentColor ,
									 Bitmap output , byte[] storage ) {
		if( storage == null )
			storage = declareStorage(output,null);

		int indexOut = 0;
		for( int y = 0; y < pixelToRegion.height; y++ ) {
			for( int x = 0; x < pixelToRegion.width; x++ ) {
				int index = pixelToRegion.unsafe_get(x,y);
				float []cv = segmentColor.get(index);

				int r,g,b;

				if( cv.length == 3 ) {
					r = (int)cv[0];
					g = (int)cv[1];
					b = (int)cv[2];
				} else {
					r = g = b = (int)cv[0];
				}

				storage[indexOut++] = (byte)r;
				storage[indexOut++] = (byte)g;
				storage[indexOut++] = (byte)b;
				storage[indexOut++] = (byte)0xFF;
			}
		}

		output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
	}
140832
public void setContent(Region content) {
        if (content != null) {
            this.content = content;
            this.content.setPickOnBounds(false);
            contentHolder.getChildren().setAll(content);
        }
    }
969604
public boolean regionMatches(char []cb, int offset, int length)
  {
    int pos = getIndex();

    char ch = current();
    for (int i = 0; i < length; i++) {
      if (cb[i + offset] != ch) {
        setIndex(pos);
        return false;
      }
      ch = next();
    }

    return true;
  }
1006131
public void addObserver(OutputObserver observer)
    {
        if (_observers==null)
            _observers=new ArrayList(4);
        _observers.add(observer);
        _observers.add(null);
    }
429332
public Map<String, Object> getObserver() {
        TreeMap<String, Object> map = new TreeMap<String, Object>();
        synchronized (eventMap) {
            for (Entry<String, Object> entry : eventMap.entrySet()) {
                if (entry.getKey().startsWith(OBSERVER))
                    map.put(entry.getKey(), entry.getValue());
            }
        }
        return map;
    }
825635
public static RegionMap getRegionParamsFromImageMosaicReader( ImageMosaicReader reader ) throws IOException {
        RegionMap envelopeParams = new RegionMap();

        Envelope envelope = reader.getOriginalEnvelope();

        DirectPosition lowerCorner = envelope.getLowerCorner();
        double[] westSouth = lowerCorner.getCoordinate();
        DirectPosition upperCorner = envelope.getUpperCorner();
        double[] eastNorth = upperCorner.getCoordinate();

        GridEnvelope2D gridRange = (GridEnvelope2D) reader.getOriginalGridRange();
        int height = gridRange.height;
        int width = gridRange.width;
        double[][] resolutionLevels = reader.getResolutionLevels();
        double xRes = resolutionLevels[0][0];
        double yRes = resolutionLevels[0][1];

        envelopeParams.put(NORTH, eastNorth[1]);
        envelopeParams.put(SOUTH, westSouth[1]);
        envelopeParams.put(WEST, westSouth[0]);
        envelopeParams.put(EAST, eastNorth[0]);
        envelopeParams.put(XRES, xRes);
        envelopeParams.put(YRES, yRes);
        envelopeParams.put(ROWS, (double) height);
        envelopeParams.put(COLS, (double) width);

        return envelopeParams;
    }
812839
@Override
    public void addSynchronizationObserver(Observer<Registry<KEY, ENTRY>,Long> observer) {
        synchronisationObservable.addObserver(observer);
    }
966047
@Override
    public void areaSelected(Area area)
    {
        //show the separator list
        if (area instanceof AreaImpl)
        {
            SeparatorSet sset = Config.createSeparators((AreaImpl) area);
            DefaultListModel<Separator> ml = new DefaultListModel<Separator>();
            for (Separator sep : sset.getHorizontal())
                ml.addElement(sep);
            for (Separator sep : sset.getVertical())
                ml.addElement(sep);
            for (Separator sep : sset.getBoxsep())
                ml.addElement(sep);
            sepList.setModel(ml);
        }
        else
        {
            //not a grouping area -- no separators
            sepList.setModel(new DefaultListModel<Separator>());
        }
    }
1358474
public void assignLabelsToPixels( GrayS32 pixelToRegions ,
									  GrowQueue_I32 regionMemberCount ,
									  FastQueue<float[]> regionColor ) {

		regionColor.reset();
		for( int i = 0; i < clusters.size(); i++ ) {
			float[] r = regionColor.grow();
			float[] c = clusters.get(i).color;
			for( int j = 0; j < numBands; j++ ) {
				r[j] = c[j];
			}
		}

		regionMemberCount.resize(clusters.size());
		regionMemberCount.fill(0);

		int indexPixel = 0;
		for( int y = 0; y < pixelToRegions.height; y++ ) {
			int indexOutput = pixelToRegions.startIndex + y*pixelToRegions.stride;
			for( int x =0; x < pixelToRegions.width; x++ , indexPixel++ , indexOutput++) {
				Pixel p = pixels.data[indexPixel];

				// It is possible for a pixel to be unassigned if all the means move too far away from it
				// Default to a non-existant cluster if that's the case
				int best = -1;
				float bestDistance = Float.MAX_VALUE;
				// find the region/cluster which it is closest to
				for( int j = 0; j < p.clusters.size; j++ ) {
					ClusterDistance d = p.clusters.data[j];
					if( d.distance < bestDistance ) {
						bestDistance = d.distance;
						best = d.cluster.id;
					}
				}
				if( best == -1 ) {
					regionColor.grow();
					best = regionMemberCount.size();
					regionMemberCount.add(0);
				}

				pixelToRegions.data[indexOutput] = best;
				regionMemberCount.data[best]++;
			}
		}
	}