/** * 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(); } }
/** * 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(); } }