Ejemplo n.º 1
0
 public void showDomain(CellDomainNode domainNode) {
   _topLabel.setText(">>> " + domainNode.getName() + " <<<");
   _domainNode = domainNode;
   _cellPanel.clear();
   _commandPanel.clear();
   updateDomain();
 }
Ejemplo n.º 2
0
 @Override
 public void frameArrived(MessageObjectFrame frame) {
   Object obj = frame.getObject();
   if (obj instanceof CellInfo[]) {
     _infos = (CellInfo[]) obj;
     _list.removeAll();
     int systemIndex = -1;
     TreeSet<String> sorted = new TreeSet<>();
     for (CellInfo cellInfo : _infos) {
       sorted.add(cellInfo.getCellName());
     }
     Iterator<String> it = sorted.iterator();
     for (int i = 0; it.hasNext(); i++) {
       String name = it.next();
       _list.add(name);
       if (name.equals("System")) {
         systemIndex = i;
       }
     }
     if (systemIndex > -1) {
       _cellPanel.showCell(_infos[systemIndex], _domainNode.getAddress());
       _commandPanel.showCell(_infos[systemIndex], _domainNode.getAddress() + ":System");
       _list.select("System");
     }
   }
 }
 private void addTitle(CellPanel c, String pTitle) {
   mLabel lblTitle;
   c.addLast(lblTitle = new mLabel(pTitle), HSTRETCH, FILL | CENTER);
   lblTitle.backGround = new Color(127, 127, 127);
   lblTitle.foreGround = Color.White;
   lblTitle.setTag(INSETS, new Insets(2, 0, 4, 0));
 }
Ejemplo n.º 4
0
 public void setCellsData(String[] data) {
   int rowkey = Integer.parseInt(data[0]);
   if (hsmRow.get(rowkey) != null) {
     JComponent comp = null;
     ArrayList<String> alData = new ArrayList<String>();
     int nextdata = 0, enddata = 0;
     for (int i = 0; i < columnTotal; i++) {
       System.out.println("column : " + i);
       comp = hsmRow.get(rowkey)[i];
       if (comp instanceof JLabel) {
         System.out.println("   instanceof JLabel");
         ((JLabel) comp).setText(data[nextdata]);
         nextdata += 1;
       } else if (comp instanceof CellPanel) {
         System.out.println("   instanceof CellPanel");
         enddata = ((CellPanel) comp).getComponentData().length + nextdata;
         System.out.println("..enddata " + enddata);
         System.out.println("..nextdata " + nextdata);
         for (int j = nextdata; j < enddata; j++) {
           System.out.println("data (" + j + ") " + data[j]);
           alData.add(data[j]);
         }
         ((CellPanel) comp).setComponentData(alData.toArray(new String[] {}));
         nextdata = enddata;
       } else System.out.println("   other type of instance");
       alData.clear();
     }
     comp = null;
     alData = null;
   }
 }
Ejemplo n.º 5
0
 public void setCellData(int row, int column, String[] data) {
   if (hsmRow.size() <= 0) {
     System.err.println("ERROR : no row");
     return;
   }
   JComponent comp = null;
   if (hsmRow.get(row) != null) {
     comp = hsmRow.get(row)[column];
     if (comp instanceof CellPanel) ((CellPanel) comp).setComponentData(data);
   }
 }
Ejemplo n.º 6
0
 @Override
 public void actionPerformed(ActionEvent event) {
   Object o = event.getSource();
   if (o == _updateButton) {
     updateDomain();
     _cellPanel.clear();
     _commandPanel.clear();
   } else if (o == _detailButton) {
     _cards.show(_cardPanel, "cell");
     _cellMode = "cell";
   } else if (o == _commandButton) {
     _cards.show(_cardPanel, "command");
     _cellMode = "command";
   }
 }
Ejemplo n.º 7
0
  @Override
  public void itemStateChanged(ItemEvent event) {
    ItemSelectable sel = event.getItemSelectable();
    Object[] obj = sel.getSelectedObjects();
    if ((obj == null) || (obj.length == 0)) {
      return;
    }

    String cellName = obj[0].toString();
    int i = 0;
    for (; (i < _infos.length) && (!_infos[i].getCellName().equals(cellName)); i++) {}
    if (i == _infos.length) {
      System.out.println("No more in list : " + cellName);
      return;
    }
    _cellPanel.showCell(_infos[i], _domainNode.getAddress());
    _commandPanel.showCell(_infos[i], _domainNode.getAddress() + ":" + cellName);
    _cards.show(_cardPanel, _cellMode);
  }
Ejemplo n.º 8
0
 public void refreshAllCells(CellPanel cellPanel) {
   int cellRow = cellPanel.get().getPosition().getRow();
   int cellCol = cellPanel.get().getPosition().getCol();
   if (cellPanel.isHidden()) {
     decreaseUnClickedCells();
     cellPanel.display();
     if (cellPanel.get() instanceof EmptyCell) {
       for (int i = Math.max(0, cellRow - 1); i < Math.min(cellRow + 2, rows); i++)
         for (int j = Math.max(0, cellCol - 1); j < Math.min(cellCol + 2, cols); j++) {
           CellPanel cp = (CellPanel) this.getComponent(i * this.cols + j);
           if (!(cp.get() instanceof MineCell)) refreshAllCells(cp);
         }
     }
   }
 }
Ejemplo n.º 9
0
  public void run() {
    System.out.println("starting label thread");
    final int MAXIMUM_SIMULTANEUS_QUERIES = reloadMode ? 1 : 5;

    String[] firstEntities = {
      cellPanels.get(0).link.uris.first, cellPanels.get(0).link.uris.second
    };
    List<String[]> usedNameSourcesList = new LinkedList<String[]>();

    for (String[] nameSource : nameSources) {
      for (int i = 0; i < 2; i++) {
        if (firstEntities[i].startsWith(nameSource[0])) {
          if (usedNameSourcesList.contains(nameSource)) {
            // both data sources use the same name source
            break;
          }
          usedNameSourcesList.add(nameSource);
          if (usedNameSourcesList.size() == 2) {
            break;
          }
        }
      }
    }
    if (usedNameSourcesList.isEmpty()) {
      System.out.println("No name source found. Finishing label thread.");
      return;
    }
    String[][] usedNameSources = usedNameSourcesList.toArray(new String[0][]);

    for (String[] nameSource : usedNameSources) {
      // both data sources must supply geocoordinates for distance calculation
      doCalculateDistance = doCalculateDistance && new Boolean(nameSource[3]);
    }

    // synchronized(cellPanels)
    // {
    //	System.out.println(cellPanels.size());
    for (int block = 0;
        block < (int) Math.ceil(cellPanels.size() * 1.0 / MAXIMUM_SIMULTANEUS_QUERIES);
        block++) {
      int offset = block * MAXIMUM_SIMULTANEUS_QUERIES;
      int blockSize = Math.min(MAXIMUM_SIMULTANEUS_QUERIES, cellPanels.size() - offset);

      if (reloadMode) {
        // only reload faulty ones
        if (!(cellPanels.get(block).label1.getText().startsWith("error")
            || cellPanels.get(block).label2.getText().startsWith("error")
            || cellPanels.get(block).label1.getText().startsWith("java.lang.")
            || cellPanels.get(block).label2.getText().startsWith("java.lang.")
            || (this.doCalculateDistance && cellPanels.get(block).getDistance() == null))) {
          continue;
        }
      }

      String[] entities1 = new String[blockSize];
      String[] entities2 = new String[blockSize];
      String[] names1 = new String[blockSize];
      String[] names2 = new String[blockSize];

      for (int i = 0; i < blockSize; i++) {
        if (!running) {
          System.out.println("Querying aborted.");
          return;
        }
        entities1[i] = cellPanels.get(i + offset).link.uris.first;
        entities2[i] = cellPanels.get(i + offset).link.uris.second;
      }
      final int MAX_RETRIES = 10;
      int retries = 0;
      boolean ok = false;
      while (!ok && retries <= MAX_RETRIES) {
        try {
          names1 =
              CellPanel.getNames(
                  entities1,
                  usedNameSources,
                  nameToURI ? CellPanel.LINKEDCT_MODE : CellPanel.NORMAL_MODE);
          ok = true;
        } catch (Exception e) {
          e.printStackTrace();
          retries++;
          // if(DEBUG) e.printStackTrace();
          Arrays.fill(names1, e.getClass().toString().split(" ")[1]);
        }
      }

      retries = 0;
      ok = false;
      //				while(!ok&&retries<=MAX_RETRIES)
      //				{
      try {
        names2 =
            CellPanel.getNames(
                entities2,
                usedNameSources,
                nameToURI ? CellPanel.LINKEDCT_MODE : CellPanel.NORMAL_MODE);
        ok = true;
      } catch (Exception e) {
        e.printStackTrace();
        retries++;
        // if(DEBUG) e.printStackTrace();
        Arrays.fill(names2, e.getClass().toString().split(" ")[1]);
      }
      //				}
      retries = 0;
      ok = false;

      LatLng[] latLongs1 = new LatLng[blockSize];
      LatLng[] latLongs2 = new LatLng[blockSize];

      if (doCalculateDistance) {
        while (!ok && retries <= MAX_RETRIES) {
          try {
            latLongs1 = CellPanel.getLatitudesLongitudes(entities1, usedNameSources);
            ok = true;

          } catch (Exception e) {
            retries++;
            // if(DEBUG) e.printStackTrace();
            //					Arrays.fill(latLongs1, null);
            //					Arrays.fill(latLongs2, null);
          }
        }
        retries = 0;
        ok = false;
        while (!ok && retries <= MAX_RETRIES) {
          try {
            latLongs2 = CellPanel.getLatitudesLongitudes(entities2, usedNameSources);
            ok = true;

          } catch (Exception e) {
            retries++;
            // if(DEBUG) e.printStackTrace();
            //					Arrays.fill(latLongs1, null);
            //					Arrays.fill(latLongs2, null);
          }
        }
      }

      for (int i = 0; i < blockSize; i++) {
        cellPanels.get(i + offset).label1.setText(names1[i]);
        cellPanels.get(i + offset).label2.setText(names2[i]);
        //					LatLng point1 = new LatLng(latitudesLongitudes1[0][i], latitudesLongitudes1[1][i]);
        //					LatLng point2 = new LatLng(33.321321, -127.321321);
        //					double distanceInMiles = LatLngTool.distance(point1, point2, LengthUnit.MILE);
        if (doCalculateDistance) {
          try {
            cellPanels.get(i + offset).position1 = latLongs1[i];
            cellPanels.get(i + offset).position2 = latLongs2[i];
            cellPanels
                .get(i + offset)
                .setDistance(
                    LatLngTool.distance(latLongs1[i], latLongs2[i], LengthUnit.METER), "m");
          } catch (Exception e) {
            // cellPanels.get(i+offset).distanceLabel.setText("");//distance calculation not
            // possible");
          }
        } else {
          // cellPanels.get(i+offset).distanceLabel.setText("");//distance calculation not
          // possible");
        }
      }
    }
    frame.mainPanel.updateUI();
    //	}
    //			for (CellPanel cellPanel : cellPanels)
    //			{
    //				try
    //				{
    //					// ensure that the program itself is not slowed down
    //					Thread.sleep(QUERY_DELAY);
    //				} catch (InterruptedException e)
    //				{
    //					return; // label thread is only interrupted to be shut down
    //				}
    //				queryAllNames(false);
    //				if(!running) return;
    //			}
    System.out.println("finishing label thread");
  }
Ejemplo n.º 10
0
 public void clear() {
   _list.removeAll();
   _cellPanel.clear();
   _commandPanel.clear();
 }
  public FilterScreen() {
    this.title = MyLocale.getMsg(700, "Set Filter");

    //////////////////////////
    // Panel 1 - Bearing & Distance
    //////////////////////////
    addTitle(pnlBearDist, MyLocale.getMsg(714, "Bearings & Distance"));
    pnlBearDist.addNext(
        new mLabel(MyLocale.getMsg(701, "Distance: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addNext(
        chcDist = new mChoice(new String[] {"<=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlBearDist.addLast(inpDist = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlBearDist.addLast(new mLabel(""));
    pnlRose.addNext(chkNW = new mCheckBox("NW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkNNW = new mCheckBox("NNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkN = new mCheckBox("N"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkNNE = new mCheckBox("NNE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkNE = new mCheckBox("NE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkENE = new mCheckBox("ENE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkE = new mCheckBox("E "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkESE = new mCheckBox("ESE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSE = new mCheckBox("SE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkSSE = new mCheckBox("SSE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkS = new mCheckBox("S"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkSSW = new mCheckBox("SSW"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSW = new mCheckBox("SW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkWSW = new mCheckBox("WSW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkW = new mCheckBox("W "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkWNW = new mCheckBox("WNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(
        btnDeselect = new mButton(MyLocale.getMsg(716, "Deselect all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    btnDeselect.setTag(SPAN, new Dimension(2, 1));
    pnlRose.addLast(
        btnSelect = new mButton(MyLocale.getMsg(717, "Select all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addLast(pnlRose, CellConstants.STRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 2 - Cache attributes
    //////////////////////////
    addTitle(pnlAttributes, MyLocale.getMsg(720, "Status"));
    mLabel lblTitleAtt;
    pnlAttributes.addLast(
        lblTitleAtt = new mLabel(MyLocale.getMsg(715, "Show all caches with status:")),
        HSTRETCH,
        FILL);
    lblTitleAtt.setTag(SPAN, new Dimension(2, 1));
    pnlAttributes.addNext(
        chkArchived = new mCheckBox(MyLocale.getMsg(710, "Archived")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotArchived = new mCheckBox(MyLocale.getMsg(729, "Nicht archiviert")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkAvailable = new mCheckBox(MyLocale.getMsg(730, "Suchbar")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotAvailable = new mCheckBox(MyLocale.getMsg(711, "Not available")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkFound = new mCheckBox(MyLocale.getMsg(703, "Found")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotFound = new mCheckBox(MyLocale.getMsg(731, "Noch nicht gefunden")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkOwned = new mCheckBox(MyLocale.getMsg(707, "Owned")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotOwned = new mCheckBox(MyLocale.getMsg(732, "Anderer Besitzer")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        new mLabel(MyLocale.getMsg(307, "Status:")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlAttributes.addLast(
        chcStatus =
            new mComboBox(
                new String[] {
                  "",
                  MyLocale.getMsg(313, "Flag 1"),
                  MyLocale.getMsg(314, "Flag 2"),
                  MyLocale.getMsg(315, "Flag 3"),
                  MyLocale.getMsg(316, "Flag 4"),
                  MyLocale.getMsg(317, "Search"),
                  MyLocale.getMsg(318, "Found"),
                  MyLocale.getMsg(319, "Not Found"),
                  MyLocale.getMsg(320, "Owner")
                },
                0),
        CellConstants.HSTRETCH,
        (CellConstants.HFILL | CellConstants.WEST));
    pnlAttributes.addLast(chkUseRegexp = new mCheckBox(MyLocale.getMsg(299, "Regular expression")));

    //////////////////////////
    // Panel 3 - Cache ratings
    //////////////////////////
    addTitle(pnlRatings, MyLocale.getMsg(718, "Cache ratings"));
    pnlRatings.addNext(
        new mLabel(MyLocale.getMsg(702, "Difficulty: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlRatings.addNext(
        chcDiff = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(difIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0", "3.5",
    // "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpDiff = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlRatings.addNext(new mLabel("Terrain: "), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlRatings.addNext(
        chcTerr = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(terrIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0",
    // "3.5", "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpTerr = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 4 - Cache types
    //////////////////////////

    addTitle(pnlCacheTypes, MyLocale.getMsg(719, "Cache types"));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRADITIONAL)));
    pnlCacheTypes.addNext(
        chkTrad = new mCheckBox("Traditonal"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MULTI)));
    pnlCacheTypes.addLast(
        chkMulti = new mCheckBox("Multi"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_VIRTUAL)));
    pnlCacheTypes.addNext(
        chkVirtual = new mCheckBox("Virtual"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LETTERBOX)));
    pnlCacheTypes.addLast(
        chkLetter = new mCheckBox("Letterbox"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EVENT)));
    pnlCacheTypes.addNext(
        chkEvent = new mCheckBox("Event"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WEBCAM)));
    pnlCacheTypes.addLast(
        chkWebcam = new mCheckBox("Webcam"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_UNKNOWN)));
    pnlCacheTypes.addNext(
        chkMystery = new mCheckBox("Mystery"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EARTH)));
    pnlCacheTypes.addLast(
        chkEarth = new mCheckBox("Earth"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LOCATIONLESS)));
    pnlCacheTypes.addNext(
        chkLocless = new mCheckBox("Locationless"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MEGA_EVENT)));
    pnlCacheTypes.addLast(
        chkMega = new mCheckBox("Mega-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CITO)));
    pnlCacheTypes.addNext(
        chkCito = new mCheckBox("Cito-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // pnlCacheTypes.addLast(addiWptChk = new mCheckBox("Add. Wpt"), CellConstants.DONTSTRETCH,
    // CellConstants.FILL);
    // pnlCacheTypes.addLast(new mLabel(""));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CUSTOM)));
    pnlCacheTypes.addLast(
        chkCustom = new mCheckBox("Custom"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WHEREIGO)));
    pnlCacheTypes.addNext(
        chkWherigo = new myChkBox("WherIGo"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_DRIVE_IN)));
    pnlCacheTypes.addNext(
        addiWptChk = new myChkBox("Add. Wpt"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // addiWptChk.modify(0,NotAnEditor);
    //////////////////////////
    // Panel 5 - Addi waypoints
    //////////////////////////
    addTitle(pnlAddi, MyLocale.getMsg(726, "Additional waypoints"));
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_PARKING)));
    pnlAddi.addNext(
        chkParking = new mCheckBox("Parking"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_STAGE)));
    pnlAddi.addLast(
        chkStage = new mCheckBox("Stage"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_QUESTION)));
    pnlAddi.addNext(
        chkQuestion = new mCheckBox("Question"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_FINAL)));
    pnlAddi.addLast(
        chkFinal = new mCheckBox("Final"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRAILHEAD)));
    pnlAddi.addNext(
        chkTrailhead = new mCheckBox("Trailhead"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_REFERENCE)));
    pnlAddi.addLast(
        chkReference = new mCheckBox("Reference"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addLast(new mLabel(""), VSTRETCH, FILL);

    //////////////////////////
    // Panel 6 - Cache container
    //////////////////////////
    addTitle(pnlContainer, MyLocale.getMsg(727, "Cache container"));
    pnlContainer.addLast(chkMicro = new mCheckBox("Micro"));
    pnlContainer.addLast(chkSmall = new mCheckBox("Small"));
    pnlContainer.addLast(chkRegular = new mCheckBox("Regular"));
    pnlContainer.addLast(chkLarge = new mCheckBox("Large"));
    pnlContainer.addLast(chkVeryLarge = new mCheckBox("Very Large"));
    pnlContainer.addLast(chkOther = new mCheckBox("Other"));

    //////////////////////////
    // Panel 7 - Search
    //////////////////////////
    addTitle(pnlSearch, "Search");
    pnlSearch.addLast(new mLabel("To be implemented"));

    //////////////////////////
    // Panel 8 - Cache attributes
    //////////////////////////

    if (MyLocale.getScreenHeight() > 240)
      addTitle(pnlCacheAttributes, MyLocale.getMsg(737, "Attributes"));
    pnlCacheAttributes.addNext(
        new mLabel(MyLocale.getMsg(739, "Filter on") + ":"),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlCacheAttributes.addLast(
        chcAttrib =
            new mChoice(
                new String[] {
                  MyLocale.getMsg(740, "all"),
                  MyLocale.getMsg(741, "one"),
                  MyLocale.getMsg(742, "none")
                },
                0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));

    attV = new AttributesSelector();
    pnlCacheAttributes.addLast(
        attV,
        CellConstants.STRETCH | CellConstants.LEFT /*|CellConstants.BORDER*/,
        CellConstants.STRETCH);
    attV.setSelectionMasks(0l, 0l);

    Frame frmScreen = new Frame();
    mLabel lblInfo;
    frmScreen
        .addLast(
            lblInfo =
                new mLabel(MyLocale.getMsg(725, "Note: Filters are additive, active filter=green")))
        .setTag(SPAN, new Dimension(2, 1));
    lblInfo.setTag(INSETS, new Insets(0, 0, 2, 0));
    frmScreen.borderStyle =
        UIConstants.BDR_RAISEDOUTER | UIConstants.BDR_SUNKENINNER | UIConstants.BF_BOTTOM;
    this.addLast(frmScreen, HSTRETCH, HFILL);

    CellPanel pnlButtons = new CellPanel();
    pnlButtons.addLast(new mLabel("Filter"));
    pnlButtons.addLast(btnBearing = new mButton(MyLocale.getMsg(721, "Bearing")));
    pnlButtons.addLast(btnAttributes = new mButton(MyLocale.getMsg(720, "Attributes")));
    pnlButtons.addLast(btnRatings = new mButton(MyLocale.getMsg(722, "Ratings")));
    pnlButtons.addLast(btnTypes = new mButton(MyLocale.getMsg(723, "Types")));
    pnlButtons.addLast(btnAddi = new mButton(MyLocale.getMsg(733, "Add. Wpt")));
    pnlButtons.addLast(btnContainer = new mButton(MyLocale.getMsg(724, "Container")));
    pnlButtons.addLast(btnCacheAttributes = new mButton(MyLocale.getMsg(738, "Attributes")));
    // Search ist für 0.9n noch deaktiviert
    // pnlButtons.addLast(btnSearch=new mButton("Search")); btnSearch.modify(Disabled,0);
    addNext(pnlButtons, HSTRETCH, FILL);

    cp.addItem(pnlBearDist, "Bear", null);
    cp.addItem(pnlAttributes, "Att", null);
    cp.addItem(pnlRatings, "DT", null);
    cp.addItem(pnlCacheTypes, "Type", null);
    cp.addItem(pnlAddi, "Addi", null);
    cp.addItem(pnlContainer, "Size", null);
    cp.addItem(pnlSearch, "Search", null);
    cp.addItem(pnlCacheAttributes, "Attr", null);
    addLast(cp, VSTRETCH, FILL);

    CellPanel savDelPanel = new CellPanel(); // Panel for "save" and "delete" button
    savDelPanel.equalWidths = true;
    mImage savImg = new mImage("clsave.png");
    savImg.transparentColor = new Color(255, 0, 0);
    savDelPanel.addNext(btnSaveFlt = new mButton(savImg), STRETCH, FILL);
    savDelPanel.addLast(btnDelFlt = new mButton(new mImage("trash.png")), STRETCH, FILL);
    Panel fltListPanel = new Panel();
    fltListPanel.addLast(fltList = new mChoice());
    fltListPanel.addLast(savDelPanel);
    CellPanel btPanel = new CellPanel();
    btPanel.equalWidths = true;
    btPanel.addNext(fltListPanel, CellConstants.STRETCH, CellConstants.FILL);
    btPanel.addNext(
        btnCancel = new mButton(MyLocale.getMsg(708, "Cancel")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    btPanel.addLast(
        btnApply = new mButton(MyLocale.getMsg(709, "Apply")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    //		btPanel.addLast(btnRoute = new mButton("Route"),CellConstants.STRETCH, CellConstants.FILL);
    addLast(
        btPanel.setTag(CellConstants.SPAN, new Dimension(3, 1)),
        CellConstants.STRETCH,
        CellConstants.FILL);

    int sw = MyLocale.getScreenWidth();
    int sh = MyLocale.getScreenHeight();
    Preferences pref = Global.getPref();
    int fs = pref.fontSize;
    int psx;
    int psy;
    if ((sw > 300) && (sh > 300)) {
      // larger screens: size according to fontsize
      psx = 240;
      psy = 260;
      if (fs > 12) {
        psx = 300;
        psy = 330;
      }
      if (fs > 17) {
        psx = 400;
        psy = 340;
      }
      if (fs > 23) {
        psx = 500;
        psy = 350;
      }
      setPreferredSize(psx, psy);
    } else {
      // small screens: fixed size
      if (sh > 240) setPreferredSize(240, 260);
      else setPreferredSize(240, 240);
    }
    cp.select(3);

    // Populating the comboBox of saved filters
    buildFilterList();
  }
Ejemplo n.º 12
0
  private void setPanel(List<ObjectInfo> tar) {
    this.targetObject = tar;
    columnWidth = new HashMap<Integer, Integer>();
    rowLength = new HashMap<Integer, Integer>();
    cellpanel.clear();

    for (int i = 0; i < tar.size(); i++) {
      ObjectInfo oin = tar.get(i);
      if ((oin.isLinked() == true || oin.hasLink() == true) && oin.set == true) {

        if (!mode) {
          cellpanel.put(oin, new CellPanel(oin));
        } else {

        }

        Integer length = rowLength.get(oin.getPy());
        Integer width = columnWidth.get(oin.getPx());
        if (length == null || cellpanel.get(oin).getPreferredSize().height > length) {
          rowLength.put(
              new Integer(oin.getPy()), new Integer(cellpanel.get(oin).getPreferredSize().height));
        }
        if (width == null || cellpanel.get(oin).getPreferredSize().width > width) {
          columnWidth.put(
              new Integer(oin.getPx()), new Integer(cellpanel.get(oin).getPreferredSize().width));
        }
      }
    }

    for (Iterator<Entry<ObjectInfo, CellPanel>> it = cellpanel.entrySet().iterator();
        it.hasNext(); ) {
      Entry<ObjectInfo, CellPanel> entry = it.next();
      ObjectInfo object = entry.getKey();
      CellPanel panel = entry.getValue();
      try {
        if (panel != null) {
          /*int px = 0;
          int py = 0;
          for(int i = 0; i < object.getPx(); i++){
          	px += rowLength.get(i);
          }
          for(int i = 0; i < object.getPy(); i++){
          	py += columnWidth.get(i);
          }
          if(panel.getCellLength() > cellLength /2){
          	panel.setBounds(object.getPx() * (columnWidth.get(object.getPx())+ 40) + 25  , object.getPy() * (rowLength.get(object.getPy())+ 40) + 20, panel.getMaximumSize().width,panel.getMaximumSize().height );
          }else{
          	panel.setBounds(object.getPx() * (columnWidth.get(object.getPx())+ 40) + 25  , object.getPy() * (rowLength.get(object.getPy())+ 40) +(rowLength.get(object.getPy()) /2) - panel.getCellLength()/2, panel.getMaximumSize().width,panel.getMaximumSize().height );
          }
          add(panel, JLayeredPane.DEFAULT_LAYER);*/
          if (panel != null) {
            int px = 0;
            int py = 0;
            for (int i = 0; i < object.getPy(); i++) {
              if (rowLength.get(i) != null) {
                py += rowLength.get(i);
              }
              py += 60;
            }
            for (int i = 0; i < object.getPx(); i++) {
              if (columnWidth.get(i) != null) {
                px += columnWidth.get(i);
              }
              px += 60;
            }
            panel.setBounds(
                px + 25, py + 40, panel.getMaximumSize().width, panel.getMaximumSize().height);

            add(panel, JLayeredPane.DEFAULT_LAYER);
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }