@Nullable
 public GraphPrintCell getGraphPrintCellForRow(TableModel model, int rowIndex) {
   if (rowIndex >= model.getRowCount()) {
     return null;
   }
   Object commitValue = model.getValueAt(rowIndex, AbstractVcsLogTableModel.COMMIT_COLUMN);
   if (commitValue instanceof GraphCommitCell) {
     GraphCommitCell commitCell = (GraphCommitCell) commitValue;
     return commitCell.getPrintCell();
   }
   return null;
 }
예제 #2
0
  private Row[] getViewToModel() {
    if (viewToModel == null) {
      int tableModelRowCount = tableModel.getRowCount();
      viewToModel = new Row[tableModelRowCount];
      for (int row = 0; row < tableModelRowCount; row++) {
        viewToModel[row] = new Row(row);
      }

      if (isSorting()) {
        Arrays.sort(viewToModel);
      }
    }
    return viewToModel;
  }
예제 #3
0
 /**
  * Display the tree rooted at node tn in the graph as a dendogram.
  *
  * @param tn the root node of the tree to display
  */
 private void display(TreeNode tn) {
   double[] segs = dendogram(tn);
   double distance = 10.;
   if (tn instanceof Cluster) {
     distance = ((Cluster) tn).getSimilarity();
   } else {
     distance = ((DefaultMutableTreeNode) tn).getDepth();
   }
   gs.setData(segs, GraphDataModel.FORMAT_XY);
   graph.getXAxis().setMin(distance);
   graph.getXAxis().setMax(0.);
   graph.getYAxis().setMin(tm.getRowCount() - .5);
   graph.getYAxis().setMax(-.5);
   repaint();
 }
  private static void setColumnWidths(JTable table, MetricTableSpecification tableSpecification) {
    final TableModel model = table.getModel();
    final TableColumnModel columnModel = table.getColumnModel();

    final List<Integer> columnWidths = tableSpecification.getColumnWidths();
    final List<String> columnOrder = tableSpecification.getColumnOrder();
    if (columnWidths != null && !columnWidths.isEmpty()) {

      final int columnCount = model.getColumnCount();
      for (int i = 0; i < columnCount; i++) {
        final String columnName = model.getColumnName(i);
        final int index = columnOrder.indexOf(columnName);
        if (index != -1) {
          final Integer width = columnWidths.get(index);
          final TableColumn column = columnModel.getColumn(i);
          column.setPreferredWidth(width.intValue());
        }
      }
    } else {
      final Graphics graphics = table.getGraphics();
      final Font font = table.getFont();
      final FontMetrics fontMetrics = table.getFontMetrics(font);

      final int rowCount = model.getRowCount();
      int maxFirstColumnWidth = 100;
      for (int i = 0; i < rowCount; i++) {
        final String name = (String) model.getValueAt(i, 0);
        if (name != null) {
          final Rectangle2D stringBounds = fontMetrics.getStringBounds(name, graphics);
          final double stringWidth = stringBounds.getWidth();
          if (stringWidth > maxFirstColumnWidth) {
            maxFirstColumnWidth = (int) stringWidth;
          }
        }
      }

      final int allocatedFirstColumnWidth = Math.min(300, maxFirstColumnWidth + 5);
      final TableColumn column = columnModel.getColumn(0);
      column.setPreferredWidth(allocatedFirstColumnWidth);
    }
  }
예제 #5
0
 /**
  * Return a label for the given point on the graph axis
  *
  * @param value the value on the graph
  * @return the label for the given value
  */
 private String getLeafLabel(double value) {
   String label = Double.toString(value);
   try {
     int v = (int) value;
     int r = idxMap.getSrc(v);
     if (r < 0 || r >= tm.getRowCount()) {
       return "";
     }
     if (labelColumn >= 0 && labelColumn < tm.getColumnCount()) {
       Object o = tm.getValueAt(r, labelColumn);
       return o != null ? o.toString() : "";
     }
   } catch (Exception ex) {
     ExceptionHandler.popupException("" + ex);
   }
   try {
     label = Integer.toString((int) value);
   } catch (Exception ex) {
     ExceptionHandler.popupException("" + ex);
   }
   return label;
 }
예제 #6
0
  public void calculaSumas() {
    try {
      TableModel tm = this.tablaPrincipal.getModel();
      int tamTabla = tm.getRowCount();
      double costo, cantidad, totalFila, sumaTotal;
      sumaTotal = 0.0;

      for (int i = 0; i < tamTabla; i++) {
        if (tm.getValueAt(i, 2) != null && tm.getValueAt(i, 3) != null) {
          costo = Double.valueOf(String.valueOf(tm.getValueAt(i, 2)));
          cantidad = Double.valueOf(String.valueOf(tm.getValueAt(i, 3)));
          totalFila = costo * cantidad;

          tm.setValueAt(totalFila, i, 4);
          sumaTotal += totalFila;
        }
      }

      txtSumaTotal.setText(String.valueOf(sumaTotal));
    } catch (Exception e) {
      Dialogos.lanzarAlerta("Cantidades invalidas, puede que algun numero este mal escrito");
    }
  }
예제 #7
0
 public int getRowCount() {
   return (myModel == null) ? 0 : myModel.getRowCount();
 }
예제 #8
0
 public int getRowCount() {
   return (tableModel == null) ? 0 : tableModel.getRowCount();
 }
예제 #9
0
 public int getRowCount() {
   return parentModel.getRowCount();
 }
예제 #10
0
  public JunctionLinkDataFrame(final JunctionLink jl) {
    super(
        jl.getCurrName() + " properties",
        false, // resizable
        false, // closable
        false, // maximizable
        true); // iconifiable
    // PSRender.onHold();
    super.setBackground(back_color);
    super.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            reload();
            SelectedObject.setSelectedObject(jl);
          }
        });
    PSRender.moveToTop(jl.getBound(), 0.5);
    ml = jl;
    setLocation(50, 50);
    dataModelMain = new HeadTable(jl);
    tableMain = new JTable(dataModelMain);
    tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20));
    //        tableMain.setBackground(back_color);

    // code
    TableColumn column_code = tableMain.getColumn("Code");
    DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer();
    rendererCode.setToolTipText("Enter new code for this path");
    column_code.setCellRenderer(rendererCode);
    column_code.setCellEditor(new TextFieldEditor());
    // name
    TableColumn column_name = tableMain.getColumn("Name");
    LanguageButtonRender render_name = new LanguageButtonRender();
    render_name.setToolTipText("Path name. Press for change name");
    column_name.setCellRenderer(render_name);
    LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox());
    column_name.setCellEditor(editor_name);
    // junction 1
    TableColumn column_junc_1 = tableMain.getColumn("Junction 1");
    MLButtonRenderer rendererJunc_1 = new MLButtonRenderer();
    rendererJunc_1.setToolTipText("Code of first Junction, click for open properties");
    column_junc_1.setCellRenderer(rendererJunc_1);
    MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox());
    column_junc_1.setCellEditor(editorJunc);
    // junction 2
    TableColumn column_junc_2 = tableMain.getColumn("Junction 2");
    MLButtonRenderer rendererJunc_2 = new MLButtonRenderer();
    rendererJunc_2.setToolTipText("Code of second Junction, click for open properties");
    column_junc_2.setCellRenderer(rendererJunc_2);
    column_junc_2.setCellEditor(editorJunc);
    // type
    JComboBox comboBoxType = new JComboBox();
    String roadNames[] = jl.getTypeNames();
    for (int i = 0, len = roadNames.length; i < len; i++) {
      comboBoxType.addItem(roadNames[i]);
    }
    TableColumn column_type = tableMain.getColumn("Type");
    DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer();
    rendererType.setToolTipText("To change road type click for combo box");
    column_type.setCellRenderer(rendererType);
    column_type.setCellEditor(new DefaultCellEditor(comboBoxType));
    // legth
    TableColumn column_length = tableMain.getColumn("Length");
    DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer();
    rendererLen.setToolTipText("The path length in meters");
    column_length.setCellRenderer(rendererLen);

    scrollpaneMain = new JScrollPane(tableMain);
    scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    scrollpaneMain.setPreferredSize(new Dimension(500, 50));

    Container contentPane = super.getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);

    c.ipady = 0; // make this component tall
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(scrollpaneMain, c);
    //        scrollpaneMain.setBackground(back_color);
    //        scrollpaneMain.setForeground(back_color);
    contentPane.add(scrollpaneMain);

    TableModel dataModelPoints = new PointTableModel(jl);
    tablePoints = new JTable(dataModelPoints);
    tablePoints.setPreferredScrollableViewportSize(
        new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight()));
    ListModel lm =
        new AbstractListModel() {
          public int getSize() {
            return 1000;
          }

          public Object getElementAt(int index) {
            return "" + index;
          }
        };
    JList rowHeader = new JList(lm);
    rowHeader.setFixedCellWidth(20);

    rowHeader.setFixedCellHeight(tablePoints.getRowHeight());
    // + tablePoints.getRowMargin());

    rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints));

    scrollPanePoints = new JScrollPane(tablePoints);
    scrollPanePoints.setWheelScrollingEnabled(true);
    scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    int mh;
    if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) {
      mh = 100;
    } else {
      mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight();
    }
    scrollPanePoints.setPreferredSize(new Dimension(200, mh));
    scrollPanePoints.setRowHeaderView(rowHeader);

    c.ipadx = 200;
    c.weightx = 0.5;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(scrollPanePoints, c);
    //        scrollPanePoints.setBackground(back_color);
    contentPane.add(scrollPanePoints);

    button_ok = new JButton("Ok");
    button_ok.addActionListener(this);
    JPanel buttonPane = new JPanel(null);
    buttonPane.setPreferredSize(new Dimension(500, 100));
    button_ok.setBounds(205, 40, 90, 40);
    buttonPane.add(button_ok);
    c.ipady = 10; // make this component tall
    c.ipadx = 10;
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 2;
    c.gridy = 2;
    gridbag.setConstraints(buttonPane, c);
    buttonPane.setBackground(back_color);
    contentPane.add(buttonPane);

    super.pack();
    super.setVisible(true);

    // MapApplication.getDesktop().setSelectedFrame(this);

  }