示例#1
0
 public synchronized void ReviseItemsInReflectionWindow(
     TReflectionWindowStruc RW, byte[] ExistingItemsBA, TCanceller Canceller)
     throws IOException, CancelException {
   TSpaceHint LastItem = null;
   TSpaceHint Item = Items;
   while (Item != null) {
     boolean flRemove = false;
     if (RW.Container_IsNodeVisible(Item.BindingPointX, Item.BindingPointY)) {
       flRemove = true;
       int Idx = 0;
       int _ItemsCount = TDataConverter.ConvertLEByteArrayToInt32(ExistingItemsBA, Idx);
       Idx += 4;
       for (int I = 0; I < _ItemsCount; I++) {
         int ItemID = TDataConverter.ConvertLEByteArrayToInt32(ExistingItemsBA, Idx);
         Idx += 8; // . Int64
         if (ItemID == Item.ID) {
           flRemove = false;
           break; // . >
         }
         Idx = Item.ByteArraySkip(ExistingItemsBA, Idx);
       }
     }
     if (flRemove) {
       if (LastItem != null) LastItem.Next = Item.Next;
       else Items = Item.Next;
       ItemsTable.remove(Item.ID);
       ItemsCount--;
     } else LastItem = Item;
     // .
     if (Canceller != null) Canceller.Check();
     // .
     Item = Item.Next;
   }
 }
示例#2
0
 public synchronized void FromByteArray(byte[] BA, TCanceller Canceller)
     throws IOException, CancelException {
   RemoveOldItems();
   // .
   int Idx = 0;
   int _ItemsCount = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
   Idx += 4;
   for (int I = 0; I < _ItemsCount; I++) {
     int ItemID = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
     Idx += 8; // . Int64
     TSpaceHint Item = ItemsTable.get(ItemID);
     if (Item == null) {
       Item = new TSpaceHint(ItemID, Reflector.metrics);
       // .
       Item.Next = Items;
       Items = Item;
       ItemsCount++;
       // .
       ItemsTable.put(ItemID, Item);
     }
     Idx = Item.FromByteArray(BA, Idx);
     // .
     if (Canceller != null) Canceller.Check();
   }
 }
示例#3
0
 public void UnSelectAll() {
   TSpaceHint Item = Items;
   while (Item != null) {
     Item.flSelected = false;
     // .
     Item = Item.Next;
   }
 }
示例#4
0
 public synchronized void SaveItems() throws IOException {
   FileOutputStream FOS = new FileOutputStream(HintsFileName);
   try {
     byte[] ItemsCountBA = TDataConverter.ConvertInt32ToLEByteArray(ItemsCount);
     FOS.write(ItemsCountBA);
     TSpaceHint Item = Items;
     while (Item != null) {
       byte[] BA = Item.ToByteArray();
       short ItemDataSize = (short) BA.length;
       byte[] ItemDataSizeBA = TDataConverter.ConvertInt16ToLEByteArray(ItemDataSize);
       FOS.write(ItemDataSizeBA);
       FOS.write(BA);
       // .
       Item = Item.Next;
     }
   } finally {
     FOS.close();
   }
 }
示例#5
0
 public TSpaceHint Select(TReflectionWindowStruc RW, double VisibleFactor, float pX, float pY) {
   double RW_SqrScale = Math.pow(RW.Scale(), 2);
   TSpaceHint Item = Items;
   while (Item != null) {
     if (RW.Container_IsNodeVisible(Item.BindingPointX, Item.BindingPointY)) {
       if ((Item.BaseSquare * RW_SqrScale) >= VisibleFactor) {
         TXYCoord P = RW.ConvertToScreen(Item.BindingPointX, Item.BindingPointY);
         if (((RW.Xmn <= P.X) && (P.X <= RW.Xmx)) && ((RW.Ymn <= P.Y) && (P.Y <= RW.Ymx))) {
           float W = 0;
           float H = 0;
           // .
           synchronized (ItemsImageDataFiles) {
             TSpaceHintImageDataFile ImageDataFile =
                 ItemsImageDataFiles.ItemsTable.get(Item.InfoImageDATAFileID);
             if ((ImageDataFile != null) && (ImageDataFile.Data != null)) {
               RectF ImageRect = ImageDataFile.Data_GetDestinationRect(ItemImageMinSize);
               W = ImageRect.width() + 1.0F;
               H = ImageRect.height();
             }
           }
           // .
           Rect TR = new Rect();
           Item.paint.getTextBounds(Item.InfoString, 0, Item.InfoString.length(), TR);
           W += (TR.right - TR.left);
           if (Item.InfoStringFontSize > H) H = (TR.bottom - TR.top);
           // .
           if ((((P.X - ItemSpacing) <= pX) && (pX <= (P.X + W + ItemSpacing)))
               && ((((P.Y - H - ItemSpacing) <= pY) && (pY <= (P.Y + ItemSpacing))))) {
             Item.flSelected = true;
             return Item.Clone(); // . ->
           }
         }
       }
     }
     Item.flSelected = false;
     // .
     Item = Item.Next;
   }
   return null;
 }
示例#6
0
 public synchronized void LoadItems() throws IOException {
   Items = null;
   ItemsCount = 0;
   TSpaceHint LastItem = null;
   // .
   File F = new File(HintsFileName);
   if (F.exists()) {
     FileInputStream FIS = new FileInputStream(HintsFileName);
     try {
       byte[] ItemsCountBA = new byte[4];
       FIS.read(ItemsCountBA);
       int _ItemsCount = TDataConverter.ConvertLEByteArrayToInt32(ItemsCountBA, 0);
       // .
       byte[] ItemData = new byte[1024]; // . max item data size
       for (int I = 0; I < _ItemsCount; I++) {
         byte[] ItemDataSizeBA = new byte[2];
         FIS.read(ItemDataSizeBA);
         short ItemDataSize = TDataConverter.ConvertLEByteArrayToInt16(ItemDataSizeBA, 0);
         FIS.read(ItemData, 0, ItemDataSize);
         // .
         int Idx = 0;
         int ItemID = TDataConverter.ConvertLEByteArrayToInt32(ItemData, Idx);
         Idx += 8; // . Int64
         TSpaceHint NewItem = new TSpaceHint(ItemID, Reflector.metrics);
         NewItem.FromByteArray(ItemData, Idx);
         if (ItemsTable.get(ItemID) == null) {
           // . insert into queue
           if (LastItem != null) LastItem.Next = NewItem;
           else Items = NewItem;
           ItemsTable.put(ItemID, NewItem);
           ItemsCount++;
           // .
           LastItem = NewItem;
         }
       }
     } finally {
       FIS.close();
     }
   }
 }
示例#7
0
 private synchronized void ItemsImageDataFiles_FromByteArray(byte[] BA, TCanceller Canceller)
     throws IOException, CancelException {
   RemoveOldItems();
   // .
   int Idx = 0;
   int _ItemsCount = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
   Idx += 4;
   for (int I = 0; I < _ItemsCount; I++) {
     int HintID = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
     Idx += 8; // . Int64
     int ImageDataFileID = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
     Idx += 8; // . Int64
     TSpaceHintImageDataFile ItemsImageDataFiles_Item =
         ItemsImageDataFiles.GetItem(ImageDataFileID);
     Idx = ItemsImageDataFiles_Item.FromByteArray(BA, Idx);
     // .
     TSpaceHint Hint = ItemsTable.get(HintID);
     if (Hint != null) Hint.InfoImageDATAFileID = ImageDataFileID;
     // .
     if (Canceller != null) Canceller.Check();
   }
 }
示例#8
0
 private synchronized void RemoveOldItems() {
   if (ItemsCount < (1.1 * MaxItemsCount)) return; // . ->
   TSpaceHint RemoveItem = null;
   ItemsCount = 0;
   TSpaceHint Item = Items;
   while (Item != null) {
     ItemsCount++;
     if (ItemsCount >= MaxItemsCount) {
       RemoveItem = Item.Next;
       Item.Next = null;
       // .
       break; // . >
     }
     // .
     Item = Item.Next;
   }
   while (RemoveItem != null) {
     ItemsTable.remove(RemoveItem.ID);
     // .
     RemoveItem = RemoveItem.Next;
   }
 }
示例#9
0
 public TSpaceHint Clone() {
   TSpaceHint Result = new TSpaceHint(ID, metrics);
   // .
   Result.InfoComponent_Type = InfoComponent_Type;
   Result.InfoComponent_ID = InfoComponent_ID;
   Result.BindingPointX = BindingPointX;
   Result.BindingPointY = BindingPointY;
   Result.BaseSquare = BaseSquare;
   Result.InfoImageDATAFileID = InfoImageDATAFileID;
   Result.InfoString = InfoString;
   Result.InfoStringFontColor = InfoStringFontColor;
   Result.InfoStringFontSize = InfoStringFontSize;
   Result.InfoStringFontName = InfoStringFontName;
   Result.flSelected = flSelected;
   // .
   return Result;
 }