001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005 006package armyc2.c5isr.JavaLineArray; 007import java.util.ArrayList; 008 009import armyc2.c5isr.JavaTacticalRenderer.TGLight; 010import armyc2.c5isr.renderer.utilities.ErrorLogger; 011import armyc2.c5isr.renderer.utilities.RendererException; 012import armyc2.c5isr.renderer.utilities.RendererSettings; 013 014/** 015 * A class for the interface between the points calculation CELineArray and 016 * the tactical renderer. 017 * 018 */ 019public final class CELineArray { 020 private static final String _className="CELineArray"; 021 /** 022 * public function to return the line count required for all of the symbols 023 * 024 * @param plArrayOfLongs the client points as an array of POINT2 in pixels. 025 * @param lElements the number of client points. 026 * @param ChannelWidth the chanel width in pixels 027 * 028 * @return the number of points which will be required for the symbol. 029 */ 030 public static int CGetLineCountDouble(TGLight tg, 031 double[] plArrayOfLongs, 032 int lElements, //number of points 033 int ChannelWidth) { 034 int lResult = 0; 035 try { 036 //declarations 037 int lPtrcntr = 0; 038 int lLowerFlotCount = 0, lUpperFlotCount = 0; 039 POINT2[] pLinePoints = new POINT2[lElements]; 040 POINT2[] pLowerLinePoints = new POINT2[lElements], 041 pUpperLinePoints = new POINT2[lElements], 042 pUpperLowerLinePoints = new POINT2[2 * lElements + 2]; 043 short i = 0; 044 //end declarations 045 046 if (lElements <= 0) { 047 return -1; 048 } 049 050 lineutility.InitializePOINT2Array(pLinePoints); 051 lineutility.InitializePOINT2Array(pUpperLinePoints); 052 lineutility.InitializePOINT2Array(pLowerLinePoints); 053 for (i = 0; i < lElements; i++) { 054 pLinePoints[i].x = plArrayOfLongs[lPtrcntr]; 055 lPtrcntr++; 056 pLinePoints[i].y = plArrayOfLongs[lPtrcntr]; 057 lPtrcntr++; 058 } 059 for (i = 0; i < lElements; i++) { 060 pLowerLinePoints[i] = new POINT2(pLinePoints[i]); 061 pUpperLinePoints[i] = new POINT2(pLinePoints[i]); 062 } 063 064 switch (tg.get_LineType()) { 065 case TacticalLines.CHANNEL: 066 case TacticalLines.CHANNEL_FLARED: 067 case TacticalLines.CHANNEL_DASHED: 068 lResult = 2 * lElements; 069 break; 070 case TacticalLines.MAIN: 071 case TacticalLines.MAIN_STRAIGHT: 072 case TacticalLines.AIRAOA: 073 case TacticalLines.SPT: 074 case TacticalLines.SPT_STRAIGHT: 075 //points for these need not be bounded 076 //they have an extra 8 points for the arrowhead 077 lResult = 2 * lElements + 8; 078 break; 079 case TacticalLines.FRONTAL_ATTACK: 080 lResult = 2 * lElements + 15; 081 break; 082 case TacticalLines.TURNING_MOVEMENT: 083 lResult = 2 * lElements + 14; 084 break; 085 case TacticalLines.MOVEMENT_TO_CONTACT: 086 lResult = 2 * lElements + 24; 087 break; 088 case TacticalLines.CATK: 089 lResult = 2 * lElements + 8; 090 break; 091 case TacticalLines.CATKBYFIRE: 092 lResult = 2 * lElements + 17; 093 break; 094 case TacticalLines.AAAAA: 095 lResult = 2 * lElements + 19; 096 break; 097 case TacticalLines.LC: 098 pUpperLinePoints = Channels.GetChannelArray2Double(1, pUpperLinePoints, 1, lElements, tg.get_LineType(), ChannelWidth); 099 pLowerLinePoints = Channels.GetChannelArray2Double(1, pLowerLinePoints, 0, lElements, tg.get_LineType(), ChannelWidth); 100 lUpperFlotCount = flot.GetFlotCountDouble(pUpperLinePoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), lElements); 101 lLowerFlotCount = flot.GetFlotCountDouble(pLowerLinePoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), lElements); 102 lResult = lUpperFlotCount + lLowerFlotCount; 103 break; 104 default: 105 //call GetCountersDouble for the remaining line types. 106 lResult = countsupport.GetCountersDouble(tg, lElements, pLinePoints, null); 107 break; 108 } 109 110 111 //clean up 112 //pvblCounters = null; 113 pLinePoints = null; 114 pLowerLinePoints = null; 115 pUpperLinePoints = null; 116 pUpperLowerLinePoints = null; 117 //GC.Collect(); 118 } catch (Exception exc) { 119 ErrorLogger.LogException(_className ,"CGetLineCountDouble", 120 new RendererException("Failed inside CGetLineCount " + Integer.toString(tg.get_LineType()), exc)); 121 } 122 return (lResult); 123 } 124 /** 125 * Return true is the line type is a channel type 126 * @param lineType line type 127 * @return 128 */ 129 public static int CIsChannel(int lineType) { 130 int lResult = 0; 131 try { 132 switch (lineType) { 133 case TacticalLines.CATK: 134 case TacticalLines.CATKBYFIRE: 135 case TacticalLines.LC: 136 case TacticalLines.AIRAOA: 137 case TacticalLines.AAAAA: 138 case TacticalLines.MAIN: 139 case TacticalLines.MAIN_STRAIGHT: 140 case TacticalLines.SPT: 141 case TacticalLines.SPT_STRAIGHT: 142 case TacticalLines.FRONTAL_ATTACK: 143 case TacticalLines.TURNING_MOVEMENT: 144 case TacticalLines.MOVEMENT_TO_CONTACT: 145 case TacticalLines.UNSP: 146 case TacticalLines.SFENCE: 147 case TacticalLines.DFENCE: 148 case TacticalLines.DOUBLEA: 149 case TacticalLines.LWFENCE: 150 case TacticalLines.HWFENCE: 151 case TacticalLines.BBS_LINE: 152 case TacticalLines.SINGLEC: 153 case TacticalLines.DOUBLEC: 154 case TacticalLines.TRIPLE: 155 case TacticalLines.CHANNEL: 156 case TacticalLines.CHANNEL_FLARED: 157 case TacticalLines.CHANNEL_DASHED: 158 lResult = 1; 159 break; 160 default: 161 lResult = 0; 162 break; 163 } 164 } 165 catch (Exception exc) 166 { 167 ErrorLogger.LogException(_className ,"CIsChannel", 168 new RendererException("Failed inside CIsChannel " + Integer.toString(lineType), exc)); 169 } 170 return lResult; 171 } 172 private static String _client=""; 173 public static void setClient(String value) 174 { 175 _client=value; 176 Channels.setClient(value); 177 } 178 public static String getClient() 179 { 180 return _client; 181 } 182// public static void setMinLength(double value) 183// { 184// DISMSupport.setMinLength(value); 185// arraysupport.setMinLength(value); 186// countsupport.setMinLength(value); 187// return; 188// } 189}