Merge lp:~tapaal-contributor/tapaal/cpn-remove-add into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1630
Merge reported by: Kenneth Yrke Jørgensen
Merged at revision: not available
Proposed branch: lp:~tapaal-contributor/tapaal/cpn-remove-add
Merge into: lp:tapaal
Diff against target: 53900 lines (+27963/-9776)
461 files modified
build.gradle (+36/-34)
gradle/wrapper/gradle-wrapper.properties (+5/-6)
gradlew (+2/-0)
gradlew.bat (+4/-18)
src/dk/aau/cs/TCTL/AritmeticOperator.java (+1/-1)
src/dk/aau/cs/TCTL/LTLGNode.java (+1/-1)
src/dk/aau/cs/TCTL/LTLUNode.java (+1/-1)
src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj (+6/-6)
src/dk/aau/cs/TCTL/StringPosition.java (+2/-3)
src/dk/aau/cs/TCTL/TCTLAUNode.java (+1/-1)
src/dk/aau/cs/TCTL/TCTLAbstractProperty.java (+0/-2)
src/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java (+0/-14)
src/dk/aau/cs/TCTL/TCTLAndListNode.java (+1/-2)
src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java (+0/-25)
src/dk/aau/cs/TCTL/TCTLConstNode.java (+1/-1)
src/dk/aau/cs/TCTL/TCTLEFNode.java (+0/-2)
src/dk/aau/cs/TCTL/TCTLOrListNode.java (+1/-2)
src/dk/aau/cs/TCTL/TCTLPlusListNode.java (+1/-1)
src/dk/aau/cs/TCTL/TCTLTermListNode.java (+1/-1)
src/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java (+36/-34)
src/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java (+2/-2)
src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java (+55/-40)
src/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java (+7/-7)
src/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java (+10/-7)
src/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java (+4/-3)
src/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java (+1/-10)
src/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java (+35/-23)
src/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java (+2/-2)
src/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java (+2/-2)
src/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java (+2/-2)
src/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java (+1/-1)
src/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java (+4/-5)
src/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java (+4/-5)
src/dk/aau/cs/approximation/ApproximationWorker.java (+187/-117)
src/dk/aau/cs/approximation/OverApproximation.java (+10/-9)
src/dk/aau/cs/approximation/UnderApproximation.java (+43/-55)
src/dk/aau/cs/io/LoadTACPN.java (+439/-0)
src/dk/aau/cs/io/LoadedModel.java (+11/-9)
src/dk/aau/cs/io/LoadedQueries.java (+1/-2)
src/dk/aau/cs/io/ModelLoader.java (+3/-3)
src/dk/aau/cs/io/NetWriter.java (+3/-3)
src/dk/aau/cs/io/PNMLWriter.java (+150/-26)
src/dk/aau/cs/io/PNMLoader.java (+521/-453)
src/dk/aau/cs/io/TapnEngineXmlLoader.java (+993/-0)
src/dk/aau/cs/io/TapnLegacyXmlLoader.java (+58/-54)
src/dk/aau/cs/io/TapnXmlLoader.java (+397/-110)
src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+146/-39)
src/dk/aau/cs/io/TraceImportExport.java (+25/-22)
src/dk/aau/cs/io/XMLFormatter.java (+1/-1)
src/dk/aau/cs/io/batchProcessing/BatchProcessingResultsExporter.java (+4/-4)
src/dk/aau/cs/io/batchProcessing/LoadedBatchProcessingModel.java (+1/-1)
src/dk/aau/cs/io/queries/QueryLoader.java (+2/-5)
src/dk/aau/cs/io/queries/SUMOQueryLoader.java (+10/-12)
src/dk/aau/cs/io/queries/TAPNQueryLoader.java (+35/-16)
src/dk/aau/cs/io/queries/XMLQueryLoader.java (+22/-17)
src/dk/aau/cs/io/writeTACPN.java (+455/-0)
src/dk/aau/cs/model/CPN/ArcExpressionParser/ArcExpressionParser.jj (+273/-0)
src/dk/aau/cs/model/CPN/Color.java (+137/-0)
src/dk/aau/cs/model/CPN/ColorMultiset.java (+144/-0)
src/dk/aau/cs/model/CPN/ColorType.java (+142/-0)
src/dk/aau/cs/model/CPN/ColoredTimeInterval.java (+148/-0)
src/dk/aau/cs/model/CPN/ColoredTimeInvariant.java (+108/-0)
src/dk/aau/cs/model/CPN/ExpressionSupport/ExprStringPosition.java (+35/-0)
src/dk/aau/cs/model/CPN/ExpressionSupport/ExprValues.java (+40/-0)
src/dk/aau/cs/model/CPN/Expressions/AddExpression.java (+185/-0)
src/dk/aau/cs/model/CPN/Expressions/AllExpression.java (+137/-0)
src/dk/aau/cs/model/CPN/Expressions/AndExpression.java (+124/-0)
src/dk/aau/cs/model/CPN/Expressions/ArcExpression.java (+37/-0)
src/dk/aau/cs/model/CPN/Expressions/ColorExpression.java (+62/-0)
src/dk/aau/cs/model/CPN/Expressions/DotConstantExpression.java (+107/-0)
src/dk/aau/cs/model/CPN/Expressions/EqualityExpression.java (+119/-0)
src/dk/aau/cs/model/CPN/Expressions/Expression.java (+64/-0)
src/dk/aau/cs/model/CPN/Expressions/ExpressionContext.java (+31/-0)
src/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java (+118/-0)
src/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java (+121/-0)
src/dk/aau/cs/model/CPN/Expressions/GuardExpression.java (+30/-0)
src/dk/aau/cs/model/CPN/Expressions/InequalityExpression.java (+117/-0)
src/dk/aau/cs/model/CPN/Expressions/LeftRightGuardExpression.java (+6/-0)
src/dk/aau/cs/model/CPN/Expressions/LessThanEqExpression.java (+120/-0)
src/dk/aau/cs/model/CPN/Expressions/LessThanExpression.java (+121/-0)
src/dk/aau/cs/model/CPN/Expressions/NotExpression.java (+87/-0)
src/dk/aau/cs/model/CPN/Expressions/NumberOfExpression.java (+182/-0)
src/dk/aau/cs/model/CPN/Expressions/OrExpression.java (+124/-0)
src/dk/aau/cs/model/CPN/Expressions/PlaceHolderArcExpression.java (+76/-0)
src/dk/aau/cs/model/CPN/Expressions/PlaceHolderColorExpression.java (+106/-0)
src/dk/aau/cs/model/CPN/Expressions/PlaceHolderExpression.java (+5/-0)
src/dk/aau/cs/model/CPN/Expressions/PlaceHolderGuardExpression.java (+75/-0)
src/dk/aau/cs/model/CPN/Expressions/PredecessorExpression.java (+127/-0)
src/dk/aau/cs/model/CPN/Expressions/ScalarProductExpression.java (+114/-0)
src/dk/aau/cs/model/CPN/Expressions/SubtractExpression.java (+138/-0)
src/dk/aau/cs/model/CPN/Expressions/SuccessorExpression.java (+125/-0)
src/dk/aau/cs/model/CPN/Expressions/TupleExpression.java (+238/-0)
src/dk/aau/cs/model/CPN/Expressions/UserOperatorExpression.java (+140/-0)
src/dk/aau/cs/model/CPN/Expressions/UserSortExpression.java (+92/-0)
src/dk/aau/cs/model/CPN/Expressions/VariableExpression.java (+180/-0)
src/dk/aau/cs/model/CPN/GuardExpressionParser/GuardExpressionParser.jj (+223/-0)
src/dk/aau/cs/model/CPN/ProductType.java (+188/-0)
src/dk/aau/cs/model/CPN/Variable.java (+34/-0)
src/dk/aau/cs/model/NTA/Location.java (+1/-1)
src/dk/aau/cs/model/NTA/trace/SymbolicState.java (+5/-5)
src/dk/aau/cs/model/NTA/trace/TimeDelayFiringAction.java (+2/-2)
src/dk/aau/cs/model/NTA/trace/TraceToken.java (+4/-11)
src/dk/aau/cs/model/NTA/trace/TransitionFiring.java (+5/-13)
src/dk/aau/cs/model/tapn/ConstantStore.java (+11/-12)
src/dk/aau/cs/model/tapn/IntWeight.java (+1/-1)
src/dk/aau/cs/model/tapn/LocalTimedMarking.java (+2/-2)
src/dk/aau/cs/model/tapn/LocalTimedPlace.java (+42/-5)
src/dk/aau/cs/model/tapn/NetworkMarking.java (+3/-3)
src/dk/aau/cs/model/tapn/RatBound.java (+4/-4)
src/dk/aau/cs/model/tapn/SharedPlace.java (+51/-13)
src/dk/aau/cs/model/tapn/SharedTransition.java (+20/-12)
src/dk/aau/cs/model/tapn/TAPNQuery.java (+1/-1)
src/dk/aau/cs/model/tapn/TimeInterval.java (+3/-3)
src/dk/aau/cs/model/tapn/TimeInvariant.java (+3/-3)
src/dk/aau/cs/model/tapn/TimedArcPetriNet.java (+65/-10)
src/dk/aau/cs/model/tapn/TimedArcPetriNetNetwork.java (+355/-18)
src/dk/aau/cs/model/tapn/TimedInhibitorArc.java (+12/-7)
src/dk/aau/cs/model/tapn/TimedInputArc.java (+58/-12)
src/dk/aau/cs/model/tapn/TimedOutputArc.java (+30/-3)
src/dk/aau/cs/model/tapn/TimedPlace.java (+55/-7)
src/dk/aau/cs/model/tapn/TimedToken.java (+50/-12)
src/dk/aau/cs/model/tapn/TimedTransition.java (+49/-10)
src/dk/aau/cs/model/tapn/TransportArc.java (+72/-10)
src/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java (+6/-6)
src/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java (+2/-2)
src/dk/aau/cs/model/tapn/simulation/TAPNNetworkTimeDelayStep.java (+0/-4)
src/dk/aau/cs/model/tapn/simulation/TimeDelayStep.java (+3/-3)
src/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java (+2/-6)
src/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java (+1/-1)
src/dk/aau/cs/translations/Degree2Converter.java (+14/-12)
src/dk/aau/cs/translations/ReductionOption.java (+1/-1)
src/dk/aau/cs/translations/tapn/BroadcastTranslation.java (+6/-5)
src/dk/aau/cs/translations/tapn/CombiTranslation.java (+6/-6)
src/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java (+4/-3)
src/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java (+2/-1)
src/dk/aau/cs/translations/tapn/StandardTranslation.java (+2/-1)
src/dk/aau/cs/translations/tapn/TAPNToTimedConservativeTAPNConverter.java (+2/-0)
src/dk/aau/cs/util/ExecutabilityChecker.java (+0/-42)
src/dk/aau/cs/util/FormatException.java (+4/-0)
src/dk/aau/cs/util/IntervalOperations.java (+8/-8)
src/dk/aau/cs/util/MemoryMonitor.java (+1/-2)
src/dk/aau/cs/util/Require.java (+0/-4)
src/dk/aau/cs/verification/BoundednessAnalysisResult.java (+3/-3)
src/dk/aau/cs/verification/BufferDrain.java (+7/-2)
src/dk/aau/cs/verification/EngineHelperFunctions.java (+94/-0)
src/dk/aau/cs/verification/ITAPNComposer.java (+2/-0)
src/dk/aau/cs/verification/IconSelector.java (+4/-4)
src/dk/aau/cs/verification/ModelChecker.java (+6/-3)
src/dk/aau/cs/verification/ProcessRunner.java (+2/-2)
src/dk/aau/cs/verification/QueryResult.java (+29/-7)
src/dk/aau/cs/verification/ReductionStats.java (+27/-30)
src/dk/aau/cs/verification/Stats.java (+9/-23)
src/dk/aau/cs/verification/TAPNComposer.java (+84/-65)
src/dk/aau/cs/verification/TAPNTraceDecomposer.java (+3/-2)
src/dk/aau/cs/verification/TraceConverter.java (+3/-2)
src/dk/aau/cs/verification/UPPAAL/UppaalIconSelector.java (+1/-1)
src/dk/aau/cs/verification/UPPAAL/Verifyta.java (+37/-88)
src/dk/aau/cs/verification/UPPAAL/VerifytaOptions.java (+4/-4)
src/dk/aau/cs/verification/UPPAAL/VerifytaTraceInterpreter.java (+3/-2)
src/dk/aau/cs/verification/VerificationOptions.java (+12/-6)
src/dk/aau/cs/verification/VerificationResult.java (+45/-29)
src/dk/aau/cs/verification/VerifyTAPN/VerifyCPNExporter.java (+149/-0)
src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java (+144/-150)
src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPNOptions.java (+95/-22)
src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPNUnfoldOptions.java (+68/-0)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java (+464/-429)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java (+8/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNExporter.java (+5/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java (+152/-79)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java (+8/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNUnfoldOptions.java (+100/-0)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTACPNExporter.java (+32/-0)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java (+151/-144)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java (+81/-74)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java (+52/-21)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java (+19/-2)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNTraceParser.java (+3/-1)
src/dk/aau/cs/verification/batchProcessing/BatchProcessingVerificationOptions.java (+3/-8)
src/dk/aau/cs/verification/batchProcessing/BatchProcessingVerificationResult.java (+1/-1)
src/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java (+61/-66)
src/net/tapaal/Preferences.java (+8/-0)
src/net/tapaal/TAPAAL.java (+20/-26)
src/net/tapaal/copypaste/CopyPastImportExport.kt (+312/-0)
src/net/tapaal/export/TikZExporter.java (+215/-147)
src/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java (+9/-4)
src/net/tapaal/gui/GuiFrameActions.java (+16/-10)
src/net/tapaal/gui/GuiFrameController.java (+144/-110)
src/net/tapaal/gui/GuiFrameControllerActions.java (+7/-6)
src/net/tapaal/gui/SafeGuiFrameActions.java (+3/-3)
src/net/tapaal/gui/TabActions.java (+28/-12)
src/net/tapaal/gui/debug/Debug.kt (+32/-0)
src/net/tapaal/gui/debug/UndoRedoSpy.kt (+53/-0)
src/net/tapaal/gui/petrinet/Context.java (+10/-9)
src/net/tapaal/gui/petrinet/NameGenerator.java (+1/-1)
src/net/tapaal/gui/petrinet/TAPNLens.java (+27/-0)
src/net/tapaal/gui/petrinet/TabTransformer.java (+185/-11)
src/net/tapaal/gui/petrinet/Template.java (+3/-2)
src/net/tapaal/gui/petrinet/animation/AnimationTokenSelectDialog.java (+3/-3)
src/net/tapaal/gui/petrinet/animation/ArcTokenSelector.java (+5/-5)
src/net/tapaal/gui/petrinet/animation/DelayEnabledTransitionControl.java (+3/-3)
src/net/tapaal/gui/petrinet/animation/TransitionFiringComponent.java (+15/-14)
src/net/tapaal/gui/petrinet/dialog/BatchProcessingDialog.java (+80/-122)
src/net/tapaal/gui/petrinet/dialog/BatchProcessingResultsTableModel.java (+2/-2)
src/net/tapaal/gui/petrinet/dialog/ExportBatchDialog.java (+25/-21)
src/net/tapaal/gui/petrinet/dialog/ExportBatchResultTableModel.java (+1/-1)
src/net/tapaal/gui/petrinet/dialog/FileNameCellRenderer.java (+1/-1)
src/net/tapaal/gui/petrinet/dialog/NameVisibilityPanel.java (+7/-7)
src/net/tapaal/gui/petrinet/dialog/NewTAPNPanel.java (+93/-31)
src/net/tapaal/gui/petrinet/dialog/QueryDialog.java (+319/-205)
src/net/tapaal/gui/petrinet/dialog/StatisticsPanel.java (+16/-16)
src/net/tapaal/gui/petrinet/dialog/UnfoldDialog.java (+179/-0)
src/net/tapaal/gui/petrinet/dialog/WorkflowDialog.java (+63/-55)
src/net/tapaal/gui/petrinet/editor/ColorComboBoxRenderer.java (+52/-0)
src/net/tapaal/gui/petrinet/editor/ColorComboboxPanel.java (+163/-0)
src/net/tapaal/gui/petrinet/editor/ColorTypeDialogPanel.java (+1145/-0)
src/net/tapaal/gui/petrinet/editor/ColoredArcGuardPanel.java (+1200/-0)
src/net/tapaal/gui/petrinet/editor/ColoredTimeIntervalDialogPanel.java (+446/-0)
src/net/tapaal/gui/petrinet/editor/ColoredTimeInvariantDialogPanel.java (+318/-0)
src/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java (+996/-0)
src/net/tapaal/gui/petrinet/editor/ColortypeListCellRenderer.java (+59/-0)
src/net/tapaal/gui/petrinet/editor/ConstantsDialogPanel.java (+36/-34)
src/net/tapaal/gui/petrinet/editor/ConstantsListModel.java (+2/-2)
src/net/tapaal/gui/petrinet/editor/ConstantsPane.java (+650/-206)
src/net/tapaal/gui/petrinet/editor/DeleteSharedPlaceOrTransitionAction.java (+49/-36)
src/net/tapaal/gui/petrinet/editor/SharedPlaceNamePanel.java (+8/-12)
src/net/tapaal/gui/petrinet/editor/SharedPlacesAndTransitionsPanel.java (+29/-41)
src/net/tapaal/gui/petrinet/editor/SharedTransitionNamePanel.java (+12/-15)
src/net/tapaal/gui/petrinet/editor/TemplateExplorer.java (+135/-278)
src/net/tapaal/gui/petrinet/editor/VariablesDialogPanel.java (+328/-0)
src/net/tapaal/gui/petrinet/model/GuiModelManager.java (+523/-0)
src/net/tapaal/gui/petrinet/model/ModelViolation.java (+19/-0)
src/net/tapaal/gui/petrinet/model/RequirementChecker.java (+28/-0)
src/net/tapaal/gui/petrinet/model/Result.java (+29/-0)
src/net/tapaal/gui/petrinet/smartdraw/SmartDrawDialog.java (+90/-289)
src/net/tapaal/gui/petrinet/smartdraw/SmartDrawListener.java (+1/-1)
src/net/tapaal/gui/petrinet/smartdraw/SmartDrawWorker.java (+65/-51)
src/net/tapaal/gui/petrinet/undo/AddConstantEditCommand.java (+6/-7)
src/net/tapaal/gui/petrinet/undo/AddFileBatchProcessingCommand.java (+4/-4)
src/net/tapaal/gui/petrinet/undo/AddFileExportBatchCommand.java (+2/-3)
src/net/tapaal/gui/petrinet/undo/AddQueryCommand.java (+5/-6)
src/net/tapaal/gui/petrinet/undo/AddSharedPlaceCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/AddSharedTransitionCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/AddTemplateCommand.java (+3/-4)
src/net/tapaal/gui/petrinet/undo/AddTimedInhibitorArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/AddTimedInputArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/AddTimedOutputArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/AddTimedPlaceCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/AddTimedTransitionCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/AddTransportArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/ChangeAllNamesVisibilityCommand.java (+7/-7)
src/net/tapaal/gui/petrinet/undo/ChangeSpacingEditCommand.java (+7/-8)
src/net/tapaal/gui/petrinet/undo/ChangedInvariantCommand.java (+1/-1)
src/net/tapaal/gui/petrinet/undo/Colored/AddColorTypeCommand.java (+30/-0)
src/net/tapaal/gui/petrinet/undo/Colored/AddVariableCommand.java (+29/-0)
src/net/tapaal/gui/petrinet/undo/Colored/ColoredPlaceMarkingEditCommand.java (+78/-0)
src/net/tapaal/gui/petrinet/undo/Colored/RemoveColorTypeFromNetworkCommand.java (+33/-0)
src/net/tapaal/gui/petrinet/undo/Colored/RemoveVariableFromNetworkCommand.java (+33/-0)
src/net/tapaal/gui/petrinet/undo/Colored/SetArcExpressionCommand.java (+29/-0)
src/net/tapaal/gui/petrinet/undo/Colored/SetColoredArcIntervalsCommand.java (+30/-0)
src/net/tapaal/gui/petrinet/undo/Colored/SetTransitionExpressionCommand.java (+29/-0)
src/net/tapaal/gui/petrinet/undo/Colored/SetTransportArcExpressionsCommand.java (+35/-0)
src/net/tapaal/gui/petrinet/undo/Colored/UpdateColorTypeCommand.java (+77/-0)
src/net/tapaal/gui/petrinet/undo/Colored/UpdatePTColorTypeCommand.java (+31/-0)
src/net/tapaal/gui/petrinet/undo/Colored/UpdateVariableCommand.java (+40/-0)
src/net/tapaal/gui/petrinet/undo/Command.java (+1/-1)
src/net/tapaal/gui/petrinet/undo/DeleteQueriesCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/DeleteSharedPlaceCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/DeleteSharedTransitionCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/DeleteTimedInhibitorArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/DeleteTimedInputArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/DeleteTimedOutputArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/DeleteTimedPlaceCommand.java (+12/-10)
src/net/tapaal/gui/petrinet/undo/DeleteTimedTransitionCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/DeleteTransportArcCommand.java (+4/-3)
src/net/tapaal/gui/petrinet/undo/MakePlaceNewSharedCommand.java (+17/-9)
src/net/tapaal/gui/petrinet/undo/MakePlaceNewSharedMultiCommand.java (+14/-7)
src/net/tapaal/gui/petrinet/undo/MakePlaceSharedCommand.java (+7/-7)
src/net/tapaal/gui/petrinet/undo/MakeTransitionNewSharedCommand.java (+4/-4)
src/net/tapaal/gui/petrinet/undo/MakeTransitionNewSharedMultiCommand.java (+6/-6)
src/net/tapaal/gui/petrinet/undo/MakeTransitionSharedCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/MoveElementDownCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/MoveElementUpCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/MovePlaceTransitionObjectCommand.java (+14/-13)
src/net/tapaal/gui/petrinet/undo/RemoveConstantEditCommand.java (+6/-7)
src/net/tapaal/gui/petrinet/undo/RemoveFileBatchProcessingCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/RemoveFileExportBatchCommand.java (+2/-3)
src/net/tapaal/gui/petrinet/undo/RemoveQueriesCommand.java (+8/-9)
src/net/tapaal/gui/petrinet/undo/RemoveTemplateCommand.java (+7/-7)
src/net/tapaal/gui/petrinet/undo/RenameSharedPlaceCommand.java (+6/-6)
src/net/tapaal/gui/petrinet/undo/RenameSharedTransitionCommand.java (+6/-6)
src/net/tapaal/gui/petrinet/undo/RenameTemplateCommand.java (+6/-7)
src/net/tapaal/gui/petrinet/undo/RenameTimedPlaceCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/RenameTimedTransitionCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/SortConstantsCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/SortQueriesCommand.java (+1/-1)
src/net/tapaal/gui/petrinet/undo/SortSharedPlacesCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/SortSharedTransitionsCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/SortTemplatesCommand.java (+6/-6)
src/net/tapaal/gui/petrinet/undo/TimedPlaceMarkingEditCommand.java (+4/-4)
src/net/tapaal/gui/petrinet/undo/ToggleTemplateActivationCommand.java (+3/-4)
src/net/tapaal/gui/petrinet/undo/ToggleTransitionUncontrollableCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/ToggleTransitionUrgentCommand.java (+5/-5)
src/net/tapaal/gui/petrinet/undo/UndoRedoBuffer.java (+95/-0)
src/net/tapaal/gui/petrinet/undo/UnsharePlaceCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/undo/UnshareTransitionCommand.java (+1/-1)
src/net/tapaal/gui/petrinet/undo/UpdateConstantEditCommand.java (+7/-8)
src/net/tapaal/gui/petrinet/undo/UpdateNameLabelOffsetCommand.java (+2/-2)
src/net/tapaal/gui/petrinet/verification/ChooseInclusionPlacesDialog.java (+17/-21)
src/net/tapaal/gui/petrinet/verification/EngineDialogPanel.java (+9/-9)
src/net/tapaal/gui/petrinet/verification/EngineSupportOptions.java (+5/-5)
src/net/tapaal/gui/petrinet/verification/InclusionPlaces.java (+1/-1)
src/net/tapaal/gui/petrinet/verification/KBoundAnalyzer.java (+36/-23)
src/net/tapaal/gui/petrinet/verification/RunKBoundAnalysis.java (+12/-8)
src/net/tapaal/gui/petrinet/verification/RunVerification.java (+156/-152)
src/net/tapaal/gui/petrinet/verification/RunVerificationBase.java (+172/-146)
src/net/tapaal/gui/petrinet/verification/RunningVerificationDialog.java (+12/-6)
src/net/tapaal/gui/petrinet/verification/TAPNQuery.java (+78/-15)
src/net/tapaal/gui/petrinet/verification/UPPAAALStandardOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/UPPAALBroadcastDegree2Options.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/UPPAALBroadcastOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/UPPAALCombiOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/UPPAALOptimizedStandardOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/UnfoldNet.java (+350/-0)
src/net/tapaal/gui/petrinet/verification/Verifier.java (+229/-199)
src/net/tapaal/gui/petrinet/verification/VerifyDTAPNEngineOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/VerifyPNEngineOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java (+3/-2)
src/net/tapaal/gui/petrinet/widgets/QueryPane.java (+43/-56)
src/net/tapaal/gui/petrinet/widgets/SidePane.java (+1/-1)
src/net/tapaal/gui/swingcomponents/BugHandledJXMultisplitPane.java (+1/-1)
src/net/tapaal/gui/swingcomponents/MultiLineAutoWrappingToolTip.java (+1/-1)
src/net/tapaal/gui/swingcomponents/MultiLineAutoWrappingTooltipUI.java (+1/-1)
src/net/tapaal/gui/swingcomponents/NonsearchableJComboBox.java (+1/-1)
src/net/tapaal/gui/swingcomponents/NonsearchableJList.java (+1/-1)
src/net/tapaal/swinghelpers/CustomJSpinner.java (+0/-1)
src/net/tapaal/swinghelpers/DecimalOnlyDocumentFilter.java (+43/-47)
src/net/tapaal/swinghelpers/DispatchEventsToParentHandler.java (+36/-36)
src/net/tapaal/swinghelpers/GridBagHelper.java (+12/-6)
src/net/tapaal/swinghelpers/RequestFocusListener.java (+0/-3)
src/net/tapaal/swinghelpers/ToggleButtonWithoutText.java (+0/-1)
src/net/tapaal/versioncheck/VersionChecker.java (+2/-2)
src/pipe/gui/Constants.java (+10/-16)
src/pipe/gui/FileFinder.java (+1/-1)
src/pipe/gui/GuiFrame.java (+269/-171)
src/pipe/gui/MessengerImpl.java (+1/-1)
src/pipe/gui/TAPAALGUI.java (+30/-83)
src/pipe/gui/TabComponent.java (+4/-3)
src/pipe/gui/canvas/Canvas.java (+1/-1)
src/pipe/gui/canvas/DrawingSurfaceImpl.java (+78/-172)
src/pipe/gui/canvas/Grid.java (+10/-25)
src/pipe/gui/canvas/PrototypeCanvas.java (+1/-1)
src/pipe/gui/canvas/SelectionManager.java (+78/-98)
src/pipe/gui/canvas/Zoomer.java (+7/-5)
src/pipe/gui/handler/AnnotationNoteHandler.java (+0/-56)
src/pipe/gui/handler/ArcHandler.java (+0/-77)
src/pipe/gui/handler/ArcPathPointHandler.java (+0/-95)
src/pipe/gui/handler/NoteHandler.java (+0/-13)
src/pipe/gui/handler/PetriNetObjectHandler.java (+0/-168)
src/pipe/gui/handler/PlaceHandler.java (+0/-45)
src/pipe/gui/handler/PlaceTransitionObjectHandler.java (+0/-57)
src/pipe/gui/handler/TimedArcHandler.java (+0/-31)
src/pipe/gui/handler/TransitionHandler.java (+0/-44)
src/pipe/gui/petrinet/Export.java (+96/-102)
src/pipe/gui/petrinet/PetriNetTab.java (+974/-1115)
src/pipe/gui/petrinet/action/EditAnnotationBackgroundAction.java (+2/-2)
src/pipe/gui/petrinet/action/EditAnnotationBorderAction.java (+4/-4)
src/pipe/gui/petrinet/action/EditNoteAction.java (+2/-2)
src/pipe/gui/petrinet/action/GuiAction.java (+1/-2)
src/pipe/gui/petrinet/action/ShowHideInfoAction.java (+2/-2)
src/pipe/gui/petrinet/action/SplitArcAction.java (+5/-5)
src/pipe/gui/petrinet/action/SplitArcPointAction.java (+4/-4)
src/pipe/gui/petrinet/action/ToggleArcPointAction.java (+4/-4)
src/pipe/gui/petrinet/animation/AnimationControlSidePanel.java (+24/-22)
src/pipe/gui/petrinet/animation/AnimationHistoryList.java (+11/-10)
src/pipe/gui/petrinet/animation/AnimationHistorySidePanel.java (+11/-7)
src/pipe/gui/petrinet/animation/AnimationSettingsDialog.java (+11/-9)
src/pipe/gui/petrinet/animation/Animator.java (+35/-33)
src/pipe/gui/petrinet/animation/EnabledTransitionsList.java (+12/-10)
src/pipe/gui/petrinet/animation/SimulationControl.java (+10/-11)
src/pipe/gui/petrinet/animation/SimulatorFocusTraversalPolicy.java (+21/-12)
src/pipe/gui/petrinet/dataLayer/DataLayer.java (+11/-33)
src/pipe/gui/petrinet/editor/AnnotationPanel.java (+2/-2)
src/pipe/gui/petrinet/editor/EditorFocusTraversalPolicy.java (+8/-6)
src/pipe/gui/petrinet/editor/GuardDialogue.java (+112/-92)
src/pipe/gui/petrinet/editor/PlaceEditorPanel.java (+715/-81)
src/pipe/gui/petrinet/editor/TAPNTransitionEditor.java (+61/-38)
src/pipe/gui/petrinet/graphicElements/AnnotationNote.java (+66/-51)
src/pipe/gui/petrinet/graphicElements/Arc.java (+56/-22)
src/pipe/gui/petrinet/graphicElements/ArcPath.java (+18/-15)
src/pipe/gui/petrinet/graphicElements/ArcPathPoint.java (+60/-20)
src/pipe/gui/petrinet/graphicElements/Drawable.java (+1/-1)
src/pipe/gui/petrinet/graphicElements/GraphicalElement.java (+1/-17)
src/pipe/gui/petrinet/graphicElements/NameLabel.java (+8/-9)
src/pipe/gui/petrinet/graphicElements/Note.java (+26/-30)
src/pipe/gui/petrinet/graphicElements/PetriNetObject.java (+37/-79)
src/pipe/gui/petrinet/graphicElements/PetriNetObjectWithLabel.java (+9/-9)
src/pipe/gui/petrinet/graphicElements/Place.java (+38/-19)
src/pipe/gui/petrinet/graphicElements/PlaceTransitionObject.java (+38/-7)
src/pipe/gui/petrinet/graphicElements/Transition.java (+45/-22)
src/pipe/gui/petrinet/graphicElements/Translatable.java (+1/-1)
src/pipe/gui/petrinet/graphicElements/Zoomable.java (+1/-1)
src/pipe/gui/petrinet/graphicElements/tapn/TimedInhibitorArcComponent.java (+36/-32)
src/pipe/gui/petrinet/graphicElements/tapn/TimedInputArcComponent.java (+54/-27)
src/pipe/gui/petrinet/graphicElements/tapn/TimedOutputArcComponent.java (+54/-34)
src/pipe/gui/petrinet/graphicElements/tapn/TimedPlaceComponent.java (+379/-285)
src/pipe/gui/petrinet/graphicElements/tapn/TimedTransitionComponent.java (+99/-37)
src/pipe/gui/petrinet/graphicElements/tapn/TimedTransportArcComponent.java (+106/-83)
src/pipe/gui/petrinet/handler/LabelHandler.java (+10/-10)
src/pipe/gui/petrinet/undo/AddAnnotationNoteCommand.java (+4/-4)
src/pipe/gui/petrinet/undo/AddArcPathPointEditCommand.java (+8/-8)
src/pipe/gui/petrinet/undo/AnnotationBorderEditCommand.java (+5/-5)
src/pipe/gui/petrinet/undo/AnnotationTextEditCommand.java (+6/-6)
src/pipe/gui/petrinet/undo/ArcPathPointTypeEditCommand.java (+5/-5)
src/pipe/gui/petrinet/undo/ArcTimeIntervalEditCommand.java (+6/-6)
src/pipe/gui/petrinet/undo/CompundCommand.java (+29/-0)
src/pipe/gui/petrinet/undo/DeleteAnnotationNoteCommand.java (+4/-4)
src/pipe/gui/petrinet/undo/DeleteArcPathPointEditCommand.java (+11/-11)
src/pipe/gui/petrinet/undo/TAPNElementCommand.java (+3/-3)
src/pipe/gui/petrinet/undo/TransitionRotationEditCommand.java (+5/-5)
src/pipe/gui/petrinet/undo/TranslatePetriNetObjectEditCommand.java (+6/-6)
src/pipe/gui/petrinet/undo/UndoManager.java (+16/-11)
src/pipe/gui/swingcomponents/EscapableDialog.java (+49/-0)
src/pipe/gui/swingcomponents/WidthAdjustingComboBox.java (+60/-0)
src/pipe/gui/swingcomponents/filebrowser/FileBrowser.java (+187/-0)
src/pipe/gui/undo/TimedPlaceInvariantEdit.java (+0/-33)
src/pipe/gui/widgets/EscapableDialog.java (+0/-49)
src/pipe/gui/widgets/filebrowser/FileBrowser.java (+0/-53)
src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java (+0/-178)
src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java (+0/-191)
src/resources/Example nets/ERK.tapn (+1/-1)
src/resources/Example nets/alternating-bit-protocol-components.tapn (+1/-1)
src/resources/Example nets/alternating-bit-protocol-transport.tapn (+1/-1)
src/resources/Example nets/alternating-bit-protocol.tapn (+1/-1)
src/resources/Example nets/cpn-packet.tapn (+351/-0)
src/resources/Example nets/fischer-protocol.tapn (+1/-1)
src/resources/Example nets/game-harddisk.tapn (+1/-1)
src/resources/Example nets/home-construction.tapn (+1/-1)
src/resources/Example nets/intro-example.tapn (+2/-2)
src/resources/Example nets/package-delivery.tapn (+1/-1)
src/resources/Example nets/philosophers.tapn (+539/-0)
src/resources/Example nets/producer-consumer.tapn (+1/-1)
src/resources/Example nets/referendum-colored.tapn (+285/-0)
src/resources/Example nets/referendum-timed-colored.tapn (+223/-0)
src/resources/Example nets/shortest-path.tapn (+1/-1)
src/resources/Example nets/token-ring.tapn (+437/-0)
src/resources/Example nets/train-level-crossing.tapn (+1/-1)
src/resources/Example nets/two-phase-locking.tapn (+1/-1)
src/resources/Example nets/untimedGame.tapn (+1/-1)
src/resources/Example nets/webserver.tapn (+1/-1)
src/resources/Example nets/workflow-advanced.tapn (+1/-1)
src/resources/Example nets/workflow-complaint.tapn (+1/-1)
src/resources/Example nets/workflow-medical.tapn (+1/-1)
src/resources/Example nets/workflow-payment.tapn (+1/-1)
src/resources/Example nets/workflow-simple.tapn (+1/-1)
tests/dk/aau/cs/io/TapnXmlLoaderTest.kt (+1/-1)
tests/dk/aau/cs/model/tapn/LocalTimedPlaceTest.kt (+107/-0)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/cpn-remove-add
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+417133@code.launchpad.net

This proposal supersedes a proposal from 2022-03-11.

Commit message

Removed the add button and moved the color type combobox

Description of the change

The color type comobox is moved to the left side of the dialog.
The undo/redo should be able to revert colortype changes as well.
Added placeholders in the color combobox to make more intuitive.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

If you make a product of enumaration and integer range, make a guard of that type. Things get broken. Also if you save/load the net again and click in the guard on equality sign, it will show that it is of type Dot, even though it was decleared as another color type. Also, the color type for equality etc. shows only too little of text and the > closing paranthesis for a tupple is broken (shows as \gte).

review: Needs Fixing
1629. By Jiri Srba

merged with cpn-gui-dev

1630. By Lena Ernstsen

variables are also displayed in color combobox for product types

Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.gradle'
2--- build.gradle 2021-08-11 11:19:19 +0000
3+++ build.gradle 2022-03-21 20:20:44 +0000
4@@ -1,27 +1,38 @@
5 plugins {
6 id 'java'
7 id 'application'
8- id 'org.jetbrains.kotlin.jvm' version '1.3.71'
9+ id 'org.jetbrains.kotlin.jvm' version '1.6.10'
10+ id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10'
11 id "ca.coglinc.javacc" version "2.4.0"
12 }
13
14 group 'net.tapaal'
15 version '4.0-SNAPSHOT'
16
17+var targetJavaVersion = JavaVersion.VERSION_11
18+var targetKotlinVersion = "1.6"
19 java {
20- sourceCompatibility = JavaVersion.VERSION_11
21- targetCompatibility = JavaVersion.VERSION_11
22-}
23+ sourceCompatibility = targetJavaVersion
24+ targetCompatibility = targetJavaVersion
25+}
26+
27+compileKotlin {
28+ sourceCompatibility = targetJavaVersion
29+ targetCompatibility = targetJavaVersion
30+
31+ kotlinOptions {
32+ jvmTarget = targetJavaVersion
33+ apiVersion = targetKotlinVersion
34+ languageVersion = targetKotlinVersion
35+ }
36+}
37+
38+mainClassName = 'TAPAAL'
39
40 repositories {
41 mavenCentral()
42 }
43
44-compileJavacc {
45- inputDirectory = file('src/')
46- //outputDirectory = file(project.buildDir.absolutePath + '/generated/javacc')
47-}
48-
49 //Set the soruce and resource dir
50 sourceSets {
51 main {
52@@ -43,52 +54,43 @@
53 }
54 }
55
56-mainClassName = 'TAPAAL'
57+compileJavacc {
58+ inputDirectory = file('src/')
59+}
60+
61
62 jar {
63 exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
64
65 //Sets the main call for the Jar, you can double click to run the jar file
66 manifest {
67- attributes 'Main-Class': 'TAPAAL'
68+ attributes (
69+ 'Main-Class': mainClassName
70+ )
71 }
72 //The following lines makes libs a part of the build jar file (standalone jar)
73 //from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
74 }
75
76 dependencies {
77- implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
78+ implementation group: 'commons-cli', name: 'commons-cli', version: '1.5.0'
79 implementation group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.5-1'
80- implementation group: 'net.java.dev.jna', name: 'jna', version: '4.5.1'
81- implementation 'org.jetbrains:annotations:16.0.2'
82- //compile group: 'com.apple', name: 'AppleJavaExtensions', version: '1.4' // Not working
83+ implementation group: 'net.java.dev.jna', name: 'jna', version: '5.9.0'
84+ implementation 'org.jetbrains:annotations:22.0.0'
85+ implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
86
87 //Add jars from libs dir
88- implementation fileTree(dir: 'libs', include: ['*.jar'])
89+ //implementation fileTree(dir: 'libs', include: ['*.jar'])
90
91- //Junit
92+ //JUnit
93 testImplementation(
94- 'org.junit.jupiter:junit-jupiter-api:5.4.2'
95+ 'org.junit.jupiter:junit-jupiter-api:5.8.2'
96 )
97 testRuntimeOnly(
98- 'org.junit.jupiter:junit-jupiter-engine:5.4.2',
99- 'org.junit.vintage:junit-vintage-engine:5.4.2'
100+ 'org.junit.jupiter:junit-jupiter-engine:5.8.2',
101+ 'org.junit.vintage:junit-vintage-engine:5.8.2'
102 )
103- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
104 }
105 test {
106 useJUnitPlatform()
107- afterTest { desc, result ->
108- logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
109- }
110-}
111-compileKotlin {
112- kotlinOptions {
113- jvmTarget = JavaVersion.VERSION_11
114- }
115-}
116-compileTestKotlin {
117- kotlinOptions {
118- jvmTarget = JavaVersion.VERSION_11
119- }
120 }
121
122=== modified file 'gradle/wrapper/gradle-wrapper.jar'
123Binary files gradle/wrapper/gradle-wrapper.jar and gradle/wrapper/gradle-wrapper.jar differ
124=== modified file 'gradle/wrapper/gradle-wrapper.properties'
125--- gradle/wrapper/gradle-wrapper.properties 2020-04-06 12:41:08 +0000
126+++ gradle/wrapper/gradle-wrapper.properties 2022-03-21 20:20:44 +0000
127@@ -1,6 +1,5 @@
128-#Mon Apr 06 14:40:09 CEST 2020
129-distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
130-distributionBase=GRADLE_USER_HOME
131-distributionPath=wrapper/dists
132-zipStorePath=wrapper/dists
133-zipStoreBase=GRADLE_USER_HOME
134+distributionBase=GRADLE_USER_HOME
135+distributionPath=wrapper/dists
136+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
137+zipStoreBase=GRADLE_USER_HOME
138+zipStorePath=wrapper/dists
139
140=== modified file 'gradlew'
141--- gradlew 2020-09-01 08:14:52 +0000
142+++ gradlew 2022-03-21 20:20:44 +0000
143@@ -82,6 +82,7 @@
144
145 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
146
147+
148 # Determine the Java command to use to start the JVM.
149 if [ -n "$JAVA_HOME" ] ; then
150 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
151@@ -129,6 +130,7 @@
152 if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
153 APP_HOME=`cygpath --path --mixed "$APP_HOME"`
154 CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
155+
156 JAVACMD=`cygpath --unix "$JAVACMD"`
157
158 # We build the pattern for arguments to be converted via cygpath
159
160=== modified file 'gradlew.bat'
161--- gradlew.bat 2020-03-28 10:29:30 +0000
162+++ gradlew.bat 2022-03-21 20:20:44 +0000
163@@ -40,7 +40,7 @@
164
165 set JAVA_EXE=java.exe
166 %JAVA_EXE% -version >NUL 2>&1
167-if "%ERRORLEVEL%" == "0" goto init
168+if "%ERRORLEVEL%" == "0" goto execute
169
170 echo.
171 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
172@@ -54,7 +54,7 @@
173 set JAVA_HOME=%JAVA_HOME:"=%
174 set JAVA_EXE=%JAVA_HOME%/bin/java.exe
175
176-if exist "%JAVA_EXE%" goto init
177+if exist "%JAVA_EXE%" goto execute
178
179 echo.
180 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
181@@ -64,28 +64,14 @@
182
183 goto fail
184
185-:init
186-@rem Get command-line arguments, handling Windows variants
187-
188-if not "%OS%" == "Windows_NT" goto win9xME_args
189-
190-:win9xME_args
191-@rem Slurp the command line arguments.
192-set CMD_LINE_ARGS=
193-set _SKIP=2
194-
195-:win9xME_args_slurp
196-if "x%~1" == "x" goto execute
197-
198-set CMD_LINE_ARGS=%*
199-
200 :execute
201 @rem Setup the command line
202
203 set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
204
205+
206 @rem Execute Gradle
207-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
208+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
209
210 :end
211 @rem End local scope for the variables with windows NT shell
212
213=== modified file 'src/dk/aau/cs/TCTL/AritmeticOperator.java'
214--- src/dk/aau/cs/TCTL/AritmeticOperator.java 2020-11-06 19:41:50 +0000
215+++ src/dk/aau/cs/TCTL/AritmeticOperator.java 2022-03-21 20:20:44 +0000
216@@ -4,7 +4,7 @@
217
218 public class AritmeticOperator extends TCTLAbstractStateProperty {
219
220- String operator;
221+ final String operator;
222
223 public AritmeticOperator(String operator) {
224 this.operator = operator;
225
226=== modified file 'src/dk/aau/cs/TCTL/LTLGNode.java'
227--- src/dk/aau/cs/TCTL/LTLGNode.java 2021-10-08 06:26:14 +0000
228+++ src/dk/aau/cs/TCTL/LTLGNode.java 2022-03-21 20:20:44 +0000
229@@ -20,7 +20,7 @@
230 }
231
232 public LTLGNode() {
233- this.property = new TCTLStatePlaceHolder();;
234+ this.property = new TCTLStatePlaceHolder();
235 this.property.setParent(this);
236 }
237
238
239=== modified file 'src/dk/aau/cs/TCTL/LTLUNode.java'
240--- src/dk/aau/cs/TCTL/LTLUNode.java 2021-10-08 06:26:14 +0000
241+++ src/dk/aau/cs/TCTL/LTLUNode.java 2022-03-21 20:20:44 +0000
242@@ -54,7 +54,7 @@
243 StringPosition leftPos = new StringPosition(leftStart, leftEnd, left);
244
245 int rightStart = right.isSimpleProperty() ? 0 : 1;
246- rightStart += leftEnd + 3 + + (left.isSimpleProperty() ? 0 : 1);
247+ rightStart += leftEnd + 3 + (left.isSimpleProperty() ? 0 : 1);
248 int rightEnd = rightStart + right.toString().length();
249 StringPosition rightPos = new StringPosition(rightStart, rightEnd, right);
250
251
252=== modified file 'src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj'
253--- src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj 2021-09-30 07:05:48 +0000
254+++ src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj 2022-03-21 20:20:44 +0000
255@@ -127,12 +127,12 @@
256 TCTLAbstractStateProperty child = null;
257 }
258 {
259- (
260- <EF> child = OrExpr() {return new TCTLEFNode(child); }
261- | <EG> child = OrExpr() {return new TCTLEGNode(child); }
262- | <AF> child = OrExpr() {return new TCTLAFNode(child); }
263- | <AG> child = OrExpr() {return new TCTLAGNode(child); }
264- )
265+ (
266+ <EF> child = OrExpr() {return new TCTLEFNode(child); }
267+ | <EG> child = OrExpr() {return new TCTLEGNode(child); }
268+ | <AF> child = OrExpr() {return new TCTLAFNode(child); }
269+ | <AG> child = OrExpr() {return new TCTLAGNode(child); }
270+ )
271 }
272
273 TCTLAbstractStateProperty OrExpr() :
274
275=== modified file 'src/dk/aau/cs/TCTL/StringPosition.java'
276--- src/dk/aau/cs/TCTL/StringPosition.java 2011-02-03 19:03:15 +0000
277+++ src/dk/aau/cs/TCTL/StringPosition.java 2022-03-21 20:20:44 +0000
278@@ -4,10 +4,9 @@
279
280 private int startIndex;
281 private int endIndex;
282- private TCTLAbstractProperty object;
283+ private final TCTLAbstractProperty object;
284
285- public StringPosition(int startIndex, int endIndex,
286- TCTLAbstractProperty object) {
287+ public StringPosition(int startIndex, int endIndex, TCTLAbstractProperty object) {
288 this.startIndex = startIndex;
289 this.endIndex = endIndex;
290 this.object = object;
291
292=== modified file 'src/dk/aau/cs/TCTL/TCTLAUNode.java'
293--- src/dk/aau/cs/TCTL/TCTLAUNode.java 2020-11-06 19:41:50 +0000
294+++ src/dk/aau/cs/TCTL/TCTLAUNode.java 2022-03-21 20:20:44 +0000
295@@ -50,7 +50,7 @@
296 StringPosition leftPos = new StringPosition(leftStart, leftEnd, left);
297
298 int rightStart = right.isSimpleProperty() ? 0 : 1;
299- rightStart += leftEnd + 3 + + (left.isSimpleProperty() ? 0 : 1);
300+ rightStart += leftEnd + 3 + (left.isSimpleProperty() ? 0 : 1);
301 int rightEnd = rightStart + right.toString().length();
302 StringPosition rightPos = new StringPosition(rightStart, rightEnd, right);
303
304
305=== modified file 'src/dk/aau/cs/TCTL/TCTLAbstractProperty.java'
306--- src/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2021-08-16 07:29:37 +0000
307+++ src/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2022-03-21 20:20:44 +0000
308@@ -2,8 +2,6 @@
309
310 import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
311
312-import java.util.Locale;
313-
314 public abstract class TCTLAbstractProperty {
315
316 // used to determine whether to put parenthesis around the property
317
318=== modified file 'src/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java'
319--- src/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java 2011-02-03 19:03:15 +0000
320+++ src/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java 2022-03-21 20:20:44 +0000
321@@ -18,18 +18,4 @@
322
323 @Override
324 public abstract TCTLAbstractStateProperty copy();
325-
326- // public abstract void accept(ICSLVisitor visitor) throws
327- // ModelCheckingException;
328-
329- // protected abstract void setCompositionality(boolean
330- // withinSteadyStateOperator);
331-
332- // public void setCompositionality() {
333- // setCompositionality(false);
334- // }
335- //
336- // public boolean isCompositional() {
337- // return isCompositional;
338- // }
339 }
340
341=== modified file 'src/dk/aau/cs/TCTL/TCTLAndListNode.java'
342--- src/dk/aau/cs/TCTL/TCTLAndListNode.java 2020-11-06 19:41:50 +0000
343+++ src/dk/aau/cs/TCTL/TCTLAndListNode.java 2022-03-21 20:20:44 +0000
344@@ -77,8 +77,7 @@
345 s.append(" and ");
346 }
347
348- s.append(prop.isSimpleProperty() ? prop.toString() : "("
349- + prop.toString() + ")");
350+ s.append(prop.isSimpleProperty() ? prop.toString() : "(" + prop + ")");
351 firstTime = false;
352 }
353
354
355=== modified file 'src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java'
356--- src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java 2020-11-06 19:41:50 +0000
357+++ src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java 2022-03-21 20:20:44 +0000
358@@ -94,31 +94,6 @@
359 return false;
360 }
361
362-/* @Override
363- public StringPosition[] getChildren() {
364- StringPosition[] children = new StringPosition[2];
365-
366- int start = 0;
367- int end = 0;
368- boolean leftSimpleProperty = left.isSimpleProperty();
369-
370- start = leftSimpleProperty ? 0 : 1;
371- end = start + left.toString().length();
372-
373- StringPosition posLeft = new StringPosition(start, end, left);
374-
375- start = end + 5 + (right.isSimpleProperty() ? 0 : 1)
376- + (leftSimpleProperty ? 0 : 1);
377-
378- end = start + right.toString().length();
379-
380- StringPosition posRight = new StringPosition(start, end, right);
381-
382- children[0] = posLeft;
383- children[1] = posRight;
384- return children;
385- }*/
386-
387 @Override
388 public TCTLAbstractProperty findFirstPlaceHolder() {
389 TCTLAbstractProperty rightP = right.findFirstPlaceHolder();
390
391=== modified file 'src/dk/aau/cs/TCTL/TCTLConstNode.java'
392--- src/dk/aau/cs/TCTL/TCTLConstNode.java 2020-11-06 19:41:50 +0000
393+++ src/dk/aau/cs/TCTL/TCTLConstNode.java 2022-03-21 20:20:44 +0000
394@@ -4,7 +4,7 @@
395
396 public class TCTLConstNode extends TCTLAbstractStateProperty {
397
398- int constant;
399+ final int constant;
400
401 public TCTLConstNode(int constant) {
402 this.constant = constant;
403
404=== modified file 'src/dk/aau/cs/TCTL/TCTLEFNode.java'
405--- src/dk/aau/cs/TCTL/TCTLEFNode.java 2021-09-14 20:13:01 +0000
406+++ src/dk/aau/cs/TCTL/TCTLEFNode.java 2022-03-21 20:20:44 +0000
407@@ -2,8 +2,6 @@
408
409 import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
410
411-import java.util.HashMap;
412-
413 public class TCTLEFNode extends TCTLAbstractPathProperty {
414
415 private TCTLAbstractStateProperty property;
416
417=== modified file 'src/dk/aau/cs/TCTL/TCTLOrListNode.java'
418--- src/dk/aau/cs/TCTL/TCTLOrListNode.java 2020-11-06 19:41:50 +0000
419+++ src/dk/aau/cs/TCTL/TCTLOrListNode.java 2022-03-21 20:20:44 +0000
420@@ -77,8 +77,7 @@
421 s.append(" or ");
422 }
423
424- s.append(prop.isSimpleProperty() ? prop.toString() : "("
425- + prop.toString() + ")");
426+ s.append(prop.isSimpleProperty() ? prop.toString() : "(" + prop + ")");
427 firstTime = false;
428 }
429
430
431=== modified file 'src/dk/aau/cs/TCTL/TCTLPlusListNode.java'
432--- src/dk/aau/cs/TCTL/TCTLPlusListNode.java 2020-11-06 19:41:50 +0000
433+++ src/dk/aau/cs/TCTL/TCTLPlusListNode.java 2022-03-21 20:20:44 +0000
434@@ -8,7 +8,7 @@
435 //Represents a list of terms and the operators between then, these are all stored in the terms list
436 public class TCTLPlusListNode extends TCTLAbstractStateProperty {
437
438- ArrayList<TCTLAbstractStateProperty> terms;
439+ final ArrayList<TCTLAbstractStateProperty> terms;
440
441 public TCTLPlusListNode(ArrayList<TCTLAbstractStateProperty> terms) {
442 this.terms = terms;
443
444=== modified file 'src/dk/aau/cs/TCTL/TCTLTermListNode.java'
445--- src/dk/aau/cs/TCTL/TCTLTermListNode.java 2020-11-06 19:41:50 +0000
446+++ src/dk/aau/cs/TCTL/TCTLTermListNode.java 2022-03-21 20:20:44 +0000
447@@ -8,7 +8,7 @@
448 //Represents a list of factors and the operators between then, these are all stored in the factors list
449 public class TCTLTermListNode extends TCTLAbstractStateProperty {
450
451- ArrayList<TCTLAbstractStateProperty> factors;
452+ final ArrayList<TCTLAbstractStateProperty> factors;
453
454 public TCTLTermListNode(ArrayList<TCTLAbstractStateProperty> factors) {
455 this.factors = factors;
456
457=== modified file 'src/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java'
458--- src/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java 2017-05-14 19:42:09 +0000
459+++ src/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java 2022-03-21 20:20:44 +0000
460@@ -44,9 +44,9 @@
461 XMLCTLQueryParser parser = new XMLCTLQueryParser(prop, queryWrapper);
462 queryWrapper.setName(parser.parsePropertyName());
463
464- try{
465+ try {
466 queryWrapper.setProp(parser.AbstractProperty());
467- } catch (XMLQueryParseException e){
468+ } catch (XMLQueryParseException e) {
469 queryWrapper.setException(e);
470 Logger.log(e);
471 return false;
472@@ -87,14 +87,14 @@
473 }
474
475 private TCTLAbstractProperty parseFormula(Node property)
476- throws XMLQueryParseException{
477+ throws XMLQueryParseException {
478
479 TCTLAbstractProperty childProperty;
480 Node child = getFirstChildNode(property);
481 String nodeName = property.getNodeName();
482
483 String childNodeName = "";
484- if(child != null){
485+ if (child != null) {
486 childNodeName = child.getNodeName();
487 }
488
489@@ -366,38 +366,40 @@
490 } else if(nodeName.equals("integer-ge")){
491 return new TCTLAtomicPropositionNode(subformula1, ">=", subformula2);
492 }
493- } else if (nodeName.equals("is-fireable")){
494- // Construct a nested disjunction of transitions.
495-
496- children = getAllChildren(property);
497-
498- if(children.isEmpty()){
499+ } else if (nodeName.equals("is-fireable")) {
500+ // Construct a nested disjunction of transitions.
501+
502+ children = getAllChildren(property);
503+
504+ if (children.isEmpty()) {
505 throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
506- } else if(children.size() == 1) {
507- String[] splits = getText(children.get(0)).replace("\n", "").split("\\.");
508-
509- // Check if transition contains a template name
510- if(splits.length > 1){
511- return new TCTLTransitionNode(splits[0], splits[1]);
512+ } else if (children.size() == 1) {
513+ String[] splits = getText(children.get(0)).replace("\n", "").split("\\.");
514+
515+ // Check if transition contains a template name
516+ if (splits.length > 1) {
517+ return new TCTLTransitionNode(splits[0], splits[1]);
518 } else {
519- return new TCTLTransitionNode(splits[0]);
520- }
521- } else {
522- ArrayList<TCTLAbstractStateProperty> transitions = new ArrayList<TCTLAbstractStateProperty>();
523-
524- for(Node n : children) {
525- String[] splits = getText(n).replace("\n", "").split("\\.");
526-
527- // Check if transition contains a template name
528- if(splits.length > 1){
529- transitions.add(new TCTLTransitionNode(splits[0], splits[1]));
530- } else {
531- transitions.add(new TCTLTransitionNode(splits[0]));
532- }
533- }
534- return new TCTLOrListNode(transitions);
535- }
536- } else{
537+ return new TCTLTransitionNode(splits[0]);
538+ }
539+ } else {
540+ ArrayList<TCTLAbstractStateProperty> transitions = new ArrayList<TCTLAbstractStateProperty>();
541+
542+ for (Node n : children) {
543+ String[] splits = getText(n).replace("\n", "").split("\\.");
544+
545+ // Check if transition contains a template name
546+ if (splits.length > 1) {
547+ transitions.add(new TCTLTransitionNode(splits[0], splits[1]));
548+ } else {
549+ transitions.add(new TCTLTransitionNode(splits[0]));
550+ }
551+ }
552+ return new TCTLOrListNode(transitions);
553+ }
554+ } else if (nodeName.equals("control")) {
555+ return parseFormula(child);
556+ }else{
557 parseFormula(property);
558 }
559
560
561=== modified file 'src/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java'
562--- src/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java 2014-05-22 20:26:41 +0000
563+++ src/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java 2022-03-21 20:20:44 +0000
564@@ -3,7 +3,7 @@
565 import dk.aau.cs.TCTL.TCTLPlaceNode;
566
567 public class AddTemplateVisitor extends VisitorBase {
568- private String templateName;
569+ private final String templateName;
570
571 public AddTemplateVisitor(String templateName) {
572 this.templateName = templateName;
573
574=== modified file 'src/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java'
575--- src/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java 2019-03-22 10:13:18 +0000
576+++ src/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java 2022-03-21 20:20:44 +0000
577@@ -7,8 +7,8 @@
578 protected static final String PLOCK = "P_lock";
579 protected static final String TOKEN_TEMPLATE_NAME = "Token";
580
581- private boolean useSymmetry;
582- private int totalTokens;
583+ private final boolean useSymmetry;
584+ private final int totalTokens;
585
586 public BroadcastTranslationQueryVisitor(boolean useSymmetry, int totalTokens) {
587 this.useSymmetry = useSymmetry;
588
589=== modified file 'src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java'
590--- src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2021-10-08 06:22:05 +0000
591+++ src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2022-03-21 20:20:44 +0000
592@@ -40,24 +40,27 @@
593 private static final String XML_TRANSITION = "transition";
594 private static final String XML_INTEGERSUM = "integer-sum";
595 private static final String XML_INTEGERPRODUCT = "integer-product";
596- private static final String XML_INTEGERDIFFERENCE = "integer-difference";
597+ private static final String XML_INTEGERDIFFERENCE = "integer-difference";
598+ private static final String CONTROL = "control";
599
600- private StringBuffer XMLQuery;
601-
602- public CTLQueryVisitor() {
603- this.XMLQuery = new StringBuffer();
604- }
605-
606- public String getXMLQueryFor(TCTLAbstractProperty property, String queryName) {
607- buildXMLQuery(property, queryName);
608- return getFormatted();
609- }
610+ private final StringBuffer XMLQuery;
611+
612+ public CTLQueryVisitor() {
613+ this.XMLQuery = new StringBuffer();
614+ }
615+
616+ public String getXMLQueryFor(TCTLAbstractProperty property, String queryName, boolean control) {
617+ buildXMLQuery(property, queryName, control);
618+ return getFormatted();
619+ }
620
621- public void buildXMLQuery(TCTLAbstractProperty property, String queryName) {
622- XMLQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA));
623+ public void buildXMLQuery(TCTLAbstractProperty property, String queryName, boolean control) {
624+ XMLQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA));
625+ if (control) XMLQuery.append(startTag(CONTROL));
626 property.accept(this, null);
627- XMLQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP));
628- }
629+ if (control) XMLQuery.append(endTag(CONTROL));
630+ XMLQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP));
631+ }
632
633 public String getFormatted() {
634 XMLFormatter formatter = new XMLFormatter();
635@@ -175,13 +178,17 @@
636 assert termListNode.getProperties().get(1) instanceof AritmeticOperator;
637 AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1);
638 String op = operator.toString();
639- if (op.equals("+")) {
640- createList(termListNode.getProperties(), context, XML_INTEGERSUM);
641- } else if (op.equals("*")) {
642- createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT);
643- } else if (op.equals("-")) {
644- createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE);
645- }
646+ switch (op) {
647+ case "+":
648+ createList(termListNode.getProperties(), context, XML_INTEGERSUM);
649+ break;
650+ case "*":
651+ createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT);
652+ break;
653+ case "-":
654+ createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE);
655+ break;
656+ }
657 }
658
659 private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) {
660@@ -213,7 +220,7 @@
661 }
662
663 public void visit(TCTLConstNode tctlConstNode, Object context){
664- XMLQuery.append(wrapInTag(String.valueOf(tctlConstNode.getConstant()) + "", XML_INTEGERCONSTANT));
665+ XMLQuery.append(wrapInTag(tctlConstNode.getConstant() + "", XML_INTEGERCONSTANT));
666 }
667
668 public void visit(TCTLPlaceNode tctlPlaceNode, Object context){
669@@ -232,23 +239,31 @@
670 public void visit(TCTLAtomicPropositionNode atomicPropositionNode,
671 Object context) {
672 String opTest = atomicPropositionNode.getOp();
673- String op = new String();
674-
675- if (opTest.equals("<")){
676- op = XML_INTEGERLT;
677- } else if(opTest.equals("<=")){
678- op = XML_INTEGERLE;
679- } else if(opTest.equals("=")){
680- op = XML_INTEGEREQ;
681- } else if(opTest.equals("!=")){
682- op = XML_INTEGERNE;
683- } else if(opTest.equals(">")){
684- op = XML_INTEGERGT;
685- } else if(opTest.equals(">=")){
686- op = XML_INTEGERGE;
687- } else {
688- op = "MISSING_OPERATOR";
689- }
690+ String op;
691+
692+ switch (opTest) {
693+ case "<":
694+ op = XML_INTEGERLT;
695+ break;
696+ case "<=":
697+ op = XML_INTEGERLE;
698+ break;
699+ case "=":
700+ op = XML_INTEGEREQ;
701+ break;
702+ case "!=":
703+ op = XML_INTEGERNE;
704+ break;
705+ case ">":
706+ op = XML_INTEGERGT;
707+ break;
708+ case ">=":
709+ op = XML_INTEGERGE;
710+ break;
711+ default:
712+ op = "MISSING_OPERATOR";
713+ break;
714+ }
715
716 XMLQuery.append(startTag(op));
717 atomicPropositionNode.getLeft().accept(this, context);
718
719=== modified file 'src/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java'
720--- src/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java 2019-03-22 10:13:18 +0000
721+++ src/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java 2022-03-21 20:20:44 +0000
722@@ -11,13 +11,13 @@
723 protected static final String PLOCK = "P_lock";
724 protected static final String TOKEN_TEMPLATE_NAME = "Token";
725
726- private boolean useSymmetry;
727- private int totalTokens;
728- private TimedArcPetriNet model;
729- private Hashtable<String, Boolean> placeNameToTimed;
730- private int maxDegDif;
731- private int initTransitions;
732- private int maxTimeIn;
733+ private final boolean useSymmetry;
734+ private final int totalTokens;
735+ private final TimedArcPetriNet model;
736+ private final Hashtable<String, Boolean> placeNameToTimed;
737+ private final int maxDegDif;
738+ private final int initTransitions;
739+ private final int maxTimeIn;
740
741 public CombiTranslationQueryVisitor(boolean useSymmetry, int totalTokens, TimedArcPetriNet model, Hashtable<String, Boolean> placeNameToTimed, int maxDegDif, int initTransitions, int maxTimeIn) {
742 this.useSymmetry = useSymmetry;
743
744=== modified file 'src/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java'
745--- src/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java 2014-05-22 20:26:41 +0000
746+++ src/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java 2022-03-21 20:20:44 +0000
747@@ -6,7 +6,7 @@
748
749 public class ContainsPlaceWithDisabledTemplateVisitor extends VisitorBase implements ITCTLVisitor {
750
751- private TimedArcPetriNetNetwork network;
752+ private final TimedArcPetriNetNetwork network;
753
754 public ContainsPlaceWithDisabledTemplateVisitor(TimedArcPetriNetNetwork network){
755 this.network = network;
756@@ -14,15 +14,18 @@
757
758 @Override
759 public void visit(TCTLPlaceNode placeNode, Object context) {
760- if(placeNode.getTemplate().equals("") && network.getSharedPlaceByName(placeNode.getPlace()) != null)
761- return;
762+ if(placeNode.getTemplate().equals("") && network.getSharedPlaceByName(placeNode.getPlace()) != null) {
763+ return;
764+ }
765
766 for(TimedArcPetriNet net : network.activeTemplates()) {
767- if(placeNode.getTemplate().equals(net.name()) && net.getPlaceByName(placeNode.getPlace()) != null)
768- return;
769+ if(placeNode.getTemplate().equals(net.name()) && net.getPlaceByName(placeNode.getPlace()) != null) {
770+ return;
771+ }
772 }
773
774- if(context instanceof BooleanResult)
775- ((BooleanResult)context).setResult(false);
776+ if(context instanceof BooleanResult) {
777+ ((BooleanResult)context).setResult(false);
778+ }
779 }
780 }
781
782=== modified file 'src/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java'
783--- src/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java 2014-05-22 20:26:41 +0000
784+++ src/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java 2022-03-21 20:20:44 +0000
785@@ -3,7 +3,7 @@
786 import dk.aau.cs.TCTL.TCTLPlaceNode;
787
788 public class ContainsSharedPlaceVisitor extends VisitorBase implements ITCTLVisitor {
789- private String sharedPlaceName;
790+ private final String sharedPlaceName;
791
792 public ContainsSharedPlaceVisitor(String sharedPlaceName){
793 this.sharedPlaceName = sharedPlaceName;
794@@ -11,8 +11,9 @@
795
796 @Override
797 public void visit(TCTLPlaceNode placeNode, Object context) {
798- if(placeNode.getTemplate().equals("") && placeNode.getPlace().equals(sharedPlaceName))
799- ((BooleanResult)context).setResult(true);
800+ if(placeNode.getTemplate().equals("") && placeNode.getPlace().equals(sharedPlaceName)) {
801+ ((BooleanResult)context).setResult(true);
802+ }
803 }
804
805 }
806
807=== modified file 'src/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java'
808--- src/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java 2017-03-12 00:33:00 +0000
809+++ src/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java 2022-03-21 20:20:44 +0000
810@@ -3,7 +3,7 @@
811 import dk.aau.cs.TCTL.TCTLTransitionNode;
812
813 public class ContainsSharedTransitionVisitor extends VisitorBase implements ITCTLVisitor {
814- private String sharedTransitionName;
815+ private final String sharedTransitionName;
816
817 public ContainsSharedTransitionVisitor(String sharedTransitionName){
818 this.sharedTransitionName = sharedTransitionName;
819
820=== modified file 'src/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java'
821--- src/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java 2014-11-01 09:31:54 +0000
822+++ src/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java 2022-03-21 20:20:44 +0000
823@@ -1,8 +1,3 @@
824-/*
825- * To change this license header, choose License Headers in Project Properties.
826- * To change this template file, choose Tools | Templates
827- * and open the template in the editor.
828- */
829 package dk.aau.cs.TCTL.visitors;
830
831 import dk.aau.cs.TCTL.TCTLAbstractProperty;
832@@ -10,13 +5,9 @@
833 import dk.aau.cs.util.Tuple;
834 import java.util.ArrayList;
835
836-/**
837- *
838- * @author jakob
839- */
840 public class FixAbbrivPlaceNames extends VisitorBase {
841
842- private ArrayList<Tuple<String, String>> templatePlaceNames;
843+ private final ArrayList<Tuple<String, String>> templatePlaceNames;
844
845 public FixAbbrivPlaceNames(ArrayList<Tuple<String, String>> templatePlaceNames) {
846 this.templatePlaceNames = templatePlaceNames;
847
848=== modified file 'src/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java'
849--- src/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java 2017-03-12 00:33:00 +0000
850+++ src/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java 2022-03-21 20:20:44 +0000
851@@ -12,7 +12,7 @@
852
853 public class FixAbbrivTransitionNames extends VisitorBase {
854
855- private ArrayList<Tuple<String, String>> templateTransitionNames;
856+ private final ArrayList<Tuple<String, String>> templateTransitionNames;
857
858 public FixAbbrivTransitionNames(ArrayList<Tuple<String, String>> templateTransitionNames) {
859 this.templateTransitionNames = templateTransitionNames;
860
861=== modified file 'src/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java'
862--- src/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java 2013-05-18 21:26:56 +0000
863+++ src/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java 2022-03-21 20:20:44 +0000
864@@ -16,7 +16,7 @@
865 ((Context)context).hasDeadlock = true;
866 }
867
868- private class Context{
869+ private static class Context{
870 public boolean hasDeadlock = true;
871 }
872 }
873
874=== modified file 'src/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java'
875--- src/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java 2017-08-03 11:48:35 +0000
876+++ src/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java 2022-03-21 20:20:44 +0000
877@@ -4,7 +4,7 @@
878
879 public class IsReachabilityVisitor extends VisitorBase {
880
881- private class Context{
882+ private static class Context{
883 public boolean isReachability = true;
884 public int nTempOp = 0; // number of temporal operators
885 }
886
887=== modified file 'src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java'
888--- src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 2021-10-14 06:28:05 +0000
889+++ src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 2022-03-21 20:20:44 +0000
890@@ -42,7 +42,7 @@
891 private static final String XML_INTEGERPRODUCT = "integer-product";
892 private static final String XML_INTEGERDIFFERENCE = "integer-difference";
893
894- private StringBuffer XMLQuery;
895+ private final StringBuffer XMLQuery;
896
897 public LTLQueryVisitor() {
898 this.XMLQuery = new StringBuffer();
899@@ -137,12 +137,16 @@
900 assert termListNode.getProperties().get(1) instanceof AritmeticOperator;
901 AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1);
902 String op = operator.toString();
903- if (op.equals("+")) {
904- createList(termListNode.getProperties(), context, XML_INTEGERSUM);
905- } else if (op.equals("*")) {
906- createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT);
907- } else if (op.equals("-")) {
908- createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE);
909+ switch (op) {
910+ case "+":
911+ createList(termListNode.getProperties(), context, XML_INTEGERSUM);
912+ break;
913+ case "*":
914+ createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT);
915+ break;
916+ case "-":
917+ createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE);
918+ break;
919 }
920 }
921
922@@ -175,7 +179,7 @@
923 }
924
925 public void visit(TCTLConstNode tctlConstNode, Object context){
926- XMLQuery.append(wrapInTag(String.valueOf(tctlConstNode.getConstant()) + "", XML_INTEGERCONSTANT));
927+ XMLQuery.append(wrapInTag(tctlConstNode.getConstant() + "", XML_INTEGERCONSTANT));
928 }
929
930 public void visit(TCTLPlaceNode tctlPlaceNode, Object context){
931@@ -194,22 +198,30 @@
932 public void visit(TCTLAtomicPropositionNode atomicPropositionNode,
933 Object context) {
934 String opTest = atomicPropositionNode.getOp();
935- String op = new String();
936+ String op;
937
938- if (opTest.equals("<")){
939- op = XML_INTEGERLT;
940- } else if(opTest.equals("<=")){
941- op = XML_INTEGERLE;
942- } else if(opTest.equals("=")){
943- op = XML_INTEGEREQ;
944- } else if(opTest.equals("!=")){
945- op = XML_INTEGERNE;
946- } else if(opTest.equals(">")){
947- op = XML_INTEGERGT;
948- } else if(opTest.equals(">=")){
949- op = XML_INTEGERGE;
950- } else {
951- op = "MISSING_OPERATOR";
952+ switch (opTest) {
953+ case "<":
954+ op = XML_INTEGERLT;
955+ break;
956+ case "<=":
957+ op = XML_INTEGERLE;
958+ break;
959+ case "=":
960+ op = XML_INTEGEREQ;
961+ break;
962+ case "!=":
963+ op = XML_INTEGERNE;
964+ break;
965+ case ">":
966+ op = XML_INTEGERGT;
967+ break;
968+ case ">=":
969+ op = XML_INTEGERGE;
970+ break;
971+ default:
972+ op = "MISSING_OPERATOR";
973+ break;
974 }
975
976 XMLQuery.append(startTag(op));
977
978=== modified file 'src/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java'
979--- src/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java 2019-03-23 07:51:29 +0000
980+++ src/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java 2022-03-21 20:20:44 +0000
981@@ -11,8 +11,8 @@
982 protected static final String LOCK_BOOL = "lock";
983
984 protected static final String TOKEN_TEMPLATE_NAME = "Token";
985- private boolean useSymmetry;
986- private int totalTokens;
987+ private final boolean useSymmetry;
988+ private final int totalTokens;
989
990 public OptimizedStandardTranslationQueryVisitor(int totalTokens, boolean useSymmetry) {
991 this.useSymmetry = useSymmetry;
992
993=== modified file 'src/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java'
994--- src/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java 2014-05-22 20:26:41 +0000
995+++ src/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java 2022-03-21 20:20:44 +0000
996@@ -4,8 +4,8 @@
997
998 public class RenamePlaceTCTLVisitor extends VisitorBase{
999
1000- private String oldPlaceName;
1001- private String newPlaceName;
1002+ private final String oldPlaceName;
1003+ private final String newPlaceName;
1004
1005 public RenamePlaceTCTLVisitor(String oldName, String newName) {
1006 oldPlaceName = oldName;
1007
1008=== modified file 'src/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java'
1009--- src/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java 2017-03-12 00:33:00 +0000
1010+++ src/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java 2022-03-21 20:20:44 +0000
1011@@ -4,8 +4,8 @@
1012
1013 public class RenameTransitionTCTLVisitor extends VisitorBase{
1014
1015- private String oldTransitionName;
1016- private String newTransitionName;
1017+ private final String oldTransitionName;
1018+ private final String newTransitionName;
1019
1020 public RenameTransitionTCTLVisitor(String oldName, String newName) {
1021 oldTransitionName = oldName;
1022
1023=== modified file 'src/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java'
1024--- src/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java 2019-03-23 07:51:29 +0000
1025+++ src/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java 2022-03-21 20:20:44 +0000
1026@@ -12,7 +12,7 @@
1027
1028 protected static final String TOKEN_TEMPLATE_NAME = "Token";
1029
1030- private int totalTokens;
1031+ private final int totalTokens;
1032
1033 public StandardTranslationQueryVisitor(int totalTokens) {
1034 this.totalTokens = totalTokens;
1035
1036=== modified file 'src/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java'
1037--- src/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java 2017-03-12 00:33:00 +0000
1038+++ src/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java 2022-03-21 20:20:44 +0000
1039@@ -9,7 +9,7 @@
1040
1041 public class VerifyPlaceNamesVisitor extends VisitorBase {
1042
1043- private ArrayList<Tuple<String, String>> templatePlaceNames;
1044+ private final ArrayList<Tuple<String, String>> templatePlaceNames;
1045
1046 public VerifyPlaceNamesVisitor(ArrayList<Tuple<String, String>> templatePlaceNames) {
1047 this.templatePlaceNames = templatePlaceNames;
1048@@ -31,11 +31,10 @@
1049 c.setResult(false);
1050 }
1051 }
1052-
1053- // / context class
1054- public class Context {
1055+
1056+ public static class Context {
1057 private Boolean result;
1058- private HashSet<String> incorrectPlaceNames;
1059+ private final HashSet<String> incorrectPlaceNames;
1060
1061 public Boolean getResult() {
1062 return result;
1063
1064=== modified file 'src/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java'
1065--- src/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java 2017-03-12 00:33:00 +0000
1066+++ src/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java 2022-03-21 20:20:44 +0000
1067@@ -8,7 +8,7 @@
1068 import dk.aau.cs.util.Tuple;
1069
1070 public class VerifyTransitionNamesVisitor extends VisitorBase {
1071- private ArrayList<Tuple<String, String>> templateTransitionNames;
1072+ private final ArrayList<Tuple<String, String>> templateTransitionNames;
1073
1074 public VerifyTransitionNamesVisitor(ArrayList<Tuple<String, String>> templateTransitionNames) {
1075 this.templateTransitionNames = templateTransitionNames;
1076@@ -30,11 +30,10 @@
1077 c.setResult(false);
1078 }
1079 }
1080-
1081- // / context class
1082- public class Context {
1083+
1084+ public static class Context {
1085 private Boolean result;
1086- private HashSet<String> incorrectTransitionNames;
1087+ private final HashSet<String> incorrectTransitionNames;
1088
1089 public Boolean getResult() {
1090 return result;
1091
1092=== modified file 'src/dk/aau/cs/approximation/ApproximationWorker.java'
1093--- src/dk/aau/cs/approximation/ApproximationWorker.java 2020-12-16 21:11:57 +0000
1094+++ src/dk/aau/cs/approximation/ApproximationWorker.java 2022-03-21 20:20:44 +0000
1095@@ -2,9 +2,12 @@
1096
1097 import java.math.BigDecimal;
1098
1099-import pipe.dataLayer.TAPNQuery.TraceOption;
1100-import pipe.gui.RunVerificationBase;
1101-import pipe.gui.widgets.InclusionPlaces;
1102+import net.tapaal.gui.petrinet.TAPNLens;
1103+import pipe.gui.petrinet.dataLayer.DataLayer;
1104+import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption;
1105+import pipe.gui.TAPAALGUI;
1106+import net.tapaal.gui.petrinet.verification.RunVerificationBase;
1107+import net.tapaal.gui.petrinet.verification.InclusionPlaces;
1108 import dk.aau.cs.Messenger;
1109 import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel;
1110 import dk.aau.cs.model.tapn.TAPNQuery;
1111@@ -32,14 +35,17 @@
1112
1113 public class ApproximationWorker {
1114 public VerificationResult<TAPNNetworkTrace> normalWorker(
1115- VerificationOptions options,
1116- ModelChecker modelChecker,
1117- Tuple<TimedArcPetriNet, NameMapping> transformedModel,
1118- ITAPNComposer composer,
1119- TAPNQuery clonedQuery,
1120- RunVerificationBase verificationBase,
1121- TimedArcPetriNetNetwork model
1122- ) throws Exception {
1123+ VerificationOptions options,
1124+ ModelChecker modelChecker,
1125+ Tuple<TimedArcPetriNet, NameMapping> transformedModel,
1126+ ITAPNComposer composer,
1127+ TAPNQuery clonedQuery,
1128+ RunVerificationBase verificationBase,
1129+ TimedArcPetriNetNetwork model,
1130+ DataLayer guiModel,
1131+ net.tapaal.gui.petrinet.verification.TAPNQuery dataLayerQuery,
1132+ TAPNLens lens
1133+ ) throws Exception {
1134
1135 // If options is of an instance of VerifyTAPNOptions then save the inclusion places before verify alters them
1136 InclusionPlaces oldInclusionPlaces = null;
1137@@ -53,7 +59,9 @@
1138 }
1139
1140 VerificationResult<TAPNNetworkTrace> toReturn = null;
1141- VerificationResult<TimedArcPetriNetTrace> result = modelChecker.verify(options, transformedModel, clonedQuery);
1142+ VerificationResult<TimedArcPetriNetTrace> result;
1143+
1144+ result = modelChecker.verify(options, transformedModel, clonedQuery, guiModel, dataLayerQuery, lens);
1145
1146 if (result.error()) {
1147 options.setTraceOption(oldTraceOption);
1148@@ -66,14 +74,19 @@
1149 // If r = 1
1150 // No matter what it answered -> return that answer
1151 QueryResult queryResult = result.getQueryResult();
1152- toReturn = new VerificationResult<TAPNNetworkTrace>(
1153- queryResult,
1154- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1155- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1156- result.verificationTime(),
1157- result.stats(),
1158- result.isSolvedUsingStateEquation());
1159- toReturn.setNameMapping(transformedModel.value2());
1160+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1161+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1162+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1163+ queryResult,
1164+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1165+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1166+ result.verificationTime(),
1167+ result.stats(),
1168+ false,
1169+ result.getUnfoldedModel());
1170+ toReturn.setNameMapping(transformedModel.value2());
1171+
1172+
1173 } else {
1174 // If r > 1
1175 if (result.getTrace() != null && (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied())
1176@@ -82,14 +95,19 @@
1177 // The results are inconclusive, but we get a trace and can use trace TAPN for verification.
1178
1179 VerificationResult<TimedArcPetriNetTrace> approxResult = result;
1180- toReturn = new VerificationResult<TAPNNetworkTrace>(
1181- approxResult.getQueryResult(),
1182- decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model),
1183- decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model),
1184- approxResult.verificationTime(),
1185- approxResult.stats(),
1186- approxResult.isSolvedUsingStateEquation());
1187- toReturn.setNameMapping(transformedModel.value2());
1188+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1189+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1190+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1191+ approxResult.getQueryResult(),
1192+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1193+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1194+ approxResult.verificationTime(),
1195+ approxResult.stats(),
1196+ false,
1197+ approxResult.getUnfoldedModel());
1198+ toReturn.setNameMapping(nameMapping);
1199+
1200+
1201
1202 OverApproximation overaprx = new OverApproximation();
1203
1204@@ -103,7 +121,7 @@
1205
1206 // run model checker again for trace TAPN
1207 MemoryMonitor.cumulateMemory();
1208- result = modelChecker.verify(options, transformedOriginalModel, clonedQuery);
1209+ result = modelChecker.verify(options, transformedOriginalModel, clonedQuery, guiModel, dataLayerQuery, null);
1210
1211 if (result.error()) {
1212 options.setTraceOption(oldTraceOption);
1213@@ -127,14 +145,17 @@
1214
1215 // If satisfied trace -> Return result
1216 // This is satisfied for EF and EG and not satisfied for AG and AF
1217- toReturn = new VerificationResult<TAPNNetworkTrace>(
1218- queryResult,
1219- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1220- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1221- approxResult.verificationTime() + result.verificationTime(),
1222- approxResult.stats(),
1223- approxResult.isSolvedUsingStateEquation());
1224- toReturn.setNameMapping(transformedModel.value2());
1225+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1226+ queryResult,
1227+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1228+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1229+ approxResult.verificationTime() + result.verificationTime(),
1230+ approxResult.stats(),
1231+ false,
1232+ approxResult.getUnfoldedModel());
1233+ toReturn.setNameMapping(nameMapping);
1234+
1235+
1236 }
1237 else if (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && !result.getQueryResult().isQuerySatisfied())
1238 || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && result.getQueryResult().isQuerySatisfied())) {
1239@@ -147,14 +168,19 @@
1240 }
1241
1242 VerificationResult<TimedArcPetriNetTrace> approxResult = result;
1243- toReturn = new VerificationResult<TAPNNetworkTrace>(
1244- approxResult.getQueryResult(),
1245- decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model),
1246- decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model),
1247- approxResult.verificationTime(),
1248- approxResult.stats(),
1249- approxResult.isSolvedUsingStateEquation());
1250- toReturn.setNameMapping(transformedModel.value2());
1251+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1252+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1253+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1254+ approxResult.getQueryResult(),
1255+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1256+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1257+ approxResult.verificationTime(),
1258+ approxResult.stats(),
1259+ false,
1260+ approxResult.getUnfoldedModel());
1261+ toReturn.setNameMapping(nameMapping);
1262+
1263+
1264 } else {
1265 // We cannot use the result directly, and did not get a trace.
1266
1267@@ -162,15 +188,18 @@
1268 queryResult.setApproximationInconclusive(true);
1269
1270 VerificationResult<TimedArcPetriNetTrace> approxResult = result;
1271- toReturn = new VerificationResult<TAPNNetworkTrace>(
1272- approxResult.getQueryResult(),
1273- decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model),
1274- decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model),
1275- approxResult.verificationTime(),
1276- approxResult.stats(),
1277- approxResult.isSolvedUsingStateEquation());
1278- toReturn.setNameMapping(transformedModel.value2());
1279-
1280+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1281+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1282+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1283+ approxResult.getQueryResult(),
1284+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1285+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1286+ approxResult.verificationTime(),
1287+ approxResult.stats(),
1288+ false,
1289+ approxResult.getUnfoldedModel());
1290+ toReturn.setNameMapping(nameMapping);
1291+
1292 }
1293 }
1294 }
1295@@ -194,14 +223,19 @@
1296 // If r = 1
1297 // No matter it answered -> return that answer
1298 QueryResult queryResult= result.getQueryResult();
1299- toReturn = new VerificationResult<TAPNNetworkTrace>(
1300- queryResult,
1301- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1302- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1303- result.verificationTime(),
1304- result.stats(),
1305- result.isSolvedUsingStateEquation());
1306- toReturn.setNameMapping(transformedModel.value2());
1307+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1308+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1309+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1310+ queryResult,
1311+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1312+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1313+ result.verificationTime(),
1314+ result.stats(),
1315+ false,
1316+ result.getUnfoldedModel());
1317+ toReturn.setNameMapping(nameMapping);
1318+
1319+
1320 }
1321 else {
1322 // If r > 1
1323@@ -210,14 +244,18 @@
1324 // If ((EF OR EG) AND not satisfied) OR ((AG OR AF) and satisfied) -> Inconclusive
1325 QueryResult queryResult= result.getQueryResult();
1326 queryResult.setApproximationInconclusive(true);
1327- toReturn = new VerificationResult<TAPNNetworkTrace>(
1328- queryResult,
1329- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1330- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1331- result.verificationTime(),
1332- result.stats(),
1333- result.isSolvedUsingStateEquation());
1334- toReturn.setNameMapping(transformedModel.value2());
1335+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1336+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1337+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1338+ queryResult,
1339+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1340+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1341+ result.verificationTime(),
1342+ result.stats(),
1343+ false,
1344+ result.getUnfoldedModel());
1345+ toReturn.setNameMapping(nameMapping);
1346+
1347 } else if ((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied()
1348 || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && ! result.getQueryResult().isQuerySatisfied())) {
1349
1350@@ -225,14 +263,19 @@
1351 // If query does have deadlock or EG or AF a trace -> create trace TAPN
1352 //Create the verification satisfied result for the approximation
1353 VerificationResult<TimedArcPetriNetTrace> approxResult = result;
1354- toReturn = new VerificationResult<TAPNNetworkTrace>(
1355- approxResult.getQueryResult(),
1356- decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model),
1357- decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model),
1358- approxResult.verificationTime(),
1359- approxResult.stats(),
1360- result.isSolvedUsingStateEquation());
1361- toReturn.setNameMapping(transformedModel.value2());
1362+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1363+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1364+ toReturn = new VerificationResult<TAPNNetworkTrace>(
1365+ approxResult.getQueryResult(),
1366+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1367+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1368+ approxResult.verificationTime(),
1369+ approxResult.stats(),
1370+ false,
1371+ result.getUnfoldedModel());
1372+ toReturn.setNameMapping(nameMapping);
1373+
1374+
1375
1376 OverApproximation overaprx = new OverApproximation();
1377
1378@@ -247,7 +290,7 @@
1379
1380 //run model checker again for trace TAPN
1381 MemoryMonitor.cumulateMemory();
1382- result = modelChecker.verify(options, transformedOriginalModel, clonedQuery);
1383+ result = modelChecker.verify(options, transformedOriginalModel, clonedQuery, guiModel, dataLayerQuery, null);
1384
1385 if (result.error()) {
1386 options.setTraceOption(oldTraceOption);
1387@@ -271,16 +314,17 @@
1388 || (result.getQueryResult().queryType() == QueryType.AF && queryResult.isQuerySatisfied())) {
1389 queryResult.setApproximationInconclusive(true);
1390 }
1391-
1392+
1393 // If satisfied trace) -> Return result
1394 // This is satisfied for EF and EG and not satisfied for AG and AF
1395 toReturn = new VerificationResult<TAPNNetworkTrace>(
1396 queryResult,
1397- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1398- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1399+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1400+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1401 approxResult.verificationTime() + result.verificationTime(),
1402 approxResult.stats(),
1403- approxResult.isSolvedUsingStateEquation());
1404+ false,
1405+ approxResult.getUnfoldedModel());
1406 toReturn.setNameMapping(transformedModel.value2());
1407 }
1408 else {
1409@@ -289,28 +333,36 @@
1410 queryResult.setApproximationInconclusive(true);
1411
1412 VerificationResult<TimedArcPetriNetTrace> approxResult = result;
1413+ NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2();
1414+ TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model;
1415+
1416 toReturn = new VerificationResult<TAPNNetworkTrace>(
1417 approxResult.getQueryResult(),
1418- decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model),
1419- decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model),
1420+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1421+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1422 approxResult.verificationTime(),
1423 approxResult.stats(),
1424- approxResult.isSolvedUsingStateEquation());
1425- toReturn.setNameMapping(transformedModel.value2());
1426+ false,
1427+ approxResult.getUnfoldedModel());
1428+ toReturn.setNameMapping(nameMapping);
1429 }
1430 }
1431 }
1432 }
1433 else {
1434+ boolean isColored = (lens != null && lens.isColored() || model.isColored());
1435+ NameMapping nameMapping = isColored? result.getUnfoldedModel().value2(): transformedModel.value2();
1436+ TimedArcPetriNetNetwork netNetwork = isColored? result.getUnfoldedModel().value1().parentNetwork(): model;
1437 toReturn = new VerificationResult<TAPNNetworkTrace>(
1438 result.getQueryResult(),
1439- decomposeTrace(result.getTrace(), transformedModel.value2(), model),
1440- decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model),
1441+ decomposeTrace(result.getTrace(), nameMapping, netNetwork),
1442+ decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork),
1443 result.verificationTime(),
1444 result.stats(),
1445- result.isSolvedUsingStateEquation(),
1446- result.getRawOutput());
1447- toReturn.setNameMapping(transformedModel.value2());
1448+ false,
1449+ result.getRawOutput(),
1450+ result.getUnfoldedModel());
1451+ toReturn.setNameMapping(nameMapping);
1452 }
1453
1454 options.setTraceOption(oldTraceOption);
1455@@ -326,7 +378,7 @@
1456 public VerificationResult<TimedArcPetriNetTrace> batchWorker(
1457 Tuple<TimedArcPetriNet, NameMapping> composedModel,
1458 VerificationOptions options,
1459- pipe.dataLayer.TAPNQuery query,
1460+ net.tapaal.gui.petrinet.verification.TAPNQuery query,
1461 LoadedBatchProcessingModel model,
1462 ModelChecker modelChecker,
1463 TAPNQuery queryToVerify,
1464@@ -354,7 +406,7 @@
1465 options.setTraceOption(TraceOption.SOME);
1466 }
1467
1468- VerificationResult<TimedArcPetriNetTrace> verificationResult = modelChecker.verify(options, composedModel, queryToVerify);
1469+ VerificationResult<TimedArcPetriNetTrace> verificationResult = modelChecker.verify(options, composedModel, queryToVerify, null, query, null);
1470
1471 VerificationResult<TAPNNetworkTrace> valueNetwork = null; //The final result is meant to be a PetriNetTrace but to make traceTAPN we make a networktrace
1472 VerificationResult<TimedArcPetriNetTrace> value = null;
1473@@ -376,7 +428,8 @@
1474 verificationResult.getSecondaryTrace(),
1475 verificationResult.verificationTime(),
1476 verificationResult.stats(),
1477- verificationResult.isSolvedUsingStateEquation());
1478+ false,
1479+ verificationResult.getUnfoldedModel());
1480 value.setNameMapping(composedModel.value2());
1481 } else {
1482 // If r > 1
1483@@ -385,14 +438,17 @@
1484 // If ((EF OR EG) AND satisfied) OR ((AG OR AF) AND not satisfied)
1485 //Create the verification satisfied result for the approximation
1486 VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult;
1487+ NameMapping nameMapping = model.network().isColored()? verificationResult.getUnfoldedModel().value2(): composedModel.value2();
1488+ TimedArcPetriNetNetwork netNetwork = model.network().isColored()? verificationResult.getUnfoldedModel().value1().parentNetwork(): model.network();
1489 valueNetwork = new VerificationResult<TAPNNetworkTrace>(
1490 approxResult.getQueryResult(),
1491- decomposeTrace(approxResult.getTrace(), composedModel.value2(), model.network()),
1492- decomposeTrace(approxResult.getSecondaryTrace(), composedModel.value2(), model.network()),
1493+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1494+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1495 approxResult.verificationTime(),
1496 approxResult.stats(),
1497- verificationResult.isSolvedUsingStateEquation());
1498- valueNetwork.setNameMapping(composedModel.value2());
1499+ false,
1500+ verificationResult.getUnfoldedModel());
1501+ valueNetwork.setNameMapping(nameMapping);
1502
1503 OverApproximation overaprx = new OverApproximation();
1504
1505@@ -406,7 +462,7 @@
1506
1507 //run model checker again for trace TAPN
1508 MemoryMonitor.cumulateMemory();
1509- verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery);
1510+ verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery, null, query, null);
1511
1512 if (verificationResult.error()) {
1513 options.setTraceOption(oldTraceOption);
1514@@ -432,7 +488,8 @@
1515 approxResult.getSecondaryTrace(),
1516 approxResult.verificationTime() + verificationResult.verificationTime(),
1517 approxResult.stats(),
1518- verificationResult.isSolvedUsingStateEquation());
1519+ false,
1520+ verificationResult.getUnfoldedModel());
1521 value.setNameMapping(composedModel.value2());
1522 }
1523 else if (((verificationResult.getQueryResult().queryType() == QueryType.EF || verificationResult.getQueryResult().queryType() == QueryType.EG) && !verificationResult.getQueryResult().isQuerySatisfied())
1524@@ -451,7 +508,8 @@
1525 verificationResult.getSecondaryTrace(),
1526 verificationResult.verificationTime(),
1527 verificationResult.stats(),
1528- verificationResult.isSolvedUsingStateEquation());
1529+ false,
1530+ verificationResult.getUnfoldedModel());
1531 value.setNameMapping(composedModel.value2());
1532 }
1533 else {
1534@@ -467,7 +525,8 @@
1535 verificationResult.getSecondaryTrace(),
1536 verificationResult.verificationTime(),
1537 verificationResult.stats(),
1538- verificationResult.isSolvedUsingStateEquation());
1539+ false,
1540+ verificationResult.getUnfoldedModel());
1541 value.setNameMapping(composedModel.value2());
1542 }
1543 }
1544@@ -485,7 +544,8 @@
1545 verificationResult.getSecondaryTrace(),
1546 verificationResult.verificationTime(),
1547 verificationResult.stats(),
1548- verificationResult.isSolvedUsingStateEquation());
1549+ false,
1550+ verificationResult.getUnfoldedModel());
1551 value.setNameMapping(composedModel.value2());
1552 }
1553 else {
1554@@ -502,7 +562,8 @@
1555 verificationResult.getSecondaryTrace(),
1556 verificationResult.verificationTime(),
1557 verificationResult.stats(),
1558- verificationResult.isSolvedUsingStateEquation());
1559+ false,
1560+ verificationResult.getUnfoldedModel());
1561 value.setNameMapping(composedModel.value2());
1562
1563 }
1564@@ -514,14 +575,20 @@
1565 // If query does have deadlock -> create trace TAPN
1566 //Create the verification satisfied result for the approximation
1567 VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult;
1568- valueNetwork = new VerificationResult<TAPNNetworkTrace>(
1569- approxResult.getQueryResult(),
1570- decomposeTrace(approxResult.getTrace(), composedModel.value2(), model.network()),
1571- decomposeTrace(approxResult.getSecondaryTrace(), composedModel.value2(), model.network()),
1572- approxResult.verificationTime(),
1573- approxResult.stats(),
1574- approxResult.isSolvedUsingStateEquation());
1575- valueNetwork.setNameMapping(composedModel.value2());
1576+
1577+ NameMapping nameMapping = model.network().isColored()? verificationResult.getUnfoldedModel().value2(): composedModel.value2();
1578+ TimedArcPetriNetNetwork netNetwork = model.network().isColored()? verificationResult.getUnfoldedModel().value1().parentNetwork(): model.network();
1579+ valueNetwork = new VerificationResult<TAPNNetworkTrace>(
1580+ approxResult.getQueryResult(),
1581+ decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork),
1582+ decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork),
1583+ approxResult.verificationTime(),
1584+ approxResult.stats(),
1585+ false,
1586+ verificationResult.getUnfoldedModel());
1587+ valueNetwork.setNameMapping(nameMapping);
1588+
1589+
1590
1591 OverApproximation overaprx = new OverApproximation();
1592
1593@@ -534,7 +601,7 @@
1594
1595 //run model checker again for trace TAPN
1596 MemoryMonitor.cumulateMemory();
1597- verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery);
1598+ verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery, null, query, null);
1599
1600 if (verificationResult.error()) {
1601 options.setTraceOption(oldTraceOption);
1602@@ -564,7 +631,8 @@
1603 verificationResult.getSecondaryTrace(),
1604 verificationResult.verificationTime() + approxResult.verificationTime(),
1605 verificationResult.stats(),
1606- verificationResult.isSolvedUsingStateEquation());
1607+ false,
1608+ verificationResult.getUnfoldedModel());
1609 value.setNameMapping(composedModel.value2());
1610 }
1611 else {
1612@@ -578,7 +646,8 @@
1613 verificationResult.getSecondaryTrace(),
1614 verificationResult.verificationTime(),
1615 verificationResult.stats(),
1616- verificationResult.isSolvedUsingStateEquation());
1617+ false,
1618+ verificationResult.getUnfoldedModel());
1619 value.setNameMapping(composedModel.value2());
1620 }
1621 }
1622@@ -591,7 +660,8 @@
1623 verificationResult.getSecondaryTrace(),
1624 verificationResult.verificationTime(),
1625 verificationResult.stats(),
1626- verificationResult.isSolvedUsingStateEquation());
1627+ false,
1628+ verificationResult.getUnfoldedModel());
1629 value.setNameMapping(composedModel.value2());
1630 }
1631
1632
1633=== modified file 'src/dk/aau/cs/approximation/OverApproximation.java'
1634--- src/dk/aau/cs/approximation/OverApproximation.java 2020-07-20 12:17:24 +0000
1635+++ src/dk/aau/cs/approximation/OverApproximation.java 2022-03-21 20:20:44 +0000
1636@@ -13,6 +13,7 @@
1637 import dk.aau.cs.TCTL.TCTLNotNode;
1638 import dk.aau.cs.TCTL.TCTLOrListNode;
1639 import dk.aau.cs.TCTL.TCTLPlaceNode;
1640+import dk.aau.cs.model.CPN.ColorType;
1641 import dk.aau.cs.model.tapn.*;
1642 import dk.aau.cs.model.tapn.simulation.*;
1643 import dk.aau.cs.util.Tuple;
1644@@ -69,18 +70,18 @@
1645 oldInterval.isUpperBoundNonStrict()
1646 );
1647 }
1648-
1649+
1650 public void makeTraceTAPN(Tuple<TimedArcPetriNet, NameMapping> transformedModel, VerificationResult<TAPNNetworkTrace> result, dk.aau.cs.model.tapn.TAPNQuery query) {
1651 TimedArcPetriNet net = transformedModel.value1();
1652
1653 LocalTimedPlace currentPlace = new LocalTimedPlace("PTRACE0");
1654- TimedToken currentToken = new TimedToken(currentPlace);
1655+ TimedToken currentToken = new TimedToken(currentPlace, ColorType.COLORTYPE_DOT.getFirstColor());
1656 net.add(currentPlace);
1657 currentPlace.addToken(currentToken);
1658
1659 // Block place, which secures the net makes at most one transition not in the trace.
1660- LocalTimedPlace blockPlace = new LocalTimedPlace("PBLOCK", TimeInvariant.LESS_THAN_INFINITY);
1661- TimedToken blockToken = new TimedToken(blockPlace);
1662+ LocalTimedPlace blockPlace = new LocalTimedPlace("PBLOCK");
1663+ TimedToken blockToken = new TimedToken(blockPlace, ColorType.COLORTYPE_DOT.getFirstColor());
1664 net.add(blockPlace);
1665 blockPlace.addToken(blockToken);
1666
1667@@ -140,7 +141,7 @@
1668 (((TAPNNetworkTimedTransitionStep) step).getTransition().sharedTransition() == null ? tmpStep.getTransition().model().name() : ""),
1669 tmpStep.getTransition().name());
1670 TimedTransition firedTransition = net.getTransitionByName(nameMap.get(key));
1671- TimedTransition copyTransition = new TimedTransition(firedTransition.name() + "_traceNet_" + Integer.toString(++transitionInteger), firedTransition.isUrgent());
1672+ TimedTransition copyTransition = new TimedTransition(firedTransition.name() + "_traceNet_" + Integer.toString(++transitionInteger), firedTransition.isUrgent(), null);
1673
1674 net.add(copyTransition);
1675 net.add(new TimedInputArc(currentPlace, copyTransition, TimeInterval.ZERO_INF));
1676@@ -163,17 +164,17 @@
1677
1678 for (TimedInputArc arc : originalInput) {
1679 if (arc.destination() == firedTransition) {
1680- net.add(new TimedInputArc(arc.source(), copyTransition, arc.interval(), arc.getWeight()));
1681+ net.add(new TimedInputArc(arc.source(), copyTransition, arc.interval(), arc.getWeight(), arc.getArcExpression()));
1682 }
1683 }
1684 for (TimedOutputArc arc : originalOutput) {
1685 if (arc.source() == firedTransition) {
1686- net.add(new TimedOutputArc(copyTransition, arc.destination(), arc.getWeight()));
1687+ net.add(new TimedOutputArc(copyTransition, arc.destination(), arc.getWeight(), arc.getExpression()));
1688 }
1689 }
1690 for (TimedInhibitorArc arc : originalInhibitor) {
1691 if (arc.destination() == firedTransition) {
1692- net.add(new TimedInhibitorArc(arc.source(), copyTransition, arc.interval(), arc.getWeight()));
1693+ net.add(new TimedInhibitorArc(arc.source(), copyTransition, arc.interval(), arc.getWeight(), arc.getArcExpression()));
1694 }
1695 }
1696 for (TransportArc arc : originalTransport) {
1697@@ -200,7 +201,7 @@
1698
1699 // An input arc from pBlock to all original transitions makes sure, that we can do deadlock checks.
1700 for (TimedTransition transition : originalTransitions) {
1701- net.add(new TimedInputArc(blockPlace, transition, TimeInterval.ZERO_INF));
1702+ net.add(new TimedInputArc(blockPlace, transition, TimeInterval.ZERO_INF));
1703 }
1704 }
1705
1706
1707=== modified file 'src/dk/aau/cs/approximation/UnderApproximation.java'
1708--- src/dk/aau/cs/approximation/UnderApproximation.java 2020-07-20 12:17:24 +0000
1709+++ src/dk/aau/cs/approximation/UnderApproximation.java 2022-03-21 20:20:44 +0000
1710@@ -1,23 +1,13 @@
1711 package dk.aau.cs.approximation;
1712
1713+import dk.aau.cs.model.tapn.*;
1714+import pipe.gui.petrinet.dataLayer.DataLayer;
1715+import pipe.gui.petrinet.graphicElements.Arc;
1716+import pipe.gui.petrinet.graphicElements.Place;
1717+import pipe.gui.petrinet.graphicElements.Transition;
1718+
1719 import java.util.ArrayList;
1720
1721-import dk.aau.cs.model.tapn.Bound;
1722-import dk.aau.cs.model.tapn.IntBound;
1723-import dk.aau.cs.model.tapn.TimeInterval;
1724-import dk.aau.cs.model.tapn.TimeInvariant;
1725-import dk.aau.cs.model.tapn.TimedArcPetriNet;
1726-import dk.aau.cs.model.tapn.TimedInhibitorArc;
1727-import dk.aau.cs.model.tapn.TimedInputArc;
1728-import dk.aau.cs.model.tapn.TimedOutputArc;
1729-import dk.aau.cs.model.tapn.TimedPlace;
1730-import dk.aau.cs.model.tapn.TimedTransition;
1731-import dk.aau.cs.model.tapn.TransportArc;
1732-import pipe.dataLayer.DataLayer;
1733-import pipe.gui.graphicElements.Arc;
1734-import pipe.gui.graphicElements.Place;
1735-import pipe.gui.graphicElements.Transition;
1736-
1737 public class UnderApproximation implements ITAPNApproximation {
1738 @Override
1739 public void modifyTAPN(TimedArcPetriNet net, int approximationDenominator) {
1740@@ -141,44 +131,42 @@
1741 }
1742
1743 //Returns a copy of an approximated interval
1744- private TimeInterval modifyIntervals(TimeInterval oldInterval, int denominator){
1745- Bound newUpperBound;
1746- // Do not calculate upper bound for infinite
1747- if ( ! (oldInterval.upperBound() instanceof Bound.InfBound)) {
1748-
1749- // Calculate the new upper bound value.
1750- int oldUpperBoundValue = oldInterval.upperBound().value();
1751- newUpperBound = new IntBound((int) Math.floor((double)oldUpperBoundValue / denominator));
1752- }
1753- else
1754- newUpperBound = Bound.Infinity;
1755-
1756- // Calculate the new lower bound
1757- IntBound newLowerBound = new IntBound((int) Math.ceil((double)oldInterval.lowerBound().value() / denominator));
1758-
1759- // if the lower bound has become greater than the upper bound by rounding
1760- if ( ! (oldInterval.upperBound() instanceof Bound.InfBound) && newLowerBound.value() > newUpperBound.value())
1761- {
1762- newLowerBound = new IntBound((int) Math.floor((double)oldInterval.lowerBound().value() / denominator));
1763- newUpperBound = new IntBound((int) Math.floor((double)oldInterval.upperBound().value() / denominator));
1764- }
1765-
1766- boolean isLowerBoundNonStrict = oldInterval.isLowerBoundNonStrict();
1767- boolean isUpperBoundNonStrict = oldInterval.isUpperBoundNonStrict();
1768-
1769- // if the interval becomes too small we make it a bit bigger to secure, that we do not have to delete the arc
1770- if ( (newUpperBound.value() == newLowerBound.value()) && !(oldInterval.isLowerBoundNonStrict() && oldInterval.isUpperBoundNonStrict()))
1771- {
1772- isUpperBoundNonStrict = true;
1773- isLowerBoundNonStrict = true;
1774- }
1775-
1776- return new TimeInterval(
1777- isLowerBoundNonStrict,
1778- newLowerBound,
1779- newUpperBound,
1780- isUpperBoundNonStrict
1781- );
1782- }
1783+ private TimeInterval modifyIntervals(TimeInterval oldInterval, int denominator) {
1784+ Bound newUpperBound;
1785+ // Do not calculate upper bound for infinite
1786+ if (!(oldInterval.upperBound() instanceof Bound.InfBound)) {
1787+
1788+ // Calculate the new upper bound value.
1789+ int oldUpperBoundValue = oldInterval.upperBound().value();
1790+ newUpperBound = new IntBound((int) Math.floor((double) oldUpperBoundValue / denominator));
1791+ } else {
1792+ newUpperBound = Bound.Infinity;
1793+ }
1794+
1795+ // Calculate the new lower bound
1796+ IntBound newLowerBound = new IntBound((int) Math.ceil((double) oldInterval.lowerBound().value() / denominator));
1797+
1798+ // if the lower bound has become greater than the upper bound by rounding
1799+ if (!(oldInterval.upperBound() instanceof Bound.InfBound) && newLowerBound.value() > newUpperBound.value()) {
1800+ newLowerBound = new IntBound((int) Math.floor((double) oldInterval.lowerBound().value() / denominator));
1801+ newUpperBound = new IntBound((int) Math.floor((double) oldInterval.upperBound().value() / denominator));
1802+ }
1803+
1804+ boolean isLowerBoundNonStrict = oldInterval.isLowerBoundNonStrict();
1805+ boolean isUpperBoundNonStrict = oldInterval.isUpperBoundNonStrict();
1806+
1807+ // if the interval becomes too small we make it a bit bigger to secure, that we do not have to delete the arc
1808+ if ((newUpperBound.value() == newLowerBound.value()) && !(oldInterval.isLowerBoundNonStrict() && oldInterval.isUpperBoundNonStrict())) {
1809+ isUpperBoundNonStrict = true;
1810+ isLowerBoundNonStrict = true;
1811+ }
1812+
1813+ return new TimeInterval(
1814+ isLowerBoundNonStrict,
1815+ newLowerBound,
1816+ newUpperBound,
1817+ isUpperBoundNonStrict
1818+ );
1819+ }
1820
1821 }
1822
1823=== removed directory 'src/dk/aau/cs/gui'
1824=== removed directory 'src/dk/aau/cs/gui/components'
1825=== removed directory 'src/dk/aau/cs/gui/components/handlers'
1826=== removed directory 'src/dk/aau/cs/gui/smartDraw'
1827=== removed directory 'src/dk/aau/cs/gui/undo'
1828=== added file 'src/dk/aau/cs/io/LoadTACPN.java'
1829--- src/dk/aau/cs/io/LoadTACPN.java 1970-01-01 00:00:00 +0000
1830+++ src/dk/aau/cs/io/LoadTACPN.java 2022-03-21 20:20:44 +0000
1831@@ -0,0 +1,439 @@
1832+package dk.aau.cs.io;
1833+
1834+import dk.aau.cs.model.CPN.*;
1835+import dk.aau.cs.model.CPN.Expressions.*;
1836+import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
1837+import dk.aau.cs.util.FormatException;
1838+import dk.aau.cs.util.Require;
1839+import dk.aau.cs.util.Tuple;
1840+import org.w3c.dom.Element;
1841+import org.w3c.dom.Node;
1842+
1843+import java.util.*;
1844+
1845+public class LoadTACPN { //the import feature for CPN and load for TACPN share similarities. These similarities are shared here. Feel free to find a better name for this class
1846+
1847+ private final HashMap<String, ColorType> colortypes = new HashMap<>();
1848+ private final HashMap<String, Variable> variables = new HashMap<>();
1849+ private final HashMap<String, ColorExpression> tupleVarExpressions = new HashMap<>();
1850+ private final Collection<String> messages = new ArrayList<>(10);
1851+
1852+ public HashMap<String, ColorType> getColortypes() {
1853+ return colortypes;
1854+ }
1855+
1856+ public HashMap<String, Variable> getVariables() {
1857+ return variables;
1858+ }
1859+
1860+ public Collection<String> getMessages() {return messages;}
1861+ //skipWS
1862+ // Takes a given node and returns it if it is an element,
1863+ // otherwise returns its first element sibling.
1864+ // This allows skipping past whitespace nodes.
1865+ private static Node skipWS(Node node) {
1866+ if (node != null && !(node instanceof Element)) {
1867+ return skipWS(node.getNextSibling());
1868+ } else {
1869+ return node;
1870+ }
1871+ }
1872+
1873+ private static Node getAttribute(Node node, String attribute) {
1874+ return node.getAttributes().getNamedItem(attribute);
1875+ }
1876+
1877+ public void parseDeclarations(Node node, TimedArcPetriNetNetwork network) throws FormatException {
1878+ if(!(node instanceof Element)){
1879+ return;
1880+ }
1881+ Node child = skipWS(node.getFirstChild());
1882+ while(child != null){
1883+ String childName = child.getNodeName();
1884+ if (childName.equals("namedsort")){
1885+ parseNamedSort(child, network);
1886+ } else if (childName.equals("variabledecl")){
1887+ String id = getAttribute(child, "id").getNodeValue();
1888+ String name = getAttribute(child, "name").getNodeValue();
1889+ ColorType ct = parseUserSort(child);
1890+ Variable var = new Variable(name, id, ct);
1891+ Require.that(variables.put(id, var) == null, "the id " + id + ", was already used");
1892+ network.add(var);
1893+ } else {
1894+ parseDeclarations(child, network);
1895+ }
1896+
1897+ child = skipWS(child.getNextSibling());
1898+ }
1899+ Vector<String> variablesForRemoval = new Vector<>();
1900+ HashMap<String, Variable> newVars = new HashMap<>();
1901+ StringBuilder renameWarnings = new StringBuilder();
1902+ // Convert product variables into variables for the constituent of the product
1903+ for(String varName : variables.keySet()){
1904+ Variable var = variables.get(varName);
1905+ if(var.getColorType().isProductColorType()){
1906+ int constituentCounter = 1;
1907+
1908+ Vector<ColorExpression> constituentVarExpressions = new Vector<>();
1909+ renameWarnings.append("The product variable ").append(var.getName()).append(", was unfolded to (");
1910+
1911+ for(ColorType colorType : var.getColorType().getProductColorTypes()){
1912+ StringBuilder elementSubstring = new StringBuilder("_" + constituentCounter);
1913+ while (variables.containsKey(varName + elementSubstring) || newVars.containsKey(varName + elementSubstring)){
1914+ elementSubstring.append("_1");
1915+ }
1916+
1917+ renameWarnings.append(varName).append(elementSubstring).append(",");
1918+
1919+ Variable newVar = new Variable(var.getName() + elementSubstring, varName + elementSubstring, colorType);
1920+ Require.that(newVars.put(varName + elementSubstring, newVar) == null, "the id " + varName + elementSubstring + ", was already used");
1921+ network.add(newVar);
1922+ constituentVarExpressions.addElement(new VariableExpression(newVar));
1923+ constituentCounter++;
1924+ }
1925+ renameWarnings.deleteCharAt(renameWarnings.length()-1);
1926+ renameWarnings.append(")\n");
1927+
1928+ tupleVarExpressions.put(varName, new TupleExpression(constituentVarExpressions));
1929+ network.remove(var);
1930+ variablesForRemoval.addElement(varName);
1931+ }
1932+ }
1933+ for(String varName : variablesForRemoval){
1934+ variables.remove(varName);
1935+ }
1936+ for(String varName : newVars.keySet()){
1937+ variables.put(varName, newVars.get(varName));
1938+ }
1939+
1940+ if(renameWarnings.length() > 0){
1941+ messages.add(renameWarnings.toString());
1942+ //JOptionPane.showConfirmDialog(CreateGui.getApp(), renameWarnings.toString(), "Product Variables unfolded", JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE);
1943+ }
1944+ }
1945+ private void parseNamedSort(Node node, TimedArcPetriNetNetwork network) throws FormatException {
1946+ //We always use the dot colortype
1947+ colortypes.put("dot", ColorType.COLORTYPE_DOT);
1948+ network.add(ColorType.COLORTYPE_DOT);
1949+
1950+ Node type = skipWS(node.getFirstChild());
1951+ String typetag = type.getNodeName();
1952+ String name = getAttribute(node, "name").getNodeValue();
1953+ String id = getAttribute(node, "id").getNodeValue();
1954+
1955+ if (typetag.equals("productsort")) {
1956+ ProductType pt = new ProductType(name);
1957+ Node typechild = skipWS(type.getFirstChild());
1958+ while (typechild != null) {
1959+ if (typechild.getNodeName().equals("usersort")) {
1960+ String constituent = getAttribute(typechild, "declaration").getNodeValue();
1961+ pt.addType(colortypes.get(constituent));
1962+ }
1963+ typechild = skipWS(typechild.getNextSibling());
1964+ }
1965+ Require.that(colortypes.put(id, pt) == null, "the name " + id + ", was already used");
1966+ network.add(pt);
1967+ } else {
1968+ ColorType ct = new ColorType(name, id);
1969+ if (typetag.equals("dot")) {
1970+ return;
1971+ } else if (typetag.equals("finiteintrange")){
1972+ int start = Integer.parseInt(getAttribute(type, "start").getNodeValue());
1973+ int end = Integer.parseInt(getAttribute(type, "end").getNodeValue());
1974+ for(int i = start; i <= end; i++){
1975+ ct.addColor(String.valueOf(i));
1976+ }
1977+ } else {
1978+ Node typechild = skipWS(type.getFirstChild());
1979+ while (typechild != null) {
1980+ Node colorId = getAttribute(typechild, "id");
1981+ if (colorId != null) {
1982+ ct.addColor(colorId.getNodeValue());
1983+ typechild = skipWS(typechild.getNextSibling());
1984+ } else {
1985+ throw new FormatException(String.format("No id found on %s\n", typechild.getNodeName()));
1986+ }
1987+ }
1988+ }
1989+ Require.that(colortypes.put(id, ct) == null, "the name " + id + ", was already used");
1990+ network.add(ct);
1991+ }
1992+ }
1993+
1994+ public ColorType parseUserSort(Node node) throws FormatException {
1995+ if (node instanceof Element) {
1996+ Node child = skipWS(node.getFirstChild());
1997+ while (child != null) {
1998+ String name = child.getNodeName();
1999+ if (name.equals("usersort")) {
2000+ Node decl = getAttribute(child, "declaration");
2001+ return colortypes.get(decl.getNodeValue());
2002+ } else if (name.matches("structure|type|subterm")) {
2003+ return parseUserSort(child);
2004+ }
2005+ child = skipWS(child.getNextSibling());
2006+ }
2007+ }
2008+ throw new FormatException(String.format("Could not parse %s as an usersort\n", node.getNodeName()));
2009+ }
2010+
2011+ public ArcExpression parseArcExpression(Node node) throws FormatException {
2012+ String name = node.getNodeName();
2013+ if (name.equals("numberof")) {
2014+ return parseNumberOfExpression(node);
2015+ } else if (name.equals("add")) {
2016+ Vector<ArcExpression> constituents = new Vector<>();
2017+
2018+ Node child = skipWS(node.getFirstChild());
2019+ while (child != null) {
2020+ ArcExpression subterm = parseArcExpression(child);
2021+ constituents.add(subterm);
2022+ child = skipWS(child.getNextSibling());
2023+ }
2024+ return new AddExpression(constituents);
2025+ } else if (name.equals("subtract")) {
2026+ Node headchild = skipWS(node.getFirstChild());
2027+ ArcExpression headexp = parseArcExpression(headchild);
2028+
2029+ Node nextchild = skipWS(headchild.getNextSibling());
2030+ while (nextchild != null) {
2031+ ArcExpression nextexp = parseArcExpression(nextchild);
2032+ headexp = new SubtractExpression(headexp, nextexp);
2033+ nextchild = skipWS(nextchild.getNextSibling());
2034+ }
2035+ return headexp;
2036+ } else if (name.equals("scalarproduct")) {
2037+ Node scalar = skipWS(node.getFirstChild());
2038+ Integer scalarval = parseNumberConstantExpression(scalar);
2039+
2040+ Node child = skipWS(scalar.getNextSibling());
2041+ ArcExpression childexp = parseArcExpression(child);
2042+
2043+ return new ScalarProductExpression(scalarval, childexp);
2044+ }else if (name.equals("all")){
2045+ ColorType ct = parseUserSort(node);
2046+ Vector<ColorExpression> ceVector = new Vector<>();
2047+ ceVector.add(new AllExpression(ct));
2048+ return new NumberOfExpression(1,ceVector);
2049+
2050+ } else if (name.matches("subterm|structure")) {
2051+ Node child = skipWS(node.getFirstChild());
2052+ return parseArcExpression(child);
2053+ } else if (name.matches("tuple")){
2054+ Vector<ColorExpression> ceVector = new Vector<>();
2055+ ceVector.add(parseColorExpression(node));
2056+ return new NumberOfExpression(1, ceVector);
2057+ } else{
2058+ throw new FormatException(String.format("Could not parse %s as an arc expression\n", name));
2059+ }
2060+ }
2061+
2062+ private NumberOfExpression parseNumberOfExpression(Node node) throws FormatException {
2063+ Node number = skipWS(node.getFirstChild());
2064+ //The number constant may be omitted.
2065+ //In that case, this parsing returns null.
2066+ Integer numberval = parseNumberConstantExpression(number);
2067+ Node subnode;
2068+ if (numberval != null) {
2069+ //The subexpression comes after the number constant.
2070+ subnode = skipWS(number.getNextSibling());
2071+ } else {
2072+ //The number we read was actually the subexpression.
2073+ subnode = number;
2074+ numberval = 1;
2075+ }
2076+ Vector<ColorExpression> colorexps = new Vector<>();
2077+ while (subnode != null) {
2078+ ColorExpression colorexp = parseColorExpression(subnode);
2079+ colorexps.add(colorexp);
2080+ subnode = skipWS(subnode.getNextSibling());
2081+ }
2082+ return new NumberOfExpression(numberval, colorexps);
2083+
2084+ }
2085+
2086+ private Integer parseNumberConstantExpression(Node node) {
2087+ String name = node.getNodeName();
2088+ if (name.equals("numberconstant")) {
2089+ String value = getAttribute(node, "value").getNodeValue();
2090+ return Integer.valueOf(value);
2091+ } else if (name.equals("subterm")) {
2092+ Node child = skipWS(node.getFirstChild());
2093+ return parseNumberConstantExpression(child);
2094+ } else {
2095+ return null;
2096+ }
2097+ }
2098+
2099+ private ColorExpression parseColorExpression(Node node) throws FormatException {
2100+ String name = node.getNodeName();
2101+ if (name.equals("dotconstant")) {
2102+ return new DotConstantExpression();
2103+ } else if (name.equals("variable")) {
2104+ String varname = getAttribute(node, "refvariable").getNodeValue();
2105+ Variable var = variables.get(varname);
2106+ if(var != null){
2107+ return new VariableExpression(var);
2108+ } else {
2109+ return tupleVarExpressions.get(varname);
2110+ }
2111+ } else if (name.equals("useroperator")) {
2112+ String colorname = getAttribute(node, "declaration").getNodeValue();
2113+ Color color = getColor(colorname);
2114+ return new UserOperatorExpression(color);
2115+ } else if (name.equals("successor")) {
2116+ Node child = skipWS(node.getFirstChild());
2117+ ColorExpression childexp = parseColorExpression(child);
2118+ return new SuccessorExpression(childexp);
2119+ } else if (name.equals("predecessor")) {
2120+ Node child = skipWS(node.getFirstChild());
2121+ ColorExpression childexp = parseColorExpression(child);
2122+ return new PredecessorExpression(childexp);
2123+ } else if(name.equals("all")){
2124+ ColorType ct = parseUserSort(node);
2125+ return new AllExpression(ct);
2126+ } else if (name.equals("tuple")) {
2127+ Vector<ColorExpression> colorexps = new Vector<>();
2128+
2129+ Node child = skipWS(node.getFirstChild());
2130+ while (child != null) {
2131+ ColorExpression colorexp = parseColorExpression(child);
2132+ colorexps.add(colorexp);
2133+ child = skipWS(child.getNextSibling());
2134+ }
2135+ //Sometimes PNML nets have tuples with only 1 color, we just remove the tuple
2136+ if(colorexps.size() < 2){
2137+ return colorexps.get(0);
2138+ }
2139+ return new TupleExpression(colorexps);
2140+ } else if (name.matches("subterm|structure")) {
2141+ Node child = skipWS(node.getFirstChild());
2142+ return parseColorExpression(child);
2143+ } else if (name.equals("finiteintrangeconstant")){
2144+ String value = getAttribute(node, "value").getNodeValue();
2145+ //we assume first child is finiteintrange
2146+ Node intRangeElement = skipWS(node.getFirstChild());
2147+ String start = getAttribute(intRangeElement, "start").getNodeValue();
2148+ String end = getAttribute(intRangeElement, "end").getNodeValue();
2149+ return new UserOperatorExpression(findColorForIntRange(value,start,end));
2150+
2151+ } else {
2152+ throw new FormatException(String.format("Could not parse %s as an color expression\n", name));
2153+ }
2154+ }
2155+
2156+ /// This will select the wrong color if the is overlap in naming, eg for IntegerRangeExpr (1,2,3,4) & (1,2)
2157+ private dk.aau.cs.model.CPN.Color getColor(String colorname) throws FormatException {
2158+ for (ColorType ct : colortypes.values()) {
2159+ for (dk.aau.cs.model.CPN.Color c : ct) {
2160+ if (c.getName().equals(colorname)) {
2161+ return c;
2162+ }
2163+ }
2164+ }
2165+ throw new FormatException(String.format("The color \"%s\" was not declared\n", colorname));
2166+ }
2167+
2168+ public GuardExpression parseGuardExpression(Node node) throws FormatException {
2169+ String name = node.getNodeName();
2170+ if (name.matches("lt|lessthan")) {
2171+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2172+ return new LessThanExpression(subexps.value1(), subexps.value2());
2173+ } else if (name.matches("gt|greaterthan")) {
2174+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2175+ return new GreaterThanExpression(subexps.value1(), subexps.value2());
2176+ } else if (name.matches("leq|lessthanorequal")) {
2177+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2178+ return new LessThanEqExpression(subexps.value1(), subexps.value2());
2179+ } else if (name.matches("geq|greaterthanorequal")) {
2180+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2181+ return new GreaterThanEqExpression(subexps.value1(), subexps.value2());
2182+ } else if (name.matches("eq|equality")) {
2183+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2184+ return new EqualityExpression(subexps.value1(), subexps.value2());
2185+ } else if (name.matches("neq|inequality")) {
2186+ Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node);
2187+ return new InequalityExpression(subexps.value1(), subexps.value2());
2188+ } else if (name.equals("not")) {
2189+ Node child = skipWS(node.getFirstChild());
2190+ GuardExpression childexp = parseGuardExpression(child);
2191+ return new NotExpression(childexp);
2192+ } else if (name.equals("and")) {
2193+ Tuple<GuardExpression, GuardExpression> subexps = parseLRGuardExpressions(node);
2194+ return new AndExpression(subexps.value1(), subexps.value2());
2195+ } else if (name.equals("or")) {
2196+ Node left = skipWS(node.getFirstChild());
2197+ Node right = skipWS(left.getNextSibling());
2198+ if(right == null){
2199+ return parseGuardExpression(left);
2200+ }
2201+ GuardExpression parentOr = new OrExpression(parseGuardExpression(left), parseGuardExpression(right));
2202+ for (var it = skipWS(right.getNextSibling()); it != null; it = skipWS(it.getNextSibling())){
2203+ parentOr = new OrExpression(parentOr, parseGuardExpression(it));
2204+ }
2205+ return parentOr;
2206+ } else if (name.matches("subterm|structure")) {
2207+ Node child = skipWS(node.getFirstChild());
2208+ return parseGuardExpression(child);
2209+ } else {
2210+ throw new FormatException(String.format("Could not parse %s as a guard expression\n", name));
2211+ }
2212+ }
2213+
2214+ private Tuple<ColorExpression,ColorExpression> parseLRColorExpressions(Node node) throws FormatException {
2215+ Node left = skipWS(node.getFirstChild());
2216+ ColorExpression leftexp = parseColorExpression(left);
2217+ Node right = skipWS(left.getNextSibling());
2218+ ColorExpression rightexp = parseColorExpression(right);
2219+ return new Tuple<>(leftexp, rightexp);
2220+ }
2221+
2222+ private Tuple<GuardExpression,GuardExpression> parseLRGuardExpressions(Node node) throws FormatException {
2223+ Node left = skipWS(node.getFirstChild());
2224+ GuardExpression leftexp = parseGuardExpression(left);
2225+ Node right = skipWS(left.getNextSibling());
2226+ GuardExpression rightexp = parseGuardExpression(right);
2227+ return new Tuple<>(leftexp, rightexp);
2228+ }
2229+
2230+ Color findColorForIntRange(String value, String start, String end) throws FormatException {
2231+ for(var ct : colortypes.values()){
2232+ if(ct.getColors().get(0).getColorName().equals(start) && ct.getColors().get(ct.getColors().size()-1).getColorName().equals(end)){
2233+ for (dk.aau.cs.model.CPN.Color c : ct) {
2234+ if (c.getName().equals(value)) {
2235+ return c;
2236+ }
2237+ }
2238+ }
2239+ }
2240+ throw new FormatException(String.format("The color \"%s\" was not declared in an int range\n", value));
2241+ }
2242+
2243+ public AddExpression constructCleanAddExpression(ColorType ct, ColorMultiset multiset){
2244+ Vector<ArcExpression> coloredTokenList = new Vector<>();
2245+
2246+ for(Color c : ct.getColors()){
2247+ int numberOf = multiset.get(c);
2248+ if(numberOf < 1){
2249+ continue;
2250+ }
2251+ Vector<ColorExpression> v = new Vector<>();
2252+ if(ct.isProductColorType()){
2253+ Vector<ColorExpression> tupleColors = new Vector<>();
2254+ for(Color tupleCol : c.getTuple()){
2255+ UserOperatorExpression color = new UserOperatorExpression(tupleCol);
2256+ tupleColors.add(color);
2257+ }
2258+ TupleExpression tupleExpr = new TupleExpression(tupleColors);
2259+ v.add(tupleExpr);
2260+ } else {
2261+ UserOperatorExpression color = new UserOperatorExpression(c);
2262+ v.add(color);
2263+ }
2264+ NumberOfExpression numOf = new NumberOfExpression(numberOf,v);
2265+ coloredTokenList.add(numOf);
2266+
2267+ }
2268+ return new AddExpression(coloredTokenList);
2269+ }
2270+}
2271
2272=== modified file 'src/dk/aau/cs/io/LoadedModel.java'
2273--- src/dk/aau/cs/io/LoadedModel.java 2020-08-26 12:29:25 +0000
2274+++ src/dk/aau/cs/io/LoadedModel.java 2022-03-21 20:20:44 +0000
2275@@ -1,12 +1,11 @@
2276 package dk.aau.cs.io;
2277
2278 import java.util.Collection;
2279-import java.util.List;
2280
2281-import dk.aau.cs.gui.TabContent;
2282+import net.tapaal.gui.petrinet.TAPNLens;
2283 import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel;
2284-import pipe.dataLayer.TAPNQuery;
2285-import pipe.dataLayer.Template;
2286+import net.tapaal.gui.petrinet.verification.TAPNQuery;
2287+import net.tapaal.gui.petrinet.Template;
2288 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
2289
2290 public class LoadedModel implements LoadedBatchProcessingModel {
2291@@ -15,9 +14,9 @@
2292 private final Collection<TAPNQuery> queries;
2293 private final TimedArcPetriNetNetwork network;
2294 private final Collection<String> messages;
2295- private final TabContent.TAPNLens lens;
2296+ private final TAPNLens lens;
2297
2298- public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TabContent.TAPNLens lens){
2299+ public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TAPNLens lens){
2300 this.templates = templates;
2301 this.network = network;
2302 this.queries = queries;
2303@@ -30,15 +29,18 @@
2304 public TimedArcPetriNetNetwork network(){ return network; }
2305 public Collection<String> getMessages() { return messages; }
2306
2307- public TabContent.TAPNLens getLens(){
2308+ public TAPNLens getLens(){
2309 if (lens != null) {
2310 return lens;
2311 } else {
2312 boolean isNetTimed = !network().isUntimed();
2313 boolean isNetGame = network().hasUncontrollableTransitions();
2314+ boolean isNetColored = network.isColored();
2315
2316- return new TabContent.TAPNLens(isNetTimed, isNetGame);
2317+ return new TAPNLens(isNetTimed, isNetGame, isNetColored);
2318 }
2319 }
2320-
2321+ public boolean isColored(){
2322+ return lens.isColored();
2323+ }
2324 }
2325\ No newline at end of file
2326
2327=== modified file 'src/dk/aau/cs/io/LoadedQueries.java'
2328--- src/dk/aau/cs/io/LoadedQueries.java 2020-10-09 07:59:49 +0000
2329+++ src/dk/aau/cs/io/LoadedQueries.java 2022-03-21 20:20:44 +0000
2330@@ -1,6 +1,5 @@
2331 package dk.aau.cs.io;
2332-import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
2333-import pipe.dataLayer.TAPNQuery;
2334+import net.tapaal.gui.petrinet.verification.TAPNQuery;
2335 import java.util.Collection;
2336
2337 public class LoadedQueries {
2338
2339=== modified file 'src/dk/aau/cs/io/ModelLoader.java'
2340--- src/dk/aau/cs/io/ModelLoader.java 2021-08-10 11:37:11 +0000
2341+++ src/dk/aau/cs/io/ModelLoader.java 2022-03-21 20:20:44 +0000
2342@@ -7,7 +7,7 @@
2343 import java.io.InputStream;
2344
2345 import dk.aau.cs.TCTL.Parsing.ParseException;
2346-import dk.aau.cs.gui.TabContent;
2347+import net.tapaal.gui.petrinet.TAPNLens;
2348
2349 public class ModelLoader {
2350
2351@@ -52,12 +52,12 @@
2352 return oldFormatLoader.load(new ByteArrayInputStream(baos.toByteArray()));
2353
2354 } catch(Throwable e2) {
2355- throw new ParseException(e1.getMessage());
2356+ throw new Exception(e1.getMessage(), e1);
2357 }
2358 }
2359 }
2360
2361- public TabContent.TAPNLens loadLens(InputStream file) throws Exception{
2362+ public TAPNLens loadLens(InputStream file) throws Exception{
2363 TapnXmlLoader newFormatLoader = new TapnXmlLoader();
2364 ByteArrayOutputStream baos = new ByteArrayOutputStream();
2365 byte[] buffer = new byte[1024];
2366
2367=== renamed file 'src/pipe/dataLayer/NetWriter.java' => 'src/dk/aau/cs/io/NetWriter.java'
2368--- src/pipe/dataLayer/NetWriter.java 2014-05-22 21:26:05 +0000
2369+++ src/dk/aau/cs/io/NetWriter.java 2022-03-21 20:20:44 +0000
2370@@ -1,4 +1,4 @@
2371-package pipe.dataLayer;
2372+package dk.aau.cs.io;
2373
2374 import java.io.ByteArrayOutputStream;
2375 import java.io.File;
2376@@ -12,7 +12,7 @@
2377 public interface NetWriter {
2378 void savePNML(File file) throws NullPointerException, IOException,
2379 ParserConfigurationException, DOMException,
2380- TransformerConfigurationException, TransformerException;
2381+ TransformerException;
2382
2383- ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException;
2384+ ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerException;
2385 }
2386
2387=== modified file 'src/dk/aau/cs/io/PNMLWriter.java'
2388--- src/dk/aau/cs/io/PNMLWriter.java 2020-07-13 13:58:47 +0000
2389+++ src/dk/aau/cs/io/PNMLWriter.java 2022-03-21 20:20:44 +0000
2390@@ -17,20 +17,20 @@
2391 import javax.xml.transform.dom.DOMSource;
2392 import javax.xml.transform.stream.StreamResult;
2393
2394+import net.tapaal.gui.petrinet.TAPNLens;
2395 import org.w3c.dom.DOMException;
2396 import org.w3c.dom.Document;
2397 import org.w3c.dom.Element;
2398
2399-import pipe.dataLayer.DataLayer;
2400-import pipe.dataLayer.NetWriter;
2401+import pipe.gui.petrinet.dataLayer.DataLayer;
2402 import pipe.gui.MessengerImpl;
2403-import pipe.gui.graphicElements.Arc;
2404-import pipe.gui.graphicElements.Place;
2405-import pipe.gui.graphicElements.Transition;
2406-import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent;
2407-import pipe.gui.graphicElements.tapn.TimedOutputArcComponent;
2408-import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
2409-import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
2410+import pipe.gui.petrinet.graphicElements.Arc;
2411+import pipe.gui.petrinet.graphicElements.Place;
2412+import pipe.gui.petrinet.graphicElements.Transition;
2413+import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;
2414+import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent;
2415+import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;
2416+import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent;
2417 import dk.aau.cs.model.tapn.TimedArcPetriNet;
2418 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
2419 import dk.aau.cs.util.Require;
2420@@ -41,19 +41,21 @@
2421 private final TimedArcPetriNetNetwork network;
2422 private TimedArcPetriNet composedNetwork;
2423 private final HashMap<TimedArcPetriNet, DataLayer> guiModels;
2424+ private final TAPNLens lens;
2425+ private final writeTACPN writeTACPN;
2426
2427- public PNMLWriter(
2428- TimedArcPetriNetNetwork network,
2429- HashMap<TimedArcPetriNet, DataLayer> guiModels) {
2430+ public PNMLWriter(TimedArcPetriNetNetwork network, HashMap<TimedArcPetriNet, DataLayer> guiModels, TAPNLens lens) {
2431 this.network = network;
2432 this.guiModels = guiModels;
2433+ this.lens = lens;
2434+ writeTACPN = new writeTACPN(network);
2435 }
2436
2437- public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {
2438+ public ByteArrayOutputStream savePNML() throws ParserConfigurationException, DOMException, TransformerException {
2439 Document document = null;
2440 Transformer transformer = null;
2441 ByteArrayOutputStream os = new ByteArrayOutputStream();
2442- TAPNComposer composer = new TAPNComposer(new MessengerImpl(), guiModels, true, true);
2443+ TAPNComposer composer = new TAPNComposer(new MessengerImpl(), guiModels, lens, true, true);
2444 composedNetwork = composer.transformModel(network).value1();
2445
2446 // Build a Petri Net XML Document
2447@@ -69,17 +71,21 @@
2448 pnmlRootNode.appendChild(netNode);
2449 netNode.setAttribute("id", composedNetwork.name());
2450 netNode.setAttribute("type", "http://www.pnml.org/version-2009/grammar/ptnet");
2451-
2452+
2453+ Element nameNode = document.createElement("name"); //Name of the net
2454+ netNode.appendChild(nameNode);
2455+ Element nameText = document.createElement("text");
2456+ nameNode.appendChild(nameText);
2457+ nameText.setTextContent(composedNetwork.name());
2458+
2459+ if(lens.isColored()) {
2460+ writeTACPN.appendDeclarations(document, netNode);
2461+ }
2462+
2463 Element pageNode = document.createElement("page"); //Page node
2464 netNode.appendChild(pageNode);
2465 pageNode.setAttribute("id", "page0");
2466-
2467- Element nameNode = document.createElement("name"); //Name of the net
2468- netNode.appendChild(nameNode);
2469- Element nameText = document.createElement("text");
2470- nameNode.appendChild(nameText);
2471- nameText.setTextContent(composedNetwork.name());
2472-
2473+
2474 appendPlaces(document, composer.getGuiModel(), pageNode);
2475 appendTransitions(document, composer.getGuiModel(), pageNode);
2476 appendArcs(document, composer.getGuiModel(), pageNode);
2477@@ -96,7 +102,7 @@
2478 return os;
2479 }
2480
2481- public void savePNML(File file) throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {
2482+ public void savePNML(File file) throws IOException, ParserConfigurationException, DOMException, TransformerException {
2483 Require.that(file != null, "Error: file to save to was null");
2484
2485 try {
2486@@ -130,21 +136,36 @@
2487 private void appendPlaces(Document document, DataLayer guiModel, Element NET) {
2488 Place[] places = guiModel.getPlaces();
2489 for (Place place : places) {
2490- NET.appendChild(createPlaceElement((TimedPlaceComponent) place, guiModel, document));
2491+ if (lens.isColored()){
2492+ NET.appendChild(createColorPlaceElement((TimedPlaceComponent) place, guiModel, document));
2493+ }
2494+ else {
2495+ NET.appendChild(createPlaceElement((TimedPlaceComponent) place, guiModel, document));
2496+ }
2497 }
2498 }
2499
2500 private void appendTransitions(Document document, DataLayer guiModel, Element NET) {
2501 Transition[] transitions = guiModel.getTransitions();
2502 for (Transition transition : transitions) {
2503- NET.appendChild(createTransitionElement((TimedTransitionComponent) transition, document));
2504+ if(lens.isColored()) {
2505+ NET.appendChild(createColoredTransitionElement((TimedTransitionComponent) transition, document));
2506+ }
2507+ else {
2508+ NET.appendChild(createTransitionElement((TimedTransitionComponent) transition, document));
2509+ }
2510 }
2511 }
2512
2513 private void appendArcs(Document document, DataLayer guiModel, Element NET) {
2514 Arc[] arcs = guiModel.getArcs();
2515 for (Arc arc : arcs) {
2516- NET.appendChild(createArcElement(arc, guiModel, document));
2517+ if(lens.isColored()) {
2518+ NET.appendChild(createColoredArcElement(arc,guiModel , document));
2519+ }
2520+ else {
2521+ NET.appendChild(createArcElement(arc, guiModel, document));
2522+ }
2523 }
2524 }
2525
2526@@ -188,6 +209,38 @@
2527 return placeElement;
2528 }
2529
2530+ private Element createColorPlaceElement(TimedPlaceComponent inputPlace, DataLayer guiModel, Document document) {
2531+ Require.that(inputPlace != null, "Error: inputPlace was null");
2532+ Require.that(guiModel != null, "Error: guiModel was null");
2533+ Require.that(document != null, "Error: document was null");
2534+
2535+ Element placeElement = document.createElement("place");
2536+ placeElement.setAttribute("id", (inputPlace.getId() != null ? inputPlace.getId() : inputPlace.getName()));
2537+
2538+
2539+ Element name = document.createElement("name"); //Name
2540+ placeElement.appendChild(name);
2541+ Element nameText = document.createElement("text");
2542+ name.appendChild(nameText);
2543+ nameText.setTextContent(inputPlace.underlyingPlace().name());
2544+ Element nameGraphics = document.createElement("graphics");
2545+ name.appendChild(nameGraphics);
2546+ Element nameOffset = document.createElement("offset");
2547+ nameGraphics.appendChild(nameOffset);
2548+ nameOffset.setAttribute("x", String.valueOf(Math.round(inputPlace.getNameOffsetX())));
2549+ nameOffset.setAttribute("y", String.valueOf(Math.round(inputPlace.getNameOffsetY())));
2550+
2551+ Element graphics = document.createElement("graphics");
2552+ placeElement.appendChild(graphics);
2553+ Element offset = document.createElement("position");
2554+ graphics.appendChild(offset);
2555+ offset.setAttribute("x", String.valueOf(Math.round(inputPlace.getPositionX())));
2556+ offset.setAttribute("y", String.valueOf(Math.round(inputPlace.getPositionY())));
2557+
2558+ writeTACPN.appendColoredPlaceDependencies(inputPlace.underlyingPlace(), document, placeElement);
2559+ return placeElement;
2560+ }
2561+
2562 private Element createTransitionElement(TimedTransitionComponent inputTransition, Document document) {
2563 Require.that(inputTransition != null, "Error: inputTransition was null");
2564 Require.that(document != null, "Error: document was null");
2565@@ -217,6 +270,36 @@
2566 return transitionElement;
2567 }
2568
2569+ private Element createColoredTransitionElement (TimedTransitionComponent inputTransition, Document document) {
2570+ Require.that(inputTransition != null, "Error: inputTransition was null");
2571+ Require.that(document != null, "Error: document was null");
2572+
2573+ Element transitionElement = document.createElement("transition");
2574+ transitionElement.setAttribute("id", (inputTransition.getId() != null ? inputTransition.getId() : "error"));
2575+
2576+ Element name = document.createElement("name"); //Name
2577+ transitionElement.appendChild(name);
2578+ Element nameGraphics = document.createElement("graphics");
2579+ name.appendChild(nameGraphics);
2580+ Element nameOffset = document.createElement("offset");
2581+ nameGraphics.appendChild(nameOffset);
2582+ nameOffset.setAttribute("x", String.valueOf(Math.round(inputTransition.getNameOffsetX())));
2583+ nameOffset.setAttribute("y", String.valueOf(Math.round(inputTransition.getNameOffsetY())));
2584+ Element nameText = document.createElement("text");
2585+ name.appendChild(nameText);
2586+ nameText.setTextContent(inputTransition.underlyingTransition().name());
2587+
2588+ Element graphics = document.createElement("graphics");
2589+ transitionElement.appendChild(graphics);
2590+ Element offset = document.createElement("position");
2591+ graphics.appendChild(offset);
2592+ offset.setAttribute("x", String.valueOf(Math.round(inputTransition.getPositionX())));
2593+ offset.setAttribute("y", String.valueOf(Math.round(inputTransition.getPositionY())));
2594+
2595+ writeTACPN.appendColoredTransitionDependencies(inputTransition.underlyingTransition(), document, transitionElement);
2596+ return transitionElement;
2597+ }
2598+
2599 private Element createArcElement(Arc arc, DataLayer guiModel, Document document) {
2600 Require.that(arc != null, "Error: inputArc was null");
2601 Require.that(guiModel != null, "Error: guiModel was null");
2602@@ -258,6 +341,47 @@
2603
2604 return arcElement;
2605 }
2606+
2607+ private Element createColoredArcElement(Arc arc, DataLayer guiModel, Document document) {
2608+ Require.that(arc != null, "Error: inputArc was null");
2609+ Require.that(guiModel != null, "Error: guiModel was null");
2610+ Require.that(document != null, "Error: document was null");
2611+
2612+ Element arcElement = document.createElement("arc");
2613+ arcElement.setAttribute("id", (arc.getId() != null ? arc.getId() : "error"));
2614+ arcElement.setAttribute("source", (arc.getSource().getId() != null ? arc.getSource().getId() : ""));
2615+ arcElement.setAttribute("target", (arc.getTarget().getId() != null ? arc.getTarget().getId() : ""));
2616+
2617+ writeTACPN.appendColoredArcsDependencies(arc, guiModel, document, arcElement);
2618+
2619+ if (arc instanceof TimedOutputArcComponent && arc.getWeight().value() > 1 ) {
2620+ Element inscription = document.createElement("inscription");
2621+ arcElement.appendChild(inscription);
2622+ Element text = document.createElement("text");
2623+ inscription.appendChild(text);
2624+ text.setTextContent(arc.getWeight().nameForSaving(false)+"");
2625+ }
2626+
2627+ if(arc instanceof TimedInhibitorArcComponent){
2628+ arcElement.setAttribute("type", "inhibitor");
2629+ } else {
2630+ arcElement.setAttribute("type", "normal");
2631+ }
2632+
2633+ //ArcPath
2634+ int arcPoints = arc.getArcPath().getArcPathDetails().length;
2635+ if (arcPoints > 2) {
2636+ Element graphics = document.createElement("graphics");
2637+ arcElement.appendChild(graphics);
2638+
2639+ String[][] point = arc.getArcPath().getArcPathDetails();
2640+ for (int j = 1; j < arcPoints-1; j++) { // Do not write the first and last point
2641+ graphics.appendChild(createArcPoint(point[j][0],
2642+ point[j][1], point[j][2], document, j));
2643+ }
2644+ }
2645+ return arcElement;
2646+ }
2647
2648 private Element createArcPoint(String x, String y, String type, Document document, int id) {
2649 Require.that(document != null, "Error: document was null");
2650
2651=== modified file 'src/dk/aau/cs/io/PNMLoader.java'
2652--- src/dk/aau/cs/io/PNMLoader.java 2020-08-26 12:29:25 +0000
2653+++ src/dk/aau/cs/io/PNMLoader.java 2022-03-21 20:20:44 +0000
2654@@ -6,28 +6,25 @@
2655 import java.io.FileNotFoundException;
2656 import java.io.IOException;
2657 import java.io.InputStream;
2658-import java.util.ArrayList;
2659-import java.util.Arrays;
2660-import java.util.HashMap;
2661-import java.util.HashSet;
2662+import java.util.*;
2663
2664 import javax.xml.parsers.DocumentBuilder;
2665 import javax.xml.parsers.DocumentBuilderFactory;
2666 import javax.xml.parsers.ParserConfigurationException;
2667
2668-import dk.aau.cs.gui.TabContent;
2669+import net.tapaal.gui.petrinet.TAPNLens;
2670+import dk.aau.cs.model.CPN.*;
2671+import dk.aau.cs.model.CPN.Expressions.*;
2672 import org.w3c.dom.Document;
2673 import org.w3c.dom.Element;
2674 import org.w3c.dom.Node;
2675 import org.w3c.dom.NodeList;
2676 import org.xml.sax.SAXException;
2677
2678-import dk.aau.cs.gui.NameGenerator;
2679-import dk.aau.cs.model.tapn.Bound;
2680+import net.tapaal.gui.petrinet.NameGenerator;
2681 import dk.aau.cs.model.tapn.IntWeight;
2682 import dk.aau.cs.model.tapn.LocalTimedPlace;
2683 import dk.aau.cs.model.tapn.TimeInterval;
2684-import dk.aau.cs.model.tapn.TimeInvariant;
2685 import dk.aau.cs.model.tapn.TimedArcPetriNet;
2686 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
2687 import dk.aau.cs.model.tapn.TimedInhibitorArc;
2688@@ -38,463 +35,534 @@
2689 import dk.aau.cs.model.tapn.TimedTransition;
2690 import dk.aau.cs.util.FormatException;
2691 import dk.aau.cs.util.Require;
2692-import pipe.dataLayer.DataLayer;
2693-import pipe.dataLayer.TAPNQuery;
2694-import pipe.dataLayer.Template;
2695-import pipe.gui.Pipe;
2696-import pipe.gui.Zoomer;
2697-import pipe.gui.graphicElements.Arc;
2698-import pipe.gui.graphicElements.PlaceTransitionObject;
2699-import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent;
2700-import pipe.gui.graphicElements.tapn.TimedInputArcComponent;
2701-import pipe.gui.graphicElements.tapn.TimedOutputArcComponent;
2702-import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
2703-import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
2704+import pipe.gui.petrinet.dataLayer.DataLayer;
2705+import net.tapaal.gui.petrinet.verification.TAPNQuery;
2706+import net.tapaal.gui.petrinet.Template;
2707+import pipe.gui.Constants;
2708+import pipe.gui.canvas.Zoomer;
2709+import pipe.gui.petrinet.graphicElements.Arc;
2710+import pipe.gui.petrinet.graphicElements.PlaceTransitionObject;
2711+import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;
2712+import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent;
2713+import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent;
2714+import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;
2715+import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent;
2716
2717 public class PNMLoader {
2718-
2719- private final TabContent.TAPNLens lens = TabContent.TAPNLens.Default;
2720+ private TAPNLens lens;
2721
2722 enum GraphicsType { Position, Offset }
2723
2724- private final NameGenerator nameGenerator = new NameGenerator();
2725- private final IdResolver idResolver = new IdResolver();
2726- private final HashSet<String> arcs = new HashSet<String>();
2727- private final HashMap<String, TimedPlace> places = new HashMap<String, TimedPlace>();
2728- private final HashMap<String, TimedTransition> transitions = new HashMap<String, TimedTransition>();
2729-
2730- //If the net is too big, do not make the graphics
2731- private int netSize = 0;
2732- private final int maxNetSize = 4000;
2733- private boolean hasPositionalInfo = false;
2734-
2735- public PNMLoader() {
2736- }
2737-
2738- public LoadedModel load(File file) throws FormatException{
2739- try{
2740- return load(new FileInputStream(file));
2741- } catch (FileNotFoundException e){
2742- return null;
2743- } catch (NullPointerException e){
2744- throw new FormatException("the PNML file cannot be parsed due to syntax errors");
2745- }
2746- }
2747-
2748- public LoadedModel load(InputStream file) throws FormatException{
2749- Document doc = loadDocument(file);
2750-
2751- return parse(doc);
2752- }
2753-
2754- private Document loadDocument(InputStream file) {
2755- try {
2756- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
2757- return builder.parse(file);
2758- } catch (ParserConfigurationException | IOException | SAXException e) {
2759- return null;
2760- }
2761- }
2762-
2763- private LoadedModel parse(Document doc) throws FormatException {
2764- idResolver.clear();
2765-
2766- TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork();
2767-
2768- //We assume there is only one net per file (this is what we call a TAPN Network)
2769- Node pnmlElement = doc.getElementsByTagName("pnml").item(0);
2770- Node netNode = getFirstDirectChild(pnmlElement, "net");
2771-
2772- String name = getTAPNName(netNode);
2773-
2774- TimedArcPetriNet tapn = new TimedArcPetriNet(name);
2775- tapn.setCheckNames(false);
2776- network.add(tapn);
2777- nameGenerator.add(tapn);
2778-
2779- //We assume there is only one page pr. file (this is what we call a net)
2780- Template template = new Template(tapn, new DataLayer(), new Zoomer());
2781-
2782- parseTimedArcPetriNet(netNode, tapn, template);
2783- template.setHasPositionalInfo(hasPositionalInfo);
2784-
2785- network.setPaintNet(isNetDrawable());
2786- tapn.setCheckNames(true);
2787- return new LoadedModel(network, Arrays.asList(template), new ArrayList<TAPNQuery>(), new ArrayList<>(), null);
2788- }
2789-
2790- private String getTAPNName(Node netNode) {
2791- if(!(netNode instanceof Element)){
2792- return nameGenerator.getNewTemplateName();
2793- }
2794- String result = null;
2795-
2796- Node name = getFirstDirectChild(netNode, "name");
2797- if(name != null){
2798- result = getFirstDirectChild(name, "text").getTextContent();
2799- }
2800-
2801- if(name == null || name.equals("")){
2802- return nameGenerator.getNewTemplateName();
2803- }
2804-
2805- return NamePurifier.purify(result);
2806- }
2807-
2808- private void parseTimedArcPetriNet(Node netNode, TimedArcPetriNet tapn, Template template) throws FormatException {
2809- //We assume there is only one page pr. file (this is what we call a net)
2810- Node node = getFirstDirectChild(netNode, "page").getFirstChild();
2811- Node first = node;
2812-
2813- //Calculate netsize
2814- while(node != null){
2815- netSize += 1;
2816- node = node.getNextSibling();
2817- }
2818-
2819- node = first;
2820- //We parse the places and transitions first
2821- while(node != null){
2822- String tag = node.getNodeName();
2823- if(tag.equals("place")){
2824- parsePlace(node, tapn, template);
2825- } else if(tag.equals("transition")){
2826- parseTransition(node, tapn, template);
2827- }
2828- node = node.getNextSibling();
2829- }
2830-
2831- //We parse the transitions last, as we need the places and transitions it refers to
2832- node = first;
2833- while(node != null){
2834- String tag = node.getNodeName();
2835- if(tag.equals("arc")){
2836- parseArc(node, template);
2837- }
2838- node = node.getNextSibling();
2839- }
2840- }
2841-
2842- private void parsePlace(Node node, TimedArcPetriNet tapn, Template template) {
2843- if(!(node instanceof Element)){
2844- return;
2845- }
2846-
2847- Name name = parseName(getFirstDirectChild(node, "name"));
2848- if(name == null){
2849- name = new Name(nameGenerator.getNewPlaceName(template.model()));
2850- }
2851- Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position);
2852- String id = NamePurifier.purify(((Element) node).getAttribute("id"));
2853- InitialMarking marking = parseMarking(getFirstDirectChild(node, "initialMarking"));
2854-
2855- TimedPlace place = new LocalTimedPlace(id, new TimeInvariant(false, new Bound.InfBound()));
2856- Require.that(places.put(id, place) == null && !transitions.containsKey(id),
2857- "The name: " + id + ", was already used");
2858- tapn.add(place);
2859-
2860- if(isNetDrawable()){
2861- //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique
2862- TimedPlaceComponent placeComponent = new TimedPlaceComponent(position.x, position.y, id, name.point.x, name.point.y, lens);
2863- placeComponent.setUnderlyingPlace(place);
2864- template.guiModel().addPetriNetObject(placeComponent);
2865- }
2866-
2867- idResolver.add(tapn.name(), id, id);
2868-
2869- for (int i = 0; i < marking.marking; i++) {
2870- tapn.parentNetwork().marking().add(new TimedToken(place));
2871- }
2872- }
2873-
2874- private InitialMarking parseMarking(Node node) {
2875- if(!(node instanceof Element)){
2876- return new InitialMarking();
2877- }
2878-
2879- Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset);
2880-
2881- int marking = Integer.parseInt(getFirstDirectChild(node, "text").getTextContent());
2882-
2883- return new InitialMarking(marking, offset);
2884- }
2885-
2886- private void parseTransition(Node node, TimedArcPetriNet tapn, Template template) {
2887- if(!(node instanceof Element)){
2888- return;
2889- }
2890-
2891- Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position);
2892- Name name = parseName(getFirstDirectChild(node, "name"));
2893- if(name == null){
2894- name = new Name(nameGenerator.getNewTransitionName(template.model()));
2895- }
2896- String id = NamePurifier.purify(((Element) node).getAttribute("id"));
2897-
2898- TimedTransition transition = new TimedTransition(id);
2899- Require.that(transitions.put(id, transition) == null && !places.containsKey(id),
2900- "The id: " + id + ", was already used");
2901- tapn.add(transition);
2902-
2903- if(isNetDrawable()){
2904- TimedTransitionComponent transitionComponent =
2905- //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique
2906- new TimedTransitionComponent(position.x, position.y, id, name.point.x, name.point.y, true, false, 0, 0, lens);
2907- transitionComponent.setUnderlyingTransition(transition);
2908- template.guiModel().addPetriNetObject(transitionComponent);
2909- }
2910- idResolver.add(tapn.name(), id, id);
2911- }
2912-
2913- private void parseArc(Node node, Template template) throws FormatException {
2914- if(!(node instanceof Element)){
2915- return;
2916- }
2917-
2918- Element element = (Element) node;
2919-
2920- String id = element.getAttribute("id");
2921- String sourceId = NamePurifier.purify(element.getAttribute("source"));
2922- String targetId = NamePurifier.purify(element.getAttribute("target"));
2923- String type = element.getAttribute("type");
2924-
2925- String sourceName = idResolver.get(template.model().name(), sourceId);
2926- String targetName = idResolver.get(template.model().name(), targetId);
2927-
2928- TimedPlace sourcePlace = places.get(sourceName);
2929- TimedPlace targetPlace = places.get(targetName);
2930-
2931- TimedTransition sourceTransition = transitions.get(sourceName);
2932- TimedTransition targetTransition = transitions.get(targetName);
2933-
2934- PlaceTransitionObject source = template.guiModel().getPlaceTransitionObject(sourceName);
2935- PlaceTransitionObject target = template.guiModel().getPlaceTransitionObject(targetName);
2936-
2937- //Inscription
2938- int weight = 1;
2939- Node inscription = getFirstDirectChild(node, "inscription");
2940- if(inscription != null){
2941- Node text = getFirstDirectChild(inscription, "text");
2942- if(text != null){
2943- String weightString = text.getTextContent().trim();
2944+ private final NameGenerator nameGenerator = new NameGenerator();
2945+ private final IdResolver idResolver = new IdResolver();
2946+ private final HashSet<String> arcs = new HashSet<String>();
2947+ private final HashMap<String, TimedPlace> places = new HashMap<String, TimedPlace>();
2948+ private final HashMap<String, TimedTransition> transitions = new HashMap<String, TimedTransition>();
2949+ private final HashMap<String, ColorType> colortypes = new HashMap<String, ColorType>();
2950+ private final HashMap<String, Variable> variables = new HashMap<String, Variable>();
2951+
2952+ //If the net is too big, do not make the graphics
2953+ private int netSize = 0;
2954+ private final int maxNetSize = 4000;
2955+ private boolean hasPositionalInfo = false;
2956+ private final LoadTACPN loadTACPN;
2957+
2958+ public PNMLoader() {
2959+ this.lens = TAPNLens.Default;
2960+ loadTACPN = new LoadTACPN();
2961+ }
2962+
2963+ public LoadedModel load(File file) throws FormatException{
2964+ try{
2965+ return load(new FileInputStream(file));
2966+ } catch (FileNotFoundException e){
2967+ return null;
2968+ } catch (NullPointerException e){
2969+ throw new FormatException("the PNML file cannot be parsed due to syntax errors", e);
2970+ }
2971+ }
2972+
2973+ public LoadedModel load(InputStream file) throws FormatException{
2974+ Document doc = loadDocument(file);
2975+
2976+ return parse(doc);
2977+ }
2978+
2979+ private Document loadDocument(InputStream file) {
2980+ try {
2981+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
2982+ return builder.parse(file);
2983+ } catch (ParserConfigurationException | IOException | SAXException e) {
2984+ return null;
2985+ }
2986+ }
2987+
2988+ private LoadedModel parse(Document doc) throws FormatException {
2989+ idResolver.clear();
2990+
2991+ TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork();
2992+
2993+ //We assume there is only one net per file (this is what we call a TAPN Network)
2994+ Node pnmlElement = doc.getElementsByTagName("pnml").item(0);
2995+ Node netNode = getFirstDirectChild(pnmlElement, "net");
2996+
2997+ lens = new TAPNLens(false, false, getFirstDirectChild(netNode, "declaration") != null);
2998+
2999+ String name = getTAPNName(netNode);
3000+
3001+ TimedArcPetriNet tapn = new TimedArcPetriNet(name);
3002+ tapn.setCheckNames(false);
3003+ network.add(tapn);
3004+ nameGenerator.add(tapn);
3005+
3006+ //We assume there is only one page pr. file (this is what we call a net)
3007+ Template template = new Template(tapn, new DataLayer(), new Zoomer());
3008+
3009+ parseTimedArcPetriNet(netNode, tapn, template, network);
3010+ template.setHasPositionalInfo(hasPositionalInfo);
3011+
3012+ network.setPaintNet(isNetDrawable());
3013+ tapn.setCheckNames(true);
3014+
3015+ return new LoadedModel(network, List.of(template), new ArrayList<TAPNQuery>(), new ArrayList<>(), lens);
3016+ }
3017+
3018+ private String getTAPNName(Node netNode) {
3019+ if(!(netNode instanceof Element)){
3020+ return nameGenerator.getNewTemplateName();
3021+ }
3022+ String result = null;
3023+
3024+ Node name = getFirstDirectChild(netNode, "name");
3025+ if(name != null){
3026+ result = getFirstDirectChild(name, "text").getTextContent();
3027+ }
3028+
3029+ if(name == null || name.equals("")){
3030+ return nameGenerator.getNewTemplateName();
3031+ }
3032+
3033+ return NamePurifier.purify(result);
3034+ }
3035+
3036+ private void parseTimedArcPetriNet(Node netNode, TimedArcPetriNet tapn, Template template, TimedArcPetriNetNetwork network) throws FormatException {
3037+ if (lens.isColored()) {
3038+ Node declarations = getFirstDirectChild(netNode, "declaration");
3039+ loadTACPN.parseDeclarations(declarations, network);
3040+ }
3041+
3042+ //We assume there is only one page pr. file (this is what we call a net)
3043+ Node node = getFirstDirectChild(netNode, "page").getFirstChild();
3044+ Node first = node;
3045+
3046+ //Calculate netsize
3047+ while(node != null){
3048+ netSize += 1;
3049+ node = node.getNextSibling();
3050+ }
3051+
3052+ node = first;
3053+ //We parse the places and transitions first
3054+ while(node != null){
3055+ String tag = node.getNodeName();
3056+ if(tag.equals("place")){
3057+ parsePlace(node, tapn, template);
3058+ } else if(tag.equals("transition")){
3059+ parseTransition(node, tapn, template);
3060+ }
3061+ node = node.getNextSibling();
3062+ }
3063+ //We parse the transitions last, as we need the places and transitions it refers to
3064+ node = first;
3065+ while(node != null){
3066+ String tag = node.getNodeName();
3067+ if(tag.equals("arc")){
3068+ parseArc(node, template);
3069+ }
3070+ node = node.getNextSibling();
3071+ }
3072+ }
3073+ private void parsePlace(Node node, TimedArcPetriNet tapn, Template template) throws FormatException {
3074+ if (!(node instanceof Element)) {
3075+ return;
3076+ }
3077+
3078+ Name name = parseName(getFirstDirectChild(node, "name"));
3079+ if (name == null) {
3080+ name = new Name(nameGenerator.getNewPlaceName(template.model()));
3081+ }
3082+ Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position);
3083+ String id = NamePurifier.purify(((Element) node).getAttribute("id"));
3084+ ArcExpression colorMarking = null;
3085+ Point markingOffset = null;
3086+ TimedPlace place;
3087+ InitialMarking marking = parseMarking(getFirstDirectChild(node, "initialMarking"));
3088+ ColorType colorType = ColorType.COLORTYPE_DOT;
3089+ Node typeNode = getFirstDirectChild(node, "type");
3090+ if (typeNode != null) {
3091+ try {
3092+ colorType = loadTACPN.parseUserSort(typeNode);
3093+ } catch (FormatException e) {
3094+ e.printStackTrace();
3095+ }
3096+ }
3097+ Node markingNode = getFirstDirectChild(node, "hlinitialMarking");
3098+ if (markingNode instanceof Element) {
3099+ try {
3100+ colorMarking = loadTACPN.parseArcExpression(((Element) markingNode).getElementsByTagName("structure").item(0));
3101+ } catch (FormatException e) {
3102+ e.printStackTrace();
3103+ }
3104+ }
3105+ place = new LocalTimedPlace(id, colorType);
3106+
3107+ Require.that(places.put(id, place) == null && !transitions.containsKey(id),
3108+ "The name: " + id + ", was already used");
3109+ tapn.add(place);
3110+
3111+ if (isNetDrawable()) {
3112+ //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique
3113+ TimedPlaceComponent placeComponent;
3114+ placeComponent = new TimedPlaceComponent(position.x, position.y, id, name.point.x, name.point.y, lens);
3115+ placeComponent.setUnderlyingPlace(place);
3116+ template.guiModel().addPetriNetObject(placeComponent);
3117+ }
3118+
3119+ idResolver.add(tapn.name(), id, id);
3120+
3121+
3122+ if (colorMarking != null) {
3123+ ExpressionContext context = new ExpressionContext(new HashMap<String, Color>(), loadTACPN.getColortypes());
3124+ ColorMultiset cm = colorMarking.eval(context);
3125+ place.setTokenExpression(loadTACPN.constructCleanAddExpression(colorType,cm));
3126+ for (TimedToken ct : cm.getTokens(place)) {
3127+ tapn.parentNetwork().marking().add(ct);
3128+ }
3129+
3130+ } else {
3131+ for (int i = 0; i < marking.marking; i++) {
3132+ tapn.parentNetwork().marking().add(new TimedToken(place, ColorType.COLORTYPE_DOT.getFirstColor()));
3133+ }
3134+ if (marking.marking > 1) {
3135+ Vector<ColorExpression> v = new Vector<>();
3136+ v.add(new DotConstantExpression());
3137+ Vector<ArcExpression> numbOfExpression = new Vector<>();
3138+ numbOfExpression.add(new NumberOfExpression(marking.marking, v));
3139+ place.setTokenExpression(new AddExpression(numbOfExpression));
3140+ }
3141+ }
3142+ }
3143+
3144+
3145+ private static Node skipWS(Node node) {
3146+ if (node != null && !(node instanceof Element)) {
3147+ return skipWS(node.getNextSibling());
3148+ } else {
3149+ return node;
3150+ }
3151+ }
3152+
3153+ private static Node getAttribute(Node node, String attribute) {
3154+ return node.getAttributes().getNamedItem(attribute);
3155+ }
3156+
3157+
3158+ private InitialMarking parseMarking(Node node) {
3159+ if(!(node instanceof Element)){
3160+ return new InitialMarking();
3161+ }
3162+
3163+ Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset);
3164+
3165+ int marking = Integer.parseInt(getFirstDirectChild(node, "text").getTextContent());
3166+
3167+ return new InitialMarking(marking, offset);
3168+ }
3169+
3170+ private void parseTransition(Node node, TimedArcPetriNet tapn, Template template) throws FormatException {
3171+ if(!(node instanceof Element)){
3172+ return;
3173+ }
3174+
3175+ Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position);
3176+ Name name = parseName(getFirstDirectChild(node, "name"));
3177+ if(name == null){
3178+ name = new Name(nameGenerator.getNewTransitionName(template.model()));
3179+ }
3180+ String id = NamePurifier.purify(((Element) node).getAttribute("id"));
3181+
3182+ GuardExpression guardExpression = null;
3183+ Node conditionNode = getFirstDirectChild(node, "condition");
3184+ if (conditionNode != null) {
3185+ guardExpression = loadTACPN.parseGuardExpression(getFirstDirectChild(conditionNode, "structure"));
3186+ }
3187+
3188+ TimedTransition transition = new TimedTransition(id, guardExpression);
3189+ Require.that(transitions.put(id, transition) == null && !places.containsKey(id),
3190+ "The id: " + id + ", was already used");
3191+ tapn.add(transition);
3192+
3193+ if(isNetDrawable()){
3194+ TimedTransitionComponent transitionComponent =
3195+ //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique
3196+ new TimedTransitionComponent(position.x, position.y, id, name.point.x, name.point.y, 0, lens);
3197+ transitionComponent.setUnderlyingTransition(transition);
3198+ template.guiModel().addPetriNetObject(transitionComponent);
3199+ }
3200+ idResolver.add(tapn.name(), id, id);
3201+ }
3202+
3203+ private void parseArc(Node node, Template template) throws FormatException {
3204+ if(!(node instanceof Element)){
3205+ return;
3206+ }
3207+
3208+ Element element = (Element) node;
3209+
3210+ String id = element.getAttribute("id");
3211+ String sourceId = NamePurifier.purify(element.getAttribute("source"));
3212+ String targetId = NamePurifier.purify(element.getAttribute("target"));
3213+ String type = element.getAttribute("type");
3214+
3215+ String sourceName = idResolver.get(template.model().name(), sourceId);
3216+ String targetName = idResolver.get(template.model().name(), targetId);
3217+
3218+ TimedPlace sourcePlace = places.get(sourceName);
3219+ TimedPlace targetPlace = places.get(targetName);
3220+
3221+ TimedTransition sourceTransition = transitions.get(sourceName);
3222+ TimedTransition targetTransition = transitions.get(targetName);
3223+
3224+ PlaceTransitionObject source = template.guiModel().getPlaceTransitionObject(sourceName);
3225+ PlaceTransitionObject target = template.guiModel().getPlaceTransitionObject(targetName);
3226+
3227+ //Inscription
3228+ int weight = 1;
3229+ Node inscription = getFirstDirectChild(node, "inscription");
3230+ if(inscription != null){
3231+ Node text = getFirstDirectChild(inscription, "text");
3232+ if(text != null){
3233+ String weightString = text.getTextContent().trim();
3234 try {
3235 weight = Integer.parseInt(weightString);
3236 } catch (NumberFormatException ignored) {} //Default values is 1
3237- }
3238- }
3239-
3240- int _startx = 0, _starty = 0, _endx = 0, _endy = 0;
3241-
3242- if(isNetDrawable()){
3243- // add the insets and offset
3244- _startx = source.getX() + source.centreOffsetLeft();
3245- _starty = source.getY() + source.centreOffsetTop();
3246-
3247- _endx = target.getX() + target.centreOffsetLeft();
3248- _endy = target.getY() + target.centreOffsetTop();
3249- }
3250-
3251- Arc tempArc;
3252-
3253- if(type != null && type.equals("inhibitor")) {
3254- tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template);
3255- } else if(sourcePlace != null && targetTransition != null) {
3256- tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template);
3257- } else if(sourceTransition != null && targetPlace != null) {
3258- tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, _endx, _endy, template);
3259- } else {
3260- throw new FormatException("Arcs must be only between places and transitions");
3261- }
3262-
3263- if(isNetDrawable()) parseArcPath(element, tempArc);
3264- }
3265-
3266- private void parseArcPath(Element arc, Arc tempArc) {
3267- Element element = (Element) getFirstDirectChild(arc, "graphics");
3268- if(element == null) return;
3269- NodeList nodelist = element.getElementsByTagName("position");
3270- if (nodelist.getLength() > 0) {
3271- for (int i = 0; i < nodelist.getLength(); i++) {
3272- Node node = nodelist.item(i);
3273- if (node instanceof Element) {
3274- Element position = (Element) node;
3275- if ("position".equals(position.getNodeName())) {
3276- String arcTempX = position.getAttribute("x");
3277- String arcTempY = position.getAttribute("y");
3278-
3279- double arcPointX = Double.parseDouble(arcTempX);
3280+ }
3281+ }
3282+
3283+ int _startx = 0, _starty = 0, _endx = 0, _endy = 0;
3284+
3285+ if(isNetDrawable()){
3286+ // add the insets and offset
3287+ _startx = source.getX() + source.centreOffsetLeft();
3288+ _starty = source.getY() + source.centreOffsetTop();
3289+
3290+ _endx = target.getX() + target.centreOffsetLeft();
3291+ _endy = target.getY() + target.centreOffsetTop();
3292+ }
3293+
3294+ Arc tempArc;
3295+ ArcExpression arcExpression = null;
3296+ Node hlInscriptionNode = getFirstDirectChild(node, "hlinscription");
3297+ if (hlInscriptionNode != null) {
3298+ arcExpression = loadTACPN.parseArcExpression(getFirstDirectChild(hlInscriptionNode, "structure"));
3299+ }
3300+
3301+ if(type != null && type.equals("inhibitor")) {
3302+ tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, arcExpression, _endx, _endy, template);
3303+ } else if(sourcePlace != null && targetTransition != null) {
3304+ tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, arcExpression, _endx, _endy, template);
3305+ } else if(sourceTransition != null && targetPlace != null) {
3306+ tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, arcExpression, _endx, _endy, template);
3307+ } else {
3308+ throw new FormatException("Arcs must be only between places and transitions");
3309+ }
3310+
3311+ if(isNetDrawable()) parseArcPath(element, tempArc);
3312+ }
3313+
3314+ private void parseArcPath(Element arc, Arc tempArc) {
3315+ Element element = (Element) getFirstDirectChild(arc, "graphics");
3316+ if(element == null) return;
3317+ NodeList nodelist = element.getElementsByTagName("position");
3318+ if (nodelist.getLength() > 0) {
3319+ for (int i = 0; i < nodelist.getLength(); i++) {
3320+ Node node = nodelist.item(i);
3321+ if (node instanceof Element) {
3322+ Element position = (Element) node;
3323+ if ("position".equals(position.getNodeName())) {
3324+ String arcTempX = position.getAttribute("x");
3325+ String arcTempY = position.getAttribute("y");
3326+
3327+ double arcPointX = Double.parseDouble(arcTempX);
3328 double arcPointY = Double.parseDouble(arcTempY);
3329- arcPointX += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
3330- arcPointY += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
3331-
3332- //We add the point at i+1 as the starting and end points of
3333- //the arc is already in the path as point number 0 and 1
3334- tempArc.getArcPath().addPoint(i+1,arcPointX, arcPointY, false);
3335- }
3336- }
3337- }
3338- }
3339- }
3340-
3341- private Name parseName(Node node){
3342- if(!(node instanceof Element)){
3343- return null;
3344- }
3345- Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset);
3346-
3347- String name = getFirstDirectChild(node, "text").getTextContent();
3348- if(name == null || name.equals("")){
3349- return null;
3350- }
3351-
3352- name = NamePurifier.purify(name);
3353- return new Name(name, offset);
3354- }
3355-
3356- private Point parseGraphics(Node node, GraphicsType type){
3357- if(!(node instanceof Element)){
3358- if(type == GraphicsType.Offset)
3359- return new Point(0, -10);
3360- else
3361- return new Point(100, 100);
3362- }
3363-
3364- hasPositionalInfo = true;
3365- Element offset = (Element)getFirstDirectChild(node, type == GraphicsType.Offset ? "offset" : "position");
3366-
3367- String x = offset.getAttribute("x");
3368- String y = offset.getAttribute("y");
3369-
3370- int xd = Math.round(Float.parseFloat(x));
3371- int yd = Math.round(Float.parseFloat(y));
3372-
3373- return new Point(xd, yd);
3374- }
3375-
3376- private static class Name{
3377- String name;
3378- Point point;
3379-
3380- public Name(String newPlaceName) {
3381- this(newPlaceName, new Point());
3382- }
3383-
3384- public Name(String name, Point p) {
3385- this.name = name;
3386- this.point = p;
3387- }
3388-
3389- @Override
3390- public String toString() {
3391- return name + ";" + point;
3392- }
3393- }
3394-
3395- private static class InitialMarking{
3396- int marking;
3397- Point point;
3398-
3399- public InitialMarking() {
3400- this(0, new Point());
3401- }
3402-
3403-
3404- public InitialMarking(int marking, Point p) {
3405- this.marking = marking;
3406- this.point = p;
3407- }
3408-
3409- @Override
3410- public String toString() {
3411- return marking + ";" + point;
3412- }
3413- }
3414-
3415- private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
3416- PlaceTransitionObject target, int weight, int _endx,
3417+ arcPointX += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
3418+ arcPointY += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
3419+
3420+ //We add the point at i+1 as the starting and end points of
3421+ //the arc is already in the path as point number 0 and 1
3422+ tempArc.getArcPath().addPoint(i+1,arcPointX, arcPointY, false);
3423+ }
3424+ }
3425+ }
3426+ }
3427+ }
3428+
3429+ private Name parseName(Node node){
3430+ if(!(node instanceof Element)){
3431+ return null;
3432+ }
3433+ Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset);
3434+
3435+ String name = getFirstDirectChild(node, "text").getTextContent();
3436+ if(name == null || name.equals("")){
3437+ return null;
3438+ }
3439+
3440+ name = NamePurifier.purify(name);
3441+ return new Name(name, offset);
3442+ }
3443+
3444+ private Point parseGraphics(Node node, GraphicsType type){
3445+ if(!(node instanceof Element)){
3446+ if(type == GraphicsType.Offset)
3447+ return new Point(0, -10);
3448+ else
3449+ return new Point(100, 100);
3450+ }
3451+
3452+ hasPositionalInfo = true;
3453+ Element offset = (Element)getFirstDirectChild(node, type == GraphicsType.Offset ? "offset" : "position");
3454+
3455+ String x = offset.getAttribute("x");
3456+ String y = offset.getAttribute("y");
3457+
3458+ int xd = Math.round(Float.parseFloat(x));
3459+ int yd = Math.round(Float.parseFloat(y));
3460+
3461+ return new Point(xd, yd);
3462+ }
3463+
3464+ private static class Name{
3465+ final String name;
3466+ final Point point;
3467+
3468+ public Name(String newPlaceName) {
3469+ this(newPlaceName, new Point());
3470+ }
3471+
3472+ public Name(String name, Point p) {
3473+ this.name = name;
3474+ this.point = p;
3475+ }
3476+
3477+ @Override
3478+ public String toString() {
3479+ return name + ";" + point;
3480+ }
3481+ }
3482+
3483+ private static class InitialMarking{
3484+ final int marking;
3485+ final Point point;
3486+
3487+ public InitialMarking() {
3488+ this(0, new Point());
3489+ }
3490+
3491+
3492+ public InitialMarking(int marking, Point p) {
3493+ this.marking = marking;
3494+ this.point = p;
3495+ }
3496+
3497+ @Override
3498+ public String toString() {
3499+ return marking + ";" + point;
3500+ }
3501+ }
3502+
3503+ private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
3504+ PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx,
3505 int _endy, Template template) throws FormatException {
3506-
3507- TimedInputArc inputArc = new TimedInputArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight));
3508-
3509- Require.that(places.containsKey(inputArc.source().name()), "The source place must be part of the petri net.");
3510- Require.that(transitions.containsKey(inputArc.destination().name()), "The destination transition must be part of the petri net");
3511- if(!arcs.add(inputArc.source().name() + "-in-" + inputArc.destination().name())) {
3512- throw new FormatException("Multiple arcs between a place and a transition is not allowed");
3513- }
3514-
3515- TimedInputArcComponent arc = null;
3516-
3517- if(isNetDrawable()){
3518- arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId), lens);
3519- arc.setUnderlyingArc(inputArc);
3520-
3521- template.guiModel().addPetriNetObject(arc);
3522- }
3523-
3524- template.model().add(inputArc);
3525-
3526- return arc;
3527-
3528-
3529- }
3530-
3531- private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source,
3532- PlaceTransitionObject target, int weight, int _endx,
3533+ TimedInputArc inputArc = new TimedInputArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight), arcExpression);
3534+
3535+ Require.that(places.containsKey(inputArc.source().name()), "The source place must be part of the petri net.");
3536+ Require.that(transitions.containsKey(inputArc.destination().name()), "The destination transition must be part of the petri net");
3537+ if(!arcs.add(inputArc.source().name() + "-in-" + inputArc.destination().name())) {
3538+ throw new FormatException("Multiple arcs between a place and a transition is not allowed");
3539+ }
3540+
3541+ TimedInputArcComponent arc = null;
3542+
3543+ if(isNetDrawable()){
3544+ arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId), lens);
3545+ arc.setUnderlyingArc(inputArc);
3546+
3547+ template.guiModel().addPetriNetObject(arc);
3548+ }
3549+
3550+ template.model().add(inputArc);
3551+
3552+ return arc;
3553+
3554+
3555+ }
3556+
3557+ private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source,
3558+ PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx,
3559 int _endy, Template template) throws FormatException {
3560-
3561- TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight));
3562-
3563- Require.that(places.containsKey(outputArc.destination().name()), "The destination place must be part of the petri net.");
3564- Require.that(transitions.containsKey(outputArc.source().name()), "The source transition must be part of the petri net");
3565- if(!arcs.add(outputArc.source().name() + "-out-" + outputArc.destination().name())) {
3566- throw new FormatException("Multiple arcs between a place and a transition is not allowed");
3567- }
3568-
3569- TimedOutputArcComponent arc = null;
3570-
3571- if(isNetDrawable()){
3572- arc = new TimedOutputArcComponent(
3573+ TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight),arcExpression);
3574+
3575+ Require.that(places.containsKey(outputArc.destination().name()), "The destination place must be part of the petri net.");
3576+ Require.that(transitions.containsKey(outputArc.source().name()), "The source transition must be part of the petri net");
3577+ if(!arcs.add(outputArc.source().name() + "-out-" + outputArc.destination().name())) {
3578+ throw new FormatException("Multiple arcs between a place and a transition is not allowed");
3579+ }
3580+
3581+ TimedOutputArcComponent arc = null;
3582+
3583+ if(isNetDrawable()){
3584+ arc = new TimedOutputArcComponent(
3585 source, target, weight, arcId);
3586- arc.setUnderlyingArc(outputArc);
3587-
3588- template.guiModel().addPetriNetObject(arc);
3589-
3590- }
3591-
3592- template.model().add(outputArc);
3593- return arc;
3594- }
3595-
3596- private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
3597- PlaceTransitionObject target, int weight, int _endx,
3598+ arc.setUnderlyingArc(outputArc);
3599+
3600+ template.guiModel().addPetriNetObject(arc);
3601+
3602+ }
3603+
3604+ template.model().add(outputArc);
3605+ return arc;
3606+ }
3607+
3608+ private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
3609+ PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx,
3610 int _endy, Template template) {
3611- TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(
3612- new TimedInputArcComponent(
3613- new TimedOutputArcComponent(source, target, weight, arcId)
3614- ),
3615- (""));
3616-
3617- TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight));
3618-
3619- tempArc.setUnderlyingArc(inhibArc);
3620- template.guiModel().addPetriNetObject(tempArc);
3621- template.model().add(inhibArc);
3622-
3623- return tempArc;
3624- }
3625-
3626- private boolean isNetDrawable(){
3627- return netSize <= maxNetSize;
3628- }
3629-
3630- Node getFirstDirectChild(Node parent, String tagName){
3631- NodeList children = parent.getChildNodes();
3632- for(int i = 0; i < children.getLength(); i++){
3633- if(children.item(i).getNodeName().equals(tagName)){
3634- return children.item(i);
3635- }
3636- }
3637- return null;
3638- }
3639+ TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(
3640+ new TimedInputArcComponent(
3641+ new TimedOutputArcComponent(source, target, weight, arcId)
3642+ ));
3643+
3644+ TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight), arcExpression);
3645+
3646+ tempArc.setUnderlyingArc(inhibArc);
3647+ template.guiModel().addPetriNetObject(tempArc);
3648+ template.model().add(inhibArc);
3649+
3650+ return tempArc;
3651+ }
3652+
3653+ private boolean isNetDrawable(){
3654+ return netSize <= maxNetSize;
3655+ }
3656+
3657+ Node getFirstDirectChild(Node parent, String tagName){
3658+ NodeList children = parent.getChildNodes();
3659+ for(int i = 0; i < children.getLength(); i++){
3660+ if(children.item(i).getNodeName().equals(tagName)){
3661+ return children.item(i);
3662+ }
3663+ }
3664+ return null;
3665+ }
3666
3667 }
3668
3669=== added file 'src/dk/aau/cs/io/TapnEngineXmlLoader.java'
3670--- src/dk/aau/cs/io/TapnEngineXmlLoader.java 1970-01-01 00:00:00 +0000
3671+++ src/dk/aau/cs/io/TapnEngineXmlLoader.java 2022-03-21 20:20:44 +0000
3672@@ -0,0 +1,993 @@
3673+package dk.aau.cs.io;
3674+
3675+import net.tapaal.gui.petrinet.NameGenerator;
3676+import net.tapaal.gui.petrinet.TAPNLens;
3677+import dk.aau.cs.io.queries.TAPNQueryLoader;
3678+import dk.aau.cs.model.CPN.*;
3679+import dk.aau.cs.model.CPN.Expressions.*;
3680+import dk.aau.cs.model.tapn.*;
3681+import dk.aau.cs.util.FormatException;
3682+import dk.aau.cs.util.Require;
3683+import kotlin.Pair;
3684+import org.w3c.dom.Document;
3685+import org.w3c.dom.Element;
3686+import org.w3c.dom.Node;
3687+import org.w3c.dom.NodeList;
3688+import org.xml.sax.SAXException;
3689+import pipe.gui.petrinet.dataLayer.DataLayer;
3690+import net.tapaal.gui.petrinet.Template;
3691+import pipe.gui.Constants;
3692+import pipe.gui.canvas.Zoomer;
3693+import pipe.gui.petrinet.graphicElements.AnnotationNote;
3694+import pipe.gui.petrinet.graphicElements.Arc;
3695+import pipe.gui.petrinet.graphicElements.Place;
3696+import pipe.gui.petrinet.graphicElements.PlaceTransitionObject;
3697+import pipe.gui.petrinet.graphicElements.tapn.*;
3698+
3699+import javax.xml.parsers.DocumentBuilder;
3700+import javax.xml.parsers.DocumentBuilderFactory;
3701+import javax.xml.parsers.ParserConfigurationException;
3702+import java.io.File;
3703+import java.io.IOException;
3704+import java.util.*;
3705+
3706+/*
3707+ This is a huge quick hack to allow reading an unfolded net from then engine.
3708+ The engine format uses <graphics> tags to store elements unlike the tapn format.
3709+
3710+ It feel like this should not work, but it seems to do, and we needed a quick hack to get it working.
3711+
3712+ */
3713+
3714+public class TapnEngineXmlLoader {
3715+ private static final String PLACENAME_ERROR_MESSAGE = "The keywords \"true\" and \"false\" are reserved and can not be used as place names.\nPlaces with these names will be renamed to \"_true\" and \"_false\" respectively.\n\n Note that any queries using these places may not be parsed correctly.";
3716+
3717+ private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
3718+ private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
3719+ private final HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>();
3720+ private final HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>> coloredTransportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>>();
3721+ private ArcExpression transportExpr;
3722+
3723+ private final NameGenerator nameGenerator = new NameGenerator();
3724+ private boolean firstInhibitorIntervalWarning = true;
3725+ private boolean firstPlaceRenameWarning = true;
3726+ private final IdResolver idResolver = new IdResolver();
3727+ private final Collection<String> messages = new ArrayList<>(10);
3728+ private final LoadTACPN loadTACPN = new LoadTACPN();
3729+
3730+ boolean hasFeatureTag = false;
3731+ private TAPNLens lens = TAPNLens.Default;
3732+
3733+ public TapnEngineXmlLoader() {}
3734+
3735+ public LoadedModel load(File file) throws Exception {
3736+ Require.that(file != null && file.exists(), "file must be non-null and exist");
3737+
3738+ Document doc = loadDocument(file);
3739+ if(doc == null) return null;
3740+ try {
3741+ return parse(doc);
3742+ } catch (FormatException | NullPointerException e) {
3743+ throw e;
3744+ } catch (Exception e) {
3745+ throw new Exception("One or more necessary attributes were not found\n - One or more attribute values have an incorrect type", e);
3746+ }
3747+ }
3748+
3749+ private Document loadDocument(File file) {
3750+ try {
3751+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
3752+ return builder.parse(file);
3753+ } catch (ParserConfigurationException | IOException | SAXException e) {
3754+ return null;
3755+ }
3756+ }
3757+
3758+ private LoadedModel parse(Document doc) throws FormatException {
3759+ idResolver.clear();
3760+
3761+ ConstantStore constants = new ConstantStore(parseConstants(doc));
3762+ TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants, new ArrayList<>());
3763+ NodeList declarations = doc.getElementsByTagName("declaration");
3764+
3765+ if (declarations.getLength() > 0) {
3766+ for (int i = 0; i < declarations.getLength(); i++) {
3767+ Node node = declarations.item(i);
3768+ if (node.getNodeName().equals("declaration")) {
3769+ loadTACPN.parseDeclarations(node, network);
3770+ }
3771+ }
3772+ for(String message : loadTACPN.getMessages()){
3773+ messages.add(message);
3774+ }
3775+ } else{
3776+ network.add(ColorType.COLORTYPE_DOT);
3777+ }
3778+ parseSharedPlaces(doc, network, constants);
3779+ parseSharedTransitions(doc, network);
3780+
3781+ Collection<Template> templates = parseTemplates(doc, network, constants);
3782+ LoadedQueries loadedQueries = new TAPNQueryLoader(doc, network).parseQueries();
3783+
3784+ if (loadedQueries != null) {
3785+ for (String message : loadedQueries.getMessages()) {
3786+ messages.add(message);
3787+ }
3788+ }
3789+ network.buildConstraints();
3790+
3791+ parseBound(doc, network);
3792+
3793+ parseFeature(doc, network);
3794+
3795+ if (hasFeatureTag) {
3796+ return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, lens);
3797+ } else {
3798+ return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, null);
3799+ }
3800+ }
3801+
3802+ private void parseBound(Document doc, TimedArcPetriNetNetwork network){
3803+ if(doc.getElementsByTagName("k-bound").getLength() > 0){
3804+ int i = Integer.parseInt(doc.getElementsByTagName("k-bound").item(0).getAttributes().getNamedItem("bound").getNodeValue());
3805+ network.setDefaultBound(i);
3806+ }
3807+ }
3808+
3809+ private void parseFeature(Document doc, TimedArcPetriNetNetwork network) {
3810+ if (doc.getElementsByTagName("feature").getLength() > 0) {
3811+ NodeList nodeList = doc.getElementsByTagName("feature");
3812+
3813+ hasFeatureTag = true;
3814+
3815+ var isTimedElement = nodeList.item(0).getAttributes().getNamedItem("isTimed");
3816+ boolean isTimed = isTimedElement == null ? network.isTimed() : Boolean.parseBoolean(isTimedElement.getNodeValue());
3817+
3818+ var isGameElement = nodeList.item(0).getAttributes().getNamedItem("isGame");
3819+ boolean isGame = isGameElement == null ? network.hasUncontrollableTransitions() : Boolean.parseBoolean(isGameElement.getNodeValue());
3820+
3821+ var isColoredElement = nodeList.item(0).getAttributes().getNamedItem("isColored");
3822+ boolean isColored = isColoredElement == null ? network.isColored() : Boolean.parseBoolean(isColoredElement.getNodeValue());
3823+
3824+ lens = new TAPNLens(isTimed, isGame, isColored);
3825+ }
3826+ }
3827+
3828+ private void parseFeature(Document doc) {
3829+ if (doc.getElementsByTagName("feature").getLength() > 0) {
3830+ NodeList nodeList = doc.getElementsByTagName("feature");
3831+
3832+ hasFeatureTag = true;
3833+
3834+ var isTimed = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isTimed").getNodeValue());
3835+ var isGame = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isGame").getNodeValue());
3836+ var isColored = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isColored").getNodeValue());
3837+
3838+ lens = new TAPNLens(isTimed, isGame, isColored);
3839+ }
3840+ }
3841+
3842+ private void parseSharedPlaces(Document doc, TimedArcPetriNetNetwork network, ConstantStore constants) {
3843+ NodeList sharedPlaceNodes = doc.getElementsByTagName("shared-place");
3844+
3845+ for(int i = 0; i < sharedPlaceNodes.getLength(); i++){
3846+ Node node = sharedPlaceNodes.item(i);
3847+
3848+ if(node instanceof Element){
3849+ SharedPlace place = parseSharedPlace((Element)node, network, constants);
3850+ network.add(place);
3851+ }
3852+ }
3853+ }
3854+
3855+ private SharedPlace parseSharedPlace(Element element, TimedArcPetriNetNetwork network, ConstantStore constants) {
3856+ String name = element.getAttribute("name");
3857+ TimeInvariant invariant = TimeInvariant.parse(element.getAttribute("invariant"), constants);
3858+ //int numberOfTokens = Integer.parseInt(element.getAttribute("initialMarking"));
3859+
3860+ if(name.equalsIgnoreCase("true") || name.equalsIgnoreCase("false")) {
3861+ name = "_" + name;
3862+ if(firstPlaceRenameWarning) {
3863+ messages.add(PLACENAME_ERROR_MESSAGE);
3864+ firstPlaceRenameWarning = false;
3865+ }
3866+ }
3867+ SharedPlace place = new SharedPlace(name, invariant);
3868+ place.setCurrentMarking(network.marking());
3869+ place.setColorType(parsePlaceColorType(element));
3870+ //place.addTokens(numbesrOfTokens);
3871+ addColoredDependencies(place,element, network, constants);
3872+
3873+
3874+ return place;
3875+ }
3876+
3877+ private void parseSharedTransitions(Document doc, TimedArcPetriNetNetwork network) {
3878+ NodeList sharedTransitionNodes = doc.getElementsByTagName("shared-transition");
3879+
3880+ for(int i = 0; i < sharedTransitionNodes.getLength(); i++){
3881+ Node node = sharedTransitionNodes.item(i);
3882+
3883+ if(node instanceof Element){
3884+ SharedTransition transition = parseSharedTransition((Element)node);
3885+ network.add(transition);
3886+ }
3887+ }
3888+ }
3889+
3890+ private SharedTransition parseSharedTransition(Element element) {
3891+ String name = element.getAttribute("name");
3892+ boolean urgent = Boolean.parseBoolean(element.getAttribute("urgent"));
3893+ boolean isUncontrollable = element.getAttribute("player").equals("1");
3894+
3895+ SharedTransition st = new SharedTransition(name);
3896+ st.setUrgent(urgent);
3897+ st.setUncontrollable(isUncontrollable);
3898+ return st;
3899+ }
3900+
3901+ private Collection<Template> parseTemplates(Document doc, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
3902+ Collection<Template> templates = new ArrayList<Template>();
3903+ NodeList nets = doc.getElementsByTagName("net");
3904+
3905+ if(nets.getLength() <= 0)
3906+ throw new FormatException("File did not contain any TAPN components.");
3907+
3908+ for (int i = 0; i < nets.getLength(); i++) {
3909+ Template template = parseTimedArcPetriNet(nets.item(i), network, constants);
3910+ template.setHasPositionalInfo(true); //We assume that all templates have positional info
3911+ templates.add(template);
3912+ }
3913+ return templates;
3914+ }
3915+
3916+ private List<Constant> parseConstants(Document doc) {
3917+ List<Constant> constants = new ArrayList<Constant>();
3918+ NodeList constantNodes = doc.getElementsByTagName("constant");
3919+ for (int i = 0; i < constantNodes.getLength(); i++) {
3920+ Node c = constantNodes.item(i);
3921+
3922+ if (c instanceof Element) {
3923+ Constant constant = parseConstant((Element) c);
3924+ constants.add(constant);
3925+ }
3926+ }
3927+ return constants;
3928+ }
3929+
3930+ private Template parseTimedArcPetriNet(Node tapnNode, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
3931+ String name = getTAPNName(tapnNode);
3932+
3933+ boolean active = getActiveStatus(tapnNode);
3934+
3935+ TimedArcPetriNet tapn = new TimedArcPetriNet(name);
3936+ tapn.setActive(active);
3937+ network.add(tapn);
3938+ nameGenerator.add(tapn);
3939+
3940+ DataLayer guiModel = new DataLayer();
3941+ Template template = new Template(tapn, guiModel, new Zoomer());
3942+
3943+ NodeList nodeList = tapnNode.getChildNodes();
3944+ for (int i = 0; i < nodeList.getLength(); i++) {
3945+
3946+ Node node = nodeList.item(i);
3947+ if(node instanceof Element){
3948+ parseElement((Element)node, template, network, constants);
3949+ }
3950+ }
3951+
3952+ return template;
3953+ }
3954+
3955+ private boolean getActiveStatus(Node tapnNode) {
3956+ if (tapnNode instanceof Element) {
3957+ Element element = (Element)tapnNode;
3958+ String activeString = element.getAttribute("active");
3959+
3960+ if (activeString == null || activeString.equals(""))
3961+ return true;
3962+ else
3963+ return activeString.equals("true");
3964+ } else {
3965+ return true;
3966+ }
3967+ }
3968+
3969+ private void parseElement(Element element, Template template, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
3970+ if ("labels".equals(element.getNodeName())) {
3971+ AnnotationNote note = parseAnnotation(element);
3972+ template.guiModel().addPetriNetObject(note);
3973+ } else if ("place".equals(element.getNodeName())) {
3974+ TimedPlaceComponent place = parsePlace(element, network, template.model(), constants);
3975+ template.guiModel().addPetriNetObject(place);
3976+ } else if ("transition".equals(element.getNodeName())) {
3977+ TimedTransitionComponent transition = parseTransition(element, network, template.model());
3978+ template.guiModel().addPetriNetObject(transition);
3979+ } else if (element.getNodeName().matches("arc|outputArc|inputArc|inhibitorArc|transportArc")) {
3980+ parseAndAddArc(element, template, constants, network);
3981+ }
3982+ }
3983+
3984+ private boolean isNameAllowed(String name) {
3985+ Require.that(name != null, "name was null");
3986+
3987+ return !name.isEmpty() && java.util.regex.Pattern.matches("[a-zA-Z]([_a-zA-Z0-9])*", name);
3988+ }
3989+
3990+
3991+ private String getTAPNName(Node tapnNode) {
3992+ if (tapnNode instanceof Element) {
3993+ Element element = (Element)tapnNode;
3994+ String name = element.getAttribute("name");
3995+
3996+ if (name == null || name.equals(""))
3997+ name = element.getAttribute("id");
3998+
3999+ if(!isNameAllowed(name)){
4000+ name = nameGenerator.getNewTemplateName();
4001+ }
4002+ nameGenerator.updateTemplateIndex(name);
4003+ return name;
4004+ } else {
4005+ return nameGenerator.getNewTemplateName();
4006+ }
4007+ }
4008+
4009+ private AnnotationNote parseAnnotation(Element annotation) {
4010+ int positionXInput = 0;
4011+ int positionYInput = 0;
4012+ int widthInput = 0;
4013+ int heightInput = 0;
4014+ boolean borderInput = true;
4015+
4016+ String positionXTempStorage = annotation.getAttribute("positionX");
4017+ String positionYTempStorage = annotation.getAttribute("positionY");
4018+ String widthTemp = annotation.getAttribute("width");
4019+ String heightTemp = annotation.getAttribute("height");
4020+ String borderTemp = annotation.getAttribute("border");
4021+
4022+ String text = annotation.getTextContent();
4023+
4024+ if (positionXTempStorage.length() > 0) {
4025+ positionXInput = Integer.parseInt(positionXTempStorage) + 1;
4026+ }
4027+
4028+ if (positionYTempStorage.length() > 0) {
4029+ positionYInput = Integer.parseInt(positionYTempStorage) + 1;
4030+ }
4031+
4032+ if (widthTemp.length() > 0) {
4033+ widthInput = Integer.parseInt(widthTemp) + 1;
4034+ }
4035+
4036+ if (heightTemp.length() > 0) {
4037+ heightInput = Integer.parseInt(heightTemp) + 1;
4038+ }
4039+
4040+ if (borderTemp.length() > 0) {
4041+ borderInput = Boolean.parseBoolean(borderTemp);
4042+ } else {
4043+ borderInput = true;
4044+ }
4045+ return new AnnotationNote(text, positionXInput, positionYInput, widthInput, heightInput, borderInput);
4046+ }
4047+
4048+ private TimedTransitionComponent parseTransition(Element transition, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn) {
4049+ String posX = transition.getAttribute("positionX");
4050+ String posY = transition.getAttribute("positionY");
4051+ String nameOffsetX = transition.getAttribute("nameOffsetX");
4052+ String nameOffsetY = transition.getAttribute("nameOffsetY");
4053+ String angleStr = transition.getAttribute("angle");
4054+ String priorityStr = transition.getAttribute("priority");
4055+ int positionXInput = 0;
4056+ int positionYInput = 0;
4057+ int nameOffsetXInput = 0;
4058+ int nameOffsetYInput = 0;
4059+ int angle = 0;
4060+ int priority = 0;
4061+ if(!posX.isEmpty()){
4062+ positionXInput = (int)Double.parseDouble(posX);
4063+ }
4064+ if(!posY.isEmpty()){
4065+ positionYInput = (int)Double.parseDouble(posY);
4066+ }
4067+
4068+ var g = transition.getElementsByTagName("position");
4069+ if (g.getLength() > 0) {
4070+ positionXInput = Integer.parseInt(((Element) g.item(0)).getAttribute("x"));
4071+ positionYInput = Integer.parseInt(((Element) g.item(0)).getAttribute("y"));
4072+ }
4073+
4074+ if(!nameOffsetX.isEmpty()){
4075+ nameOffsetXInput = (int)Double.parseDouble(nameOffsetX);
4076+ }
4077+ if(!nameOffsetY.isEmpty()){
4078+ nameOffsetYInput = (int)Double.parseDouble(nameOffsetY);
4079+ }
4080+ if(!angleStr.isEmpty()){
4081+ angle = Integer.parseInt(angleStr);
4082+ }
4083+ if(!priorityStr.isEmpty()){
4084+ priority = Integer.parseInt(priorityStr);
4085+ }
4086+ String idInput = transition.getAttribute("id");
4087+ String nameInput = transition.getAttribute("name");
4088+ boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent"));
4089+
4090+ String player = transition.getAttribute("player");
4091+
4092+ idResolver.add(tapn.name(), idInput, nameInput);
4093+
4094+ boolean infiniteServer = transition.getAttribute("infiniteServer").equals("true");
4095+
4096+ boolean displayName = transition.getAttribute("displayName").equals("false") ? false : true;
4097+
4098+
4099+ if (idInput.length() == 0 && nameInput.length() > 0) {
4100+ idInput = nameInput;
4101+ }
4102+
4103+ if (nameInput.length() == 0 && idInput.length() > 0) {
4104+ nameInput = idInput;
4105+ }
4106+ GuardExpression guardExpr = null;
4107+
4108+ Node conditionNode = getFirstDirectChild(transition, "condition");
4109+ if (conditionNode != null) {
4110+ try {
4111+ guardExpr = loadTACPN.parseGuardExpression(getFirstDirectChild(conditionNode, "structure"));
4112+ } catch (FormatException e) {
4113+ e.printStackTrace();
4114+ }
4115+ }
4116+
4117+ TimedTransition t = new TimedTransition(nameInput, guardExpr);
4118+ t.setUrgent(isUrgent);
4119+ t.setUncontrollable(player.equals("1"));
4120+ if(network.isNameUsedForShared(nameInput)){
4121+ t.setName(nameGenerator.getNewTransitionName(tapn)); // introduce temporary name to avoid exceptions
4122+ tapn.add(t);
4123+ network.getSharedTransitionByName(nameInput).makeShared(t);
4124+ }else{
4125+ tapn.add(t);
4126+ }
4127+ nameGenerator.updateIndicesForAllModels(nameInput);
4128+ TimedTransitionComponent transitionComponent = new TimedTransitionComponent(
4129+ positionXInput, positionYInput, idInput,
4130+ nameOffsetXInput, nameOffsetYInput,
4131+ angle, lens);
4132+ transitionComponent.setUnderlyingTransition(t);
4133+
4134+ if (!displayName){
4135+ transitionComponent.setAttributesVisible(false);
4136+ }
4137+ return transitionComponent;
4138+ }
4139+
4140+ private TimedPlaceComponent parsePlace(Element place, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn, ConstantStore constants) {
4141+ String placePosX = place.getAttribute("positionX");
4142+ String placePosY = place.getAttribute("positionY");
4143+ String nameOffsetX = place.getAttribute("nameOffsetX");
4144+ String nameOffsetY = place.getAttribute("nameOffsetY");
4145+ int positionXInput = 0;
4146+ int positionYInput = 0;
4147+ if(!placePosX.isBlank()){
4148+ positionXInput = (int)Double.parseDouble(placePosX);
4149+ }
4150+ if(!placePosY.isBlank()){
4151+ positionYInput = (int)Double.parseDouble(placePosY);
4152+ }
4153+
4154+ var g = place.getElementsByTagName("position");
4155+ if (g.getLength() > 0) {
4156+ positionXInput = Integer.parseInt(((Element) g.item(0)).getAttribute("x"));
4157+ positionYInput = Integer.parseInt(((Element) g.item(0)).getAttribute("y"));
4158+ }
4159+
4160+ String idInput = place.getAttribute("id");
4161+ String nameInput = place.getAttribute("name");
4162+
4163+ int nameOffsetXInput = 0;
4164+ int nameOffsetYInput = 0;
4165+ if(!nameOffsetX.isEmpty()){
4166+ nameOffsetXInput = (int)Double.parseDouble(nameOffsetX);
4167+ }
4168+ if(!nameOffsetY.isEmpty()){
4169+ nameOffsetYInput = (int)Double.parseDouble(nameOffsetY);
4170+ }
4171+
4172+ String invariant = place.getAttribute("invariant");
4173+ boolean displayName = place.getAttribute("displayName").equals("false") ? false : true;
4174+
4175+ if (idInput.length() == 0 && nameInput.length() > 0) {
4176+ idInput = nameInput;
4177+ }
4178+
4179+ if (nameInput.length() == 0 && idInput.length() > 0) {
4180+ nameInput = idInput;
4181+ }
4182+
4183+ if(nameInput.equalsIgnoreCase("true") || nameInput.equalsIgnoreCase("false")) {
4184+ nameInput = "_" + nameInput;
4185+ if(firstPlaceRenameWarning) {
4186+ messages.add(PLACENAME_ERROR_MESSAGE);
4187+ firstPlaceRenameWarning = false;
4188+ }
4189+ }
4190+
4191+ idResolver.add(tapn.name(), idInput, nameInput);
4192+
4193+ TimedPlace p;
4194+ if(network.isNameUsedForShared(nameInput)){
4195+ p = network.getSharedPlaceByName(nameInput);
4196+ tapn.add(p);
4197+ }else{
4198+ p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants), parsePlaceColorType(place));
4199+ tapn.add(p);
4200+ addColoredDependencies(p,place, network, constants);
4201+
4202+ }
4203+ nameGenerator.updateIndicesForAllModels(nameInput);
4204+ TimedPlaceComponent placeComponent = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, lens);
4205+ placeComponent.setUnderlyingPlace(p);
4206+
4207+ if (!displayName){
4208+ placeComponent.setAttributesVisible(false);
4209+ }
4210+
4211+ return placeComponent;
4212+ }
4213+
4214+ private ColorType parsePlaceColorType(Element element){
4215+ ColorType ct = ColorType.COLORTYPE_DOT;
4216+ Node typeNode = element.getElementsByTagName("type").item(0);
4217+ if (typeNode != null) {
4218+ try {
4219+ ct = loadTACPN.parseUserSort(typeNode);
4220+ } catch (FormatException e) {
4221+ e.printStackTrace();
4222+ }
4223+ }
4224+ return ct;
4225+ }
4226+
4227+ private void addColoredDependencies(TimedPlace p, Element place, TimedArcPetriNetNetwork network, ConstantStore constants){
4228+ List<ColoredTimeInvariant> ctiList = new ArrayList<ColoredTimeInvariant>();
4229+ int initialMarkingInput = Integer.parseInt(place.getAttribute("initialMarking"));
4230+
4231+ ArcExpression colorMarking = null;
4232+ NodeList nodes = place.getElementsByTagName("colorinvariant");
4233+ if (nodes != null) {
4234+ for (int i = 0; i < nodes.getLength(); i++) {
4235+ Pair<String, Vector<Color>> pair = parseColorInvariant((Element) nodes.item(i), network);
4236+ ColoredTimeInvariant cti = ColoredTimeInvariant.parse(pair.getFirst(), constants, pair.getSecond());
4237+ ctiList.add(cti);
4238+ }
4239+ }
4240+ if (place.getAttribute("inscription").length() > 0) {
4241+ ctiList.add(ColoredTimeInvariant.parse(place.getAttribute("inscription"), constants, new Vector<Color>() {{
4242+ add(Color.STAR_COLOR);
4243+ }}));
4244+ }
4245+ Node hlInitialMarkingNode = place.getElementsByTagName("hlinitialMarking").item(0);
4246+
4247+ if (hlInitialMarkingNode instanceof Element) {
4248+ try {
4249+ colorMarking = loadTACPN.parseArcExpression(((Element)hlInitialMarkingNode).getElementsByTagName("structure").item(0));
4250+ } catch (FormatException e) {
4251+ e.printStackTrace();
4252+ }
4253+ }
4254+
4255+
4256+ p.setCtiList(ctiList);
4257+ ExpressionContext context = new ExpressionContext(new HashMap<String, Color>(), loadTACPN.getColortypes());
4258+ if(colorMarking!= null){
4259+ ColorMultiset cm = colorMarking.eval(context);
4260+
4261+ p.setTokenExpression(loadTACPN.constructCleanAddExpression(p.getColorType(),cm));
4262+
4263+
4264+ for (TimedToken ctElement : cm.getTokens(p)) {
4265+ network.marking().add(ctElement);
4266+ //p.addToken(ctElement);
4267+ }
4268+
4269+ } else {
4270+ for (int i = 0; i < initialMarkingInput; i++) {
4271+ //Regular tokens will just be dotconstant
4272+ network.marking().add(new TimedToken(p, ColorType.COLORTYPE_DOT.getFirstColor()));
4273+ }
4274+ if(initialMarkingInput > 1) {
4275+ Vector<ColorExpression> v = new Vector<>();
4276+ v.add(new DotConstantExpression());
4277+ Vector<ArcExpression> numbOfExpression = new Vector<>();
4278+ numbOfExpression.add(new NumberOfExpression(initialMarkingInput, v));
4279+ p.setTokenExpression(new AddExpression(numbOfExpression));
4280+ }
4281+ }
4282+ }
4283+
4284+ private void parseAndAddArc(Element arc, Template template, ConstantStore constants, TimedArcPetriNetNetwork network) throws FormatException {
4285+ String idInput = arc.getAttribute("id");
4286+ String sourceInput = arc.getAttribute("source");
4287+ String targetInput = arc.getAttribute("target");
4288+ boolean taggedArc = arc.getAttribute("tagged").equals("true") ? true : false;
4289+ String inscriptionTempStorage = arc.getAttribute("inscription");
4290+ String type = arc.getAttribute("type");
4291+ if(type.isEmpty()){
4292+ switch (arc.getNodeName()) {
4293+ case "transportArc":
4294+ type = "transport";
4295+ break;
4296+ case "inhibitorArc":
4297+ type = "inhibitor";
4298+ break;
4299+ case "inputArc":
4300+ type = "timed";
4301+ break;
4302+ default:
4303+ type = "";
4304+ break;
4305+ }
4306+ }
4307+ int nameOffsetXInput;
4308+ int nameOffsetYInput;
4309+
4310+ //This check is done, as arcs in nets saved before this change do not have a nameOffset
4311+ if(!arc.getAttribute("nameOffsetX").equals("") && !arc.getAttribute("nameOffsetY").equals("")) {
4312+ nameOffsetXInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetX"));
4313+ nameOffsetYInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetY"));
4314+ } else {
4315+ nameOffsetXInput = 0;
4316+ nameOffsetYInput = 0;
4317+ }
4318+
4319+ sourceInput = idResolver.get(template.model().name(), sourceInput);
4320+ targetInput = idResolver.get(template.model().name(), targetInput);
4321+
4322+ PlaceTransitionObject sourceIn = template.guiModel().getPlaceTransitionObject(sourceInput);
4323+ PlaceTransitionObject targetIn = template.guiModel().getPlaceTransitionObject(targetInput);
4324+
4325+ // add the insets and offset
4326+ int _startx = sourceIn.getX() + sourceIn.centreOffsetLeft();
4327+ int _starty = sourceIn.getY() + sourceIn.centreOffsetTop();
4328+
4329+ int _endx = targetIn.getX() + targetIn.centreOffsetLeft();
4330+ int _endy = targetIn.getY() + targetIn.centreOffsetTop();
4331+
4332+ //Get weight if any
4333+ Weight weight = new IntWeight(1);
4334+ if(arc.hasAttribute("weight")){
4335+ weight = Weight.parseWeight(arc.getAttribute("weight"), constants);
4336+ }
4337+ ArcExpression arcExpr = null;
4338+ List<ColoredTimeInterval> ctiList = new ArrayList<ColoredTimeInterval>();
4339+ Node hlInscription = getFirstDirectChild(arc, "hlinscription");
4340+ if (hlInscription != null)
4341+ hlInscription = getFirstDirectChild(hlInscription, "structure");
4342+ if (hlInscription != null)
4343+ arcExpr = loadTACPN.parseArcExpression(hlInscription);
4344+
4345+ NodeList intervalNodes = arc.getElementsByTagName("colorinterval");
4346+ if (intervalNodes != null) {
4347+ for (int i = 0; i < intervalNodes.getLength(); i++) {
4348+ if (intervalNodes.item(i) instanceof Element) {
4349+ Element interval = (Element) intervalNodes.item(i);
4350+ Pair<String, Vector<Color>> pair = parseColorInvariant(interval, network);
4351+ ColoredTimeInterval coloredinterval = ColoredTimeInterval.parse(pair.getFirst(), constants, pair.getSecond());
4352+ ctiList.add(coloredinterval);
4353+ }
4354+ }
4355+ }
4356+
4357+ Arc tempArc;
4358+ Arc tempArc2 = null;
4359+
4360+ if (type.equals("tapnInhibitor") || type.equals("inhibitor")) {
4361+
4362+ tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc,
4363+ inscriptionTempStorage, sourceIn, targetIn,
4364+ _endx, _endy,template, constants, weight, arcExpr);
4365+
4366+ } else {
4367+ if (type.equals("timed")) {
4368+ tempArc = parseAndAddTimedInputArc(idInput, taggedArc,
4369+ inscriptionTempStorage, sourceIn, targetIn,
4370+ _endx, _endy, template, constants, weight, ctiList, arcExpr);
4371+
4372+ } else if (type.equals("transport")) {
4373+ String transition = arc.getAttribute("transition");
4374+ if(transition.isEmpty()){
4375+ tempArc = parseAndAddTransportArc(idInput, taggedArc,
4376+ inscriptionTempStorage, sourceIn, targetIn,
4377+ _endx, _endy, template, constants, weight, ctiList, arcExpr);
4378+ } else {
4379+ transition = idResolver.get(template.model().name(), transition);
4380+ PlaceTransitionObject transitionIn = template.guiModel().getPlaceTransitionObject(transition);
4381+
4382+ tempArc = parseAndAddTransportArc(idInput, taggedArc,
4383+ inscriptionTempStorage, sourceIn, transitionIn,
4384+ _endx, _endy, template, constants, weight, ctiList, arcExpr);
4385+
4386+ tempArc2 = parseAndAddTransportArc(idInput, taggedArc,
4387+ inscriptionTempStorage, transitionIn, targetIn,
4388+ _endx, _endy, template, constants, weight, ctiList, arcExpr);
4389+ }
4390+ } else {
4391+ tempArc = parseAndAddTimedOutputArc(idInput, taggedArc,
4392+ inscriptionTempStorage, sourceIn, targetIn,
4393+ _endx, _endy, template, weight, arcExpr);
4394+ }
4395+
4396+ }
4397+ tempArc.setNameOffsetX(nameOffsetXInput);
4398+ tempArc.setNameOffsetY(nameOffsetYInput);
4399+
4400+ parseArcPath(arc, tempArc);
4401+ if(tempArc2 != null){
4402+ tempArc2.setNameOffsetX(nameOffsetXInput);
4403+ tempArc2.setNameOffsetY(nameOffsetYInput);
4404+
4405+ parseArcPath(arc, tempArc2);
4406+ }
4407+ }
4408+
4409+ private TimedOutputArcComponent parseAndAddTimedOutputArc(String idInput, boolean taggedArc,
4410+ String inscriptionTempStorage, PlaceTransitionObject sourceIn,
4411+ PlaceTransitionObject targetIn,
4412+ int _endx, int _endy, Template template, Weight weight, ArcExpression expr) throws FormatException {
4413+
4414+ TimedOutputArcComponent tempArc = new TimedOutputArcComponent(sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.parseInt(inscriptionTempStorage) : 1), idInput);
4415+
4416+ TimedPlace place = template.model().getPlaceByName(targetIn.getName());
4417+ TimedTransition transition = template.model().getTransitionByName(sourceIn.getName());
4418+
4419+ TimedOutputArc outputArc = new TimedOutputArc(transition, place, weight, expr);
4420+ tempArc.setUnderlyingArc(outputArc);
4421+
4422+ if(template.model().hasArcFromTransitionToPlace(outputArc.source(),outputArc.destination())) {
4423+ throw new FormatException("Multiple arcs between a place and a transition is not allowed");
4424+ }
4425+
4426+ template.guiModel().addPetriNetObject(tempArc);
4427+ template.model().add(outputArc);
4428+
4429+ return tempArc;
4430+ }
4431+
4432+ private TimedTransportArcComponent parseAndAddTransportArc(String idInput, boolean taggedArc,
4433+ String inscriptionTempStorage, PlaceTransitionObject sourceIn,
4434+ PlaceTransitionObject targetIn,
4435+ int _endx, int _endy, Template template, ConstantStore constants, Weight weight, List<ColoredTimeInterval> ctiList, ArcExpression expr) {
4436+
4437+
4438+ String[] inscriptionSplit = {};
4439+ if (inscriptionTempStorage.contains(":")) {
4440+ inscriptionSplit = inscriptionTempStorage.split(":");
4441+ } else{
4442+ inscriptionSplit = new String[]{inscriptionTempStorage};
4443+ }
4444+ boolean isInPreSet = false;
4445+ if (sourceIn instanceof Place) {
4446+ isInPreSet = true;
4447+ }
4448+
4449+ TimedTransportArcComponent tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), -1, isInPreSet);
4450+
4451+
4452+ if (isInPreSet) {
4453+ if (postsetArcs.containsKey(targetIn)) {
4454+ TimedTransportArcComponent postsetTransportArc = postsetArcs.get(targetIn);
4455+ TimedPlace sourcePlace = template.model().getPlaceByName(sourceIn.getName());
4456+ TimedTransition trans = template.model().getTransitionByName(targetIn.getName());
4457+ TimedPlace destPlace = template.model().getPlaceByName(postsetTransportArc.getTarget().getName());
4458+
4459+ TimeInterval timeInterval = TimeInterval.parse(inscriptionSplit[0], constants);
4460+
4461+ assert (sourcePlace != null);
4462+ assert (trans != null);
4463+ assert (destPlace != null);
4464+ int groupNr = 1;
4465+ if(inscriptionSplit.length < 2){
4466+ for (Object pt : tempArc.getTarget().getPostset()) {
4467+ if (pt instanceof TimedTransportArcComponent) {
4468+ if (((TimedTransportArcComponent) pt).getGroupNr() > groupNr) {
4469+ groupNr = ((TimedTransportArcComponent) pt).getGroupNr();
4470+ }
4471+ }
4472+ }
4473+ } else {
4474+ groupNr = Integer.parseInt(inscriptionSplit[1]);
4475+ }
4476+ tempArc.setGroupNr(groupNr);
4477+ postsetTransportArc.setGroupNr(groupNr);
4478+
4479+ TransportArc transArc = new TransportArc(sourcePlace, trans, destPlace, timeInterval, weight,expr,transportExpr);
4480+ transArc.setColorTimeIntervals(ctiList);
4481+
4482+ tempArc.setUnderlyingArc(transArc);
4483+ postsetTransportArc.setUnderlyingArc(transArc);
4484+ template.guiModel().addPetriNetObject(tempArc);
4485+ template.guiModel().addPetriNetObject(postsetTransportArc);
4486+ template.model().add(transArc);
4487+
4488+ postsetArcs.remove(targetIn);
4489+ } else {
4490+ transportExpr = expr;
4491+ presetArcs.put((TimedTransitionComponent) targetIn, tempArc);
4492+ transportArcsTimeIntervals.put(tempArc, TimeInterval.parse(inscriptionSplit[0], constants));
4493+ coloredTransportArcsTimeIntervals.put(tempArc, ctiList);
4494+
4495+ }
4496+ } else {
4497+ if (presetArcs.containsKey(sourceIn)) {
4498+ TimedTransportArcComponent presetTransportArc = presetArcs.get(sourceIn);
4499+ TimedPlace sourcePlace = template.model().getPlaceByName(presetTransportArc.getSource().getName());
4500+ TimedTransition trans = template.model().getTransitionByName(sourceIn.getName());
4501+ TimedPlace destPlace = template.model().getPlaceByName(targetIn.getName());
4502+ TimeInterval interval = transportArcsTimeIntervals.get(presetTransportArc);
4503+ List<ColoredTimeInterval> timeIntervals = coloredTransportArcsTimeIntervals.get(presetTransportArc);
4504+
4505+ assert (sourcePlace != null);
4506+ assert (trans != null);
4507+ assert (destPlace != null);
4508+ int groupNr = 1;
4509+ if(inscriptionSplit.length < 2){
4510+ for (Object pt : tempArc.getSource().getPostset()) {
4511+ if (pt instanceof TimedTransportArcComponent) {
4512+ if (((TimedTransportArcComponent) pt).getGroupNr() > groupNr) {
4513+ groupNr = ((TimedTransportArcComponent) pt).getGroupNr();
4514+ }
4515+ }
4516+ }
4517+ } else {
4518+ groupNr = Integer.parseInt(inscriptionSplit[1]);
4519+ }
4520+ tempArc.setGroupNr(groupNr);
4521+ presetTransportArc.setGroupNr(groupNr);
4522+
4523+ TransportArc transArc = new TransportArc(sourcePlace, trans, destPlace, interval, weight,transportExpr,expr);
4524+ transArc.setColorTimeIntervals(timeIntervals);
4525+ transportExpr = null;
4526+
4527+ tempArc.setUnderlyingArc(transArc);
4528+ presetTransportArc.setUnderlyingArc(transArc);
4529+ template.guiModel().addPetriNetObject(presetTransportArc);
4530+ template.guiModel().addPetriNetObject(tempArc);
4531+ template.model().add(transArc);
4532+
4533+ presetArcs.remove(sourceIn);
4534+ transportArcsTimeIntervals.remove(presetTransportArc);
4535+ } else {
4536+ postsetArcs.put((TimedTransitionComponent) sourceIn, tempArc);
4537+ transportExpr = expr;
4538+ }
4539+ }
4540+ return tempArc;
4541+ }
4542+
4543+ private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc,
4544+ String inscriptionTempStorage, PlaceTransitionObject sourceIn,
4545+ PlaceTransitionObject targetIn,
4546+ int _endx, int _endy, Template template, ConstantStore constants, Weight weight,List<ColoredTimeInterval> ctiList, ArcExpression expr ) throws FormatException {
4547+ TimedInputArcComponent tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput), lens);
4548+
4549+
4550+
4551+
4552+ TimedPlace place = template.model().getPlaceByName(sourceIn.getName());
4553+ TimedTransition transition = template.model().getTransitionByName(targetIn.getName());
4554+
4555+ TimeInterval timeInterval = TimeInterval.parse(inscriptionTempStorage, constants);
4556+ //ctiList.add(ColoredTimeInterval.parse(inscriptionTempStorage, constants, new Vector<Color>(){{add(Color.STAR_COLOR);}}));
4557+
4558+
4559+ TimedInputArc inputArc = new TimedInputArc(place, transition, timeInterval, weight, expr);
4560+ inputArc.setColorTimeIntervals(ctiList);
4561+ tempArc.setUnderlyingArc(inputArc);
4562+
4563+ if(template.model().hasArcFromPlaceToTransition(inputArc.source(), inputArc.destination())) {
4564+ throw new FormatException("Multiple arcs between a place and a transition is not allowed");
4565+ }
4566+
4567+ template.guiModel().addPetriNetObject(tempArc);
4568+ template.model().add(inputArc);
4569+
4570+ return tempArc;
4571+ }
4572+
4573+ private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc,
4574+ String inscriptionTempStorage, PlaceTransitionObject sourceIn,
4575+ PlaceTransitionObject targetIn,
4576+ int _endx, int _endy, Template template, ConstantStore constants, Weight weight, ArcExpression arcExpr) {
4577+ TimedPlace place = template.model().getPlaceByName(sourceIn.getName());
4578+ TimedTransition transition = template.model().getTransitionByName(targetIn.getName());
4579+ TimeInterval interval = TimeInterval.parse(inscriptionTempStorage, constants);
4580+
4581+ if(!interval.equals(TimeInterval.ZERO_INF) && firstInhibitorIntervalWarning) {
4582+ messages.add("The chosen model contained inhibitor arcs with unsupported intervals.\n\nTAPAAL only supports inhibitor arcs with intervals [0,inf).\n\nAny other interval on inhibitor arcs will be replaced with [0,inf).");
4583+ firstInhibitorIntervalWarning = false;
4584+ }
4585+
4586+ TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, interval, weight, arcExpr);
4587+ TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent((TimedPlaceComponent)sourceIn, (TimedTransitionComponent)targetIn, inhibArc);
4588+ tempArc.setUnderlyingArc(inhibArc);
4589+ template.guiModel().addPetriNetObject(tempArc);
4590+ template.model().add(inhibArc);
4591+
4592+ return tempArc;
4593+ }
4594+
4595+ private void parseArcPath(Element arc, Arc tempArc) {
4596+ NodeList nodelist = arc.getElementsByTagName("arcpath");
4597+ if (nodelist.getLength() > 0) {
4598+ tempArc.getArcPath().purgePathPoints();
4599+ for (int i = 0; i < nodelist.getLength(); i++) {
4600+ Node node = nodelist.item(i);
4601+ if (node instanceof Element) {
4602+ Element element = (Element) node;
4603+ if ("arcpath".equals(element.getNodeName())) {
4604+ String arcTempX = element.getAttribute("xCoord");
4605+ String arcTempY = element.getAttribute("yCoord");
4606+
4607+ // Wierd naming convention in pipe: this represents if
4608+ // the arc point is a curve point or not
4609+ String arcTempType = element.getAttribute("arcPointType");
4610+ double arcPointX = Double.parseDouble(arcTempX);
4611+ double arcPointY = Double.parseDouble(arcTempY);
4612+ arcPointX += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
4613+ arcPointY += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
4614+ boolean arcPointType = Boolean.parseBoolean(arcTempType);
4615+ tempArc.getArcPath().addPoint(arcPointX, arcPointY, arcPointType);
4616+ }
4617+ }
4618+ }
4619+ }
4620+ }
4621+
4622+ private Constant parseConstant(Element constantElement) {
4623+ String name = constantElement.getAttribute("name");
4624+ int value = Integer.parseInt(constantElement.getAttribute("value"));
4625+
4626+ return new Constant(name, value);
4627+ }
4628+
4629+ private Pair<String, Vector<Color>> parseColorInvariant(Element colorinvariant, TimedArcPetriNetNetwork network) {
4630+ String inscription, colorTypeName;
4631+ Vector<Color> colors = new Vector<Color>();
4632+ Element colorTypeELe = (Element) colorinvariant.getElementsByTagName("colortype").item(0);
4633+ inscription = colorinvariant.getElementsByTagName("inscription").item(0).getAttributes().getNamedItem("inscription").getNodeValue();
4634+ colorTypeName = colorTypeELe.getAttributes().getNamedItem("name").getNodeValue();
4635+ if (network.isNameUsedForColorType(colorTypeName)) {
4636+ NodeList colorNodeList = colorTypeELe.getElementsByTagName("color");
4637+ String colorName;
4638+ ColorType ct = network.getColorTypeByName(colorTypeName);
4639+ for (int i = 0; i < colorNodeList.getLength(); i++) {
4640+ colorName = colorNodeList.item(i).getAttributes().getNamedItem("value").getNodeValue();
4641+ colors.add(new Color(ct, 0, colorName));
4642+ }
4643+ } else {
4644+ try {
4645+ throw new FormatException("The color type used for an invariant does not exist");
4646+ } catch (FormatException e) {
4647+ e.printStackTrace();
4648+ }
4649+ }
4650+
4651+ Pair<String, Vector<Color>> pair = new Pair<String, Vector<Color>>(inscription, colors);
4652+ return pair;
4653+ }
4654+
4655+ Node getFirstDirectChild(Node parent, String tagName){
4656+ NodeList children = parent.getChildNodes();
4657+ for(int i = 0; i < children.getLength(); i++){
4658+ if(children.item(i).getNodeName().equals(tagName)){
4659+ return children.item(i);
4660+ }
4661+ }
4662+ return null;
4663+ }
4664+
4665+}
4666
4667=== modified file 'src/dk/aau/cs/io/TapnLegacyXmlLoader.java'
4668--- src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-08-26 12:29:25 +0000
4669+++ src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2022-03-21 20:20:44 +0000
4670@@ -8,43 +8,42 @@
4671 import java.util.Collection;
4672 import java.util.HashMap;
4673
4674-import javax.swing.JOptionPane;
4675 import javax.xml.parsers.DocumentBuilder;
4676 import javax.xml.parsers.DocumentBuilderFactory;
4677 import javax.xml.parsers.ParserConfigurationException;
4678
4679-import dk.aau.cs.gui.TabContent;
4680+import dk.aau.cs.model.CPN.ColorType;
4681+import net.tapaal.gui.petrinet.TAPNLens;
4682 import org.w3c.dom.Document;
4683 import org.w3c.dom.Element;
4684 import org.w3c.dom.Node;
4685 import org.w3c.dom.NodeList;
4686 import org.xml.sax.SAXException;
4687-import pipe.dataLayer.TAPNQuery;
4688-import pipe.dataLayer.TAPNQuery.ExtrapolationOption;
4689-import pipe.dataLayer.TAPNQuery.HashTableSize;
4690-import pipe.dataLayer.TAPNQuery.SearchOption;
4691-import pipe.dataLayer.TAPNQuery.TraceOption;
4692-import pipe.dataLayer.DataLayer;
4693-import pipe.dataLayer.Template;
4694-import pipe.gui.CreateGui;
4695-import pipe.gui.Pipe;
4696-import pipe.gui.Zoomer;
4697-import pipe.gui.graphicElements.AnnotationNote;
4698-import pipe.gui.graphicElements.Arc;
4699-import pipe.gui.graphicElements.Place;
4700-import pipe.gui.graphicElements.PlaceTransitionObject;
4701-import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent;
4702-import pipe.gui.graphicElements.tapn.TimedInputArcComponent;
4703-import pipe.gui.graphicElements.tapn.TimedOutputArcComponent;
4704-import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
4705-import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
4706-import pipe.gui.graphicElements.tapn.TimedTransportArcComponent;
4707-import pipe.gui.widgets.InclusionPlaces;
4708+import net.tapaal.gui.petrinet.verification.TAPNQuery;
4709+import net.tapaal.gui.petrinet.verification.TAPNQuery.ExtrapolationOption;
4710+import net.tapaal.gui.petrinet.verification.TAPNQuery.HashTableSize;
4711+import net.tapaal.gui.petrinet.verification.TAPNQuery.SearchOption;
4712+import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption;
4713+import pipe.gui.petrinet.dataLayer.DataLayer;
4714+import net.tapaal.gui.petrinet.Template;
4715+import pipe.gui.Constants;
4716+import pipe.gui.canvas.Zoomer;
4717+import pipe.gui.petrinet.graphicElements.AnnotationNote;
4718+import pipe.gui.petrinet.graphicElements.Arc;
4719+import pipe.gui.petrinet.graphicElements.Place;
4720+import pipe.gui.petrinet.graphicElements.PlaceTransitionObject;
4721+import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;
4722+import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent;
4723+import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent;
4724+import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;
4725+import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent;
4726+import pipe.gui.petrinet.graphicElements.tapn.TimedTransportArcComponent;
4727+import net.tapaal.gui.petrinet.verification.InclusionPlaces;
4728 import dk.aau.cs.TCTL.TCTLAbstractProperty;
4729 import dk.aau.cs.TCTL.Parsing.TAPAALQueryParser;
4730 import dk.aau.cs.TCTL.visitors.AddTemplateVisitor;
4731 import dk.aau.cs.TCTL.visitors.VerifyPlaceNamesVisitor;
4732-import dk.aau.cs.gui.NameGenerator;
4733+import net.tapaal.gui.petrinet.NameGenerator;
4734 import dk.aau.cs.model.tapn.Constant;
4735 import dk.aau.cs.model.tapn.ConstantStore;
4736 import dk.aau.cs.model.tapn.LocalTimedPlace;
4737@@ -82,9 +81,8 @@
4738 private boolean firstInhibitorIntervalWarning = true;
4739 private boolean firstPlaceRenameWarning = true;
4740 private final IdResolver idResolver = new IdResolver();
4741-
4742 private final Collection<String> messages = new ArrayList<>(10);
4743- private final TabContent.TAPNLens lens = TabContent.TAPNLens.Default;
4744+ private final TAPNLens lens = TAPNLens.Default;
4745
4746
4747 public TapnLegacyXmlLoader() {}
4748@@ -136,7 +134,7 @@
4749 }
4750 }
4751
4752- TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants);
4753+ TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants, new ArrayList<>());
4754 NodeList nets = tapnDoc.getElementsByTagName("net");
4755
4756 if(nets.getLength() <= 0)
4757@@ -318,7 +316,7 @@
4758 firstInhibitorIntervalWarning = false;
4759 }
4760
4761- TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, interval);
4762+ TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, interval,null);
4763
4764 tempArc.setUnderlyingArc(inhibArc);
4765 guiModel.addPetriNetObject(tempArc);
4766@@ -430,23 +428,29 @@
4767 Element element;
4768 if (node instanceof Element) {
4769 element = (Element) node;
4770- if ("labels".equals(element.getNodeName())) {
4771- parseAndAddAnnotationAsOldFormat(element);
4772- } else if ("place".equals(element.getNodeName())) {
4773- parseAndAddPlaceAsOldFormat(element, marking);
4774- } else if ("transition".equals(element.getNodeName())) {
4775- parseAndAddTransitionAsOldFormat(element);
4776- } else if ("arc".equals(element.getNodeName())) {
4777- parseAndAddArcAsOldFormat(element);
4778- } else if ("queries".equals(element.getNodeName())) {
4779- TAPNQuery query = parseQueryAsOldFormat(element);
4780-
4781-
4782- if (query != null) {
4783- query.getProperty().accept(new AddTemplateVisitor(templateName), null);
4784- queries.add(query);
4785- }
4786- }
4787+ switch (element.getNodeName()) {
4788+ case "labels":
4789+ parseAndAddAnnotationAsOldFormat(element);
4790+ break;
4791+ case "place":
4792+ parseAndAddPlaceAsOldFormat(element, marking);
4793+ break;
4794+ case "transition":
4795+ parseAndAddTransitionAsOldFormat(element);
4796+ break;
4797+ case "arc":
4798+ parseAndAddArcAsOldFormat(element);
4799+ break;
4800+ case "queries":
4801+ TAPNQuery query = parseQueryAsOldFormat(element);
4802+
4803+
4804+ if (query != null) {
4805+ query.getProperty().accept(new AddTemplateVisitor(templateName), null);
4806+ queries.add(query);
4807+ }
4808+ break;
4809+ }
4810 }
4811 }
4812
4813@@ -524,13 +528,13 @@
4814
4815 TimedTransitionComponent transition = new TimedTransitionComponent(
4816 positionXInput, positionYInput, idInput,
4817- nameOffsetXInput, nameOffsetYInput, timedTransition,
4818- infiniteServer, angle, priority, lens);
4819+ nameOffsetXInput, nameOffsetYInput,
4820+ angle, lens);
4821 transition.setUnderlyingTransition(t);
4822 guiModel.addPetriNetObject(transition);
4823 tapn.add(t);
4824 }
4825-
4826+ //TODO: implement color
4827 private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException {
4828 int positionXInput = (int) getPositionAttribute(element, "x");
4829 int positionYInput = (int) getPositionAttribute(element, "y");
4830@@ -549,7 +553,7 @@
4831 nameInput = idInput;
4832 }
4833
4834- if (nameInput.toLowerCase().equals("true") || nameInput.toLowerCase().equals("false")) {
4835+ if (nameInput.equalsIgnoreCase("true") || nameInput.equalsIgnoreCase("false")) {
4836 nameInput = "_" + nameInput;
4837 if (firstPlaceRenameWarning) {
4838 messages.add(PLACENAME_ERROR_MESSAGE);
4839@@ -560,14 +564,14 @@
4840
4841 TimedPlaceComponent place = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, lens);
4842
4843- LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants));
4844+ LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants), ColorType.COLORTYPE_DOT);
4845 tapn.add(p);
4846
4847 place.setUnderlyingPlace(p);
4848 guiModel.addPetriNetObject(place);
4849
4850 for (int i = 0; i < initialMarkingInput; i++) {
4851- marking.add(new TimedToken(p, new BigDecimal(0.0)));
4852+ marking.add(new TimedToken(p, new BigDecimal(0.0), ColorType.COLORTYPE_DOT.getFirstColor()));
4853 }
4854 }
4855
4856@@ -651,8 +655,8 @@
4857 String arcTempType = element.getAttribute("curvePoint");
4858 double arcPointX = Double.parseDouble(arcTempX);
4859 double arcPointY = Double.parseDouble(arcTempY);
4860- arcPointX += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
4861- arcPointY += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
4862+ arcPointX += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
4863+ arcPointY += Constants.ARC_CONTROL_POINT_CONSTANT + 1;
4864 boolean arcPointType = Boolean.parseBoolean(arcTempType);
4865 tempArc.getArcPath().addPoint(arcPointX, arcPointY, arcPointType);
4866 }
4867@@ -683,7 +687,7 @@
4868 if (query != null) {
4869 TAPNQuery parsedQuery = new TAPNQuery(comment, capacity, query, traceOption,
4870 searchOption, reductionOption, symmetry, true, true, true, false, false, hashTableSize,
4871- extrapolationOption,inclusionPlaces);
4872+ extrapolationOption,inclusionPlaces, lens.isColored());
4873 parsedQuery.setActive(active);
4874 parsedQuery.setDiscreteInclusion(discreteInclusion);
4875 return parsedQuery;
4876
4877=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
4878--- src/dk/aau/cs/io/TapnXmlLoader.java 2021-10-21 10:21:25 +0000
4879+++ src/dk/aau/cs/io/TapnXmlLoader.java 2022-03-21 20:20:44 +0000
4880@@ -3,38 +3,34 @@
4881 import java.io.File;
4882 import java.io.IOException;
4883 import java.io.InputStream;
4884-import java.util.ArrayList;
4885-import java.util.Collection;
4886-import java.util.HashMap;
4887-import java.util.List;
4888+import java.util.*;
4889
4890-import javax.swing.*;
4891 import javax.xml.parsers.DocumentBuilder;
4892 import javax.xml.parsers.DocumentBuilderFactory;
4893 import javax.xml.parsers.ParserConfigurationException;
4894
4895-import dk.aau.cs.debug.Logger;
4896-import dk.aau.cs.gui.TabContent;
4897-import org.w3c.dom.Document;
4898-import org.w3c.dom.Element;
4899-import org.w3c.dom.Node;
4900-import org.w3c.dom.NodeList;
4901+import dk.aau.cs.model.CPN.*;
4902+import dk.aau.cs.model.CPN.Expressions.*;
4903+import kotlin.Pair;
4904+import net.tapaal.gui.petrinet.TAPNLens;
4905+import org.w3c.dom.*;
4906 import org.xml.sax.SAXException;
4907
4908-import pipe.dataLayer.TAPNQuery;
4909-import pipe.dataLayer.DataLayer;
4910-import pipe.dataLayer.Template;
4911-import pipe.gui.CreateGui;
4912-import pipe.gui.Pipe;
4913-import pipe.gui.Zoomer;
4914-import pipe.gui.graphicElements.*;
4915-import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent;
4916-import pipe.gui.graphicElements.tapn.TimedInputArcComponent;
4917-import pipe.gui.graphicElements.tapn.TimedOutputArcComponent;
4918-import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
4919-import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
4920-import pipe.gui.graphicElements.tapn.TimedTransportArcComponent;
4921-import dk.aau.cs.gui.NameGenerator;
4922+import pipe.gui.petrinet.dataLayer.DataLayer;
4923+import net.tapaal.gui.petrinet.Template;
4924+import pipe.gui.Constants;
4925+import pipe.gui.canvas.Zoomer;
4926+import pipe.gui.petrinet.graphicElements.AnnotationNote;
4927+import pipe.gui.petrinet.graphicElements.Arc;
4928+import pipe.gui.petrinet.graphicElements.Place;
4929+import pipe.gui.petrinet.graphicElements.PlaceTransitionObject;
4930+import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;
4931+import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent;
4932+import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent;
4933+import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;
4934+import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent;
4935+import pipe.gui.petrinet.graphicElements.tapn.TimedTransportArcComponent;
4936+import net.tapaal.gui.petrinet.NameGenerator;
4937 import dk.aau.cs.io.queries.TAPNQueryLoader;
4938 import dk.aau.cs.model.tapn.Constant;
4939 import dk.aau.cs.model.tapn.ConstantStore;
4940@@ -48,7 +44,6 @@
4941 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
4942 import dk.aau.cs.model.tapn.TimedInhibitorArc;
4943 import dk.aau.cs.model.tapn.TimedInputArc;
4944-import dk.aau.cs.model.tapn.TimedMarking;
4945 import dk.aau.cs.model.tapn.TimedOutputArc;
4946 import dk.aau.cs.model.tapn.TimedPlace;
4947 import dk.aau.cs.model.tapn.TimedToken;
4948@@ -64,21 +59,24 @@
4949 private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
4950 private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
4951 private final HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>();
4952+ private final HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>> coloredTransportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>>();
4953+ private ArcExpression transportExpr;
4954
4955- private final NameGenerator nameGenerator = new NameGenerator();
4956+ private final NameGenerator nameGenerator = new NameGenerator();
4957 private boolean firstInhibitorIntervalWarning = true;
4958 private boolean firstPlaceRenameWarning = true;
4959 private final IdResolver idResolver = new IdResolver();
4960 private final Collection<String> messages = new ArrayList<>(10);
4961-
4962+ int groupPlaceHolder = 1;
4963+ private final LoadTACPN loadTACPN = new LoadTACPN();
4964 boolean hasFeatureTag = false;
4965- private TabContent.TAPNLens lens = TabContent.TAPNLens.Default;
4966+ private TAPNLens lens = TAPNLens.Default;
4967
4968 public TapnXmlLoader() {
4969
4970 }
4971
4972- public TabContent.TAPNLens loadLens(InputStream file) throws FormatException {
4973+ public TAPNLens loadLens(InputStream file) throws FormatException {
4974 Require.that(file != null, "file must be non-null and exist");
4975
4976 Document doc = loadDocument(file);
4977@@ -103,7 +101,7 @@
4978 } catch (FormatException | NullPointerException e) {
4979 throw e;
4980 } catch (Exception e) {
4981- throw new Exception("One or more necessary attributes were not found\n - One or more attribute values have an incorrect type");
4982+ throw new Exception("One or more necessary attributes were not found\n - One or more attribute values have an incorrect type", e);
4983 }
4984 }
4985
4986@@ -143,12 +141,26 @@
4987 private LoadedModel parse(Document doc) throws FormatException {
4988 idResolver.clear();
4989
4990- parseFeature(doc);
4991-
4992+
4993 ConstantStore constants = new ConstantStore(parseConstants(doc));
4994-
4995- TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants);
4996-
4997+ TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants, new ArrayList<>());
4998+ NodeList declarations = doc.getElementsByTagName("declaration");
4999+
5000+ if (declarations.getLength() > 0) {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches