예제 #1
0
파일: Parallel.java 프로젝트: visad/visad
  // type 'java Parallel' to run this application
  public static void main(String args[]) throws VisADException, RemoteException, IOException {

    RealType index = RealType.getRealType("index");
    RealType[] coords = new RealType[NCOORDS];
    for (int i = 0; i < NCOORDS; i++) {
      coords[i] = RealType.getRealType("coord" + i);
    }
    RealTupleType range = new RealTupleType(coords);
    FunctionType ftype = new FunctionType(index, range);
    Integer1DSet index_set = new Integer1DSet(NROWS);

    float[][] samples = new float[NCOORDS][NROWS];
    for (int i = 0; i < NCOORDS; i++) {
      for (int j = 0; j < NROWS; j++) {
        samples[i][j] = (float) Math.random();
      }
    }

    FlatField data = new FlatField(ftype, index_set);
    data.setSamples(samples, false);

    // create a 2-D Display using Java3D
    DisplayImpl display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D());

    parallel(display, data);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("Parallel Coordinates VisAD Application");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }