Esempio n. 1
0
 /**
  * This is the edge writing part of the {@link #writeToDot writeToDot} procedure. This part of the
  * visualization gets affected by the probabilities that are displayed at XOR-splits.
  *
  * @param bw the writer used by the framework to create the temporary dot file
  * @throws IOException if writing to the writer fails
  * @todo Peter: figure out how to place the probabilities at the tail of the edge
  */
 protected void writeEdgesToDot(Writer bw) throws IOException {
   try {
     Iterator it = this.getEdges().iterator();
     while (it.hasNext()) {
       ExtendedPNEdge e = (ExtendedPNEdge) (it.next());
       if (e.isPT()) {
         ExtendedPlace p = (ExtendedPlace) e.getSource();
         Transition t = (Transition) e.getDest();
         if (p.getOutEdges().size() > 1) {
           // for all edges coming from places with more than one
           // outgoing edge, display probability in 2 decimal
           // digits
           double prob =
               e.getProbability(
                   currentlySelectedInstances,
                   p.getTotalOutEdgeFrequency(
                       currentlySelectedInstances, advancedSettings[1], failedInstances),
                   advancedSettings[1],
                   failedInstances);
           DecimalFormat digits = new DecimalFormat();
           digits.setMaximumFractionDigits(2);
           digits.setMinimumFractionDigits(2);
           String chance = digits.format(prob);
           // replace commas with dots, since dot forces use of
           // US-Locale
           chance = chance.replace(",", ".");
           bw.write("p" + p.getNumber() + " -> t" + t.getNumber() + " [label=" + chance + "];\n");
         } else {
           // write a normal edge
           bw.write("p" + p.getNumber() + " -> t" + t.getNumber() + ";\n");
         }
       } else {
         // write a normal edge
         Place p = (Place) e.getDest();
         Transition t = (Transition) e.getSource();
         bw.write("t" + t.getNumber() + " -> p" + p.getNumber() + ";\n");
       }
     }
   } catch (Exception ex) {
     Message.add("Failure while updating the visualization.\n" + ex.toString(), 2);
     ex.printStackTrace();
   }
 }
Esempio n. 2
0
  /**
   * This is the place writing part of the writeToDot procedure (refer to it for further
   * information), which gets affected if the tokenCounterOption evaluates to true.
   *
   * @param bw The writer used by the framework to create the temporary dot file.
   * @throws IOException If writing to the writer fails.
   */
  protected void writePlacesToDot(Writer bw) throws IOException {
    // Draw places according to their waiting time level
    try {
      Iterator it = this.getPlaces().iterator();
      while (it.hasNext()) {
        ExtendedPlace p = (ExtendedPlace) (it.next());
        bw.write(
            "p"
                + p.getNumber()
                + " [shape=\"circle\",color=\"black\","
                + determinePlaceColor(p)
                + ",style=\"filled\",label=\"\",fontcolor=\"black\"];\n");

        nodeMapping.put(new String("p" + p.getNumber()), p);
      }
    } catch (Exception ex) {
      Message.add("Failure while updating the visualization.\n" + ex.toString(), 2);
      ex.printStackTrace();
    }
  }
Esempio n. 3
0
 /**
  * Method which determines the color that the place p, should get depending on its average waiting
  * time. This color is returned as String in dot-form
  *
  * @param p ExtendedPlace: the place to be colored
  * @return String
  */
 private String determinePlaceColor(ExtendedPlace p) {
   String temp = "fillcolor=";
   // paint places according to their waiting time level:
   double bnd0 = 0, bnd1 = 0, wait = 0;
   Color col0, col1, col2;
   if (p.hasSettings()) {
     bnd0 = ((Double) p.getBounds().get(0)).doubleValue() * timeDivider;
     bnd1 = ((Double) p.getBounds().get(1)).doubleValue() * timeDivider;
     col0 = (Color) p.getColors().get(0);
     col1 = (Color) p.getColors().get(1);
     col2 = (Color) p.getColors().get(2);
   } else {
     bnd0 = ((Double) bounds.get(0)).doubleValue() * timeDivider;
     bnd1 = ((Double) bounds.get(1)).doubleValue() * timeDivider;
     col0 = (Color) levelColors.get(0);
     col1 = (Color) levelColors.get(1);
     col2 = (Color) levelColors.get(2);
   }
   try {
     p.calculateMetrics(currentlySelectedInstances, advancedSettings[1], failedInstances);
     wait = (p.getMeanWaitingTime());
   } catch (Exception ex) {
   }
   // array to store HSB values in
   float[] hsb = new float[3];
   if (wait <= bnd0) {
     Color.RGBtoHSB(col0.getRed(), col0.getGreen(), col0.getBlue(), hsb);
     temp += "\"" + hsb[0] + "," + hsb[1] + "," + hsb[2] + "\"";
   } else if (wait <= bnd1) {
     Color.RGBtoHSB(col1.getRed(), col1.getGreen(), col1.getBlue(), hsb);
     temp += "\"" + hsb[0] + "," + hsb[1] + "," + hsb[2] + "\"";
   } else if (wait > bnd1) {
     // final one
     Color.RGBtoHSB(col2.getRed(), col2.getGreen(), col2.getBlue(), hsb);
     temp += "\"" + hsb[0] + "," + hsb[1] + "," + hsb[2] + "\"";
   } else {
     Color.RGBtoHSB(col0.getRed(), col0.getGreen(), col0.getBlue(), hsb);
     temp += "\"" + hsb[0] + "," + hsb[1] + "," + hsb[2] + "\"";
   }
   return temp;
 }