GWindow 'g4p' / Draws incorrectly. (Windows 'new window' problem)

GWindow ‘g4p’ / Draws incorrectly. (Windows ‘new window’ problem)


  1. Please check 2 images.
  • If it is drawn correctly, if it is drawn incorrectly
  1. Draw stops after 1 operation with ‘noLoop’.
  • Is there a way to increase the probability (accuracy) of drawing correctly?
import g4p_controls.*;
ArrayList<GWindow> windowsList;
GWindow window_cycle_list;
void WIN_SETUP_cyclist(int w_x, int w_y){

  //------------------------------------------------------//
  windowsList = G4P.getOpenWindowsAsList(windowsList);
  if(windowsList.contains(window_cycle_list)){     window_cycle_list.close(); return;}
  //------------------------------------------------------//

  //------------------------------------------------------//
  window_cycle_list = GWindow.getWindow(this, "Cycle List", w_x, w_y, 600, 300, JAVA2D);
  window_cycle_list.setActionOnClose(window_cycle_list.CLOSE_WINDOW);
  //------------------------------------------------------//
  
  //------------------------------------------------------//
  window_cycle_list.setAlwaysOnTop(true);  window_cycle_list.addDrawHandler(this,  "windowLIST");  window_cycle_list.addMouseHandler(this, "windowMouse_LIST");
  window_cycle_list.textFont(myFont_N);  window_cycle_list.imageMode(CENTER);  window_cycle_list.textAlign(CENTER); window_cycle_list.frameRate(1);
  window_cycle_list.background(255);
  window_cycle_list.rectMode(CENTER);
  //------------------------------------------------------//

}
public void windowLIST(PApplet appc, GWinData data) {
  
  int g_x=0,g_y=0,g_w=0,g_h=0,g_w2=0,g_h2=0;
  int g_c=350; 
  int g_c_y=250; 
  int g_x1=110, g_x2=330, g_x3=515;
  appc.background(255); appc.textAlign(CENTER,CENTER); 
  
  
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------// 
   g_y=40; g_h2=18;    
   boolean i_n = true; appc.noStroke();
   for (int i = 0; i < 16; i++){ 
     if(i==0){ appc.fill(0,112,192); } 
     else{
       if(i_n){i_n=false; appc.fill(255);         }
          else{i_n=true;  appc.fill(218,227,243); }
     }
     appc.rect(300,g_y+i*g_h2,600,g_h2);
   } 
  appc.stroke(255);    appc.strokeWeight(2);
  appc.line(220,0,220,600); appc.line(440,0,440,600);
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------//  
  
   
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------//  
   g_y=36;appc.textSize(16);
   appc.text("Start Date/Time",g_x1,g_y);  appc.text("End Date/Time",g_x2,g_y);   appc.text("Log",g_x3,g_y);   
   
   appc.fill(30); g_y=55;  appc.textSize(12);
   for (int i = 0; i < 15; i++){     
     appc.text(HISTORY_CYCLE[i][0],g_x1,g_y+round(g_h2*(i)));  
     appc.text(HISTORY_CYCLE[i][1],g_x2,g_y+round(g_h2*(i)));  
     appc.text(HISTORY_CYCLE[i][2],g_x3,g_y+round(g_h2*(i))); 
   }      
  //----------------------------------------------------------------------------// 
  //----------------------------------------------------------------------------//  
  
  
  //----------------------------------------------------------------------------// 
    g_x=530; g_y=12; g_w=125; g_w2=135; g_h=26; 
    appc.fill(10);
    appc.rect(g_x,g_y,g_w,g_h,30);  
    appc.fill(255); appc.textSize(15);    appc.textAlign(CENTER,CENTER);
    appc.text("EXIT",g_x,g_y-3);   
  //----------------------------------------------------------------------------// 
  

  appc.noLoop();
  return;
  
  
}

Why is this a problem?

I’m curious.

Is it a problem with the computer? Or is it a problem with the source configuration?

That would be incredibly unlikely

Depends what you mean by source configuration

Is it a problem with G4P
I can’t see that being a possibility either since the methods you are using belong to Processing :innocent:

In the first image we see that the problem arises part way through drawing a row :-1: which suggests that something in your code either changes the text alignment or the text render position.

From the code snippets provided I can’t see where the problem arises :unamused_face:

2 Likes

@quark
Thank you for your reply.

Am I the only one experiencing this phenomenon?

The configuration is as follows.

  1. 'Original window ’
  2. ‘New window’: ‘G4P library’

(There is an example of this scenario.)

  1. When a new window opens,
  2. The text in the ‘original window’ shakes, or the text in the ‘new window’ shakes.
  3. Even so, if you reduce ‘frameRate’, the frequency decreases.
  4. The current source code only runs once due to ‘noLoop’. So I think that moment was captured.

No one has reported a similar problem.

Each GWindow is effectively a separate PApplet with its own main-event-thread so each thread must be responsible for rendering its own display. Also if data is being shared between the windows this can cause problems.

I don’t think so because noLoop sets a flag to prevent the next call to draw, it doesn’t stop the draw method during its execution. So if all the text is being drawn in a single operation any call to noLoop would not affect the current frame.