Beispiel #1
0
 public void actionPerformed(ActionEvent e) {
   if (!datapanel.isInitialized()) {
     return;
   }
   datapanel.refreshData();
   panel.setDisplayPlot(true);
   panel.update(panel.getGraphics());
   frame.setSize(700, 600);
   frame.setVisible(true);
   frame.pack();
 }
  @Override
  public void valueChanged(@Nullable ListSelectionEvent notUsed) {
    if (notUsed != null && notUsed.getValueIsAdjusting()) return;

    VcsFullCommitDetails newCommitDetails = null;

    int[] rows = myGraphTable.getSelectedRows();
    if (rows.length < 1) {
      showMessage("No commits selected");
    } else if (rows.length > 1) {
      showMessage("Several commits selected");
    } else {
      ((CardLayout) getLayout()).show(this, STANDARD_LAYER);
      int row = rows[0];
      GraphTableModel tableModel = (GraphTableModel) myGraphTable.getModel();
      VcsFullCommitDetails commitData =
          myLogDataHolder.getCommitDetailsGetter().getCommitData(row, tableModel);
      if (commitData == null) {
        showMessage("No commits selected");
        return;
      }
      if (commitData instanceof LoadingDetails) {
        myLoadingPanel.startLoading();
        myCommitDetailsPanel.setData(null);
        myReferencesPanel.setReferences(Collections.<VcsRef>emptyList());
        updateDetailsBorder(null);
      } else {
        myLoadingPanel.stopLoading();
        myCommitDetailsPanel.setData(commitData);
        myReferencesPanel.setReferences(sortRefs(commitData.getId(), commitData.getRoot()));
        updateDetailsBorder(commitData);
        newCommitDetails = commitData;
      }

      List<String> branches = null;
      if (!(commitData instanceof LoadingDetails)) {
        branches =
            myLogDataHolder
                .getContainingBranchesGetter()
                .requestContainingBranches(commitData.getRoot(), commitData.getId());
      }
      myCommitDetailsPanel.setBranches(branches);

      if (!Comparing.equal(myCurrentCommitDetails, newCommitDetails)) {
        myCurrentCommitDetails = newCommitDetails;
        myScrollPane.getVerticalScrollBar().setValue(0);
      }
    }
  }
  /**
   * Paint to an offscreen graphic, e.g. a graphic for an image or svg file.
   *
   * @param g
   * @param rect
   */
  public void paintOffscreen(Graphics2D g, Rectangle rect) {

    // Get the components of the sort by X position.
    Component[] components = getComponents();
    Arrays.sort(
        components,
        new Comparator<Component>() {
          public int compare(Component component, Component component1) {
            return component.getX() - component1.getX();
          }
        });

    for (Component c : this.getComponents()) {

      if (c instanceof DataPanel) {
        Graphics2D g2d = (Graphics2D) g.create();
        Rectangle clipRect = new Rectangle(c.getBounds());
        clipRect.height = rect.height;
        g2d.setClip(clipRect);
        g2d.translate(c.getX(), 0);
        ((DataPanel) c).paintOffscreen(g2d, rect);
      }
    }
    // super.paintBorder(g);
  }
 public void setCurrentTool(RegionOfInterestTool regionOfInterestTool) {
   for (Component c : this.getComponents()) {
     if (c instanceof DataPanel) {
       ((DataPanel) c).setCurrentTool(regionOfInterestTool);
     }
   }
 }
Beispiel #5
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    g2d.setPaint(Color.black);
    g2d.setStroke(new BasicStroke());
    g2d.setFont(new Font("Century Schoolbook", Font.PLAIN, 12));
    if (d.isInitialized() && display_plot) {
      d.refreshData();
      Float xLower = d.getXLower();
      Float xUpper = d.getXUpper();
      Float xInterval = d.getXInterval();
      Float yLower = d.getYLower();
      Float yUpper = d.getYUpper();
      Float yInterval = d.getYInterval();
      Float dx = xUpper - xLower;
      Float dy = yUpper - yLower;

      drawCenteredString(g2d, d.getTitle(), 250, 25, (float) 0.);
      drawCenteredString(g2d, d.getXTitle(), 250, 475, (float) 0.);
      drawCenteredString(g2d, d.getYTitle(), 25, 250, (float) -Math.PI / 2);
      drawCenteredString(g2d, xLower.toString(), 50, 475, (float) 0);
      drawCenteredString(g2d, xUpper.toString(), 450, 475, (float) 0);
      drawCenteredString(g2d, yLower.toString(), 25, 450, (float) 0);
      drawCenteredString(g2d, yUpper.toString(), 25, 50, (float) 0);

      g2d.setPaint(Color.gray);
      for (Float x = new Float(50); x <= 450; x += 400 * xInterval / dx)
        g2d.draw(new Line2D.Float(x, 450, x, 50));
      for (Float y = new Float(50); y <= 450; y += 400 * yInterval / dy)
        g2d.draw(new Line2D.Float(45, y, 450, y));

      g2d.setPaint(Color.red);
      Float diam = new Float(8);
      int num_points = d.getNumberOfPoints();
      for (int i = 0; i < num_points; i++) {
        Float ex = 400 * (d.getPoint(i).x - xLower) / dx + 50;
        ex -= diam / 2;
        Float ey = -400 * (d.getPoint(i).y - yLower) / dy + 450;
        ey -= diam / 2;
        g2d.fill(new Ellipse2D.Float(ex, ey, diam, diam));
      }
    }
  }
 public void update() {
   setModel();
   super.update();
 }
Beispiel #7
0
  /** Initializes the painting algorithm in the DataPanel */
  private void initPainter() {
    getContentPane().remove(DataPanel);

    topx1 = 0;
    topx2 = 120;
    bottomx1 = 150;
    bottomx2 = 0;
    timer = new javax.swing.Timer(10, this);
    timer.start();

    DataPanel =
        new JPanel() {
          public void paint(Graphics g) {
            super.paint(g);
            Graphics2D g2d = (Graphics2D) g;

            panelLength = getSize().width;
            panelHeight = getSize().height;

            g2d.setStroke(new BasicStroke(10));

            GradientPaint topBarPaint =
                new GradientPaint(topx1, topy1, Color.black, topx2, topy2, Color.blue, true);

            g2d.setPaint(topBarPaint);
            g2d.drawLine(0, 0, panelLength, 0);

            GradientPaint bottomBarPaint =
                new GradientPaint(
                    bottomx1, bottomy1, Color.black, bottomx2, bottomy2, Color.blue, true);

            g2d.setPaint(bottomBarPaint);
            g2d.drawLine(0, panelHeight, panelLength, panelHeight);

            if (drawVerticalLines) {
              GradientPaint verticalBarPaint =
                  new GradientPaint(0, 0, Color.black, 0, panelHeight, Color.lightGray, true);

              g2d.setStroke(new BasicStroke(2));
              g2d.setPaint(verticalBarPaint);
              g2d.drawLine(vertx1, 6, vertx2, panelHeight - 6);
              g2d.drawLine(vert2x1, 6, vert2x2, panelHeight - 6);
            }

            g2d.setPaint(new GradientPaint(50, 0, Color.darkGray, 450, 0, Color.black));
            g2d.setFont(new Font("Verdana", 0, 18));

            double strWidth = g2d.getFontMetrics().getStringBounds(upperMessage, g2d).getWidth();
            g2d.drawString(
                upperMessage,
                (float) (panelLength / 2) - (float) (strWidth / 2),
                (float) panelHeight / 3);

            strWidth = g2d.getFontMetrics().getStringBounds(lowerMessage, g2d).getWidth();
            g2d.drawString(
                lowerMessage,
                (float) (panelLength / 2) - (float) (strWidth / 2),
                (float) panelHeight / (1.5f));
          }
        };

    DataPanel.setMinimumSize(new Dimension(450, 100));
    DataPanel.setPreferredSize(new Dimension(450, 100));
    DataPanel.setMaximumSize(new Dimension(450, 100));

    getContentPane().add(DataPanel);
    this.pack();
    centerOnScreen();
  }