Subversion Repository Public Repository

litesoft

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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.render;

import org.litesoft.logger.nonpublic.*;

public abstract class AbstractSizableRenderHelper extends AbstractRenderHelper implements SizableRenderHelper
{
    protected AbstractSizableRenderHelper( Object pRectangularRenderableObject, //
                                           RenderAccessor pRenderAccessor, //
                                           RenderSizingApproach pSizingApproach, //
                                           RenderParticipatingAdapter pParticipatingAdapter, //
                                           RenderDimensionAdapter pDimensionAdapter )
    {
        super( pRectangularRenderableObject, pRenderAccessor, pSizingApproach, pParticipatingAdapter, pDimensionAdapter );
    }

    protected DetermineNaturalSizeRHP mDetermineNaturalSize;
    protected DetermineCurrentSizeRHP mDetermineCurrentSize;
    protected MutateSizeRHP mMutateSize;

    private Integer mNaturalSize = null;
    private Integer mMinimumSize = null;

    private boolean mExplicitlySized = false;
    private Integer mSizedTo = null;
    private boolean mSizedToPending = false;

    private Integer mSetSizePending = null;
    private Integer mFloodSetSizePending = null;
    private Integer mAdjustSizeByPending = null;
    private Integer mFloodAdjustSizeByPending = null;

    public boolean isExplicitlySized()
    {
        return mExplicitlySized;
    }

    public void setExplicitlySized( boolean pExplicitlySized )
    {
        mExplicitlySized = pExplicitlySized;
    }

    protected void setSizingChange( int pCurrentSizeToIgnore, Integer pPendingNewSize )
    {
        super.setSizingChange( pCurrentSizeToIgnore, pPendingNewSize );
        mSizedToPending = (null != (mSizedTo = pPendingNewSize));
    }

    protected void LLjustParticipatingInRendering()
    {
        super.LLjustParticipatingInRendering();
        if ( mMutateSize.isProcessingNeeded() )
        {
            queue( mMutateSize );
        }
    }

    /**
     * Restore the RenderableRect to its pre-Layed-out state.
     */
    protected void LLrestoreForLayout()
    {
        if ( mSizedTo != null )
        {
            setSizingChange( mSizedTo, null );
        }
        setExplicitlySized( false );
        getDimensionAdapter().removeSetSize( getRectangularRenderableObject() ); // Remove any previous Set Sizes
        super.LLrestoreForLayout();
    }

    /**
     * Get the "Natural" Size - the size something was when it first was Rendered.
     *
     * @return null means that is not "yet" available.
     */
    public final Integer getNaturalSize()
    {
        return mNaturalSize;
    }

    protected final void setNaturalSize()
    {
        mNaturalSize = getRectSizeNow();
    }

    /**
     * Get the "Natural" 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 final RenderHelperProcess unavailableNaturalSizeRHP()
    {
        return queue( mDetermineNaturalSize );
    }

    /**
     * Get the "Current" Size.
     * <p/>
     * Renderable Objects that are not Sizable will return their "Natural" Size.
     *
     * @return null means that is not "yet" available.
     */
    public final Integer getCurrentSize()
    {
        return (getNaturalSize() != null) && isLayedOut() ? getRectSizeNow() : null;
    }

    /**
     * Get the "Current" 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 final RenderHelperProcess unavailableCurrentSizeRHP()
    {
        return queue( mDetermineCurrentSize );
    }

    /**
     * Request that all future sizing take the pNewMinimumSize as the Minimum Size.
     *
     * @param pNewMinimumSize - Must be > 0
     *
     * @throws IllegalArgumentException      if pRequestedSize <= 0
     * @throws UnsupportedOperationException if the SizingApproach is "None"
     */
    public final SizableRenderHelper setMinimumSize( int pNewMinimumSize )
            throws IllegalArgumentException, UnsupportedOperationException
    {
        assertSizableAndAtLeastOne( "Set Minimum Size to", pNewMinimumSize );
        mMinimumSize = pNewMinimumSize;
        return this;
    }

    protected final Integer LLgetMinimumSize()
    {
        return mMinimumSize;
    }

    protected final RenderHelperProcess requestSetSize( int pRequestedSize )
    {
        mMutateSize.setSize( pRequestedSize );
        return queue( mMutateSize );
    }

    protected final RenderHelperProcess requestFloodSetSize( int pRequestedSize )
    {
        mMutateSize.floodSetSize( pRequestedSize );
        return queue( mMutateSize );
    }

    protected final RenderHelperProcess requestAdjustSizeBy( int pRequestedSizeChange )
    {
        mMutateSize.adjustSizeBy( pRequestedSizeChange );
        return queue( mMutateSize );
    }

    protected final RenderHelperProcess requestFloodAdjustSizeBy( int pRequestedSizeChange )
    {
        mMutateSize.floodAdjustSizeBy( pRequestedSizeChange );
        return queue( mMutateSize );
    }

    protected final boolean LLsizeChangePending()
    {
        return mSizedToPending || (mSetSizePending != null) || (mFloodSetSizePending != null) || (mAdjustSizeByPending != null) || (mFloodAdjustSizeByPending != null);
    }

    protected final RenderProcessResult LLrequestSetSize( MutateSizeRHP pMutateSizeRHP, int pRequestedSize )
    {
        mSetSizePending = pRequestedSize;
        return LLprocessPendingSizeChange( pMutateSizeRHP );
    }

    protected final RenderProcessResult LLrequestFloodSetSize( MutateSizeRHP pMutateSizeRHP, int pRequestedSize )
    {
        mFloodSetSizePending = pRequestedSize;
        return LLprocessPendingSizeChange( pMutateSizeRHP );
    }

    protected final RenderProcessResult LLrequestAdjustSizeBy( MutateSizeRHP pMutateSizeRHP, int pRequestedSizeChange )
    {
        mAdjustSizeByPending = pRequestedSizeChange;
        return LLprocessPendingSizeChange( pMutateSizeRHP );
    }

    protected final RenderProcessResult LLrequestFloodAdjustSizeBy( MutateSizeRHP pMutateSizeRHP, int pRequestedSizeChange )
    {
        mFloodAdjustSizeByPending = pRequestedSizeChange;
        return LLprocessPendingSizeChange( pMutateSizeRHP );
    }

    protected final RenderProcessResult LLprocessPendingSizeChange( MutateSizeRHP pMutateSizeRHP )
    {
        Integer zCurrentSize = getCurrentSize();
        if ( zCurrentSize == null )
        {
            deferPending( pMutateSizeRHP, unavailableCurrentSizeRHP() );
            return RenderProcessResult.Requeued;
        }
        Integer zMinimumSize = getMinimumSize();
        if ( zMinimumSize == null )
        {
            deferPending( pMutateSizeRHP, unavailableMinimumSizeRHP() );
            return RenderProcessResult.Requeued;
        }
        if ( mSizedTo != null )
        {
            if ( !mSizedTo.equals( zCurrentSize ) )
            {
                return sizingError( pMutateSizeRHP, mSizedTo, zCurrentSize );
            }
            mSizedToPending = false;
        }
        sizingOK();
        RenderProcessResult rv = RenderProcessResult.Completed;
        if ( (mSetSizePending != null) && RenderProcessResult.Completed.equals( rv ) )
        {
            int zNewSize = mSetSizePending;
            mSetSizePending = null;
            rv = LLsetSize( pMutateSizeRHP, zCurrentSize, zMinimumSize, zNewSize, true );
        }
        if ( (mFloodSetSizePending != null) && RenderProcessResult.Completed.equals( rv ) )
        {
            int zNewSize = mFloodSetSizePending;
            mFloodSetSizePending = null;
            rv = LLsetSize( pMutateSizeRHP, zCurrentSize, zMinimumSize, zNewSize, false );
        }
        if ( (mAdjustSizeByPending != null) && RenderProcessResult.Completed.equals( rv ) )
        {
            int zNewSize = zCurrentSize + mAdjustSizeByPending;
            mAdjustSizeByPending = null;
            rv = LLsetSize( pMutateSizeRHP, zCurrentSize, zMinimumSize, zNewSize, true );
        }
        if ( (mFloodAdjustSizeByPending != null) && RenderProcessResult.Completed.equals( rv ) )
        {
            int zNewSize = zCurrentSize + mFloodAdjustSizeByPending;
            mFloodAdjustSizeByPending = null;
            rv = LLsetSize( pMutateSizeRHP, zCurrentSize, zMinimumSize, zNewSize, false );
        }
        return rv;
    }

    abstract protected RenderProcessResult sizingError( MutateSizeRHP pMutateSizeRHP, //
                                                        int pExpectedSize, int pActualSize );

    abstract protected void sizingOK();

    protected final void logSizingError( AbstractLogger pLogger, int pExpectedSize, int pActualSize, String pPlus )
    {
        pLogger.log( "SizingError: ", this, " SizedTo ", pExpectedSize, ", but Current Size = ", pActualSize, pPlus );
    }

    private RenderProcessResult LLsetSize( MutateSizeRHP pMutateSizeRHP, int pCurrentSize, int pMinimumSize, int pNewSize, boolean pExplicitlySized )
    {
        // Note: we will not be here unless ((mSizedTo == null) || (mSizedTo == pCurrentSize))
        if ( pNewSize < pMinimumSize )
        {
            pNewSize = pMinimumSize;
        }
        if ( (mSizedTo != null) && (pNewSize == mSizedTo) )
        {
            setExplicitlySized( pExplicitlySized ); // Possibly change state
            return RenderProcessResult.Completed;
        }
        if ( pNewSize == pCurrentSize ) // Nothing to do OR we did IT!
        {
            return RenderProcessResult.Completed;
        }
        setExplicitlySized( pExplicitlySized );
        return LLLsetSize( pMutateSizeRHP, pCurrentSize, pNewSize );
    }

    /**
     * Set the Size - pCurrentSize != pNewSize
     */
    abstract protected RenderProcessResult LLLsetSize( MutateSizeRHP pMutateSizeRHP, int pCurrentSize, int pNewSize );
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/render/AbstractSizableRenderHelper.java

Diff revisions: vs.
Revision Author Commited Message
947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

151 Diff Diff GeorgeS picture GeorgeS Thu 17 Mar, 2011 04:16:22 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000