DefaultViewport implements Viewport { @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"}) @Override public Viewport clone() { try { DefaultViewport vp = (DefaultViewport) super.clone(); vp.viewBounds = new Rectangle(viewBounds); vp.changeListeners = new ArrayList<>(3); return vp; } catch (CloneNotSupportedException e) { throw new IllegalStateException(e); } } DefaultViewport();  DefaultViewport(Rectangle viewBounds);  DefaultViewport(boolean modelYAxisDown);  DefaultViewport(Rectangle viewBounds, boolean modelYAxisDown); @Override boolean isModelYAxisDown(); @Override void setModelYAxisDown(boolean modelYAxisDown); @Override Rectangle getViewBounds(); @Override void setViewBounds(Rectangle viewBounds); @Override AffineTransform getViewToModelTransform(); @Override AffineTransform getModelToViewTransform(); @Override double getOrientation(); @Override void setOrientation(double orientation); @Override double getOffsetX(); @Override double getOffsetY(); @Override void setOffset(double offsetX, double offsetY); @Override void moveViewDelta(double deltaX, double deltaY); @Override double getZoomFactor(); @Override void setZoomFactor(double zoomFactor); @Override void zoom(Rectangle2D modelBounds); @Override void setZoomFactor(double zoomFactor, double modelCenterX, double modelCenterY); @Override void addListener(ViewportListener listener); @Override void removeListener(ViewportListener listener); @Override ViewportListener[] getListeners(); @Override void setTransform(Viewport other); @Override String toString(); @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"}) @Override Viewport clone();  }
@Test public void testClone() { final DefaultViewport viewport = new DefaultViewport(new Rectangle(40, 50), true); viewport.setOrientation(0.3); viewport.setZoomFactor(1.2); viewport.setOffset(-4.0, 3.7); viewport.setModelYAxisDown(true); assertEquals(0.3, viewport.getOrientation(), 1e-10); assertEquals(-4.0, viewport.getOffsetX(), 1e-10); assertEquals(3.7, viewport.getOffsetY(), 1e-10); assertEquals(1.2, viewport.getZoomFactor(), 1e-10); assertEquals(true, viewport.isModelYAxisDown()); Viewport viewportClone = viewport.clone(); assertEquals(0.3, viewportClone.getOrientation(), 1e-10); assertEquals(-4.0, viewportClone.getOffsetX(), 1e-10); assertEquals(3.7, viewportClone.getOffsetY(), 1e-10); assertEquals(1.2, viewportClone.getZoomFactor(), 1e-10); assertEquals(true, viewportClone.isModelYAxisDown()); }