public void testAdding() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); tc.add( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }
public void init( final StackedObjectPool<OrphanBlockContext> pool, final OrphanContext parent, final RenderBox contextBox, final int orphans ) { this.breakMarkerSeen = false; this.pool = pool; this.parent = parent; this.contextBox = contextBox; this.orphans = orphans; this.orphanOverride = contextBox.getCachedY(); this.orphanCount = 0; if ( orphans > 0 ) { if ( this.orphanSize == null ) { this.orphanSize = new RingBuffer<RenderNode>( orphans ); } else { this.orphanSize.resize( orphans ); } } }
public long getOrphanValue() { if ( orphans == 0 ) { return orphanOverride; } final RenderNode lastValue = orphanSize.getLastValue(); if ( lastValue == null ) { return orphanOverride; } return Math.max( orphanOverride, lastValue.getCachedY2() ); }
public void testInvalidSize() { try { new RingBuffer( 0 ); Assert.fail(); } catch ( IllegalArgumentException e ) { // ignore } }
public void endChild( final RenderBox box ) { if ( currentNode != null ) { if ( widowCount < widows && widows > 0 ) { widowSize.add( box ); box.setRestrictFinishedClearOut( RenderBox.RestrictFinishClearOut.LEAF ); } widowCount += 1; currentNode = null; } if ( parent != null ) { parent.endChild( box ); } }
private long getWidowValue() { if ( widows == 0 ) { return widowOverride; } final RenderNode box = widowSize.getLastValue(); if ( box == null ) { return widowOverride; } final long y2 = box.getCachedY2() - box.getCachedHeight(); return Math.min( widowOverride, y2 ); }
public void testAdding2() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); assertEquals( 30, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); }
public void endChild( final RenderBox box ) { if ( currentNode != null ) { if ( orphanCount < orphans && orphans > 0 ) { orphanSize.add( box ); box.setRestrictFinishedClearOut( RenderBox.RestrictFinishClearOut.LEAF ); } orphanCount += 1; currentNode = null; } if ( parent != null ) { parent.endChild( box ); } }
public void init( final StackedObjectPool<WidowBlockContext> pool, final WidowContext parent, final RenderBox contextBox, final int widows ) { this.breakMarkerSeen = false; this.pool = pool; this.parent = parent; this.contextBox = contextBox; this.widows = widows; this.widowCount = 0; this.widowOverride = contextBox.getCachedY2(); this.widowOverrideWithKeepTogether = contextBox.getCachedY2(); if ( widows > 0 ) { if ( this.widowSize == null ) { this.widowSize = new RingBuffer<RenderNode>( widows ); } else { this.widowSize.resize( widows ); } } }
public void testReplaceFirst() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.replaceLastAdded( 10 ); assertEquals( 10, (int) tc.getFirstValue() ); assertEquals( 10, (int) tc.getLastValue() ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); tc.add( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }
public void registerFinishedNode( final FinishedRenderNode box ) { if ( orphanCount < orphans && orphans > 0 ) { orphanSize.add( box ); box.getParent().setRestrictFinishedClearOut( RenderBox.RestrictFinishClearOut.RESTRICTED ); } orphanCount += box.getOrphanLeafCount(); currentNode = null; if ( parent != null ) { parent.registerFinishedNode( box ); } }
public void testReplace() { final RingBuffer<Integer> tc = new RingBuffer<Integer>( 3 ); tc.add( 10 ); tc.add( 20 ); tc.add( 30 ); assertEquals( 30, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); tc.replaceLastAdded( 40 ); assertEquals( 40, (int) tc.getLastValue() ); assertEquals( 10, (int) tc.getFirstValue() ); tc.add( 50 ); assertEquals( 50, (int) tc.getLastValue() ); assertEquals( 20, (int) tc.getFirstValue() ); }
public void registerFinishedNode( final FinishedRenderNode box ) { if ( widowCount < widows && widows > 0 ) { widowSize.add( box ); box.getParent().setRestrictFinishedClearOut( RenderBox.RestrictFinishClearOut.RESTRICTED ); } widowCount += box.getWidowLeafCount(); currentNode = null; if ( parent != null ) { parent.registerFinishedNode( box ); } }