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-boids
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-boids
Commits
a259c851
Commit
a259c851
authored
Mar 13, 2012
by
Ant01n3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok.
parent
d56143b2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
src/org/graphstream/boids/Boid.java
src/org/graphstream/boids/Boid.java
+17
-4
src/org/graphstream/boids/Context.java
src/org/graphstream/boids/Context.java
+1
-1
src/org/graphstream/boids/gui/GUI.java
src/org/graphstream/boids/gui/GUI.java
+4
-1
src/org/graphstream/boids/gui/ParticleViewer.java
src/org/graphstream/boids/gui/ParticleViewer.java
+3
-3
src/org/graphstream/glutil/SwingBuffer.java
src/org/graphstream/glutil/SwingBuffer.java
+1
-0
No files found.
src/org/graphstream/boids/Boid.java
View file @
a259c851
...
@@ -92,27 +92,37 @@ public class Boid extends AdjacencyListNode {
...
@@ -92,27 +92,37 @@ public class Boid extends AdjacencyListNode {
}
}
protected
void
checkNeighborhood
(
BoidParticle
...
particles
)
{
protected
void
checkNeighborhood
(
BoidParticle
...
particles
)
{
System
.
err
.
printf
(
"Boid %s :%n"
,
id
);
if
(
particles
!=
null
)
{
if
(
particles
!=
null
)
{
Iterator
<
Boid
>
it
=
getNeighborNodeIterator
();
Iterator
<
Boid
>
it
=
getNeighborNodeIterator
();
LinkedList
<
Boid
>
toRemove
=
null
;
LinkedList
<
Boid
>
toRemove
=
null
;
System
.
err
.
printf
(
"Sees [ "
);
for
(
BoidParticle
p
:
particles
)
{
System
.
err
.
printf
(
"%s "
,
p
.
getBoid
().
id
);
}
System
.
err
.
printf
(
"]%nHas Neighbors [ "
);
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
boolean
found
=
false
;
boolean
found
=
false
;
Boid
b
=
it
.
next
();
Boid
b
=
it
.
next
();
for
(
BoidParticle
p
:
particles
)
for
(
BoidParticle
p
:
particles
)
{
if
(
p
.
getId
().
equals
(
b
.
getParticle
().
getId
()))
{
if
(
p
.
getId
().
equals
(
b
.
getParticle
().
getId
()))
{
found
=
true
;
found
=
true
;
break
;
break
;
}
}
}
System
.
err
.
printf
(
"%s(%b)"
,
b
.
id
,
found
);
if
(!
found
&&
!
forces
.
isVisible
(
b
.
particle
,
this
.
getPosition
()))
{
if
(!
found
&&
!
forces
.
isVisible
(
b
.
particle
,
this
.
getPosition
()))
{
if
(
toRemove
==
null
)
if
(
toRemove
==
null
)
toRemove
=
new
LinkedList
<
Boid
>();
toRemove
=
new
LinkedList
<
Boid
>();
System
.
err
.
printf
(
"(del)"
);
toRemove
.
add
(
b
);
toRemove
.
add
(
b
);
}
}
}
}
System
.
err
.
printf
(
"%n"
);
if
(
toRemove
!=
null
)
{
if
(
toRemove
!=
null
)
{
for
(
Boid
b
:
toRemove
)
for
(
Boid
b
:
toRemove
)
...
@@ -121,13 +131,16 @@ public class Boid extends AdjacencyListNode {
...
@@ -121,13 +131,16 @@ public class Boid extends AdjacencyListNode {
toRemove
.
clear
();
toRemove
.
clear
();
toRemove
=
null
;
toRemove
=
null
;
}
}
System
.
err
.
printf
(
"adds link to [ "
);
for
(
BoidParticle
p
:
particles
)
{
for
(
BoidParticle
p
:
particles
)
{
if
(
getEdgeBetween
(
p
.
getBoid
().
getId
())
==
null
)
if
(
getEdgeBetween
(
p
.
getBoid
().
getId
())
==
null
)
{
getGraph
().
addEdge
(
getEdgeId
(
this
,
p
.
getBoid
()),
getId
(),
getGraph
().
addEdge
(
getEdgeId
(
this
,
p
.
getBoid
()),
getId
(),
p
.
getBoid
().
getId
());
p
.
getBoid
().
getId
());
System
.
err
.
printf
(
"%s "
,
p
.
getBoid
().
id
);
}
}
}
}
}
System
.
err
.
printf
(
"]%n"
);
}
}
public
static
final
String
getEdgeId
(
Boid
b1
,
Boid
b2
)
{
public
static
final
String
getEdgeId
(
Boid
b1
,
Boid
b2
)
{
...
...
src/org/graphstream/boids/Context.java
View file @
a259c851
...
@@ -191,7 +191,7 @@ public class Context extends AdjacencyListGraph {
...
@@ -191,7 +191,7 @@ public class Context extends AdjacencyListGraph {
boidSpecies
=
new
HashMap
<
String
,
BoidSpecies
>();
boidSpecies
=
new
HashMap
<
String
,
BoidSpecies
>();
//boidSpecies.put("default", new BoidSpecies(this, "default"));
//boidSpecies.put("default", new BoidSpecies(this, "default"));
getOrCreateSpecies
(
"default"
);
getOrCreateSpecies
(
"default"
);
space
=
new
OctreeCellSpace
(
new
Anchor
(-
2
,
-
2
,
-
2
),
new
Anchor
(
2
,
2
,
2
));
space
=
new
OctreeCellSpace
(
new
Anchor
(-
area
,
-
area
,
-
area
),
new
Anchor
(
area
,
area
,
area
));
pbox
=
new
ParticleBox
(
maxParticlesPerCell
,
space
,
new
BoidCellData
());
pbox
=
new
ParticleBox
(
maxParticlesPerCell
,
space
,
new
BoidCellData
());
}
}
...
...
src/org/graphstream/boids/gui/GUI.java
View file @
a259c851
...
@@ -8,6 +8,7 @@ import java.awt.event.ActionListener;
...
@@ -8,6 +8,7 @@ import java.awt.event.ActionListener;
import
javax.swing.JFrame
;
import
javax.swing.JFrame
;
import
javax.swing.Timer
;
import
javax.swing.Timer
;
import
org.graphstream.boids.BoidSpecies
;
import
org.graphstream.boids.Context
;
import
org.graphstream.boids.Context
;
import
org.graphstream.ui.swingViewer.Viewer
;
import
org.graphstream.ui.swingViewer.Viewer
;
import
org.graphstream.ui.swingViewer.util.Camera
;
import
org.graphstream.ui.swingViewer.util.Camera
;
...
@@ -83,7 +84,9 @@ public class GUI extends JFrame implements ActionListener
...
@@ -83,7 +84,9 @@ public class GUI extends JFrame implements ActionListener
public
static
void
main
(
String
args
[])
{
public
static
void
main
(
String
args
[])
{
Context
ctx
=
new
Context
();
Context
ctx
=
new
Context
();
GUI
gui
=
new
GUI
(
ctx
);
GUI
gui
=
new
GUI
(
ctx
);
BoidSpecies
species
=
ctx
.
getDefaultSpecies
();
species
.
angleOfView
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
for
(
int
i
=
0
;
i
<
100
;
i
++)
ctx
.
addNode
(
String
.
format
(
"boid%03d"
,
i
));
ctx
.
addNode
(
String
.
format
(
"boid%03d"
,
i
));
...
...
src/org/graphstream/boids/gui/ParticleViewer.java
View file @
a259c851
...
@@ -57,7 +57,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
...
@@ -57,7 +57,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
protected
float
near
=
1
f
;
protected
float
near
=
1
f
;
protected
float
radius
=
1.
0
3f
,
theta
,
phi
;
protected
float
radius
=
1.3f
,
theta
,
phi
;
protected
Point3
camera
;
protected
Point3
camera
;
...
@@ -67,7 +67,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
...
@@ -67,7 +67,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
protected
Cube
env
;
protected
Cube
env
;
protected
Color
background
=
new
Color
(
0
,
0
,
0
);
protected
Color
background
=
new
Color
(
255
,
255
,
255
);
// Constructors
// Constructors
...
@@ -201,7 +201,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
...
@@ -201,7 +201,7 @@ public class ParticleViewer extends JPanel implements ParticleBoxListener,
public
void
display
(
Buffer
buffer
)
{
public
void
display
(
Buffer
buffer
)
{
setView
();
setView
();
//
displayEnv();
displayEnv
();
displayParticles
();
displayParticles
();
}
}
...
...
src/org/graphstream/glutil/SwingBuffer.java
View file @
a259c851
...
@@ -479,6 +479,7 @@ public class SwingBuffer
...
@@ -479,6 +479,7 @@ public class SwingBuffer
public
void
display
()
public
void
display
()
{
{
canvas
.
display
();
canvas
.
display
();
canvas
.
swapBuffers
();
}
}
/**
/**
...
...
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