Пример #1
0
  /** Object output methods */
  public String internalGraphToString() {
    String out = new String();

    VertexCollection sortedVertices = values.topologicalSort();

    for (int i = 0; i < sortedVertices.size(); i++) {
      out += ((DiscreteAttributeItem) sortedVertices.get(i).getContent()).getValue();

      // As long as we're not on the last attribute
      if (i < sortedVertices.size() - 1) {
        if (Graph.relativePreference(sortedVertices.get(i), sortedVertices.get(i + 1))
            == Graph.NATURALLY_EQUAL) {
          out += " - ";
        } else if (Graph.relativePreference(sortedVertices.get(i), sortedVertices.get(i + 1))
            == Graph.NATURALLY_DIRECTED) {
          out += " >> ";
        } else if (Graph.relativePreference(sortedVertices.get(i), sortedVertices.get(i + 1))
            == Graph.ARTIFICIALLY_DIRECTED) {
          out += " > ";
        }
      }
    }

    return out;
  }
Пример #2
0
 public int getNumberOfValues() {
   if (logger.isDebugEnabled()) {
     logger.debug("Getting number of values for discrete attribute (" + super.getName() + ")");
     logger.debug("Number of values is " + values.getNumberOfVertices());
   }
   return values.getNumberOfVertices();
 }
Пример #3
0
 public Vertex findVertex(String valueToFind) {
   for (Vertex vertex : values.getVertexCollection()) {
     if (((AttributeItem) vertex.getContent()).getAttributeType()
         == Attribute.DISCRETE_ATTRIBUTE) {
       if (((DiscreteAttributeItem) vertex.getContent()).getValue().equals(valueToFind)) {
         return vertex;
       }
     }
   }
   return null;
 }
Пример #4
0
 public void setEquallyPreferred(String value1, String value2) {
   if (logger.isDebugEnabled()) {
     logger.debug(
         "Attribute '"
             + super.getName()
             + "': Setting values '"
             + value1
             + "' and '"
             + value2
             + "' as equally preferred");
   }
   values.addEdge(findVertex(value1), findVertex(value2));
 }
Пример #5
0
 public void setPreferredOrdering(String value1, String value2) {
   if (logger.isDebugEnabled()) {
     logger.debug(
         "Attribute '"
             + super.getName()
             + "': Setting preferred ordering between values '"
             + value1
             + "' and '"
             + value2
             + "'");
   }
   values.addDirectedEdge(findVertex(value1), findVertex(value2));
 }
Пример #6
0
 public void makeGraphFullyDirected(String method) {
   values.makeGraphFullyDirected(method);
   logger.debug("Graph has been made fully directed");
 }
Пример #7
0
 public int relativePreference(String value1, String value2) {
   return Graph.relativePreference(findVertex(value1), findVertex(value2));
 }
Пример #8
0
 public void removeValueFromAttribute(String value) {
   if (logger.isDebugEnabled()) {
     logger.debug("Attribute '" + super.getName() + "': Removing value '" + value + "'");
   }
   values.removeVertex(findVertex(value));
 }
Пример #9
0
 /** Main methods */
 public void addValueToAttribute(String value) {
   if (logger.isDebugEnabled()) {
     logger.debug("Attribute '" + super.getName() + "': Adding value '" + value + "'");
   }
   values.addVertex(new DiscreteAttributeItem(super.getName(), value));
 }
Пример #10
0
 public String showAllStuff() {
   return values.showAllStuff();
 }
Пример #11
0
 public DiscreteAttributeItem getItemAt(int indexOfItem) {
   VertexCollection sortedVertices = values.topologicalSort();
   return (DiscreteAttributeItem) sortedVertices.get(indexOfItem).getContent();
 }