litesoft
@ 947
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.render; public abstract class AbstractSimpleSizableRenderHelper extends AbstractSizableRenderHelper { protected AbstractSimpleSizableRenderHelper( Object pRectangularRenderableObject, // RenderAccessor pRenderAccessor, // RenderParticipatingAdapter pParticipatingAdapter, // RenderDimensionAdapter pDimensionAdapter ) { super( pRectangularRenderableObject, pRenderAccessor, RenderSizingApproach.Settable, pParticipatingAdapter, pDimensionAdapter ); mDetermineNaturalSize = new DetermineNaturalSizeRHP( mRROname, this, // mDetermineRectSizeNow ); mDetermineCurrentSize = new DetermineCurrentSizeRHP( mRROname, this, // mDetermineRectSizeNow, // mDetermineNaturalSize ); mMutateSize = new MutateSizeRHP( mRROname, this, // mDetermineCurrentSize ); } /** * Get the "Minimum" Size. * <p/> * Renderable Objects that are not Sizable will return their "Natural" Size. * * @return null means that is not "yet" available. */ public Integer getMinimumSize() { Integer zCurrentSize = getCurrentSize(); // Dependency Integer zNaturalSize = getNaturalSize(); // Default Integer zMinimumSize = LLgetMinimumSize(); if ( zCurrentSize == null ) { return null; } return (zMinimumSize != null) ? zMinimumSize : zNaturalSize; } /** * Get the "Minimum" Size RHP. * <p/> * Note: RHPs are Instance Equality Managed, so for the same underlying dependency the same RHP must be returned! * * @return !null RHP, where its callbacks will be notified when it is complete. */ public RenderHelperProcess unavailableMinimumSizeRHP() { return unavailableCurrentSizeRHP(); } /** * Request "this" RederableRect and its' children be layed out. * <p/> * Note: RHPs are Instance Equality Managed, so for the same underlying dependency the same RHP must be returned! * * @return null if no layout process is needed, * otherwise the returned RHP's callbacks will be notified when it is complete. */ public RenderHelperProcess layoutFromHereDown() { if ( null == getNaturalSize() ) { return unavailableNaturalSizeRHP(); } setLayedOut(); return null; } protected RenderProcessResult sizingError( MutateSizeRHP pMutateSizeRHP, int pExpectedSize, int pActualSize ) { if ( ++mDorkedCount < 20 ) { logSizingError( LOGGER.error, pExpectedSize, pActualSize, "" ); defer( pMutateSizeRHP, 50 ); // Will it Settle...? return RenderProcessResult.Requeued; } logSizingError( LOGGER.fatal, pExpectedSize, pActualSize, "" ); return RenderProcessResult.Terminated; } protected void sizingOK() { mDorkedCount = 0; } private int mDorkedCount = 0; /** * Set the Size - pCurrentSize != pNewSize */ protected RenderProcessResult LLLsetSize( MutateSizeRHP pMutateSizeRHP, int pCurrentSize, int pNewSize ) { setSizingChange( pCurrentSize, pNewSize ); getDimensionAdapter().setSize( getRectangularRenderableObject(), pNewSize ); // Set our Size // Make us wait until we get the size! deferPending( pMutateSizeRHP, unavailableCurrentSizeRHP() ); return RenderProcessResult.Requeued; } public String toString() { return toString( "SimpleSizable" ); } } |