private WVirtualImage.Rect neighbourhood(long x, long y, int marginX, int marginY) { long x1 = x - marginX; if (this.imageWidth_ != Infinite) { x1 = Math.max((long) 0, x1); } long y1 = Math.max((long) 0, y - marginY); long x2 = x + this.viewPortWidth_ + marginX; if (this.imageWidth_ != Infinite) { x2 = Math.min(this.imageWidth_, x2); } long y2 = Math.min(this.imageHeight_, y + this.viewPortHeight_ + marginY); return new WVirtualImage.Rect(x1, y1, x2, y2); }
private void internalScrollTo(long newX, long newY, boolean moveViewPort) { if (this.imageWidth_ != Infinite) { newX = Math.min(this.imageWidth_ - this.viewPortWidth_, Math.max((long) 0, newX)); } if (this.imageHeight_ != Infinite) { newY = Math.min(this.imageHeight_ - this.viewPortHeight_, Math.max((long) 0, newY)); } if (moveViewPort) { this.contents_.setOffsets(new WLength((double) -newX), EnumSet.of(Side.Left)); this.contents_.setOffsets(new WLength((double) -newY), EnumSet.of(Side.Top)); } this.generateGridItems(newX, newY); this.viewPortChanged_.trigger(this.currentX_, this.currentY_); }
private void generateGridItems(long newX, long newY) { WVirtualImage.Rect newNb = this.neighbourhood(newX, newY, this.viewPortWidth_, this.viewPortHeight_); long i1 = newNb.x1 / this.gridImageSize_; long j1 = newNb.y1 / this.gridImageSize_; long i2 = newNb.x2 / this.gridImageSize_ + 1; long j2 = newNb.y2 / this.gridImageSize_ + 1; for (int invisible = 0; invisible < 2; ++invisible) { for (long i = i1; i < i2; ++i) { for (long j = j1; j < j2; ++j) { long key = this.gridKey(i, j); WImage it = this.grid_.get(key); if (it == null) { boolean v = this.visible(i, j); if (v && !(invisible != 0) || !v && invisible != 0) { long brx = i * this.gridImageSize_ + this.gridImageSize_; long bry = j * this.gridImageSize_ + this.gridImageSize_; brx = Math.min(brx, this.imageWidth_); bry = Math.min(bry, this.imageHeight_); WImage img = this.createImage( i * this.gridImageSize_, j * this.gridImageSize_, (int) (brx - i * this.gridImageSize_), (int) (bry - j * this.gridImageSize_)); img.setAttributeValue("onmousedown", "return false;"); this.contents_.addWidget(img); img.setPositionScheme(PositionScheme.Absolute); img.setOffsets(new WLength((double) i * this.gridImageSize_), EnumSet.of(Side.Left)); img.setOffsets(new WLength((double) j * this.gridImageSize_), EnumSet.of(Side.Top)); this.grid_.put(key, img); } } } } } this.currentX_ = newX; this.currentY_ = newY; this.cleanGrid(); }