コード例 #1
0
  public void setImage(BufferedImage image, String format) {
    ImageDocument document = imageComponent.getDocument();
    BufferedImage previousImage = document.getValue();
    document.setValue(image);
    if (image == null) return;
    document.setFormat(format);
    ImageZoomModel zoomModel = getZoomModel();
    if (previousImage == null || !zoomModel.isZoomLevelChanged()) {
      // Set smart zooming behaviour on open
      Options options = OptionsManager.getInstance().getOptions();
      ZoomOptions zoomOptions = options.getEditorOptions().getZoomOptions();
      // Open as actual size
      zoomModel.setZoomFactor(1.0d);

      if (zoomOptions.isSmartZooming()) {
        Dimension prefferedSize = zoomOptions.getPrefferedSize();
        if (prefferedSize.width > image.getWidth() && prefferedSize.height > image.getHeight()) {
          // Resize to preffered size
          // Calculate zoom factor

          double factor =
              (prefferedSize.getWidth() / (double) image.getWidth()
                      + prefferedSize.getHeight() / (double) image.getHeight())
                  / 2.0d;
          zoomModel.setZoomFactor(Math.ceil(factor));
        }
      }
    }
  }
コード例 #2
0
  public void dispose() {
    Options options = OptionsManager.getInstance().getOptions();
    options.removePropertyChangeListener(optionsChangeListener);

    imageComponent.removeMouseWheelListener(wheelAdapter);
    imageComponent.getDocument().removeChangeListener(changeListener);

    removeAll();
  }
コード例 #3
0
  /** Method to create command line parser */
  private void createCmdLineParser() {
    cmdOptions = new Options();

    // add a accession option
    cmdOptions.addOption(
        ACCESSION_CMD, true, "a list of pride experiment accessions, separated by comma");
    // add a user name option
    cmdOptions.addOption(USER_NAME_CMD, true, "pride user name");
    // add a password option
    cmdOptions.addOption(PASSWORD_CMD, true, "pride password");
    // create cmd line parser
    cmdParser = new GnuParser();
  }
コード例 #4
0
 public void mouseWheelMoved(MouseWheelEvent e) {
   Options options = OptionsManager.getInstance().getOptions();
   EditorOptions editorOptions = options.getEditorOptions();
   ZoomOptions zoomOptions = editorOptions.getZoomOptions();
   if (zoomOptions.isWheelZooming() && e.isControlDown()) {
     if (e.getWheelRotation() < 0) {
       zoomModel.zoomOut();
     } else {
       zoomModel.zoomIn();
     }
     e.consume();
   }
 }
コード例 #5
0
    public void propertyChange(PropertyChangeEvent evt) {
      Options options = (Options) evt.getSource();
      EditorOptions editorOptions = options.getEditorOptions();
      TransparencyChessboardOptions chessboardOptions =
          editorOptions.getTransparencyChessboardOptions();
      GridOptions gridOptions = editorOptions.getGridOptions();

      imageComponent.setTransparencyChessboardCellSize(chessboardOptions.getCellSize());
      imageComponent.setTransparencyChessboardWhiteColor(chessboardOptions.getWhiteColor());
      imageComponent.setTransparencyChessboardBlankColor(chessboardOptions.getBlackColor());
      imageComponent.setGridLineZoomFactor(gridOptions.getLineZoomFactor());
      imageComponent.setGridLineSpan(gridOptions.getLineSpan());
      imageComponent.setGridLineColor(gridOptions.getLineColor());
    }
コード例 #6
0
ファイル: Bomberman.java プロジェクト: sujen29/Bomberman
  // This method starts a newGame by initializing everything that is necessary before calling the
  // game() method
  public void newGame() {
    // Calls the loadMap method to load the map for the game
    loadMap();

    // Calls the createPlayers method to create the players needed for the game
    createPlayers();

    // Starts the powerup manager to make powerups
    pum.startPowerUps();

    // Makes the gamePanel the only visible panel
    gamePanel.setVisible(true);
    optionsPanel.setVisible(false);
    rulesPanel.setVisible(false);
    controlsPanel.setVisible(false);
    creditsPanel.setVisible(false);
    titlePanel.setVisible(false);

    // Resets some variables needed to play the game
    winPlayer = 5;
    deadPlayers = 0;

    // Calls the game() method to play the game
    game();
  }
コード例 #7
0
  private void parseArgs(final String[] args) throws ParseException {
    final Options options = new Options();
    options.addOption("c", "claim", false, "Use Try/Claim");
    options.addOption("", "pubChannel", true, "Primary publishing channel");
    options.addOption("", "reflectChannel", true, "Reflection channel");

    final CommandLineParser parser = new GnuParser();
    final CommandLine command = parser.parse(options, args);

    if (command.hasOption("pubChannel")) {
      pubChannel = command.getOptionValue("pubChannel", "udp://localhost:44444");
    }

    if (command.hasOption("reflectChannel")) {
      reflectChannel = command.getOptionValue("reflectChannel", "udp://localhost:55555");
    }
  }
コード例 #8
0
ファイル: Bomberman.java プロジェクト: sujen29/Bomberman
 // This method makes only the credits panel visible
 public void credits() {
   // Makes only the creditsPanel visible
   gamePanel.setVisible(false);
   optionsPanel.setVisible(false);
   rulesPanel.setVisible(false);
   controlsPanel.setVisible(false);
   creditsPanel.setVisible(true);
   titlePanel.setVisible(false);
 }
コード例 #9
0
  public ExecuteVisualizer() {
    // Set textarea properties
    jtaInstructions.setWrapStyleWord(true);
    jtaInstructions.setLineWrap(true);
    jtaInstructions.setEditable(false);

    // Set ExecuteVisualizer frame layout and add components to the frame
    setLayout(new BorderLayout(5, 10));
    add(jtaInstructions, BorderLayout.CENTER);
    add(jbtStart, BorderLayout.SOUTH);

    // Set Options frame attributes
    optionsFrame.setSize(250, 350);
    optionsFrame.setTitle("Options");
    optionsFrame.setResizable(false);
    optionsFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set VisualizerFrame attributes
    vFrame.setSize(800, 475);
    vFrame.setTitle("Beats visualized");
    vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    vFrame.setLocationRelativeTo(null);

    // Set colorChoose frame attributes
    colorChooser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ColorChooser newContentPane = new ColorChooser();
    newContentPane.setOpaque(true); // content panes must be opaque
    colorChooser.setContentPane(newContentPane);
    colorChooser.setResizable(false);

    // Add listener to button which will open Options, VisualizerFrame
    // and colorChoose frame, and close the current frame
    jbtStart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            optionsFrame.setVisible(true);
            vFrame.setVisible(true);
            colorChooser.pack();
            colorChooser.setVisible(true);
            dispose();
          }
        });
  }
コード例 #10
0
ファイル: DialogExport.java プロジェクト: fpapai/basex
  @Override
  public void action(final Object comp) {
    final String pth = path();
    final IOFile io = new IOFile(pth);
    String inf = io.isDir() && io.children().length > 0 ? DIR_NOT_EMPTY : null;
    ok = !pth.isEmpty();

    final SerialMethod mth = SerialMethod.valueOf(method.getSelectedItem());
    final OptionsOption<? extends Options> opts =
        mth == SerialMethod.JSON
            ? SerializerOptions.JSON
            : mth == SerialMethod.CSV ? SerializerOptions.CSV : null;
    final boolean showmparams = opts != null;
    mparams.setEnabled(showmparams);

    if (ok) {
      gui.gopts.set(GUIOptions.INPUTPATH, pth);
      try {
        if (comp == method) {
          if (showmparams) {
            final Options mopts = options(null).get(opts);
            mparams.setToolTipText(tooltip(mopts));
            mparams.setText(mopts.toString());
          } else {
            mparams.setToolTipText(null);
            mparams.setText("");
          }
        }
        Serializer.get(new ArrayOutput(), options(mth));
      } catch (final IOException ex) {
        ok = false;
        inf = ex.getMessage();
      }
    }

    info.setText(inf, ok ? Msg.WARN : Msg.ERROR);
    enableOK(buttons, B_OK, ok);
  }
コード例 #11
0
ファイル: Bomberman.java プロジェクト: sujen29/Bomberman
  // The constructor which sets up all the JFrame, Canvas, JPanels, and sets the buffer strategy.
  public Bomberman() {
    // makes the Canvas visible
    setVisible(true);

    // Creates window and sets it up
    window = new JFrame("BOMBERMAN");
    window.setBounds(0, 0, WIDTH, HEIGHT);
    window.setResizable(false);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.addKeyListener(this);
    setBounds(0, 0, WIDTH, HEIGHT);
    window.getContentPane().setLayout(new CardLayout());

    // Creates the menu bar
    window.setJMenuBar(new Menu());

    // Creates an option panel that has all the options
    optionsPanel = new Options();
    window.getContentPane().add(optionsPanel, "OptionsPanel");

    // Creates a title panel which is the title screen
    titlePanel = new JPanel();
    titlePanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    titlePanel.setLayout(new GridLayout(1, 1));
    titlePanel.add(
        new JLabel(new ImageIcon(getClass().getClassLoader().getResource("titleScreen.png"))));
    window.getContentPane().add(titlePanel, "TitlePanel");

    // Creates and sets up the game panel where the game is played on
    gamePanel = new JPanel();
    gamePanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    gamePanel.setLayout(null);
    gamePanel.add(this);
    window.getContentPane().add(gamePanel, "GamePanel");

    // Creates a rules screen panel which is the rules screen
    rulesPanel = new JPanel();
    rulesPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    rulesPanel.setLayout(new GridLayout(1, 1));
    rulesPanel.add(new JLabel(new ImageIcon(getClass().getClassLoader().getResource("rules.png"))));
    window.getContentPane().add(rulesPanel, "RulesPanel");

    // Creates a controls screen panel which is the controls screen
    controlsPanel = new JPanel();
    controlsPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    controlsPanel.setLayout(new GridLayout(1, 1));
    controlsPanel.add(
        new JLabel(new ImageIcon(getClass().getClassLoader().getResource("controls.png"))));
    window.getContentPane().add(controlsPanel, "ControlsPanel");

    // Creates a controls screen panel which is the controls screen
    creditsPanel = new JPanel();
    creditsPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    creditsPanel.setLayout(new GridLayout(1, 1));
    creditsPanel.add(
        new JLabel(new ImageIcon(getClass().getClassLoader().getResource("credits.png"))));
    window.getContentPane().add(creditsPanel, "CreditsPanel");

    // Makes certain panels visible/invisible
    gamePanel.setVisible(false);
    optionsPanel.setVisible(false);
    rulesPanel.setVisible(false);
    controlsPanel.setVisible(false);
    creditsPanel.setVisible(false);
    titlePanel.setVisible(true);
    window.setVisible(true);

    // double buffering
    createBufferStrategy(2);
    bs = getBufferStrategy();
  }
コード例 #12
0
  /**
   * Create a new FeatureListFrame component. The constructor does not call setVisible (true).
   *
   * @param title The title to use for the new JFrame.
   * @param feature_list The FeatureList to show.
   * @param selection The Selection that the commands in the menus will operate on.
   * @param entry_group The EntryGroup object where new features/entries will be added.
   * @param goto_event_source The object that the menu item will call makeBaseVisible() on.
   */
  public FeatureListFrame(
      final String title,
      final Selection selection,
      final GotoEventSource goto_event_source,
      final EntryGroup entry_group,
      final BasePlotGroup base_plot_group) {
    super(title);

    this.entry_group = entry_group;

    feature_list = new FeatureList(entry_group, selection, goto_event_source, base_plot_group);

    final Font default_font = Options.getOptions().getFont();
    setFont(default_font);

    final JMenuBar menu_bar = new JMenuBar();
    menu_bar.setFont(default_font);
    setJMenuBar(menu_bar);

    final JMenu file_menu = new JMenu("File");
    final JMenuItem close = new JMenuItem("Close");
    close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            setVisible(false);
            FeatureListFrame.this.dispose();
            feature_list.stopListening();
          }
        });

    file_menu.add(close);
    menu_bar.add(file_menu);

    final JMenu select_menu =
        new SelectMenu(this, selection, goto_event_source, entry_group, base_plot_group);
    menu_bar.add(select_menu);

    final JMenu view_menu =
        new ViewMenu(this, selection, goto_event_source, entry_group, base_plot_group);
    menu_bar.add(view_menu);

    final JMenu goto_menu = new GotoMenu(this, selection, goto_event_source, entry_group);
    menu_bar.add(goto_menu);

    if (Options.readWritePossible()) {
      final JMenu edit_menu =
          new EditMenu(this, selection, goto_event_source, entry_group, base_plot_group, null);
      menu_bar.add(edit_menu);

      final JMenu write_menu = new WriteMenu(this, selection, entry_group);
      menu_bar.add(write_menu);

      final JMenu run_menu = new RunMenu(this, selection);
      menu_bar.add(run_menu);
    }

    final JScrollPane jsp_feature_list = new JScrollPane(feature_list);
    getContentPane().add(jsp_feature_list, "Center");

    final JPanel panel = new JPanel();

    final JButton close_button = new JButton("Close");

    panel.add(close_button);
    close_button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
            FeatureListFrame.this.dispose();
            feature_list.stopListening();
          }
        });

    getContentPane().add(panel, "South");
    pack();

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            setVisible(false);
            entry_group.removeEntryGroupChangeListener(FeatureListFrame.this);
            FeatureListFrame.this.dispose();
            feature_list.stopListening();
          }
        });

    entry_group.addEntryGroupChangeListener(this);

    final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

    int screen_height = screen.height;
    int screen_width = screen.width;

    if (screen_width <= 700 || screen_height <= 400)
      setSize(screen_width * 9 / 10, screen_height * 9 / 10);
    else setSize(700, 400);

    final int hgt = entry_group.getAllFeaturesCount() * feature_list.getLineHeight();
    feature_list.setPreferredSize(new Dimension(getSize().width * 4, hgt));
    jsp_feature_list.getVerticalScrollBar().setUnitIncrement(feature_list.getLineHeight());

    setLocation(
        new Point((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2));
  }
コード例 #13
0
ファイル: BaseXSlider.java プロジェクト: dirkk/basex
 /**
  * Checkbox.
  *
  * @param mn min value
  * @param mx max value
  * @param opt option
  * @param opts options
  * @param win parent window
  */
 public BaseXSlider(
     final int mn, final int mx, final NumberOption opt, final Options opts, final Window win) {
   this(mn, mx, opts.get(opt), win);
   options = opts;
   option = opt;
 }
コード例 #14
0
ファイル: BaseXSlider.java プロジェクト: dirkk/basex
 /** Assigns the current checkbox value to the option specified in the constructor. */
 public void assign() {
   options.set(option, value);
 }
コード例 #15
0
  ImageEditorUI(@Nullable ImageEditor editor) {
    this.editor = editor;

    Options options = OptionsManager.getInstance().getOptions();
    EditorOptions editorOptions = options.getEditorOptions();
    options.addPropertyChangeListener(optionsChangeListener);

    final PsiActionSupportFactory factory = PsiActionSupportFactory.getInstance();
    if (factory != null && editor != null) {
      copyPasteSupport =
          factory.createPsiBasedCopyPasteSupport(
              editor.getProject(),
              this,
              new PsiActionSupportFactory.PsiElementSelector() {
                public PsiElement[] getSelectedElements() {
                  PsiElement[] data = LangDataKeys.PSI_ELEMENT_ARRAY.getData(ImageEditorUI.this);
                  return data == null ? PsiElement.EMPTY_ARRAY : data;
                }
              });
    } else {
      copyPasteSupport = null;
    }

    deleteProvider = factory == null ? null : factory.createPsiBasedDeleteProvider();

    ImageDocument document = imageComponent.getDocument();
    document.addChangeListener(changeListener);

    // Set options
    TransparencyChessboardOptions chessboardOptions =
        editorOptions.getTransparencyChessboardOptions();
    GridOptions gridOptions = editorOptions.getGridOptions();
    imageComponent.setTransparencyChessboardCellSize(chessboardOptions.getCellSize());
    imageComponent.setTransparencyChessboardWhiteColor(chessboardOptions.getWhiteColor());
    imageComponent.setTransparencyChessboardBlankColor(chessboardOptions.getBlackColor());
    imageComponent.setGridLineZoomFactor(gridOptions.getLineZoomFactor());
    imageComponent.setGridLineSpan(gridOptions.getLineSpan());
    imageComponent.setGridLineColor(gridOptions.getLineColor());

    // Create layout
    ImageContainerPane view = new ImageContainerPane(imageComponent);
    view.addMouseListener(new EditorMouseAdapter());
    view.addMouseListener(new FocusRequester());

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(view);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Zoom by wheel listener
    scrollPane.addMouseWheelListener(wheelAdapter);

    // Construct UI
    setLayout(new BorderLayout());

    ActionManager actionManager = ActionManager.getInstance();
    ActionGroup actionGroup =
        (ActionGroup) actionManager.getAction(ImageEditorActions.GROUP_TOOLBAR);
    ActionToolbar actionToolbar =
        actionManager.createActionToolbar(ImageEditorActions.ACTION_PLACE, actionGroup, true);

    // Make sure toolbar is 'ready' before it's added to component hierarchy
    // to prevent ActionToolbarImpl.updateActionsImpl(boolean, boolean) from increasing popup size
    // unnecessarily
    actionToolbar.updateActionsImmediately();

    actionToolbar.setTargetComponent(this);

    JComponent toolbarPanel = actionToolbar.getComponent();
    toolbarPanel.addMouseListener(new FocusRequester());

    JLabel errorLabel =
        new JLabel(
            ImagesBundle.message("error.broken.image.file.format"),
            Messages.getErrorIcon(),
            SwingConstants.CENTER);

    JPanel errorPanel = new JPanel(new BorderLayout());
    errorPanel.add(errorLabel, BorderLayout.CENTER);

    contentPanel = new JPanel(new CardLayout());
    contentPanel.add(scrollPane, IMAGE_PANEL);
    contentPanel.add(errorPanel, ERROR_PANEL);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(toolbarPanel, BorderLayout.WEST);
    infoLabel = new JLabel((String) null, SwingConstants.RIGHT);
    infoLabel.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 2));
    topPanel.add(infoLabel, BorderLayout.EAST);

    add(topPanel, BorderLayout.NORTH);
    add(contentPanel, BorderLayout.CENTER);

    updateInfo();
  }