I just arrive to my new job and my boss told me that I had to work with visjs.org library for graphos.
I have to work with "19_scale_free_graph_clustering" example. The groups that has >=10 nodes have to change of color.
This library is so rare, the code has so much declarations that still I can't understand it. I just can change the color of all nodes but it is not the problem, I need change the groups that has >= 10 nodes in his cluster. Can someone understand me? Help me please.
Still I can't do it in 4 days, can someone help me please?
Here a snippet of the code, I don't know if I'm doing in the right part. This library has 30.000 lines of codes with so much declarations. This is a network little part that is where I'm working.
for (nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) {
var node = this.nodes[nodeId];
if (node.clusterSize > 1) {
//node.label = "[".concat(String(node.clusterSize),"]"); De esta manera se muestra el numero del nodo entre llaves
node.label = "".concat(String(node.clusterSize),"");
if(node.clusterSize >= 10){
this.defaultOptions.nodes.color.background = "#fff";// Here Im changing the color to all nodes
}
}
}
}
Related
Hope there will be nothing confusing in what I'm going to talk about, because my mother tongue is not English and my grammar is poor:p
I'm working on a mipmap analyzing tool which need to calculate with pixels from the render texture. Here's a part of the C# code:
private IEnumerator CSGroupColor(RenderTexture rt, GroupColor[] groupColors)
{
var outputBuffer = new ComputeBuffer(groupColors.Length, 8);
csKernelID = cs.FindKernel("CSGroupColor");
cs.SetTexture(csKernelID, "rt", rt);
cs.SetBuffer(csKernelID, "groupColorOut", outputBuffer);
cs.Dispatch(csKernelID, rt.width / 8, rt.height / 8, 1);
var req = AsyncGPUReadback.Request(outputBuffer);
yield return new WaitUntil(() => req.done);
req.GetData<GroupColor>().CopyTo(groupColors);
foreach (var color in groupColors)
{
if (!m_staticsDatas.TryGetValue(color.groupindex, out var vl))
continue;
if (color.value > 0)
vl.allColors.Add(color.value);
}
}
And what I want to implement next, is to make every buffer smaller(e.g.with a length of 4096), like we usually do in other asynchronous communications. Maybe I can pass the first buffer to CPU right away when it's full, and then replace it with the second buffer, and so on.
As I see it, using SetBuffer() again after req.done must be permitted to make that viable. I have been finding on Internet all day for a sample usage, but still found nothing.
Is there anyone who would give some help? Thx very much.
I have a board manager in my game, that shows what is happening, for example, if I want to buy a car and you dont have the necessary money in this board appears a message saying "You dont have enough gold".
public void setTextMonitor (string mensaje) {
textScreen = mensaje;
}
public IEnumerator DoTheDance() {
yield return new WaitForSeconds(5); // Esperar 3 seconds
textScreen = "";
}
This is my code and it's working properly, when the board shows a message after 5 seconds it's deleted but the board doesn't shows new messages and I dont know why, probably because the couroutine doesn't let setTextMonitor method to work properly dunno.
If you have another idea or other method for doing this,
I'd be really grateful
For such behavior really easy to use LeanTween asset. It's free in asset store.
Code will be close to the following:
textScreen = "You have not enough of gold";
LeanTween.DelayedCall(5f,()=>{textScreen = "";});
Though I begin with a very nicely, oriented globe:
After a lot of manual intervention and spinning, the globe may look like this:
Obviously, I should be implementing some sort of restoration function that will restore the globe on a certain axis to a point.
I have naively created the following code:
if(transform.parent.rotation.eulerAngles.y != 0)
{
goalRotation.eulerAngles = new Vector3(transform.parent.rotation.eulerAngles.x, transform.parent.rotation.eulerAngles.y, 0);
transform.parent.rotation = Quaternion.Slerp(transform.parent.rotation, goalRotation, Time.deltaTime);
}
However, this obviously does not work. It is definitely rotating the globe, but it's not moving as expected...
Is there anyone with more experience with Slerp or something similar that can rotate my globe to a 0 point?
As always, any help or advice is much appreciated.
EDIT: In case I wasn't clear before, I am looking to achieve something like this: https://gfycat.com/PeacefulJubilantCottontail (This is my solution to the problem). I did try to use other solutions here, but I guess there was a misunderstanding because they did not work.
While, the following naive code sorta works, I still feel there is a better way to do it...
if (fix && (lastControlled + 5f < Time.time))
{
goalRotation.eulerAngles = new Vector3(90, transform.parent.rotation.eulerAngles.y, 0);
transform.parent.rotation = Quaternion.Slerp(transform.parent.rotation, goalRotation, Time.deltaTime);
}
if (fix && (transform.parent.rotation.eulerAngles.x == 90) && (transform.parent.rotation.eulerAngles.z == 0))
{
fix = false;
}
The only real remaining issue I am having is that Slerp works towards the desired point, but it does not take the quickest path. Any further help would be appreciated.
Is this what you are trying to do?
quaternion defaultRotation = transform.parent.rotation;
bool returnToDefault = false;
void Update()
{
if(returnToDefault)
{
Vector 3 rot = new Vector 3 (transform.parent.rotation.x, Quaternion.Slerp(transform.parent.rotation, defaultRotation, Time.deltaTime).Euler.y, transorm.parent.rotation.y);
transform.parent.EulerAngles = rot;
}
}
And just change the variable returnToDefault to true whenever you want it to go back. Otherwise, you are constantly fighting your code, which as your wrote it is always rotating it back to default.
I'm working in Eclipse and I want to know if I can make an if statement that checks to see if the BufferedImage has been painted/drawn onto the frame. For some reason, it's not painting the correct image because clickable regions are appearing on that picture when they are not supposed to.
For example, when I click the region to go from 4>5 everything is good. When I click from 5 to go to 4 I end up at 6 because the 'regions' from 4 are appearing in 5 (The image should always be painted before the clickable regions are shown) before it's even being painted. I want to restrict this to check if the image has been painted onto the frame first.
I really don't want to use anything else besides what I have right now (so no new classes being implemented to do this task), I really just want a simple yet effective way to resolve this. Here is what I'm talking about:
...
MouseAdapter mouseHandler = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
repaint();
if(n==0)
{
if(e.getX()>=459 && e.getX()<491 && e.getY()>=111 && e.getY()<133
{
n = 4;
}
return;
}
if(n==5)
{
if(...)
{
n = 4;
}
return();
}
if(n==6)
{
if(...)
{
n = 5;
}
if(...)
{
n = 0;
}
if(...)
{
n = 6;
}
return();
}
}
...
I think you might need to give a little more information. The problem might lie in how you repaint, not whether it was painted.
If you are running another thread as your main program, you might instead want to send the mouse events synchronously to that so that the main thread can process the mouse click and then repaint.
Another solution might be to override the repaint method and paint the buffered images there, but you may have done that.
Also, a little off topic, I noticed that you used for loops to determine if the mouse was clicked in a specific area.
You could shorten the code:
for(int i=459; i<491; i++){
if(e.getX()==i){
for(int j=111; j<133; j++){
if(e.getY()==j){
//action taken
}
}
}
}
To:
if(e.getX()>=459 && e.getX()<491 && e.getY()>=111 && e.getY()<133{
//action taken
}
This would take up less space in your code and less time checking every pixel.
Back to your question.
I dont know of a function to tell if a buffered image has been painted. The ploblem that you are having though might of might not be in the code provided. Posting the rest of your code would be beneficial.
Okay I found the solution, I forgot to come back to this question and let you know. The problem was that the mouse was double clicking for some reason. You could almost say it was 'recursive'. I decided to move the mouseListener from inside the paintComponent to outside of it, and surely enough that fixed it.
I'm currently working on a game that will randomly generate a dungeon for the player. This is made up of a whole heap of different methods being called from different files. I seem to have the code working to be able to calculate how much space is available on the other side of the door.
There is a catch however; the code only seems to work when I am outputting to the console using CCLOG. I wrote a good chunk of the code without testing and decided to then work through it in steps to see how the code worked (I figured I would just get it to run without bugs and next I will check my values).
After I had established that the code was successfully checking available space in each direction, while listing the locations it had checked, I decided that I would like to remove the CCLOG output. Unfortunately though, doing this caused the code to stop working.
//First check "forward"
bottom = CGPointMake(startLocation.x + forwardDirectionModifier.x, startLocation.y + forwardDirectionModifier.y);
top = bottom;
do
{
currentLocation = CGPointMake(top.x + forwardDirectionModifier.x, top.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top = currentLocation;
CCLOG(#"Top location is %#", NSStringFromCGPoint(top));
}
} while (tileType == TileTypeFiller || top.y != 63);
This is a small snippet from the code; It is the section of code I think is most likely the issue. Essentially the problem is that if I comment out or delete the line CCLOG(#"Top location is %#", NSStringFromCGPoint(top)); it will stop working.
Here are some more details:
I have several little chunks of code like this, as long as I CCLOG in each one, it will be able to move to the next. If i were to comment out any of them, it would stop progress to the next chunk.
I can change the CCLOG to output anything and it will still work, it just has to be there.
I have tried cleaning the project.
There are more CCLOG's that aren't used inside any loops and they can be removed without consequence.
Does anyone have a solution to this? As far as I can tell, whether I do or do not output something to the console,it shouldn't have an effect on whether or not the code will execute.
Thanks in advance.
EDIT: At Ben Trengrove's suggestion, I am adding in further examples of where the CCLOG is being used.
This code immediately follows the previously listed code.
//Check left relative to door
farLeft = CGPointMake(startLocation.x + leftDirectionModifier.x, startLocation.y + leftDirectionModifier.y);
do
{
currentLocation = CGPointMake(farLeft.x + leftDirectionModifier.x, farLeft.y + leftDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
farLeft = currentLocation;
CCLOG(#"Far Left location is %#", NSStringFromCGPoint(farLeft));
}
} while (tileType == TileTypeFiller || farLeft.x !=0);
//Check forwards from far left
top2 = farLeft;
do
{
currentLocation = CGPointMake(top2.x + forwardDirectionModifier.x, top2.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top2 = currentLocation;
CCLOG(#"Top2 location is %#", NSStringFromCGPoint(top2));
}
} while ((tileType == TileTypeFiller)|| (top2.y != 63));
What does your tile cache return as a tileType when there is no tile at currentLocation ? TileTypeFiller by any chance ? if yes, you have an almost certain never ending loop there, under the right circumstances..
EDIT :
please add a line after the loop
CCLOG(#"");
and place a breakpoint on that line. See if the program stops there.
So the problem has now been solved, it seems that in part there was a fault in my logic.
Here is what I've done that now works:
do
{
currentLocation = CGPointMake(top.x + forwardDirectionModifier.x, top.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top = currentLocation;
}
locationCount++;
} while ((tileType == TileTypeFiller) && (locationCount != 15));
CCLOG(#"Top location is %#", NSStringFromCGPoint(top));
The change is that I've switched to AND as opposed to OR. I also changed the second part of the while as I realised that due to my max room size, I never needed to check more than 15 locations in any given direction.
Thanks a lot to everyone that has helped. I'm still not entirely sure though how the use of CCLOG was somehow able to help get past a fault in logic but at least it is working now.