예제 #1
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
예제 #2
0
    @Override
    public String getAccessibleName() {
      String name = super.getAccessibleName();

      if (seqs.size() > 0 && seqs.get(0).size > 0) {
        String keyValueList = "";
        for (Sequence seq : seqs) {
          if (seq.isPlotted) {
            String value = "null";
            if (seq.size > 0) {
              if (unit == Unit.BYTES) {
                value = Resources.format(Messages.SIZE_BYTES, seq.value(seq.size - 1));
              } else {
                value =
                    getFormattedValue(seq.value(seq.size - 1), false)
                        + ((unit == Unit.PERCENT) ? "%" : "");
              }
            }
            // Assume format string ends with newline
            keyValueList +=
                Resources.format(Messages.PLOTTER_ACCESSIBLE_NAME_KEY_AND_VALUE, seq.key, value);
          }
        }
        name += "\n" + keyValueList + ".";
      } else {
        name += "\n" + Messages.PLOTTER_ACCESSIBLE_NAME_NO_DATA;
      }
      return name;
    }
예제 #3
0
  public void actionPerformed(ActionEvent ev) {
    if (collapsed) {
      if (label != null) {
        remove(label);
      }
      add(comp);
      moreOrLessButton.setIcon(collapseIcon);
    } else {
      remove(comp);
      if (valueLabelStr != null) {
        if (label == null) {
          label = new JLabel(Resources.format(Messages.CURRENT_VALUE, valueLabelStr));
        }
        add(label);
      }
      moreOrLessButton.setIcon(expandIcon);
    }
    collapsed = !collapsed;

    JComponent container = (JComponent) getParent();
    if (container != null && container.getLayout() instanceof VariableGridLayout) {

      ((VariableGridLayout) container.getLayout()).setFillRow(this, !collapsed);
      container.revalidate();
    }
  }
예제 #4
0
  public HelpMenu(GUIRoot gr) {
    super(Resources.get("Help"));
    guiRoot = gr;

    JMenuItem about = new JMenuItem(Resources.get("About"));
    about.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showAbout();
          }
        });

    JMenuItem how2play = new JMenuItem(Resources.get("Getting started"));
    how2play.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showHow2Play();
          }
        });

    JMenuItem showControls = new JMenuItem(Resources.get("Show game controls"));
    showControls.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showGameControls();
          }
        });

    JMenuItem modInfo = new JMenuItem(Resources.get("Modding Info"));
    modInfo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) {
              dbc.showContent(new ModInfoPanel(guiRoot));
            }
          }
        });

    add(showControls);
    add(how2play);
    add(about);
    add(modInfo);
  }
예제 #5
0
  private void saveDataToFile(File file) {
    try {
      PrintStream out = new PrintStream(new FileOutputStream(file));

      // Print header line
      out.print("Time");
      for (Sequence seq : seqs) {
        out.print("," + seq.name);
      }
      out.println();

      // Print data lines
      if (seqs.size() > 0 && seqs.get(0).size > 0) {
        for (int i = 0; i < seqs.get(0).size; i++) {
          double excelTime = toExcelTime(times.time(i));
          out.print(String.format(Locale.ENGLISH, "%.6f", excelTime));
          for (Sequence seq : seqs) {
            out.print("," + getFormattedValue(seq.value(i), false));
          }
          out.println();
        }
      }

      out.close();
      JOptionPane.showMessageDialog(
          this,
          Resources.format(
              Messages.FILE_CHOOSER_SAVED_FILE, file.getAbsolutePath(), file.length()));
    } catch (IOException ex) {
      String msg = ex.getLocalizedMessage();
      String path = file.getAbsolutePath();
      if (msg.startsWith(path)) {
        msg = msg.substring(path.length()).trim();
      }
      JOptionPane.showMessageDialog(
          this,
          Resources.format(Messages.FILE_CHOOSER_SAVE_FAILED_MESSAGE, path, msg),
          Messages.FILE_CHOOSER_SAVE_FAILED_TITLE,
          JOptionPane.ERROR_MESSAGE);
    }
  }
예제 #6
0
    @Override
    public void approveSelection() {
      File file = getSelectedFile();
      if (file != null) {
        FileFilter filter = getFileFilter();
        if (filter != null && filter instanceof FileNameExtensionFilter) {
          String[] extensions = ((FileNameExtensionFilter) filter).getExtensions();

          boolean goodExt = false;
          for (String ext : extensions) {
            if (file.getName().toLowerCase().endsWith("." + ext.toLowerCase())) {
              goodExt = true;
              break;
            }
          }
          if (!goodExt) {
            file = new File(file.getParent(), file.getName() + "." + extensions[0]);
          }
        }

        if (file.exists()) {
          String okStr = Messages.FILE_CHOOSER_FILE_EXISTS_OK_OPTION;
          String cancelStr = Messages.FILE_CHOOSER_FILE_EXISTS_CANCEL_OPTION;
          int ret =
              JOptionPane.showOptionDialog(
                  this,
                  Resources.format(Messages.FILE_CHOOSER_FILE_EXISTS_MESSAGE, file.getName()),
                  Messages.FILE_CHOOSER_FILE_EXISTS_TITLE,
                  JOptionPane.OK_CANCEL_OPTION,
                  JOptionPane.WARNING_MESSAGE,
                  null,
                  new Object[] {okStr, cancelStr},
                  okStr);
          if (ret != JOptionPane.OK_OPTION) {
            return;
          }
        }
        setSelectedFile(file);
      }
      super.approveSelection();
    }
예제 #7
0
  public AboutDialog(JConsole jConsole) {
    super(jConsole, Resources.getText("Help.AboutDialog.title"), false);

    setAccessibleDescription(this, getText("Help.AboutDialog.accessibleDescription"));
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setResizable(false);
    JComponent cp = (JComponent) getContentPane();

    createActions();

    JLabel mastheadLabel = new JLabel(mastheadIcon);
    setAccessibleName(mastheadLabel, getText("Help.AboutDialog.masthead.accessibleName"));

    JPanel mainPanel = new TPanel(0, 0);
    mainPanel.add(mastheadLabel, NORTH);

    String jConsoleVersion = Version.getVersion();
    String vmName = System.getProperty("java.vm.name");
    String vmVersion = System.getProperty("java.vm.version");
    String urlStr = getText("Help.AboutDialog.userGuideLink.url");
    if (isBrowseSupported()) {
      urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>";
    }

    JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10));
    infoAndLogoPanel.setBackground(bgColor);

    String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF);
    JEditorPane helpLink =
        new JEditorPane(
            "text/html",
            "<html><font color=#"
                + colorStr
                + ">"
                + getText("Help.AboutDialog.jConsoleVersion", jConsoleVersion)
                + "<p>"
                + getText("Help.AboutDialog.javaVersion", (vmName + ", " + vmVersion))
                + "<p>"
                + getText("Help.AboutDialog.userGuideLink", urlStr)
                + "</html>");
    helpLink.setOpaque(false);
    helpLink.setEditable(false);
    helpLink.setForeground(textColor);
    mainPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    infoAndLogoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    helpLink.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              browse(e.getDescription());
            }
          }
        });
    infoAndLogoPanel.add(helpLink, NORTH);

    ImageIcon brandLogoIcon = new ImageIcon(getClass().getResource("resources/brandlogo.png"));
    JLabel brandLogo = new JLabel(brandLogoIcon, JLabel.LEADING);

    JButton closeButton = new JButton(closeAction);

    JPanel bottomPanel = new TPanel(0, 0);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    buttonPanel.setOpaque(false);

    mainPanel.add(infoAndLogoPanel, CENTER);
    cp.add(bottomPanel, SOUTH);

    infoAndLogoPanel.add(brandLogo, SOUTH);

    buttonPanel.setBorder(new EmptyBorder(2, 12, 2, 12));
    buttonPanel.add(closeButton);
    bottomPanel.add(buttonPanel, NORTH);

    statusBar = new JLabel(" ");
    bottomPanel.add(statusBar, SOUTH);

    cp.add(mainPanel, NORTH);

    pack();
    setLocationRelativeTo(jConsole);
    Utilities.updateTransparency(this);
  }
예제 #8
0
 public void setValueLabel(String str) {
   this.valueLabelStr = str;
   if (label != null) {
     label.setText(Resources.format(Messages.CURRENT_VALUE, valueLabelStr));
   }
 }