~tapaal-contributor/tapaal/cpn-gui-dev

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/model/tapn/SharedPlace.java

  • Committer: ptaankvist at gmail
  • Date: 2020-08-12 12:17:15 UTC
  • Revision ID: ptaankvist@gmail.com-20200812121715-56tp466jo1tcv01w
Add Colors to places. Add colored invariants to places. Hide invariant and color information according to lens

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package dk.aau.cs.model.tapn;
2
2
 
3
3
import java.util.ArrayList;
 
4
import java.util.List;
4
5
 
 
6
import dk.aau.cs.model.CPN.Color;
 
7
import dk.aau.cs.model.CPN.ColorType;
 
8
import dk.aau.cs.model.CPN.ColoredTimeInvariant;
5
9
import pipe.dataLayer.Template;
6
10
import pipe.gui.CreateGui;
7
11
import dk.aau.cs.util.Tuple;
8
12
 
9
13
public class SharedPlace extends TimedPlace{
10
 
 
 
14
    private ColorType colorType;
 
15
    private List<ColoredTimeInvariant> ctiList = new ArrayList<ColoredTimeInvariant>() {{
 
16
        add(ColoredTimeInvariant.LESS_THAN_INFINITY_DYN_COLOR(Color.STAR_COLOR));
 
17
    }};
11
18
    private TimedArcPetriNetNetwork network;
12
19
 
13
20
    public SharedPlace(String name){
14
 
                this(name, TimeInvariant.LESS_THAN_INFINITY);
 
21
                this(name, TimeInvariant.LESS_THAN_INFINITY, ColoredTimeInvariant.LESS_THAN_INFINITY_AND_DOT);
15
22
        }
16
23
        
17
 
        public SharedPlace(String name, TimeInvariant invariant){
 
24
        public SharedPlace(String name, TimeInvariant invariant, ColoredTimeInvariant CTI){
18
25
                setName(name);
19
26
                setInvariant(invariant);
 
27
                setColorTimeInvariant(CTI);
20
28
        }
21
29
 
22
30
    public void setNetwork(TimedArcPetriNetNetwork network) {
28
36
        }
29
37
        
30
38
 
31
 
 
 
39
    //TODO: check that colored time invariant is copied correctly
32
40
        public TimedPlace copy() {
33
 
                return new SharedPlace(this.name(), this.invariant().copy());
 
41
                return new SharedPlace(this.name(), this.invariant().copy(), this.getColoredTimeInvariant().copy());
34
42
        }
35
43
 
36
44
        public boolean isShared() {
102
110
                
103
111
                return new Tuple<TimedPlace.PlaceType, Integer>(type, cmax);
104
112
        }
 
113
    @Override
 
114
    public List<ColoredTimeInvariant> getCtiList() {
 
115
        return ctiList;
 
116
    }
 
117
 
 
118
    //TODO: is this the right way to set this list
 
119
    public void setCtiList(List<ColoredTimeInvariant> ctiList) {
 
120
        List<ColoredTimeInvariant> found = new ArrayList<ColoredTimeInvariant>();
 
121
        for (ColoredTimeInvariant timeInvariant : ctiList) {
 
122
            if (timeInvariant == null) {
 
123
                found.add(timeInvariant);
 
124
            }
 
125
        }
 
126
        ctiList.removeAll(found);
 
127
        this.ctiList = ctiList;
 
128
    }
 
129
 
 
130
    public void setColorType(ColorType colorType) {
 
131
        this.colorType = colorType;
 
132
    }
 
133
    @Override
 
134
    public ColorType getColorType() {return colorType;}
105
135
}