| package org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport |
| |
| import java.io.Serializable |
| 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.getSegmentPositionOfPixelLocation(pixelOrigin) |
| } |
| |
| // Layer interface |
| |
| override getSegmentCount() { |
| val endSegmentPosition = underlyingAxis.getSegmentPositionOfPixelLocation(visiblePixelRange.endPixel) |
| endSegmentPosition - originSegmentPosition + 1 |
| } |
| |
| override getStartPixelOfSegmentPosition(int segmentPosition) { |
| pixelOrigin + underlyingAxis.getStartPixelOfSegmentPosition(segmentPosition) |
| } |
| |
| override getSegmentPositionOfPixelLocation(int pixelLocation) { |
| underlyingAxis.getSegmentPositionOfPixelLocation(pixelOrigin + pixelLocation) |
| } |
| |
| override getIdOfSegmentPosition(int segmentPosition) { |
| underlyingAxis.getIdOfSegmentPosition(originSegmentPosition + segmentPosition) |
| } |
| |
| override getSegmentPositionOfId(Serializable segmentId) { |
| underlyingAxis.getSegmentPositionOfId(segmentId) - originSegmentPosition |
| } |
| |
| } |