Ejemplo n.º 1
0
  private JPanel createChartPanel(XYDataset dataset, TimeInterval ti) {
    JPanel ret = new JPanel();
    BoxLayout retLayout = new BoxLayout(ret, javax.swing.BoxLayout.Y_AXIS);
    ret.setLayout(retLayout);
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            null, // title
            "Delay, seconds",
            "Correlation",
            dataset, // dataset
            PlotOrientation.VERTICAL, // orientation
            true, // legend
            true, // tooltips
            false // include URLs
            );

    TextTitle title =
        new TextTitle(
            "Start time: "
                + TimeInterval.formatDate(
                    ti.getStartTime(), TimeInterval.DateFormatType.DATE_FORMAT_NORMAL)
                + ", Duration: "
                + ti.convert(),
            ret.getFont());
    chart.setTitle(title);
    plot = (XYPlot) chart.getPlot();
    cp = new TraceViewChartPanel(chart, true);
    ret.add(cp);
    ret.add(getOptionP());
    return ret;
  }
Ejemplo n.º 2
0
 protected void buildLine(ConnectionConfig conn, JLabel cs, JPanel pane) {
   if (conn.name().equals(JmrixConfigPane.NONE)) {
     cs.setText(" ");
     return;
   }
   ConnectionStatus.instance().addConnection(conn.name(), conn.getInfo());
   cs.setFont(pane.getFont());
   updateLine(conn, cs);
   pane.add(cs);
 }
  /** Creates the North JPanel with all the pixel location and color information */
  private void createInfoPanel() {
    // create the info panel and set the layout
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());

    // create the font
    Font largerFont = new Font(infoPanel.getFont().getName(), infoPanel.getFont().getStyle(), 14);

    // create the pixel location panel
    JPanel locationPanel = createLocationPanel(largerFont);

    // create the color information panel
    JPanel colorInfoPanel = createColorInfoPanel(largerFont);

    // add the panels to the info panel
    infoPanel.add(BorderLayout.NORTH, locationPanel);
    infoPanel.add(BorderLayout.SOUTH, colorInfoPanel);

    // add the info panel
    pictureFrame.getContentPane().add(BorderLayout.NORTH, infoPanel);
  }
  public TabbedEditor(org.colos.ejs.osejs.Osejs _ejs, String _type, String _header) {
    ejs = _ejs;
    defaultType = _type;
    defaultHeader = _header;
    defaultString = new String(res.getString(defaultHeader + ".Page"));

    MyActionListener al = new MyActionListener();

    popupMenu = new PopupMenu();
    customMenuItems(al); // Creates the top menu items
    // common menu items
    copyPage = createMenuItem("copyPage", defaultHeader, al);
    upPage = createMenuItem("upPage", defaultHeader, al);
    dnPage = createMenuItem("dnPage", defaultHeader, al);
    renamePage = createMenuItem("renamePage", defaultHeader, al);
    popupMenu.addSeparator();
    togglePage = createMenuItem("togglePage", defaultHeader, al);
    removePage = createMenuItem("removePage", defaultHeader, al);

    JPanel firstPanel = createFirstPanel();

    tabbedPanel = new JTabbedPane();
    tabbedPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    tabbedPanel.add(popupMenu);
    // tabbedPanel.setPreferredSize (res.getDimension("TabbedEditor.PreferredSize"));
    tabbedPanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mousePressed(java.awt.event.MouseEvent evt) {
            if (OSPRuntime.isPopupTrigger(evt)) // SwingUtilities.isRightMouseButton(evt))
            showMenu(evt.getComponent(), evt.getX(), evt.getY());
          }
        });
    cardLayout = new CardLayout();
    finalPanel = new JPanel(cardLayout);
    finalPanel.add(tabbedPanel, "TabbedPanel");
    finalPanel.add(firstPanel, "FirstPanel");
    setFont(finalPanel.getFont());

    Font font = InterfaceUtils.font(null, res.getString("Editor.TitleFont"));
    addPageMI.setFont(font);
    copyPage.setFont(font);
    upPage.setFont(font);
    dnPage.setFont(font);
    togglePage.setFont(font);
    removePage.setFont(font);
    renamePage.setFont(font);
    myFont = font.deriveFont(Font.PLAIN);
    showFirstPage();
  }
Ejemplo n.º 5
0
 private static int getPanelBaseline(JPanel panel, int height) {
   Border border = panel.getBorder();
   if (border instanceof TitledBorder) {
     TitledBorder titledBorder = (TitledBorder) border;
     if (titledBorder.getTitle() != null && !"".equals(titledBorder.getTitle())) {
       Font font = titledBorder.getTitleFont();
       if (font == null) {
         font = panel.getFont();
         if (font == null) {
           font = new Font("Dialog", Font.PLAIN, 12);
         }
       }
       Border border2 = titledBorder.getBorder();
       Insets borderInsets;
       if (border2 != null) {
         borderInsets = border2.getBorderInsets(panel);
       } else {
         borderInsets = EMPTY_INSETS;
       }
       FontMetrics fm = panel.getFontMetrics(font);
       int fontHeight = fm.getHeight();
       int descent = fm.getDescent();
       int ascent = fm.getAscent();
       int y = EDGE_SPACING;
       int h = height - EDGE_SPACING * 2;
       int diff;
       switch (((TitledBorder) border).getTitlePosition()) {
         case TitledBorder.ABOVE_TOP:
           diff = ascent + descent + (Math.max(EDGE_SPACING, TEXT_SPACING * 2) - EDGE_SPACING);
           return y + diff - (descent + TEXT_SPACING);
         case TitledBorder.TOP:
         case TitledBorder.DEFAULT_POSITION:
           diff = Math.max(0, ((ascent / 2) + TEXT_SPACING) - EDGE_SPACING);
           return (y + diff - descent) + (borderInsets.top + ascent + descent) / 2;
         case TitledBorder.BELOW_TOP:
           return y + borderInsets.top + ascent + TEXT_SPACING;
         case TitledBorder.ABOVE_BOTTOM:
           return (y + h) - (borderInsets.bottom + descent + TEXT_SPACING);
         case TitledBorder.BOTTOM:
           h -= fontHeight / 2;
           return ((y + h) - descent) + ((ascent + descent) - borderInsets.bottom) / 2;
         case TitledBorder.BELOW_BOTTOM:
           h -= fontHeight;
           return y + h + ascent + TEXT_SPACING;
       }
     }
   }
   return -1;
 }
Ejemplo n.º 6
0
 private JPanel createChartPanel(XYDataset dataset) {
   JPanel ret = new JPanel();
   BoxLayout retLayout = new BoxLayout(ret, javax.swing.BoxLayout.Y_AXIS);
   ret.setLayout(retLayout);
   JFreeChart chart =
       ChartFactory.createXYLineChart(
           null, // title
           "Period, s", // x-axis label
           "Coherence", // y-axis label
           dataset, // data
           PlotOrientation.VERTICAL, // orientation
           true, // create legend?
           true, // generate tooltips?
           false // generate URLs?
           );
   chart.setBackgroundPaint(Color.white);
   TextTitle title =
       new TextTitle(
           "Start time: "
               + TimeInterval.formatDate(
                   timeInterval.getStartTime(), TimeInterval.DateFormatType.DATE_FORMAT_NORMAL)
               + ", Duration: "
               + timeInterval.convert(),
           ret.getFont());
   chart.setTitle(title);
   plot = chart.getXYPlot();
   NumberAxis domainAxis = new LogarithmicAxis("Period, s");
   plot.setDomainAxis(domainAxis);
   NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
   rangeAxis.setLowerBound(0);
   rangeAxis.setUpperBound(1);
   rangeAxis.setAutoRangeIncludesZero(true);
   plot.setBackgroundPaint(Color.lightGray);
   plot.setDomainGridlinePaint(Color.white);
   plot.setRangeGridlinePaint(Color.white);
   plot.setDomainCrosshairVisible(true);
   plot.setRangeCrosshairVisible(true);
   chartPanel = new TraceViewChartPanel(chart, true);
   ret.add(chartPanel);
   ret.add(getOptionP());
   return ret;
 }
Ejemplo n.º 7
0
  @SuppressWarnings("serial")
  public JTableRenderer(final Object cell, final mxGraphComponent graphContainer) {
    this.cell = cell;
    this.graphContainer = graphContainer;
    this.graph = graphContainer.getGraph();
    setLayout(new BorderLayout());
    setBorder(
        BorderFactory.createCompoundBorder(
            ShadowBorder.getSharedInstance(), BorderFactory.createBevelBorder(BevelBorder.RAISED)));

    JPanel title = new JPanel();
    title.setBackground(new Color(149, 173, 239));
    title.setOpaque(true);
    title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));
    title.setLayout(new BorderLayout());

    JLabel icon =
        new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "preferences.gif")));
    icon.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 1));
    title.add(icon, BorderLayout.WEST);

    JLabel label = new JLabel(String.valueOf(graph.getLabel(cell)));
    label.setForeground(Color.WHITE);
    label.setFont(title.getFont().deriveFont(Font.BOLD, 11));
    label.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 2));
    title.add(label, BorderLayout.CENTER);

    JPanel toolBar2 = new JPanel();
    toolBar2.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 2));
    toolBar2.setOpaque(false);
    JButton button =
        new JButton(
            new AbstractAction(
                "", new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "minimize.gif"))) {

              public void actionPerformed(ActionEvent e) {
                graph.foldCells(graph.isCellCollapsed(cell), false, new Object[] {cell});
                ((JButton) e.getSource())
                    .setIcon(
                        new ImageIcon(
                            JTableRenderer.class.getResource(
                                IMAGE_PATH
                                    + ((graph.isCellCollapsed(cell))
                                        ? "maximize.gif"
                                        : "minimize.gif"))));
              }
            });
    button.setPreferredSize(new Dimension(16, 16));
    button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    button.setToolTipText("Collapse/Expand");
    button.setOpaque(false);
    toolBar2.add(button);

    title.add(toolBar2, BorderLayout.EAST);
    add(title, BorderLayout.NORTH);

    // CellStyle style =
    // graph.getStylesheet().getCellStyle(graph.getModel(),
    // cell);
    // if (style.getStyleClass() == null) {
    table = new MyTable();
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    if (graph.getModel().getChildCount(cell) == 0) {
      scrollPane.getViewport().setBackground(Color.WHITE);
      setOpaque(true);
      add(scrollPane, BorderLayout.CENTER);
    }

    scrollPane
        .getVerticalScrollBar()
        .addAdjustmentListener(
            new AdjustmentListener() {

              public void adjustmentValueChanged(AdjustmentEvent e) {
                graphContainer.refresh();
              }
            });

    label = new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "resize.gif")));
    label.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(label, BorderLayout.EAST);

    add(panel, BorderLayout.SOUTH);

    ResizeHandler resizeHandler = new ResizeHandler();
    label.addMouseListener(resizeHandler);
    label.addMouseMotionListener(resizeHandler);

    setMinimumSize(new Dimension(20, 30));
  }
Ejemplo n.º 8
0
  public CopiesPanel(final Project project) {
    myProject = project;
    myConnection = myProject.getMessageBus().connect(myProject);
    myVcs = SvnVcs.getInstance(myProject);
    myCurrentInfoList = null;

    final Runnable focus =
        new Runnable() {
          public void run() {
            IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
          }
        };
    final Runnable refreshView =
        new Runnable() {
          public void run() {
            final List<WCInfo> infoList = myVcs.getAllWcInfos();
            if (myCurrentInfoList != null) {
              final List<OverrideEqualsWrapper<WCInfo>> newList =
                  ObjectsConvertor.convert(
                      infoList,
                      new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
                        public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
                          return new OverrideEqualsWrapper<WCInfo>(
                              InfoEqualityPolicy.getInstance(), o);
                        }
                      },
                      ObjectsConvertor.NOT_NULL);

              if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
                myRefreshLabel.setEnabled(true);
                return;
              }
              myCurrentInfoList = newList;
            }
            Collections.sort(infoList, WCComparator.getInstance());
            updateList(infoList);
            myRefreshLabel.setEnabled(true);
            SwingUtilities.invokeLater(focus);
          }
        };
    myConnection.subscribe(
        SvnVcs.ROOTS_RELOADED,
        new Runnable() {
          public void run() {
            ApplicationManager.getApplication().invokeLater(refreshView, ModalityState.NON_MODAL);
          }
        });

    final JPanel holderPanel = new JPanel(new BorderLayout());
    FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont());
    myTextHeight = (int) (fm.getHeight() * 1.3);
    myPanel = new JPanel(new GridBagLayout());
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(myPanel, BorderLayout.NORTH);
    holderPanel.add(panel, BorderLayout.WEST);
    myRefreshLabel =
        new MyLinkLabel(
            myTextHeight,
            "Refresh",
            new LinkListener() {
              public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (myRefreshLabel.isEnabled()) {
                  myVcs.invokeRefreshSvnRoots(true);
                  myRefreshLabel.setEnabled(false);
                }
              }
            });
    myHolder = ScrollPaneFactory.createScrollPane(holderPanel);
    myHolder.setBorder(null);
    setFocusableForLinks(myRefreshLabel);
    refreshView.run();
    initView();
  }
  public CopiesPanel(final Project project) {
    myProject = project;
    myConnection = myProject.getMessageBus().connect(myProject);
    myVcs = SvnVcs.getInstance(myProject);
    myCurrentInfoList = null;

    final Runnable focus =
        new Runnable() {
          @Override
          public void run() {
            IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
          }
        };
    final Runnable refreshView =
        new Runnable() {
          @Override
          public void run() {
            final List<WCInfo> infoList = myVcs.getWcInfosWithErrors();
            final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty();
            final List<WorkingCopyFormat> supportedFormats = getSupportedFormats();
            Runnable runnable =
                new Runnable() {
                  @Override
                  public void run() {
                    if (myCurrentInfoList != null) {
                      final List<OverrideEqualsWrapper<WCInfo>> newList =
                          ObjectsConvertor.convert(
                              infoList,
                              new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
                                @Override
                                public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
                                  return new OverrideEqualsWrapper<WCInfo>(
                                      InfoEqualityPolicy.getInstance(), o);
                                }
                              },
                              ObjectsConvertor.NOT_NULL);

                      if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
                        myRefreshLabel.setEnabled(true);
                        return;
                      }
                      myCurrentInfoList = newList;
                    }
                    Collections.sort(infoList, WCComparator.getInstance());
                    updateList(infoList, supportedFormats);
                    myRefreshLabel.setEnabled(true);
                    showErrorNotification(hasErrors);
                    SwingUtilities.invokeLater(focus);
                  }
                };
            ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
          }
        };
    final Consumer<Boolean> refreshOnPooled =
        new Consumer<Boolean>() {
          @Override
          public void consume(Boolean somethingNew) {
            if (Boolean.TRUE.equals(somethingNew)) {
              if (ApplicationManager.getApplication().isUnitTestMode()) {
                refreshView.run();
              } else {
                ApplicationManager.getApplication().executeOnPooledThread(refreshView);
              }
            } else {
              ApplicationManager.getApplication()
                  .invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          myRefreshLabel.setEnabled(true);
                        }
                      },
                      ModalityState.NON_MODAL);
            }
          }
        };
    myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled);

    final JPanel holderPanel = new JPanel(new BorderLayout());
    FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont());
    myTextHeight = (int) (fm.getHeight() * 1.3);
    myPanel = new JPanel(new GridBagLayout());
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(myPanel, BorderLayout.NORTH);
    holderPanel.add(panel, BorderLayout.WEST);
    myRefreshLabel =
        new MyLinkLabel(
            myTextHeight,
            "Refresh",
            new LinkListener() {
              @Override
              public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (myRefreshLabel.isEnabled()) {
                  myVcs.invokeRefreshSvnRoots();
                  myRefreshLabel.setEnabled(false);
                }
              }
            });
    final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel);
    myHolder = pane;
    final JScrollBar vBar = pane.getVerticalScrollBar();
    vBar.setBlockIncrement(vBar.getBlockIncrement() * 5);
    vBar.setUnitIncrement(vBar.getUnitIncrement() * 5);
    myHolder.setBorder(null);
    setFocusableForLinks(myRefreshLabel);
    refreshOnPooled.consume(true);
    initView();
  }