Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gs-gama
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
graphstream
gs-gama
Commits
0b74cc7f
Commit
0b74cc7f
authored
Feb 06, 2014
by
Thibaut Démare
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the 'add node attribute' command
parent
94d0cab6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
4 deletions
+79
-4
src-gama-test/gama_model/models/test.gaml
src-gama-test/gama_model/models/test.gaml
+15
-0
src/org/graphstream/gama/extension/sender/AddNodeAttributeStatement.java
...ream/gama/extension/sender/AddNodeAttributeStatement.java
+60
-0
src/org/graphstream/gama/extension/sender/GSSender.java
src/org/graphstream/gama/extension/sender/GSSender.java
+4
-4
No files found.
src-gama-test/gama_model/models/test.gaml
View file @
0b74cc7f
...
@@ -42,6 +42,21 @@ global {
...
@@ -42,6 +42,21 @@ global {
//
Step
//
Step
gs_step
gs_sender_id
:
"test1"
gs_step_number
:
1
;
gs_step
gs_sender_id
:
"test1"
gs_step_number
:
1
;
//
Add
attributes
on
node
//
A
string
attribute
gs_add_node_attribute
gs_sender_id
:
"test1"
gs_node_id
:
"node1"
gs_attribute_name
:
"string"
gs_attribute_value
:
"a string value"
;
//
A
double
attribute
gs_add_node_attribute
gs_sender_id
:
"test1"
gs_node_id
:
"node1"
gs_attribute_name
:
"double"
gs_attribute_value
:
10.0
;
//
An
integer
attribute
gs_add_node_attribute
gs_sender_id
:
"test1"
gs_node_id
:
"node1"
gs_attribute_name
:
"integer"
gs_attribute_value
:
1
;
//
A
boolean
attribute
gs_add_node_attribute
gs_sender_id
:
"test1"
gs_node_id
:
"node1"
gs_attribute_name
:
"boolean"
gs_attribute_value
:
true
;
//
A
list
attribute
gs_add_node_attribute
gs_sender_id
:
"test1"
gs_node_id
:
"node1"
gs_attribute_name
:
"list"
gs_attribute_value
:[
1
,
2
,
3
];
//
Step
gs_step
gs_sender_id
:
"test1"
gs_step_number
:
2
;
//
Clear
//
Clear
gs_clear
gs_sender_id
:
"test1"
;
gs_clear
gs_sender_id
:
"test1"
;
...
...
src/org/graphstream/gama/extension/sender/AddNodeAttributeStatement.java
0 → 100644
View file @
0b74cc7f
package
org.graphstream.gama.extension.sender
;
import
msi.gama.precompiler.ISymbolKind
;
import
msi.gama.precompiler.GamlAnnotations.facet
;
import
msi.gama.precompiler.GamlAnnotations.facets
;
import
msi.gama.precompiler.GamlAnnotations.inside
;
import
msi.gama.precompiler.GamlAnnotations.symbol
;
import
msi.gama.runtime.IScope
;
import
msi.gama.runtime.exceptions.GamaRuntimeException
;
import
msi.gaml.descriptions.IDescription
;
import
msi.gaml.expressions.IExpression
;
import
msi.gaml.statements.AbstractStatement
;
import
msi.gaml.statements.IStatement
;
import
msi.gaml.types.IType
;
import
org.graphstream.gama.extension.GSManager
;
import
org.graphstream.gama.extension.IKeywordGSAdditional
;
@symbol
(
name
=
IKeywordGSAdditional
.
ADD_NODE_ATTRIBUTE
,
kind
=
ISymbolKind
.
SINGLE_STATEMENT
,
with_sequence
=
false
)
@inside
(
kinds
=
{
ISymbolKind
.
BEHAVIOR
,
ISymbolKind
.
SINGLE_STATEMENT
})
@facets
(
value
=
{
@facet
(
name
=
IKeywordGSAdditional
.
SENDERID
,
type
=
IType
.
STRING
,
optional
=
false
),
@facet
(
name
=
IKeywordGSAdditional
.
NODE_ID
,
type
=
IType
.
STRING
,
optional
=
false
),
@facet
(
name
=
IKeywordGSAdditional
.
ATTRIBUTE_NAME
,
type
=
IType
.
STRING
,
optional
=
false
),
@facet
(
name
=
IKeywordGSAdditional
.
ATTRIBUTE_VALUE
,
type
=
IType
.
NONE
,
optional
=
false
)})
public
class
AddNodeAttributeStatement
extends
AbstractStatement
implements
IStatement
{
final
IExpression
senderid
;
final
IExpression
nodeid
;
final
IExpression
attname
;
final
IExpression
attval
;
public
AddNodeAttributeStatement
(
IDescription
desc
)
{
super
(
desc
);
senderid
=
getFacet
(
IKeywordGSAdditional
.
SENDERID
);
nodeid
=
getFacet
(
IKeywordGSAdditional
.
NODE_ID
);
attname
=
getFacet
(
IKeywordGSAdditional
.
ATTRIBUTE_NAME
);
attval
=
getFacet
(
IKeywordGSAdditional
.
ATTRIBUTE_VALUE
);
}
@Override
protected
Object
privateExecuteIn
(
IScope
scope
)
throws
GamaRuntimeException
{
String
s
=
(
String
)(
senderid
.
value
(
scope
));
String
eid
=
(
String
)(
nodeid
.
value
(
scope
));
String
an
=
(
String
)(
attname
.
value
(
scope
));
Object
av
=
attval
.
value
(
scope
);
GSSender
sender
=
GSManager
.
getSender
(
s
);
// If it is a GamaList, it must be cast to an array
if
(
av
instanceof
msi
.
gama
.
util
.
GamaList
){
Object
[]
av_ar
=
((
msi
.
gama
.
util
.
GamaList
)
av
).
toArray
();
sender
.
sendNodeAttributeAdded
(
eid
,
an
,
av_ar
);
}
else
{
sender
.
sendNodeAttributeAdded
(
eid
,
an
,
av
);
}
return
null
;
}
}
\ No newline at end of file
src/org/graphstream/gama/extension/sender/GSSender.java
View file @
0b74cc7f
...
@@ -55,9 +55,9 @@ public class GSSender {
...
@@ -55,9 +55,9 @@ public class GSSender {
nsSender
.
graphAttributeAdded
(
sourceId
,
newEvent
(),
attribute
,
value
);
nsSender
.
graphAttributeAdded
(
sourceId
,
newEvent
(),
attribute
,
value
);
}
}
public
void
sendNodeAttributeAdded
(
lo
ng
nodeId
,
String
attribute
,
public
void
sendNodeAttributeAdded
(
Stri
ng
nodeId
,
String
attribute
,
Object
value
)
{
Object
value
)
{
nsSender
.
nodeAttributeAdded
(
sourceId
,
newEvent
(),
nodeId
+
""
,
nsSender
.
nodeAttributeAdded
(
sourceId
,
newEvent
(),
nodeId
,
attribute
,
value
);
attribute
,
value
);
}
}
...
@@ -71,8 +71,8 @@ public class GSSender {
...
@@ -71,8 +71,8 @@ public class GSSender {
nsSender
.
graphAttributeRemoved
(
sourceId
,
newEvent
(),
attribute
);
nsSender
.
graphAttributeRemoved
(
sourceId
,
newEvent
(),
attribute
);
}
}
public
void
sendNodeAttributeRemoved
(
lo
ng
nodeId
,
String
attribute
)
{
public
void
sendNodeAttributeRemoved
(
Stri
ng
nodeId
,
String
attribute
)
{
nsSender
.
nodeAttributeRemoved
(
sourceId
,
newEvent
(),
nodeId
+
""
,
nsSender
.
nodeAttributeRemoved
(
sourceId
,
newEvent
(),
nodeId
,
attribute
);
attribute
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment