« GContainer » : différence entre les versions

De GENIUS
Aller à la navigation Aller à la recherche
(Page créée avec « TBW ... Return to the introduction ↑ Go to the next page → »)
 
Aucun résumé des modifications
 
Ligne 1 : Ligne 1 :
TBW ...
When we want to merge several basic widgets (for example several [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryReal.html GEntryReal]), we can encapsulate them inside a [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel]:
* Advantage: directly displayed
* Drawback: when created, we don’t know exactly how to display it
 
Another solution is to put these objects inside a [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GContainer.html GContainer]
* Drawback: it is not possible to display it directly
* Advantages: display management will be done by the final user
 
We may use this [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GContainer.html GContainer] several times inside a same [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel] (for example several Orbit parameters or several maneuvers laws).
 
Note that, unlike [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel], one have to implement the [{{PathCurrentJavaDoc}}/fr/cnes/genius/main/GDisplay.html GDisplay] interface in order to be able to be displayed (by default, [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel] implements this interface).
 
<syntaxhighlight lang="java">
// This class must implement the GDisplay interface in order to be abled to be displayed ...
public class MyContainer extends GContainer implements GDisplay {
 
  private GButton but1;
  private GButton but2;
  private GButton but3;
 
  public MyContainer () {
    but1 = new GButton("Button1");
    but2 = new GButton("Button 2");
    but3 = new GButton("Button 3");
  }
 
  public void generic() throws GException{
    put(but1);
    put(but2);
    put(but3);
  }
 
  public void display() throws GException {
    generic();
  }
 
}
</syntaxhighlight>
 
Then this container will be called as is:
 
<syntaxhighlight lang="java">
GPanel pan = new GPanel() {
 
  private MyContainer cont = new MyContainer();
 
  public void display() throws GException {
    generic();
  }
 
  public void generic() throws GException {
    put(cont);
  }
 
};
</syntaxhighlight>
 


[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[GReadWrite_interface|Go to the next page →]]
[[GReadWrite_interface|Go to the next page →]]

Dernière version du 5 mai 2017 à 09:16

When we want to merge several basic widgets (for example several GEntryReal), we can encapsulate them inside a GPanel:

  • Advantage: directly displayed
  • Drawback: when created, we don’t know exactly how to display it

Another solution is to put these objects inside a GContainer

  • Drawback: it is not possible to display it directly
  • Advantages: display management will be done by the final user

We may use this GContainer several times inside a same GPanel (for example several Orbit parameters or several maneuvers laws).

Note that, unlike GPanel, one have to implement the GDisplay interface in order to be able to be displayed (by default, GPanel implements this interface).

// This class must implement the GDisplay interface in order to be abled to be displayed ...
public class MyContainer extends GContainer implements GDisplay {

  private GButton but1;
  private GButton but2;
  private GButton but3;

  public MyContainer () {
    but1 = new GButton("Button1");
    but2 = new GButton("Button 2");
    but3 = new GButton("Button 3");
  }

  public void generic() throws GException{
    put(but1);
    put(but2);
    put(but3);
  }

  public void display() throws GException {
    generic();
  }

}

Then this container will be called as is:

GPanel pan = new GPanel() {

  private MyContainer cont = new MyContainer();

  public void display() throws GException {
    generic();
  }

  public void generic() throws GException {
    put(cont);
  }

};


Return to the introduction ↑ Go to the next page →