@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;
 }
Example #2
0
  // 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();
  }
  /**
   * 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);
  }
Example #5
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();
  }
Example #7
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);
  }