Beispiel #1
0
  public Embedder2D(DistancedPoints p) {
    this.points = p;
    tableLastUpdated = points.getLastUpdateTime();

    savedPoints = new ArrayList<String>();
    for (int i = 0; i < points.getCount(); i++) savedPoints.add(points.getPointId(i));

    xy = new Vector2D[points.getCount()];

    for (int i = 0; i < points.getCount(); i++) xy[i] = new Vector2D(0, 0);

    maxX = 0;
    maxY = 0;
    minX = 0;
    minY = 0;
  }
Beispiel #2
0
  private void updateStructure(long u) {
    tableLastUpdated = u;

    ArrayList<String> newPoints = new ArrayList<String>();
    for (int i = 0; i < points.getCount(); i++) newPoints.add(points.getPointId(i));

    Vector2D[] newxy = new Vector2D[newPoints.size()];

    for (int i = 0; i < newxy.length; i++) {
      int index = savedPoints.indexOf(newPoints.get(i));
      if (index >= 0 && index < savedPoints.size()) newxy[i] = xy[index];
      else newxy[i] = new Vector2D();
    }

    xy = newxy;
    savedPoints = newPoints;
  }
Beispiel #3
0
  public double getY(int index) {
    if (index < 0 || index >= xy.length) {
      System.exit(0);
    }

    long u = points.getLastUpdateTime();
    if (tableLastUpdated != u) updateStructure(u);

    return xy[index].y;
  }
Beispiel #4
0
  public void setX(int index, double x) {
    if (index < 0 || index >= xy.length) {
      System.exit(0);
    }

    long u = points.getLastUpdateTime();
    if (tableLastUpdated != u) updateStructure(u);

    xy[index].x = x;

    if (x > maxX) maxX = x;
    if (x < minX) minX = x;
  }
Beispiel #5
0
  public void setY(int index, double y) {
    if (index < 0 || index >= xy.length) {

      System.exit(0);
    }

    long u = points.getLastUpdateTime();
    if (tableLastUpdated != u) updateStructure(u);

    xy[index].y = y;

    if (y > maxY) maxY = y;
    if (y < minY) minY = y;
  }
  private TreeNode getTreeNode(DendrogramNode dendrogramNode) {
    TreeNode node = new TreeNode();
    if (dendrogramNode instanceof ObservationNode) {
      String id = distancedPoints.getPointId(((ObservationNode) dendrogramNode).getObservation());
      Property<PString> pId = new Property<PString>(PROPERTY_ID, new PString(id));
      node.addProperty(pId);
    } else {
      if (dendrogramNode.getRight() != null) {
        TreeNode rightTreeNode = getTreeNode(dendrogramNode.getRight());
        node.addChild(rightTreeNode);
      }
      if (dendrogramNode.getLeft() != null) {
        TreeNode leftTreeNode = getTreeNode(dendrogramNode.getLeft());
        node.addChild(leftTreeNode);
      }
    }

    return node;
  }