Exemple #1
0
  /** Load all the data. */
  public static void init(Resolver loader, String file) {
    if (initialized) return;

    inclGraph = new SimpleDirectedGraph<GraphClass, Inclusion>(Inclusion.class);
    problems = new Vector<Problem>();
    load(loader, file, inclGraph, problems);

    // Sort problems
    Collections.sort(
        problems,
        new Comparator<Problem>() {
          public int compare(Problem o1, Problem o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });

    // Gather the classnames
    names = new TreeMap<String, GraphClass>(new LessLatex());
    for (GraphClass gclass : inclGraph.vertexSet()) names.put(gclass.toString(), gclass);

    // Gather the SCCs
    sccs = GAlg.calcSCCMap(inclGraph);

    initialized = true;
  }
Exemple #2
0
  public void renderLines(int algorithmUsed) {
    linesCoords.clear();
    Pair<List<Point2D>, Integer> results = null;
    long time = System.currentTimeMillis();
    switch (algorithmUsed) {
      case GAlg.CONVEX_HULL_GW:
        results = GiftWrapping.getInstance().convexHullGiftWrapping(verticesCoords);
        break;
      case GAlg.CONVEX_HULL_GS:
        results = GrahamScan.getInstance().convexHullGrahamScan(verticesCoords);
        break;
      case GAlg.LINKED_POINTS:
        results = new Pair<List<Point2D>, Integer>(verticesCoords, GLES20.GL_LINE_LOOP);
        break;
      case GAlg.SWEEP_TRIANGULATION:
        results = SweepTriangulation.getInstance().sweepTriangulation(verticesCoords);
        break;
      case GAlg.NAIVE_TRIANGULATION:
        results = SweepTriangulation.getInstance().naiveTriangulation(verticesCoords);
        break;
      case GAlg.KD_TREE:
        results =
            new KDTree(pointsRenderer.getSurfaceWidth(), pointsRenderer.getSurfaceHeight())
                .buildKDTree(verticesCoords);
        break;
      default:
        if (galg.getRubyMethods().containsKey(algorithmUsed)) {
          results =
              rubyAlgorithms.manipulateSceneWithRuby(
                  verticesCoords, "galgs_" + galg.getRubyMethods().get(algorithmUsed));
        }
        break;
    }

    renderMethod = (results != null) ? results.second : /* default */ GLES20.GL_POINTS;

    Log.d(GAlg.DEBUG_TAG, "#" + counter + "TIME TAKEN:" + (System.currentTimeMillis() - time));
    counter++;
    // Doesn't make any sense with less than 2 vertices.
    if (results != null && results.first != null && results.first.size() >= 2) {
      linesCoords.addAll(results.first);
      drawLines = true;
      newVertexBufferToDraw();
    }
  }