mercredi 1 juillet 2015

What's the best and easiest way to make a chart and/or graph with java?

I currently have a program that moves a named object around on a graph and when when the method findPosition() is called gets printed out in the consoul.

I'm wondering if there is a more concise way to make this chart/graph and if I could make it so there could be mulitple things moving around on a single graph at a time?

 public  void findPosition(){
    iteration++;
    System.out.println("-----------------------------------" + "\n");
    System.out.println(" ~~~POSITION CHART UPDATE: #"+iteration+"~~~\n");
    System.out.println(" y/x   0    1    2    3    4    5");
    int found = 0;
    for(int y=0;y<yPosition && y<5;y++){
            System.out.println("-"+y+"     .    .    .    .    .    .    ");
            found = y +1;  
    }
    switch(xPosition){
        case 0:System.out.println("-"+found+"   " + name + "  .    .    .    .    .    ");
        break;
        case 1:System.out.println("-"+found+"     .  " + name + "  .    .    .    .    ");
        break;
        case 2:System.out.println("-"+found+"     .    .  " + name + "  .    .    .    ");
        break;
        case 3:System.out.println("-"+found+"     .    .    .  " + name + "  .    .   ");
        break;
        case 4:System.out.println("-"+found+"     .    .    .    .  " + name + "  .   ");
        break;
        case 5:System.out.println("-"+found+"     .    .    .    .    .  " + name);
        break;
    }
    for(int i = found+1;i<=5; i++){ 
        System.out.println(-i+"     .    .    .    .    .    .    ");
    }
    System.out.println("\n");
    System.out.println(name + "'s " +"Positions: (" + xPosition + ",-" + yPosition + ")\n"
    +"-----------------------------------\n" );
}

Aucun commentaire:

Enregistrer un commentaire