@Nullable
 @Override
 public JComponent createComponent() {
   myEnabled = new JBCheckBox("Enable EditorConfig support");
   final JPanel result = new JPanel();
   result.setLayout(new BoxLayout(result, BoxLayout.LINE_AXIS));
   final JPanel panel = new JPanel(new VerticalFlowLayout());
   result.setBorder(IdeBorderFactory.createTitledBorder("EditorConfig", false));
   panel.add(myEnabled);
   final JLabel warning = new JLabel("EditorConfig may override the IDE code style settings");
   warning.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
   warning.setBorder(IdeBorderFactory.createEmptyBorder(0, 20, 0, 0));
   panel.add(warning);
   panel.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(panel);
   final JButton export = new JButton("Export");
   export.addActionListener(
       (event) -> {
         final Component parent = UIUtil.findUltimateParent(result);
         if (parent instanceof IdeFrame) {
           Utils.export(((IdeFrame) parent).getProject());
         }
       });
   export.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(export);
   return result;
 }
示例#2
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);
  }
  /** Opens a new window with a drawing view. */
  protected void open(DrawingView newDrawingView) {
    getVersionControlStrategy().assertCompatibleVersion();
    setUndoManager(new UndoManager());
    fIconkit = new Iconkit(this);
    getContentPane().setLayout(new BorderLayout());

    // status line must be created before a tool is set
    fStatusLine = createStatusLine();
    getContentPane().add(fStatusLine, BorderLayout.SOUTH);

    // create dummy tool until the default tool is activated during toolDone()
    setTool(new NullTool(this), "");
    setView(newDrawingView);
    JComponent contents = createContents(view());
    contents.setAlignmentX(LEFT_ALIGNMENT);

    JToolBar tools = createToolPalette();
    createTools(tools);

    JPanel activePanel = new JPanel();
    activePanel.setAlignmentX(LEFT_ALIGNMENT);
    activePanel.setAlignmentY(TOP_ALIGNMENT);
    activePanel.setLayout(new BorderLayout());
    activePanel.add(tools, BorderLayout.NORTH);
    activePanel.add(contents, BorderLayout.CENTER);

    getContentPane().add(activePanel, BorderLayout.CENTER);

    JMenuBar mb = new JMenuBar();
    createMenus(mb);
    setJMenuBar(mb);

    Dimension d = defaultSize();
    if (d.width > mb.getPreferredSize().width) {
      setSize(d.width, d.height);
    } else {
      setSize(mb.getPreferredSize().width, d.height);
    }
    addListeners();
    setVisible(true);
    fStorageFormatManager = createStorageFormatManager();

    toolDone();
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public SudoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.info")*/ "For installing administrator privileges are necessary",
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.tip")*/ "Please note that passwords are case-sensitive",
            parent.icons.getImageIcon("tip"),
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    JPanel spacePanel = new JPanel();
    spacePanel.setAlignmentX(LEFT_ALIGNMENT);
    spacePanel.setAlignmentY(CENTER_ALIGNMENT);
    spacePanel.setBorder(BorderFactory.createEmptyBorder(80, 30, 0, 50));
    spacePanel.setLayout(new BorderLayout(5, 5));
    spacePanel.add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.specifyAdminPassword")*/ "Please specify your password:"),
        BorderLayout.NORTH);
    passwordField = new JPasswordField();
    passwordField.addActionListener(this);
    JPanel space2Panel = new JPanel();
    space2Panel.setLayout(new BorderLayout());
    space2Panel.add(passwordField, BorderLayout.NORTH);
    space2Panel.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.CENTER);
    spacePanel.add(space2Panel, BorderLayout.CENTER);
    add(spacePanel);
  }
  /**
   * Make a GUI for the battleship game.
   *
   * @param game Game object that keeps up with the current state of the game.
   */
  public BattleshipGUI(Battleship game) {
    this.game = game;

    this.game = game;
    // Ships are visible on the human grid but not on the computer grid
    // (last argument)
    humanGrid = new Grid(game.getHumanBoard(), this, true);
    computerGrid = new Grid(game.getComputerBoard(), this, false);
    setTitle("Battleship Game");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    // Add a message field centered below the game
    Box gamePanel = new Box(BoxLayout.X_AXIS);
    add(gamePanel, BorderLayout.CENTER);
    message = new JLabel("Game begins", JLabel.CENTER);
    message.setFont(DEFAULT_FONT);
    add(message, BorderLayout.SOUTH);

    // Add human and computer panels to the game; the human panel has a
    // title, grid, and buttons; the computer panel has only a title and a
    // grid
    JPanel human = new JPanel();
    human.setLayout(new BoxLayout(human, BoxLayout.Y_AXIS));
    JPanel computer = new JPanel();
    computer.setLayout(new BoxLayout(computer, BoxLayout.Y_AXIS));
    human.setAlignmentY(Component.TOP_ALIGNMENT);
    gamePanel.add(human);
    gamePanel.add(Box.createRigidArea(new Dimension(5, 0)));
    computer.setAlignmentY(Component.TOP_ALIGNMENT);
    gamePanel.add(computer);

    // Add three parts to the human panel
    JLabel humanLabel = new JLabel("Human", JLabel.CENTER);
    humanLabel.setFont(DEFAULT_FONT);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    human.add(humanLabel);
    human.add(humanGrid);
    human.add(buttonPanel);

    // Set up the buttons
    hButton = new JButton("Horizontal");
    hButton.setFont(DEFAULT_FONT);
    hButton.addActionListener(this);
    vButton = new JButton("Vertical");
    vButton.setFont(DEFAULT_FONT);
    vButton.addActionListener(this);
    buttonPanel.add(hButton);
    buttonPanel.add(vButton);

    // Add two parts to the computer panel
    JLabel computerLabel = new JLabel("Computer", JLabel.CENTER);
    computerLabel.setFont(DEFAULT_FONT);
    computer.add(computerLabel);
    computer.add(computerGrid);

    updateStatus();

    pack();
    setVisible(true);
  }
  // Constructor for the dialogue box
  public Route_addroute_dialogue(String[] Airports) {

    String[] Carriers = {"Delta", "United"};

    // Initialize all input boxes and drop-down menus
    JTextField Routenumtxt = new JTextField("0");
    JTextField Pricetxt = new JTextField("0.00");

    JComboBox Carrierchoice = new JComboBox(Carriers);
    JComboBox DepAPchoice = new JComboBox(Airports);
    JComboBox ArrAPchoice = new JComboBox(Airports);

    TimeSelectBoxPanel Deptimechoice = new TimeSelectBoxPanel();
    TimeSelectBoxPanel Arrtimechoice = new TimeSelectBoxPanel();

    // Combine choice fields with their appropriate labels in panels
    Routenumpanel.add(Routenumlabel);
    Routenumpanel.add(Routenumtxt);
    Routenumpanel.setLayout(new BoxLayout(Routenumpanel, BoxLayout.Y_AXIS));
    Routenumpanel.setAlignmentY(CENTER_ALIGNMENT);

    Carrierpanel.add(Carrierlabel);
    Carrierpanel.add(Carrierchoice);
    Carrierpanel.setLayout(new BoxLayout(Carrierpanel, BoxLayout.Y_AXIS));
    Carrierpanel.setAlignmentY(LEFT_ALIGNMENT);

    DepAPpanel.add(DepAPlabel);
    DepAPpanel.add(DepAPchoice);
    DepAPpanel.setLayout(new BoxLayout(DepAPpanel, BoxLayout.Y_AXIS));
    DepAPpanel.setAlignmentY(CENTER_ALIGNMENT);

    Deptimepanel.add(Deptimelabel);
    Deptimepanel.add(Deptimechoice);
    Deptimepanel.setLayout(new BoxLayout(Deptimepanel, BoxLayout.Y_AXIS));
    Deptimepanel.setAlignmentY(CENTER_ALIGNMENT);

    ArrAPpanel.add(ArrAPlabel);
    ArrAPpanel.add(ArrAPchoice);
    ArrAPpanel.setLayout(new BoxLayout(ArrAPpanel, BoxLayout.Y_AXIS));
    ArrAPpanel.setAlignmentY(CENTER_ALIGNMENT);

    Arrtimepanel.add(Arrtimelabel);
    Arrtimepanel.add(Arrtimechoice);
    Arrtimepanel.setLayout(new BoxLayout(Arrtimepanel, BoxLayout.Y_AXIS));
    Arrtimepanel.setAlignmentY(CENTER_ALIGNMENT);

    Pricepanel.add(Pricelabel);
    Pricepanel.add(Pricetxt);
    Pricepanel.setLayout(new BoxLayout(Pricepanel, BoxLayout.Y_AXIS));
    Pricepanel.setAlignmentY(CENTER_ALIGNMENT);

    // Add all choice panels to the overall choice panel
    Choicepanel.setLayout(new FlowLayout());
    Choicepanel.add(Routenumpanel);
    Choicepanel.add(Carrierpanel);
    Choicepanel.add(DepAPpanel);
    Choicepanel.add(Deptimepanel);
    Choicepanel.add(ArrAPpanel);
    Choicepanel.add(Arrtimepanel);
    Choicepanel.add(Pricepanel);

    // Add the buttons to the overall button panel
    Buttonpanel.setLayout(new FlowLayout());
    Buttonpanel.add(Cancelbutton);
    Buttonpanel.add(Addroutebutton);

    // Add the choice panel and button to the dialogue box
    setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    add(Choicepanel);
    add(Buttonpanel);
  }
示例#7
0
  public FindReplaceDialog(RobocodeEditor owner) {
    super(owner, false);
    editor = owner;

    GroupLayout layout = new GroupLayout(getContentPane());

    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    JPanel optionsPanel = new JPanel();

    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options"));
    optionsPanel.add(getCaseSensitiveCheckBox());
    optionsPanel.add(getWholeWordCheckBox());
    optionsPanel.setAlignmentY(TOP_ALIGNMENT);

    JPanel usePanel = new JPanel();

    usePanel.setLayout(new BoxLayout(usePanel, BoxLayout.Y_AXIS));
    usePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Use"));
    usePanel.add(getLiteralButton());
    usePanel.add(getWildCardsButton());
    usePanel.add(getRegexButton());
    usePanel.setAlignmentY(TOP_ALIGNMENT);

    ButtonGroup buttonGroup = new ButtonGroup();

    buttonGroup.add(getLiteralButton());
    buttonGroup.add(getWildCardsButton());
    buttonGroup.add(getRegexButton());

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getFindLabel())
                            .addComponent(getFindTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceLabel())
                            .addComponent(getReplaceTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(optionsPanel)
                            .addComponent(usePanel)))
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addComponent(getFindNextButton())
                    .addComponent(getReplaceFindButton())
                    .addComponent(getReplaceButton())
                    .addComponent(getReplaceAllButton())
                    .addComponent(getCloseButton())));

    layout.linkSize(SwingConstants.HORIZONTAL, getFindLabel(), getReplaceLabel());
    layout.linkSize(
        SwingConstants.HORIZONTAL,
        getFindNextButton(),
        getReplaceFindButton(),
        getReplaceButton(),
        getReplaceAllButton(),
        getCloseButton());

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getFindLabel())
                    .addComponent(getFindTextField())
                    .addComponent(getFindNextButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getReplaceLabel())
                    .addComponent(getReplaceTextField())
                    .addComponent(getReplaceButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(optionsPanel)
                    .addComponent(usePanel)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceFindButton())
                            .addComponent(getReplaceAllButton())
                            .addComponent(getCloseButton()))));

    pack();
    setResizable(false);
  }
  public Displayer(Player x, int num) {
    super("Player " + num + " Information");
    playernum = num;
    this.x = x;

    setSize(400, 400);
    setResizable(false);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    moneyLabel = new JLabel("Money Owned:" + x.getMoney() + "");
    jcards = new JLabel("Get out of Jail Cards Owned: " + x.getJailCards());

    propertydisplay = new JComboBox(getPropertyName());
    icon = new ImageIcon(Game.wdr + "images/tokens/monopoly_token_" + x.getToken() + ".png");
    mortgage = new JButton("Manage Mortgage");
    mortgage.addActionListener(this);
    mortgage.setActionCommand("mortgage");

    buyHouse = new JButton("Buy a House");
    buyHouse.addActionListener(this);
    buyHouse.setActionCommand("buyHouse");

    sellHouse = new JButton("Sell a House");
    sellHouse.addActionListener(this);
    sellHouse.setActionCommand("sellHouse");

    sellProperty = new JButton("Sell this Property");
    sellProperty.addActionListener(this);
    sellProperty.setActionCommand("sellProperty");

    Image img = icon.getImage();
    Image newimg = img.getScaledInstance(80, 80, java.awt.Image.SCALE_SMOOTH);
    ImageIcon newicon = new ImageIcon(newimg);
    timg = new JLabel(newicon);

    propertydisplay.addItemListener(this);

    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
    p2.setAlignmentX(Component.RIGHT_ALIGNMENT);
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    p3.setAlignmentX(Component.LEFT_ALIGNMENT);

    p2.add(timg);
    p3.add(moneyLabel);
    p3.add(jcards);

    p1.add(p2);
    p1.add(p3);

    p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
    p4.setAlignmentY(Component.CENTER_ALIGNMENT);

    p4.add(propertydisplay);
    p4.add(pr1);
    p4.add(pr2);
    p4.add(pr3);
    p4.add(pr4);
    p4.add(pr5);

    p5.setLayout(new BoxLayout(p5, BoxLayout.X_AXIS));

    p5.add(mortgage);
    p5.add(buyHouse);
    p5.add(sellHouse);

    p.add(p1);
    p.add(p4);
    p.add(p5);

    add(p);
    setVisible(true);

    timer.setActionCommand("timing");
    timer.setInitialDelay(500);
    timer.start();
  }
  /** test BarbManipulationRendererJ3D */
  public static void main(String args[]) throws VisADException, RemoteException {

    System.out.println("BMR.main()");

    // construct RealTypes for wind record components
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType windx = RealType.getRealType("windx", CommonUnit.meterPerSecond);
    RealType windy = RealType.getRealType("windy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");

    // EarthVectorType extends RealTupleType and says that its
    // components are vectors in m/s with components parallel
    // to Longitude (positive east) and Latitude (positive north)
    EarthVectorType windxy = new EarthVectorType(windx, windy);

    RealType wind_dir = RealType.getRealType("wind_dir", CommonUnit.degree);
    RealType wind_speed = RealType.getRealType("wind_speed", CommonUnit.meterPerSecond);
    RealTupleType windds = null;
    if (args.length > 0) {
      System.out.println("polar winds");
      windds =
          new RealTupleType(
              new RealType[] {wind_dir, wind_speed}, new WindPolarCoordinateSystem(windxy), null);
    }

    // construct Java3D display and mappings that govern
    // how wind records are displayed
    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap lonmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(lonmap);
    ScalarMap latmap = new ScalarMap(lat, Display.YAxis);
    display.addMap(latmap);

    FlowControl flow_control;
    if (args.length > 0) {
      ScalarMap winds_map = new ScalarMap(wind_speed, Display.Flow1Radial);
      display.addMap(winds_map);
      winds_map.setRange(0.0, 1.0); // do this for barb rendering
      ScalarMap windd_map = new ScalarMap(wind_dir, Display.Flow1Azimuth);
      display.addMap(windd_map);
      windd_map.setRange(0.0, 360.0); // do this for barb rendering
      flow_control = (FlowControl) windd_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    } else {
      ScalarMap windx_map = new ScalarMap(windx, Display.Flow1X);
      display.addMap(windx_map);
      windx_map.setRange(-1.0, 1.0); // do this for barb rendering
      ScalarMap windy_map = new ScalarMap(windy, Display.Flow1Y);
      display.addMap(windy_map);
      windy_map.setRange(-1.0, 1.0); // do this for barb rendering
      flow_control = (FlowControl) windy_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    }

    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    DataReferenceImpl[] refs = new DataReferenceImpl[N * N];
    int k = 0;
    // create an array of N by N winds
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        double u = 2.0 * i / (N - 1.0) - 1.0;
        double v = 2.0 * j / (N - 1.0) - 1.0;

        // each wind record is a Tuple (lon, lat, (windx, windy), red, green)
        // set colors by wind components, just for grins
        Tuple tuple;
        double fx = 30.0 * u;
        double fy = 30.0 * v;
        if (args.length > 0) {
          double fd = Data.RADIANS_TO_DEGREES * Math.atan2(-fx, -fy);
          double fs = Math.sqrt(fx * fx + fy * fy);
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windds, new double[] {fd, fs}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        } else {
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windxy, new double[] {fx, fy}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        }

        // construct reference for wind record
        refs[k] = new DataReferenceImpl("ref_" + k);
        refs[k].setData(tuple);

        // link wind record to display via BarbManipulationRendererJ3D
        // so user can change barb by dragging it
        // drag with right mouse button and shift to change direction
        // drag with right mouse button and no shift to change speed
        BarbManipulationRendererJ3D renderer = new BarbManipulationRendererJ3D();
        renderer.setKnotsConvert(true);
        display.addReferences(renderer, refs[k]);

        // link wind record to a CellImpl that will listen for changes
        // and print them
        WindGetterJ3D cell = new WindGetterJ3D(flow_control, refs[k]);
        cell.addReference(refs[k]);

        k++;
      }
    }

    // instead of linking the wind record "DataReferenceImpl refs" to
    // the WindGetterJ3Ds, you can have some user interface event (e.g.,
    // the user clicks on "DONE") trigger code that does a getData() on
    // all the refs and stores the records in a file.

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test BarbManipulationRendererJ3D");
    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);
  }
示例#10
0
  /**
   * run 'java FlowTest middle_latitude' to test with (lat, lon) run 'java FlowTest middle_latitude
   * x' to test with (lon, lat) adjust middle_latitude for south or north
   */
  public static void main(String args[]) throws VisADException, RemoteException {
    double mid_lat = -10.0;
    if (args.length > 0) {
      try {
        mid_lat = Double.valueOf(args[0]).doubleValue();
      } catch (NumberFormatException e) {
      }
    }
    boolean swap = (args.length > 1);
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType[] types;
    if (swap) {
      types = new RealType[] {lon, lat};
    } else {
      types = new RealType[] {lat, lon};
    }
    RealTupleType earth_location = new RealTupleType(types);
    System.out.println("earth_location = " + earth_location + " mid_lat = " + mid_lat);

    RealType flowx = RealType.getRealType("flowx", CommonUnit.meterPerSecond);
    RealType flowy = RealType.getRealType("flowy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");
    EarthVectorType flowxy = new EarthVectorType(flowx, flowy);
    TupleType range = null;

    range = new TupleType(new MathType[] {flowxy, red, green});
    FunctionType flow_field = new FunctionType(earth_location, range);

    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap xmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(xmap);
    ScalarMap ymap = new ScalarMap(lat, Display.YAxis);
    display.addMap(ymap);
    ScalarMap flowx_map = new ScalarMap(flowx, Display.Flow1X);
    display.addMap(flowx_map);
    flowx_map.setRange(-10.0, 10.0);
    ScalarMap flowy_map = new ScalarMap(flowy, Display.Flow1Y);
    display.addMap(flowy_map);
    flowy_map.setRange(-10.0, 10.0);
    FlowControl flow_control = (FlowControl) flowy_map.getControl();
    flow_control.setFlowScale(0.05f);
    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    double lonlow = -10.0;
    double lonhi = 10.0;
    double latlow = mid_lat - 10.0;
    double lathi = mid_lat + 10.0;
    Linear2DSet set;
    if (swap) {
      set = new Linear2DSet(earth_location, lonlow, lonhi, N, latlow, lathi, N);
    } else {
      set = new Linear2DSet(earth_location, latlow, lathi, N, lonlow, lonhi, N);
    }
    double[][] values = new double[4][N * N];
    int m = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int k = i;
        int l = j;
        if (swap) {
          k = j;
          l = i;
        }
        double u = (N - 1.0) / 2.0 - l;
        double v = k - (N - 1.0) / 2.0;
        // double u = 2.0 * k / (N - 1.0) - 1.0;
        // double v = 2.0 * l / (N - 1.0);
        double fx = 6.0 * u;
        double fy = 6.0 * v;
        values[0][m] = fx;
        values[1][m] = fy;
        values[2][m] = u;
        values[3][m] = v;
        m++;
      }
    }
    FlatField field = new FlatField(flow_field, set);
    field.setSamples(values);
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    ref.setData(field);
    display.addReference(ref);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test FlowTest");
    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);
  }