예제 #1
1
  @Override
  public void init(EList<FragmentSubstitution> fragmentSubstitutions) {
    fsMap = new HashMap<FragmentSubstitution, FragmentSubstitutionHolder>();
    try {
      for (FragmentSubstitution fragment : fragmentSubstitutions)
        fsMap.put(fragment, new FragmentSubstitutionHolder(fragment));

      // NOTE: the call of computeCopyBaseModel should be exactly here,
      // since FragmentSubstitutionHolder actually loads all resources as
      // a side effect
      // which we lately use to define 'base model'
      // computeCopyBaseModel();

      if (detectIntersection) {
        placementCrossingFinder = new PlacementCrossingFinder(fsMap.values());
      } else {
        context.getLogger().warn("IntersectionDetection mode is not set!");
      }

      adjacentFinder =
          new AdjacentFinderImpl(new BasicEList<FragmentSubstitutionHolder>(fsMap.values()));
      adjacentResolver = new AdjacentResolverImpl(adjacentFinder);

      placementInReplacementFinder = new ReplacPlacCotainmentFinder(fsMap.values());
      placementInReplacementResolver =
          new ReplacPlacCotainmentResolver(placementInReplacementFinder);
    } catch (BasicBVREngineException e) {
      throw new UnsupportedOperationException(e);
    }
  }
예제 #2
1
 /**
  * Handle incoming message for this device by forwarding it to all features that this device
  * supports
  *
  * @param fromPort port from which the message come in
  * @param msg the incoming message
  */
 public void handleMessage(String fromPort, Msg msg) {
   synchronized (m_lastMsgReceived) {
     m_lastMsgReceived = System.currentTimeMillis();
   }
   synchronized (m_features) {
     // first update all features that are
     // not status features
     for (DeviceFeature f : m_features.values()) {
       if (!f.isStatusFeature()) {
         if (f.handleMessage(msg, fromPort)) {
           // handled a reply to a query,
           // mark it as processed
           logger.trace("handled reply of direct: {}", f);
           setFeatureQueried(null);
           break;
         }
       }
     }
     // then update all the status features,
     // e.g. when the device was last updated
     for (DeviceFeature f : m_features.values()) {
       if (f.isStatusFeature()) {
         f.handleMessage(msg, fromPort);
       }
     }
   }
 }
예제 #3
1
 /*
  * public HashMap getLeafElements() { HashMap map = new HashMap(); Object[]
  * elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++)
  * { PDMDataElement data = (PDMDataElement) elts[j];
  * map.put(data.getID(),data); } Object[] ops =
  * operations.values().toArray(); for (int i=0; i<ops.length; i++){
  * PDMOperation op = (PDMOperation) ops[i]; if
  * (!(op.getInputElements().isEmpty())){ HashMap outs =
  * op.getOutputElements(); Object[] outArray = outs.values().toArray(); for
  * (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement)
  * outArray[j]; map.remove(d.getID()); } } } return map; }
  */
 public HashMap getLeafElements() {
   HashMap result = new HashMap();
   HashSet leafOps = getLeafOperations();
   if (!(leafOps.isEmpty())) {
     Iterator it = leafOps.iterator();
     while (it.hasNext()) {
       PDMOperation op = (PDMOperation) it.next();
       PDMDataElement data = op.getOutputElement();
       result.put(data.getID(), data);
     }
   } else {
     Object[] elts = dataElements.values().toArray();
     for (int j = 0; j < elts.length; j++) {
       PDMDataElement data = (PDMDataElement) elts[j];
       result.put(data.getID(), data);
     }
     Object[] ops = operations.values().toArray();
     for (int i = 0; i < ops.length; i++) {
       PDMOperation op = (PDMOperation) ops[i];
       HashMap outs = op.getOutputElements();
       Object[] outArray = outs.values().toArray();
       for (int j = 0; j < outArray.length; j++) {
         PDMDataElement d = (PDMDataElement) outArray[j];
         result.remove(d.getID());
       }
     }
   }
   return result;
 }
  // recursive iterate hierarchical level of Sam to get all connectors from sub level.
  private void subCompositionConnectorsToCompositionModel(Component component) {
    HashMap<String, Connector> subConnectors = component.subCompositionModel.getConnectors();
    for (Connector subConnector : subConnectors.values()) {
      convertSamConnectorToTransition(subConnector);
    }

    HashMap<String, Component> subComponents = component.subCompositionModel.getComponents();
    for (Component subComponent : subComponents.values()) {
      if (subComponent.isSetSubComposition) {
        subCompositionConnectorsToCompositionModel(subComponent);
        //				HashMap<String, Component> subsubComponents =
        // subComponent.subCompositionModel.getComponents();
        //				for(Component subsubComponent : subsubComponents.values()){
        //					subCompositionConnectorsToCompositionModel(subsubComponent); //resursive call it self
        //				}
      }
      //			else{
      //				HashMap<String, Connector> subConnectors =
      // subComponent.subCompositionModel.getConnectors();
      //				for(Connector subConnector : subConnectors.values()){
      //					convertSamConnectorToTransition(subConnector);
      //				}
      //			}
    }
  }
예제 #5
1
  protected void killConnections(ibis.ipl.IbisIdentifier corpse) {
    SendPort[] sps;
    ReceivePort[] rps;

    synchronized (this) {
      sps = sendPorts.values().toArray(new SendPort[sendPorts.size()]);
      rps = receivePorts.values().toArray(new ReceivePort[receivePorts.size()]);
    }
    for (SendPort s : sps) {
      try {
        s.killConnectionsWith(corpse);
      } catch (Throwable e) {
        if (logger.isDebugEnabled()) {
          logger.debug("Got exception from killConnectionsWith", e);
        }
      }
    }
    for (ReceivePort p : rps) {
      try {
        p.killConnectionsWith(corpse);
      } catch (Throwable e) {
        if (logger.isDebugEnabled()) {
          logger.debug("Got exception from killConnectionsWith", e);
        }
      }
    }
  }
예제 #6
1
  public static HashMap<String, JSONObject> getGates(JSONObject model) {
    HashMap<String, JSONObject> resultHash = new HashMap<String, JSONObject>();

    HashMap<String, JSONObject> worldJSONs = getWorlds(model);

    for (JSONObject worldJSON : worldJSONs.values()) {
      JSONObject gateJSON = worldJSON.optJSONObject("gate");

      if (gateJSON != null) {
        String objectId = gateJSON.optString("itemId");
        if (!TextUtils.isEmpty(objectId)) {
          resultHash.put(objectId, gateJSON);
        }
      }
    }

    HashMap<String, JSONObject> missionJSONs = getMissions(model);
    for (JSONObject missionJSON : missionJSONs.values()) {
      JSONObject gateJSON = missionJSON.optJSONObject("gate");

      if (gateJSON != null) {
        String objectId = gateJSON.optString("itemId");
        if (!TextUtils.isEmpty(objectId)) {
          resultHash.put(objectId, gateJSON);
        }
      }
    }

    findInternalLists(resultHash, new String[] {"GatesListAND", "GatesListOR"}, "gates");

    return resultHash;
  }
  private ArrayList<StudentPersonalType> fetchStudents(
      HashMap<String, StudentPersonalType> studentMap, PagingInfo pagingInfo) {
    ArrayList<StudentPersonalType> studentList = new ArrayList<StudentPersonalType>();
    if (pagingInfo == null) // return all
    {
      studentList.addAll(studentMap.values());
    } else {
      pagingInfo.setTotalObjects(studentMap.size());
      if ((pagingInfo.getPageSize() * (pagingInfo.getCurrentPageNo())) > studentMap.size()) {
        return null; // Requested page outside of limits.
      }

      // retrieve applicable students
      Collection<StudentPersonalType> allStudent = studentMap.values();
      int i = 0;
      int startPos = pagingInfo.getPageSize() * pagingInfo.getCurrentPageNo();
      int endPos = startPos + pagingInfo.getPageSize();
      for (Iterator<StudentPersonalType> iter = allStudent.iterator(); iter.hasNext(); ) {
        StudentPersonalType student = iter.next();
        if ((i >= startPos) && (i < endPos)) {
          studentList.add(student);
        }
        i++;
      }
      // Set the number of object that are returned in the paging info. Will ensure HTTP headers are
      // set correctly.
      pagingInfo.setPageSize(studentList.size());
    }

    return studentList;
  }
예제 #8
0
 /**
  * deletes all items translations for a given parent
  *
  * @param parentId
  * @param parentType
  */
 public void deleteTranslationsForParent(Long parentId, Translation.ParentType parentType) {
   HashMap<String, Translation> trans = findTranslations(parentType, parentId);
   Collection<Translation> values = trans.values();
   if (values != null && values.size() > 0) {
     delete(trans.values());
   }
 }
예제 #9
0
 /** Test that each element can have its own format */
 public void testValidateElement() {
   recreateViewModel();
   String preferenceFormat = IFormattedValues.NATURAL_FORMAT;
   setInput(preferenceFormat);
   // set each element to the same element format different than the preference format, and verify
   HashMap<String, ElementFormatSetting> map = new HashMap<String, ElementFormatSetting>();
   String[] format = {IFormattedValues.HEX_FORMAT};
   makeElementFormatSetting(fViewer, TreePath.EMPTY, format, -1, 0, map);
   ArrayList<ElementFormatSetting> elementFormats =
       new ArrayList<ElementFormatSetting>(map.values());
   setFormatAndValidate(preferenceFormat, elementFormats, elementFormats, true, false, false);
   // element of same level use the same format and different levels have different formats, and
   // verify
   map.clear();
   format =
       new String[] {
         IFormattedValues.HEX_FORMAT,
         IFormattedValues.DECIMAL_FORMAT,
         IFormattedValues.OCTAL_FORMAT,
         IFormattedValues.BINARY_FORMAT,
         IFormattedValues.NATURAL_FORMAT
       };
   makeElementFormatSetting(fViewer, TreePath.EMPTY, format, -1, 0, map);
   elementFormats = new ArrayList<ElementFormatSetting>(map.values());
   setFormatAndValidate(preferenceFormat, elementFormats, elementFormats, false, false, false);
 }
예제 #10
0
 public void createProteinList() {
   minProteins = new HashMap<String, Protein>();
   for (Peptide pg : minPeptides.values()) {
     String pepName = pg.getSequence();
     for (String protName : pg.getProteins()) {
       if (minProteins.containsKey(protName)) {
         Protein prot = minProteins.get(protName);
         prot.addPeptide(pepName);
       } else {
         Protein prot = new Protein();
         prot.setName(protName);
         prot.addPeptide(pepName);
         prot.setCluster(cluster_num);
         minProteins.put(protName, prot);
       }
     }
   }
   for (Protein p : minProteins.values()) {
     ProteinInfo pInfo = new ProteinInfo();
     pInfo.setName(p.getName());
     pInfo.setDescription(p.getDescription());
     pInfo.setLength(p.getLength());
     MassSieveFrame.addProtein(pInfo);
   }
 }
예제 #11
0
  public void save() {

    // Sort list, add country to top, save types, put ids into type map
    List<RegionType> regionTypeList = new ArrayList(typeHashMap.values());
    Collections.sort(
        regionTypeList,
        (object1, object2) -> object1.getShortName().compareTo(object2.getShortName()));
    regionTypeList.add(0, new RegionType(COUNTRY_ID, COUNTRY_TYPE));
    // Add country to list after sort.
    typeHashMap.put(COUNTRY_TYPE, new RegionType(COUNTRY_ID, COUNTRY_TYPE));
    // Save
    for (RegionType regionType : regionTypeList) {
      regionType.identity = insertRegionType(regionType);
    }
    // Save countries put ids into country map
    List<Country> countryList = new ArrayList(countryHashMap.values());
    Collections.sort(
        countryList,
        (object1, object2) -> object1.getShortName().compareTo(object2.getShortName()));
    for (Country country : countryList) {
      country.identity = insertCountry(country);
    }
    // Save parent regions put ids into region map
    List<Region> regionList = new ArrayList(regionHashMap.values());
    Collections.sort(
        regionList, (object1, object2) -> object1.getShortName().compareTo(object2.getShortName()));
    for (Region region : regionList) {
      if (region.parentCode == null || region.parentCode.isEmpty()) {
        region.identity = insertRegion(region);
      }
    }
    // Save child regions
    for (Region region : regionList) {
      if (region.parentCode != null && !region.parentCode.isEmpty()) {
        region.identity = insertRegion(region);
      }
    }

    // Save Region path to root, TODO really brute force, this could be SO better.
    regionList = new ArrayList(regionHashMap.values());
    Collections.sort(
        regionList, (object1, object2) -> object1.getShortName().compareTo(object2.getShortName()));
    for (Region region : regionList) {
      if (!region.categoryName.equals(COUNTRY_TYPE)) {
        // region is not a country and so has a parent list. Country is the current top of the list.
        if (region.parentCode == null || region.parentCode.isEmpty()) {
          // if region has no parent, record country as parent node @ level 1 and leaf region as 2
          insertNodePath(region.identity, countryHashMap.get(region.countryCode).identity, 1);
          insertNodePath(region.identity, region.identity, 2);
        } else {
          // if region has a parent, record country as parent node @ level 1, parent region as 2 and
          // leaf region as 3
          insertNodePath(region.identity, countryHashMap.get(region.countryCode).identity, 1);
          insertNodePath(region.identity, regionHashMap.get(region.parentCode).identity, 2);
          insertNodePath(region.identity, region.identity, 3);
        }
      }
    }
  }
예제 #12
0
 /**
  * If empty, will return false.
  *
  * @return true if at least one value and all values are the same.
  */
 public boolean allValuesAreSame() {
   if (m_values.isEmpty()) return false;
   final int first = m_values.values().iterator().next();
   for (final int value : m_values.values()) {
     if (first != value) return false;
   }
   return true;
 }
예제 #13
0
 /**
  * @return f[] where f[i]==c indicates there were c splits which were present in exactly i trees.
  */
 public int[] countByFrequency() {
   int max = 0;
   if (splitsAddedOnlyViaTrees) max = nTrees;
   else for (int n : counts.values()) max = Math.max(max, n);
   int[] freq = new int[max];
   for (int i : counts.values()) freq[i - 1]++;
   return freq;
 }
예제 #14
0
파일: SFNode.java 프로젝트: rsvoboda/mjprof
  private String toStringSingle() {
    String indent = "       ";
    if (sf == null && children.size() > 0)
      return children.values().iterator().next().toStringSingle();
    if (children.size() == 0) return indent + sf;

    return children.values().iterator().next().toStringSingle() + "\n" + indent + sf;
  }
예제 #15
0
 void searchAccountByBalance() {
   System.out.println(
       "\nEnter your Choice\n1.Exact Balance\n2.More than Balance\n3.Less than Balance\n4.Balance Range");
   Scanner in = new Scanner(System.in);
   int amount;
   int choice = in.nextInt();
   boolean flag = true;
   switch (choice) {
     case 1:
       System.out.println("Enter the Amount to be search");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance == amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 2:
       System.out.println("Enter the Amount to be search for equal and more");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance >= amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 3:
       System.out.println("Enter the Amount to be search for equal and less");
       amount = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance <= amount) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     case 4:
       System.out.println("Enter the Amount range\nMinimum:");
       amount = in.nextInt();
       System.out.println("Maximum:");
       int max = in.nextInt();
       for (Accounts a : accounts.values()) {
         if (a.balance >= amount && a.balance <= max) {
           a.dispaly();
           flag = false;
         }
       }
       if (flag) System.out.println("No Data Found");
       break;
     default:
       System.out.println("Worn Input");
   }
 }
  // Adding switches and hosts to the network
  public void AddSwitchesAndHostsToGraph() {
    for (Switch switch_ : switches.values()) {
      AddNodeToGraph(switch_.getInetAddress(), true);
    }

    for (Host host_ : hosts.values()) {
      AddNodeToGraph(host_.getIpv4().toString(), false);
    }
  }
예제 #17
0
  /** Gets all Genomic Data. */
  private ProfileDataSummary getGenomicData(
      String cancerStudyId,
      HashMap<String, GeneticProfile> defaultGeneticProfileSet,
      SampleList defaultSampleSet,
      String geneListStr,
      ArrayList<SampleList> sampleList,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException, DaoException {

    // parse geneList, written in the OncoPrintSpec language (except for changes by XSS clean)
    double zScore =
        ZScoreUtil.getZScore(
            new HashSet<String>(defaultGeneticProfileSet.keySet()),
            new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()),
            request);
    double rppaScore = ZScoreUtil.getRPPAScore(request);

    ParserOutput theOncoPrintSpecParserOutput =
        OncoPrintSpecificationDriver.callOncoPrintSpecParserDriver(
            geneListStr,
            new HashSet<String>(defaultGeneticProfileSet.keySet()),
            new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()),
            zScore,
            rppaScore);

    ArrayList<String> geneList = new ArrayList<String>();
    geneList.addAll(theOncoPrintSpecParserOutput.getTheOncoPrintSpecification().listOfGenes());

    ArrayList<ProfileData> profileDataList = new ArrayList<ProfileData>();
    Set<String> warningUnion = new HashSet<String>();

    for (GeneticProfile profile : defaultGeneticProfileSet.values()) {
      try {
        GetProfileData remoteCall =
            new GetProfileData(
                profile, geneList, StringUtils.join(defaultSampleSet.getSampleList(), " "));
        ProfileData pData = remoteCall.getProfileData();
        warningUnion.addAll(remoteCall.getWarnings());
        profileDataList.add(pData);
      } catch (IllegalArgumentException e) {
        e.getStackTrace();
      }
    }

    ProfileMerger merger = new ProfileMerger(profileDataList);
    ProfileData mergedProfile = merger.getMergedProfile();

    ProfileDataSummary dataSummary =
        new ProfileDataSummary(
            mergedProfile,
            theOncoPrintSpecParserOutput.getTheOncoPrintSpecification(),
            zScore,
            rppaScore);
    return dataSummary;
  }
예제 #18
0
 /** Lift of isValueValid to FiltersPanel */
 public boolean isValueValid() {
   for (KeywordsPanel fp : filter2keywords.values()) {
     if (!fp.isValueValid()) return false;
   }
   for (TypesPanel tp : filter2types.values()) {
     if (!tp.isValueValid()) return false;
   }
   if (txtFilterName.getText().length() == 0) return false;
   return true;
 }
예제 #19
0
 protected void updateHiScore() {
   // used to calculate winner
   hiScore = Double.MIN_VALUE;
   for (Double d : playerScore.values()) {
     if (d > hiScore) hiScore = d;
   }
   for (Double d : teamScore.values()) {
     if (d > hiScore) hiScore = d;
   }
 }
예제 #20
0
  public Set<String> getSources() {
    HashSet<String> set = new HashSet<String>();
    for (ExecutableNode exNode : executableNodes.values()) {
      set.add(exNode.getJobPropsSource());
    }

    for (FlowProps props : flowProps.values()) {
      set.add(props.getSource());
    }
    return set;
  }
  public final int[] getGenes() {
    HashMap<Integer, Neuron> mappedNeurons =
        new HashMap<Integer, Neuron>(inputs.size() + outputs.size() + neurons.size());

    // input IDs start from 0 and increase
    for (int i = 0; i < inputs.size(); i++) {
      inputs.get(i).ID = i;
      mappedNeurons.put(i, inputs.get(i));
    }

    // output IDs start from -1 and decrease
    for (int i = 0; i < outputs.size(); i++) {
      outputs.get(i).ID = -i - 1;
      mappedNeurons.put(-i - 1, outputs.get(i));
    }

    // neuron IDs start after input IDs and increase
    for (int i = 0; i < neurons.size(); i++) {
      neurons.get(i).ID = i + inputs.size();
      mappedNeurons.put(i + inputs.size(), neurons.get(i));
    }

    // Calculate the number of connections
    int numConnections = 0;
    for (Neuron n : mappedNeurons.values()) numConnections += n.outgoingConnections.size();

    // initiate the genes array to the exact length
    int[] genes = new int[3 + (mappedNeurons.size() * 4) + (numConnections * 3)];

    genes[0] = inputs.size();
    genes[1] = outputs.size();
    genes[2] = neurons.size();

    int geneIndex = 3;
    for (Neuron n : mappedNeurons.values()) {
      genes[geneIndex] = n.ID;
      genes[geneIndex + 1] = n.cluster.clusterNum;
      genes[geneIndex + 2] = n.threshold;
      genes[geneIndex + 3] = n.startingLevel;

      geneIndex += 4;
    }

    for (Neuron n : mappedNeurons.values())
      for (Connection c : n.outgoingConnections) {
        genes[geneIndex] = c.source.ID;
        genes[geneIndex + 1] = c.destination.ID;
        genes[geneIndex + 2] = c.strength;

        geneIndex += 3;
      }

    return genes;
  }
  public void createWorkFlow() {
    for (BasicGeneratorGetter getter : generatorGetterGroup.values()) {
      log.info("Start the generator : " + getter.getName());
      getter.generator.start();
    }

    for (BasicExecutorGetter getter : executorGetterGroup.values()) {
      log.info("Start the executor : " + getter.getName());
      getter.executor.start();
    }
  }
예제 #23
0
  @Override
  public void run() {

    try {
      while (true) {
        Log.d("graph", "foi");
        if (wifi.isWifiEnabled()) {
          WifiInfo wifiINFO = wifi.getConnectionInfo();
          Log.d("MyDebug", "" + wifiINFO.getIpAddress());
          wifi.startScan();
          List<ScanResult> sr = wifi.getScanResults();

          for (WifiStrengthXYSeries s : hash.values()) {
            plot.removeSeries(s);
          }
          plot.removeMarkers();

          for (ScanResult r : sr) {
            WifiStrengthXYSeries series = hash.get(r.SSID);
            if (series == null) {
              series =
                  new WifiStrengthXYSeries(
                      r.SSID,
                      (r.frequency - 2407) / 5,
                      r.level,
                      ColorPool.getColor(hash.size()),
                      ColorPool.getTransparentColor(hash.size()));
              hash.put(r.SSID, series);

            } else {
              series.setChannel((r.frequency - 2407) / 5);
              series.setStrength(r.level);
              series.update();
            }

            plot.addSeries(series, series.getFormatter());
            plot.addMarker(
                series.getMarker(activity.getResources().getConfiguration().orientation));
          }

          plot.redraw();
        }
        Thread.sleep(1000);
      }

    } catch (InterruptedException e) {

      for (WifiStrengthXYSeries s : hash.values()) {
        plot.removeSeries(s);
      }
    }
  }
예제 #24
0
  public boolean drainOutput(float amount) {
    if (metals != null && metals.values().size() > 0) {
      int numMetals = metals.values().size();
      amount /= numMetals;
      for (Object am : metals.values()) {

        ((MetalPair) am).amount -= amount;
      }

      updateCurrentAlloy();
    }
    return true;
  }
 /**
  * HACK, accessed from inner class, overriden from derived class
  *
  * <p>sum all originators' usage arrays
  *
  * @param originator2usage
  * @param dummySubscription
  * @param bundle
  * @return
  */
 public double[] adjustForecastPerTariff(
     HashMap<CapacityOriginator, double[]> originator2usage,
     TariffSubscription dummySubscription,
     CapacityBundle bundle) {
   // sum all originators' usage arrays
   double[] result = new double[originator2usage.values().iterator().next().length];
   for (double[] usage : originator2usage.values()) {
     for (int i = 0; i < result.length; ++i) {
       result[i] += usage[i] / bundle.getPopulation();
     }
   }
   return result;
 }
  // recursive iterate hierarchical level of Sam to get all arcs from sub level.
  private void subCompositionArcsToCompositionModel(Component component) {
    HashMap<String, sam_model.Arc> subArcs = component.subCompositionModel.getArcs();
    for (sam_model.Arc subArc : subArcs.values()) {
      convertSamArcToPNArc(subArc);
    }

    HashMap<String, Component> subComponents = component.subCompositionModel.getComponents();
    for (Component subComponent : subComponents.values()) {
      if (subComponent.isSetSubComposition) {
        subCompositionArcsToCompositionModel(subComponent); // resursive call it self
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object,
   *      java.lang.Object)
   */
  protected void inputChanged(Object input, Object oldInput) {
    IStylingGraphModelFactory factory = getFactory();
    factory.setConnectionStyle(getConnectionStyle());
    factory.setNodeStyle(getNodeStyle());

    // Save the old map so we can set the size and position of any nodes
    // that are the same
    Map oldNodesMap = nodesMap;
    Graph graph = (Graph) getControl();
    graph.setSelection(new GraphNode[0]);

    Iterator iterator = nodesMap.values().iterator();
    while (iterator.hasNext()) {
      GraphNode node = (GraphNode) iterator.next();
      if (!node.isDisposed()) {
        node.dispose();
      }
    }

    iterator = connectionsMap.values().iterator();
    while (iterator.hasNext()) {
      GraphConnection connection = (GraphConnection) iterator.next();
      if (!connection.isDisposed()) {
        connection.dispose();
      }
    }

    nodesMap = new HashMap();
    connectionsMap = new HashMap();

    graph = factory.createGraphModel(graph);

    ((Graph) getControl()).setNodeStyle(getNodeStyle());
    ((Graph) getControl()).setConnectionStyle(getConnectionStyle());

    // check if any of the pre-existing nodes are still present
    // in this case we want them to keep the same location & size
    for (Iterator iter = oldNodesMap.keySet().iterator(); iter.hasNext(); ) {
      Object data = iter.next();
      GraphNode newNode = (GraphNode) nodesMap.get(data);
      if (newNode != null) {
        GraphNode oldNode = (GraphNode) oldNodesMap.get(data);
        newNode.setLocation(oldNode.getLocation().x, oldNode.getLocation().y);
        if (oldNode.isSizeFixed()) {
          newNode.setSize(oldNode.getSize().width, oldNode.getSize().height);
        }
      }
    }

    applyLayout();
  }
예제 #28
0
 public void updateParsimony() {
   for (Protein prot : minProteins.values()) {
     for (String pepName : prot.getPeptides()) {
       Peptide pep = minPeptides.get(pepName);
       prot.addAssociatedProteins(pep.getProteins());
     }
   }
   for (Protein prot : minProteins.values()) {
     prot.updateParsimony(minProteins);
   }
   for (Protein prot : minProteins.values()) {
     prot.computeParsimonyType();
   }
 }
  private void samConnectorToCompositionModel() {
    HashMap<String, Connector> samConnectors = this.samModel.getConnectors();
    for (Connector connector : samConnectors.values()) {
      convertSamConnectorToTransition(connector);
    }

    // subCompositions also has connectors
    HashMap<String, Component> samComponents = this.samModel.getComponents();
    for (Component component : samComponents.values()) {
      if (component.isSetSubComposition) {
        subCompositionConnectorsToCompositionModel(component);
      }
    }
  }
  private void samArcToCompositionModel() {
    HashMap<String, sam_model.Arc> samArcs = this.samModel.getArcs();
    for (sam_model.Arc arc : samArcs.values()) {
      convertSamArcToPNArc(arc);
    }

    // subCompositions also has arcs
    HashMap<String, Component> samComponents = this.samModel.getComponents();
    for (Component component : samComponents.values()) {
      if (component.isSetSubComposition) {
        subCompositionArcsToCompositionModel(component);
      }
    }
  }