예제 #1
0
  public ColorMapVisualization(MRAPanel panel, String defaultEntity, String fieldToPlot) {
    this.logSource = panel.getSource();
    this.curEntity = defaultEntity;
    setLayout(new MigLayout());

    // Parse field to plot
    String part[] = fieldToPlot.split("\\.");
    messageName = part[0];
    varName = part[1];

    // Initialize entityList with the ALL shorthand
    entityList.add("ALL");

    // Misc setups and interface build
    redrawButton.addActionListener(this);
    entCombo.setModel(new DefaultComboBoxModel<String>(entityList));

    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(cmapMinValue);
    toolbar.add(cmapMaxValue);
    toolbar.add(cmapCombo);
    toolbar.add(entCombo);
    toolbar.add(redrawButton);
    toolbar.add(savePng);
    toolbar.add(savePdf);

    add(toolbar, "w 100%, wrap");
    add(container, "w 100%, h 100%");

    cmapCombo.setSelectedItem(ColorMapFactory.createJetColorMap());
    cmapCombo.setRenderer(new ColorMapListRenderer());

    revalidate();
  }
예제 #2
0
  @Override
  public void mouseClicked(MouseEvent e) {
    TreePath[] path = tree.getSelectionPaths();
    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
      if (path == null) return;
      if (path.length == 1 && path[0].getPath().length == 2) {
        final String fileToOpen = path[0].getPath()[1].toString();
        IMraLog log = source.getLog(fileToOpen);
        panel.loadVisualization(new LogTableVisualization(log, panel), true);
      }
    }
    if (e.getButton() == MouseEvent.BUTTON3) {
      if (path == null) return;

      if (path.length == 1 && path[0].getPath().length == 2) {
        final String fileToOpen = path[0].getPath()[1].toString();
        JPopupMenu popup = new JPopupMenu();

        String text = I18n.textf("Show %log data", fileToOpen);

        popup
            .add(text)
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent e) {
                    IMraLog log = source.getLog(fileToOpen);
                    panel.loadVisualization(new LogTableVisualization(log, panel), true);
                  }
                });

        popup.show(tree, e.getX(), e.getY());
        return;
      }

      final Vector<String> fieldsToPlot = new Vector<String>();
      int count = 0;

      for (int i = 0; i < path.length; i++) {
        if (path[i].getPath().length == 3) {
          count++;
          String message = path[i].getPath()[1].toString();
          String field = path[i].getPath()[2].toString();

          fieldsToPlot.add(message + "." + field);
        }
      }

      if (count == 0) return;

      JPopupMenu popup = new JPopupMenu();

      popup
          .add(I18n.text("Plot data"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                  panel.loadVisualization(
                      new GenericPlot(fieldsToPlot.toArray(new String[0]), panel), true);
                }
              });

      popup
          .add(I18n.text("Timeline Plot"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {
                  panel.loadVisualization(
                      new ReplayPlot(panel, fieldsToPlot.toArray(new String[0])), true);
                }
              });

      popup
          .add(I18n.text("Plot data on new window"))
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent e) {

                  LLFChart chart = new GenericPlot(fieldsToPlot.toArray(new String[0]), panel);
                  MRAChartPanel fcp = new MRAChartPanel(chart, source, panel);
                  JDialog dialog = new JDialog(ConfigFetch.getSuperParentAsFrame());
                  dialog.setTitle("[MRA] " + chart.getName());
                  dialog.setIconImage(ImageUtils.getScaledImage("images/menus/graph.png", 16, 16));
                  dialog.add(fcp);
                  dialog.setSize(640, 480);
                  dialog.setResizable(true);
                  dialog.setVisible(true);
                  fcp.regeneratePanel();
                }
              });
      if (count == 1) {
        popup
            .add(I18n.text("Plot ColorMap"))
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent e) {
                    NeptusLog.pub().info("<###> " + fieldsToPlot);
                    panel.loadVisualization(
                        new ColorMapVisualization(panel, "ALL", fieldsToPlot.get(0)), true);
                  }
                });
      }
      popup.show(tree, e.getX(), e.getY());
    }
  }
예제 #3
0
 public LsfTreeMouseAdapter(MRAPanel mraPanel) {
   panel = mraPanel;
   tree = panel.getTree();
   source = panel.getSource();
 }