litesoft
@ HEAD
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 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.GWT.client.widgets.nonpublic; import org.litesoft.GWT.client.widgets.*; import org.litesoft.commonfoundation.base.*; import org.litesoft.commonfoundation.typeutils.gregorian.*; import org.litesoft.core.simpletypes.temporal.*; import org.litesoft.ui.support.nonpublic.*; import com.google.gwt.user.client.ui.*; import java.util.*; public class CreditsPanel extends SizeableSimplePanel { public CreditsPanel( CreditsData[] pCreditsData ) { super( false ); setWidget( new HTML( createHTML( pCreditsData ) ) ); addStyleName( "litesoft-CreditsFixedFont" ); } private String createHTML( CreditsData[] pCreditsData ) { if ( Currently.isNullOrEmpty( pCreditsData ) ) { return ""; } int longestWhoLength = 2; CalendarYMD earliestStartDate = pCreditsData[0].getStartDate(); CalendarYMD latestEndDate = pCreditsData[0].getEndDate(); for ( int i = 0; i < pCreditsData.length; i++ ) { CreditsData creditsData = pCreditsData[i]; int whoLength = creditsData.getWho().length(); CalendarYMD startDate = creditsData.getStartDate(); CalendarYMD endDate = creditsData.getEndDate(); while ( whoLength > longestWhoLength ) { longestWhoLength += 2; } if ( !startDate.afterOrEqual( earliestStartDate ) ) { earliestStartDate = startDate; } if ( !endDate.beforeOrEqual( latestEndDate ) ) { latestEndDate = endDate; } } longestWhoLength += 3; Arrays.sort( pCreditsData ); HtmlBuilder builder = new HtmlBuilder( "litesoft-CreditsColorized" ); // Add Header for ( int i = longestWhoLength; i > 0; i-- ) { builder.addNBSP(); } CreditsData.MonthYear zMY = new CreditsData.MonthYear( earliestStartDate ); do { builder.addNBSP(); builder.add( zMY.toString() ); } while ( zMY.incMonth().isLessThanOrEqual( latestEndDate ) ); builder.newLine(); // Add Seperator for ( int i = longestWhoLength; i > 0; i-- ) { builder.add( '-' ); } zMY = new CreditsData.MonthYear( earliestStartDate ); do { builder.add( '-' ); builder.add( '+' ); builder.add( '-' ); builder.add( '-' ); builder.add( '-' ); builder.add( '-' ); } while ( zMY.incMonth().isLessThanOrEqual( latestEndDate ) ); builder.add( '-' ); builder.newLine(); for ( int i = 0; i < pCreditsData.length; i++ ) { CreditsData creditsData = pCreditsData[i]; builder.add( creditsData.getWho(), longestWhoLength ); builder.addNBSP(); zMY = new CreditsData.MonthYear( earliestStartDate ); do { int year = zMY.getYear(); int month = zMY.getMonth(); int daysInMonth = Month.daysIn( year, month ); int lastSplit = (daysInMonth + 18) / 2; builder.colorize( creditsData.wasActiveDuring( year, month, 1, 6 ) ); builder.add( '|' ); // 1 builder.colorize( creditsData.wasActiveDuring( year, month, 7, 12 ) ); builder.addNBSP(); // 2 builder.colorize( creditsData.wasActiveDuring( year, month, 13, 18 ) ); builder.add( '.' ); // 3 builder.colorize( creditsData.wasActiveDuring( year, month, 19, lastSplit ) ); builder.addNBSP(); // 4 builder.colorize( creditsData.wasActiveDuring( year, month, lastSplit + 1, daysInMonth ) ); builder.add( '.' ); // 5 zMY.incMonth(); builder.colorize( creditsData.wasActiveDuring( zMY.getYear(), zMY.getMonth(), 1, 1 ) ); builder.addNBSP(); // 6 } while ( zMY.isLessThanOrEqual( latestEndDate ) ); builder.newLine(); } //To change body of created methods use File | Settings | File Templates. return builder.toString(); } private static class HtmlBuilder { private StringBuilder mSB = new StringBuilder(); private boolean mColorize = false; private String mColorStyle; private int mOffset = 0; public HtmlBuilder( String pColorStyle ) { mColorStyle = pColorStyle; } public void colorize( boolean pColorize ) { mColorize = pColorize; } public void newLine() { mColorize = false; mSB.append( "<br>" ); mOffset = 0; } private void LLaddChar( String pChar ) { if ( mColorize ) { mSB.append( "<span class='" ).append( mColorStyle ).append( "'>" ); mSB.append( pChar ); mSB.append( "</span>" ); } else { mSB.append( pChar ); } mOffset++; } public void addNBSP() { LLaddChar( " " ); } public void addSP() { if ( mColorize || ((mOffset & 1) == 1) ) { addNBSP(); } else { LLaddChar( "." ); } } public void add( char pChar ) { if ( pChar == ' ' ) { addNBSP(); } else { LLaddChar( Character.toString( pChar ) ); } } public void add( String pString ) { if ( pString != null ) { for ( int i = 0; i < pString.length(); i++ ) { add( pString.charAt( i ) ); } } } public void add( String pString, int pToLength ) { if ( pString != null ) { for ( int i = 0; i < pString.length(); i++ ) { add( pString.charAt( i ) ); pToLength--; } addNBSP(); while ( --pToLength > 0 ) { addSP(); } } } public String toString() { return mSB.toString(); } } } |
Commits for litesoft/trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/widgets/nonpublic/CreditsPanel.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
863 Diff | GeorgeS | Fri 16 Nov, 2012 22:14:29 +0000 | |
860 Diff | GeorgeS | Mon 05 Nov, 2012 01:39:02 +0000 | |
851 Diff | GeorgeS | Mon 08 Oct, 2012 00:05:32 +0000 | Breaking the code as Temporal changes are implemented... |
809 Diff | GeorgeS | Thu 16 Aug, 2012 04:10:46 +0000 | |
60 Diff | GeorgeS | Tue 24 Aug, 2010 00:37:36 +0000 | |
49 | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |