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
a7893412
Commit
a7893412
authored
Feb 07, 2014
by
Thibaut Démare
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the 'add/remove graph attribute' commands and their tests
parent
f57d483f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
11 deletions
+147
-11
src-gama-test/gama_model/models/test.gaml
src-gama-test/gama_model/models/test.gaml
+18
-0
src-java-test/org/graphstream/gama/tests/SimpleSinkAdapter.java
...va-test/org/graphstream/gama/tests/SimpleSinkAdapter.java
+26
-11
src/org/graphstream/gama/extension/IKeywordGSAdditional.java
src/org/graphstream/gama/extension/IKeywordGSAdditional.java
+2
-0
src/org/graphstream/gama/extension/sender/AddGraphAttributeStatement.java
...eam/gama/extension/sender/AddGraphAttributeStatement.java
+56
-0
src/org/graphstream/gama/extension/sender/RemoveGraphAttributeStatement.java
.../gama/extension/sender/RemoveGraphAttributeStatement.java
+45
-0
No files found.
src-gama-test/gama_model/models/test.gaml
View file @
a7893412
...
...
@@ -72,6 +72,24 @@ global {
//
Step
gs_step
gs_sender_id
:
"test1"
gs_step_number
:
3
;
//
Add
attributes
on
node
//
A
string
attribute
gs_add_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"string"
gs_attribute_value
:
"a string value"
;
//
A
double
attribute
gs_add_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"double"
gs_attribute_value
:
10.0
;
//
An
integer
attribute
gs_add_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"integer"
gs_attribute_value
:
1
;
//
A
boolean
attribute
gs_add_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"boolean"
gs_attribute_value
:
true
;
//
A
list
attribute
gs_add_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"list"
gs_attribute_value
:[
1
,
2
,
3
];
//
Remove
graph
attribute
gs_remove_graph_attribute
gs_sender_id
:
"test1"
gs_attribute_name
:
"string"
;
//
Step
gs_step
gs_sender_id
:
"test1"
gs_step_number
:
4
;
//
Clear
//
gs_clear
gs_sender_id
:
"test1"
;
...
...
src-java-test/org/graphstream/gama/tests/SimpleSinkAdapter.java
View file @
a7893412
...
...
@@ -21,34 +21,49 @@ public class SimpleSinkAdapter extends SinkAdapter {
public
void
stepBegins
(
String
sourceId
,
long
timeId
,
double
step
)
{
System
.
out
.
println
(
"Edges attributes :"
);
for
(
Edge
e
:
graph
.
getEachEdge
()){
for
(
Object
o
:
e
.
getAttributeKeySet
()){
System
.
out
.
println
(
e
.
getAttribute
(
(
String
)
o
).
getClass
());
if
(
e
.
getAttribute
(
(
String
)
o
).
getClass
().
isArray
()){
Object
[]
array
=
(
Object
[])
e
.
getAttribute
(
(
String
)
o
);
for
(
String
o
:
e
.
getAttributeKeySet
()){
System
.
out
.
println
(
e
.
getAttribute
(
o
).
getClass
());
if
(
e
.
getAttribute
(
o
).
getClass
().
isArray
()){
Object
[]
array
=
(
Object
[])
e
.
getAttribute
(
o
);
System
.
out
.
print
(
'\t'
);
for
(
Object
ob
:
array
)
System
.
out
.
print
(
ob
);
System
.
out
.
println
();
}
else
{
System
.
out
.
println
(
"\tvalue = "
+
e
.
getAttribute
(
(
String
)
o
));
System
.
out
.
println
(
"\tvalue = "
+
e
.
getAttribute
(
o
));
}
}
}
System
.
out
.
println
(
"Nodes attributes :"
);
for
(
Node
e
:
graph
.
getEachNode
()){
for
(
Object
o
:
e
.
getAttributeKeySet
()){
System
.
out
.
println
(
e
.
getAttribute
(
(
String
)
o
).
getClass
());
if
(
e
.
getAttribute
(
(
String
)
o
).
getClass
().
isArray
()){
Object
[]
array
=
(
Object
[])
e
.
getAttribute
(
(
String
)
o
);
for
(
String
o
:
e
.
getAttributeKeySet
()){
System
.
out
.
println
(
e
.
getAttribute
(
o
).
getClass
());
if
(
e
.
getAttribute
(
o
).
getClass
().
isArray
()){
Object
[]
array
=
(
Object
[])
e
.
getAttribute
(
o
);
System
.
out
.
print
(
'\t'
);
for
(
Object
ob
:
array
)
System
.
out
.
print
(
ob
);
System
.
out
.
println
();
}
else
{
System
.
out
.
println
(
"\tvalue = "
+
e
.
getAttribute
((
String
)
o
));
}
}
System
.
out
.
println
(
"\tvalue = "
+
e
.
getAttribute
(
o
));
}
}
}
System
.
out
.
println
(
"Graph attributes :"
);
for
(
String
o
:
graph
.
getAttributeKeySet
()){
System
.
out
.
println
(
graph
.
getAttribute
(
o
).
getClass
());
if
(
graph
.
getAttribute
(
o
).
getClass
().
isArray
()){
Object
[]
array
=
(
Object
[])
graph
.
getAttribute
(
o
);
System
.
out
.
print
(
'\t'
);
for
(
Object
ob
:
array
)
System
.
out
.
print
(
ob
);
System
.
out
.
println
();
}
else
{
System
.
out
.
println
(
"\tvalue = "
+
graph
.
getAttribute
(
o
));
}
}
}
...
...
src/org/graphstream/gama/extension/IKeywordGSAdditional.java
View file @
a7893412
...
...
@@ -7,6 +7,7 @@ public class IKeywordGSAdditional implements IKeyword {
public
static
final
String
ADD_EDGE
=
"gs_add_edge"
;
public
static
final
String
ADD_EDGE_ATTRIBUTE
=
"gs_add_edge_attribute"
;
public
static
final
String
ADD_GRAPH_ATTRIBUTE
=
"gs_add_graph_attribute"
;
public
static
final
String
ADD_NODE
=
"gs_add_node"
;
public
static
final
String
ADD_NODE_ATTRIBUTE
=
"gs_add_node_attribute"
;
public
static
final
String
ADD_SENDER
=
"gs_add_sender"
;
...
...
@@ -15,6 +16,7 @@ public class IKeywordGSAdditional implements IKeyword {
public
static
final
String
CLOSE
=
"gs_close"
;
public
static
final
String
REMOVE_EDGE
=
"gs_remove_edge"
;
public
static
final
String
REMOVE_EDGE_ATTRIBUTE
=
"gs_remove_edge_attribute"
;
public
static
final
String
REMOVE_GRAPH_ATTRIBUTE
=
"gs_remove_graph_attribute"
;
public
static
final
String
REMOVE_NODE
=
"gs_remove_node"
;
public
static
final
String
REMOVE_NODE_ATTRIBUTE
=
"gs_remove_node_attribute"
;
public
static
final
String
STEP
=
"gs_step"
;
...
...
src/org/graphstream/gama/extension/sender/AddGraphAttributeStatement.java
0 → 100644
View file @
a7893412
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_GRAPH_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
.
ATTRIBUTE_NAME
,
type
=
IType
.
STRING
,
optional
=
false
),
@facet
(
name
=
IKeywordGSAdditional
.
ATTRIBUTE_VALUE
,
type
=
IType
.
NONE
,
optional
=
false
)})
public
class
AddGraphAttributeStatement
extends
AbstractStatement
implements
IStatement
{
final
IExpression
senderid
;
final
IExpression
attname
;
final
IExpression
attval
;
public
AddGraphAttributeStatement
(
IDescription
desc
)
{
super
(
desc
);
senderid
=
getFacet
(
IKeywordGSAdditional
.
SENDERID
);
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
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
.
sendGraphAttributeAdded
(
an
,
av_ar
);
}
else
{
sender
.
sendGraphAttributeAdded
(
an
,
av
);
}
return
null
;
}
}
\ No newline at end of file
src/org/graphstream/gama/extension/sender/RemoveGraphAttributeStatement.java
0 → 100644
View file @
a7893412
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
.
REMOVE_GRAPH_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
.
ATTRIBUTE_NAME
,
type
=
IType
.
STRING
,
optional
=
false
)})
public
class
RemoveGraphAttributeStatement
extends
AbstractStatement
implements
IStatement
{
final
IExpression
senderid
;
final
IExpression
attname
;
public
RemoveGraphAttributeStatement
(
IDescription
desc
)
{
super
(
desc
);
senderid
=
getFacet
(
IKeywordGSAdditional
.
SENDERID
);
attname
=
getFacet
(
IKeywordGSAdditional
.
ATTRIBUTE_NAME
);
}
@Override
protected
Object
privateExecuteIn
(
IScope
scope
)
throws
GamaRuntimeException
{
String
s
=
(
String
)(
senderid
.
value
(
scope
));
String
an
=
(
String
)(
attname
.
value
(
scope
));
GSSender
sender
=
GSManager
.
getSender
(
s
);
sender
.
sendGraphAttributeRemoved
(
an
);
return
null
;
}
}
\ No newline at end of file
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