blob: 5e9e11d1532823247c787a9ec5f84528dfcd1b0a [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport
import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRange
import org.eclipse.nebula.widgets.nattable.core.layer.axis.Axis
class ViewportAxis implements Axis {
val Axis underlyingAxis
/**
* Indicates the visible portion of the axis. Note that the pixel locations returned by this ClientDimensionProvider
* must be in terms of underlying axis pixel coordinates.
*/
val PixelRange visiblePixelRange
int pixelOrigin
new(Axis underlyingAxis, PixelRange visiblePixelRange) {
this.underlyingAxis = underlyingAxis
this.visiblePixelRange = visiblePixelRange
}
def getPixelOrigin() { pixelOrigin }
def void setPixelOrigin(int pixelOrigin) {
this.pixelOrigin = pixelOrigin
}
def int getOriginSegmentPosition() {
underlyingAxis.getSegmentPositionByPixelLocation(pixelOrigin)
}
// Layer interface
override getSegmentCount() {
val endSegmentPosition = underlyingAxis.getSegmentPositionByPixelLocation(visiblePixelRange.endPixel)
endSegmentPosition - originSegmentPosition + 1
}
override getStartPixelOfSegmentPosition(int segmentPosition) {
pixelOrigin + underlyingAxis.getStartPixelOfSegmentPosition(segmentPosition)
}
override getSegmentPositionByPixelLocation(int pixelLocation) {
underlyingAxis.getSegmentPositionByPixelLocation(pixelOrigin + pixelLocation)
}
override getIdOfSegmentPosition(int segmentPosition) {
underlyingAxis.getIdOfSegmentPosition(originSegmentPosition + segmentPosition)
}
override getSegment(int segmentPosition) {
underlyingAxis.getSegment(originSegmentPosition + segmentPosition)
}
}