~tapaal-contributor/tapaal/autodetect-lens-check2

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java

  • Committer: srba.jiri at gmail
  • Date: 2020-08-03 14:00:57 UTC
  • mfrom: (1067.2.23 tapaalSaveLoad)
  • Revision ID: srba.jiri@gmail.com-20200803140057-ut4f08qccu63dv24
merged in lp:~tapaal-contributor/tapaal/load-and-save-time-and-game-net-properties introducing lense (timed,game) for future implementation of net projections

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
        private Iterable<TAPNQuery> queries;
56
56
        private Iterable<Constant> constants;
57
57
        private final TimedArcPetriNetNetwork network;
 
58
    private boolean isTimed;
 
59
    private boolean isGame;
58
60
 
59
61
        public TimedArcPetriNetNetworkWriter(
60
62
                        TimedArcPetriNetNetwork network, 
66
68
                this.queries = queries;
67
69
                this.constants = constants;
68
70
        }
 
71
 
 
72
    public TimedArcPetriNetNetworkWriter(
 
73
        TimedArcPetriNetNetwork network,
 
74
        Iterable<Template> templates,
 
75
        Iterable<TAPNQuery> queries,
 
76
        Iterable<Constant> constants,
 
77
        boolean isTimed,
 
78
        boolean isGame) {
 
79
        this.network = network;
 
80
        this.templates = templates;
 
81
        this.queries = queries;
 
82
        this.constants = constants;
 
83
        this.isTimed = isTimed;
 
84
        this.isGame = isGame;
 
85
    }
69
86
        
70
87
        public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {
71
88
                Document document = null;
89
106
                appendTemplates(document, pnmlRootNode);
90
107
                appendQueries(document, pnmlRootNode);
91
108
                appendDefaultBound(document, pnmlRootNode);
 
109
                appendFeature(document, pnmlRootNode);
92
110
 
93
111
                document.normalize();
94
112
                // Create Transformer with XSL Source File
139
157
                element.setAttribute("bound", network.getDefaultBound() + "");
140
158
                root.appendChild(element);
141
159
        }
 
160
 
 
161
    private void appendFeature(Document document, Element root) {
 
162
        String isTimed = "true";
 
163
        String isGame = "true";
 
164
        if (!this.isTimed) {
 
165
            isTimed = "false";
 
166
        }
 
167
        if (!this.isGame) {
 
168
            isGame = "false";
 
169
        }
 
170
 
 
171
        root.appendChild(createFeatureElement(isTimed, isGame, document));
 
172
    }
 
173
 
 
174
    private Element createFeatureElement(String isTimed, String isGame, Document document) {
 
175
        Require.that(document != null, "Error: document was null");
 
176
        Element feature = document.createElement("feature");
 
177
 
 
178
        feature.setAttribute("isTimed", isTimed);
 
179
        feature.setAttribute("isGame", isGame);
 
180
 
 
181
        return feature;
 
182
    }
142
183
        
143
184
        private void appendSharedPlaces(Document document, Element root) {
144
185
                for(SharedPlace place : network.sharedPlaces()){
194
235
 
195
236
                        Attr netAttrType = document.createAttribute("type");
196
237
                        netAttrType.setValue("P/T net");
197
 
 
198
238
                        NET.setAttributeNode(netAttrType);
199
239
 
200
240
                        appendAnnotationNotes(document, guiModel, NET);