List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:com.peterbochs.PeterBochsDebugger.java
@SuppressWarnings("unused") private void updateInstructionUsingNasm(BigInteger address) { try {// w w w. j a v a 2 s. c om if (address == null) { address = BigInteger.valueOf(0); } jStatusLabel.setText("Updating instruction"); String result = Disassemble.disassemble(address, 32); String lines[] = result.split("\n"); if (lines.length > 0) { DefaultTableModel model = (DefaultTableModel) instructionTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } jStatusProgressBar.setMaximum(lines.length - 1); for (int x = 0; x < lines.length; x++) { jStatusProgressBar.setValue(x); try { model.addRow(new String[] { lines[x].substring(0, 10).trim(), lines[x].substring(20).trim(), lines[x].substring(10, 20).trim() }); } catch (Exception ex) { ex.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void updateBreakpoint() { try {/*from ww w. j a va 2 s. c o m*/ jStatusLabel.setText("Updating breakpoint"); // commandReceiver.setCommandNoOfLine(-1); commandReceiver.clearBuffer(); sendCommand("info break"); Thread.currentThread(); String result = commandReceiver.getCommandResultUntilEnd(); String[] lines = result.split("\n"); DefaultTableModel model = (DefaultTableModel) breakpointTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } for (int x = 1; x < lines.length; x++) { if (lines[x].contains("breakpoint")) { Vector<String> strs = new Vector<String>(Arrays.asList(lines[x].trim().split(" \\s"))); strs.add("0"); // hit count if (strs.size() > 1) { strs.remove(1); model.addRow(strs); } } } this.jRefreshELFBreakpointButtonActionPerformed(null); jStatusLabel.setText(""); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:app.RunApp.java
/** * Set frequency of labelsets//from ww w .j a va 2s.co m * * @param jtable Table * @param dataset Dataset * @param stat Statistics * @param cp Plot * @return Generated TableModel * @throws Exception */ private TableModel labelsetsFrequencyTableModel(JTable jtable, MultiLabelInstances dataset, Statistics stat, CategoryPlot cp) throws Exception { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; DefaultCategoryDataset myData = new DefaultCategoryDataset(); tableModel.addColumn("Labelset Id"); tableModel.addColumn("# Examples"); tableModel.addColumn("Frequency"); double freq; //Labelsets frequency HashMap<LabelSet, Integer> result = stat.labelCombCount(); labelsetStringsByFreq = new ArrayList<>(result.size()); double sum = 0.0; Set<LabelSet> keysets = result.keySet(); Object[] row = new Object[3]; int count = 1; ArrayList<ImbalancedFeature> listImbalanced = new ArrayList(); ImbalancedFeature temp; int value; for (LabelSet current : keysets) { value = result.get(current); temp = new ImbalancedFeature(current.toString(), value); listImbalanced.add(temp); } labelsetsSorted = new ImbalancedFeature[listImbalanced.size()]; labelsetsFrequency = new double[listImbalanced.size()]; while (!listImbalanced.isEmpty()) { temp = Utils.getMax(listImbalanced); labelsetsSorted[count - 1] = temp; value = temp.getAppearances(); labelsetsFrequency[count - 1] = value; row[0] = count; freq = value * 1.0 / dataset.getNumInstances(); sum += freq; String valueFreq = Double.toString(freq); row[1] = value; row[2] = MetricUtils.getValueFormatted(valueFreq, 4); tableModel.addRow(row); String id = "ID: " + Integer.toString(count); myData.setValue(freq, id, ""); labelsetStringsByFreq.add(temp.getName()); count++; listImbalanced.remove(temp); } jtable.setModel(tableModel); jtable.setBounds(jtable.getBounds()); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(50); tcm.getColumn(1).setPreferredWidth(50); tcm.getColumn(2).setPreferredWidth(60); //graph cp.setDataset(myData); sum = sum / keysets.size(); Marker start = new ValueMarker(sum); start.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); start.setLabel(" Mean: " + MetricUtils.truncateValue(sum, 4)); start.setPaint(Color.red); cp.addRangeMarker(start); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Set label IR// ww w .j a v a 2 s. com * * @param jtable Table * @param stat Statistics * @param cp CategoryPlot * @return Generated TableModel * @throws Exception */ private TableModel irLabelsetsTableModel(JTable jtable, Statistics stat, CategoryPlot cp) throws Exception { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; DefaultCategoryDataset myData = new DefaultCategoryDataset(); tableModel.addColumn("Labelset id"); tableModel.addColumn("IR values"); //Labelsets frequency HashMap<LabelSet, Integer> labelsetsFrequency = stat.labelCombCount(); labelsetStringByIR = new ArrayList<>(labelsetsFrequency.size()); Set<LabelSet> keysets = labelsetsFrequency.keySet(); Object[] row = new Object[2]; int count = 1; double IR_labelset; int max = getMax(keysets, labelsetsFrequency); ArrayList<ImbalancedFeature> listImbalanced = new ArrayList(); ImbalancedFeature temp; int value; for (LabelSet current : keysets) { value = labelsetsFrequency.get(current); IR_labelset = max / (value * 1.0); String temp1 = MetricUtils.truncateValue(IR_labelset, 4); IR_labelset = Double.parseDouble(temp1); temp = new ImbalancedFeature(current.toString(), value, IR_labelset); listImbalanced.add(temp); } labelsetsIRSorted = new ImbalancedFeature[listImbalanced.size()]; labelsetsByIR = new double[listImbalanced.size()]; //stores IR per labelset String truncate; while (!listImbalanced.isEmpty()) { temp = Utils.getMin(listImbalanced); labelsetsIRSorted[count - 1] = temp; labelsetsByIR[count - 1] = temp.getIRIntraClass(); row[0] = count; truncate = Double.toString(temp.getIRIntraClass()); row[1] = MetricUtils.getValueFormatted(truncate, 3); tableModel.addRow(row); myData.setValue(temp.getIRIntraClass(), Integer.toString(count), ""); labelsetStringByIR.add(temp.getName()); count++; listImbalanced.remove(temp); } jtable.setModel(tableModel); jtable.setBounds(jtable.getBounds()); //Resize columns TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(50); tcm.getColumn(1).setPreferredWidth(50); //graph cp.setDataset(myData); //get mean double sum = 0; for (int i = 0; i < labelsetsIRSorted.length; i++) { sum += labelsetsIRSorted[i].getIRIntraClass(); } sum = sum / labelsetsIRSorted.length; Marker start = new ValueMarker(sum); start.setPaint(Color.blue); start.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); start.setLabel(" Mean: " + MetricUtils.truncateValue(sum, 4)); cp.addRangeMarker(start); return jtable.getModel(); }
From source file:com.peterbochs.PeterBochsDebugger.java
private void parseELF(File elfFile) { jELFDumpPanel.remove(jTabbedPane4);// w w w . j a v a 2 s. c om jTabbedPane4 = null; jELFDumpPanel.add(getJTabbedPane4(), BorderLayout.CENTER); HashMap map = ElfUtil.getELFDetail(elfFile); if (map != null) { // header DefaultTableModel model = (DefaultTableModel) jELFHeaderTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } Set entries = ((HashMap) map.get("header")).entrySet(); Iterator it = entries.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Vector<String> v = new Vector<String>(); v.add(entry.getKey().toString()); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("header " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); model.addRow(v); } // end header // section model = (DefaultTableModel) jELFSectionTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } int sectionNo = 0; while (map.get("section" + sectionNo) != null) { entries = ((HashMap) map.get("section" + sectionNo)).entrySet(); it = entries.iterator(); Vector<String> v = new Vector<String>(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("section " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == String.class) { bytesStr = (String) entry.getValue(); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); } model.addRow(v); sectionNo++; } // end section // program header model = (DefaultTableModel) jProgramHeaderTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } int programHeaderNo = 0; while (map.get("programHeader" + programHeaderNo) != null) { entries = ((HashMap) map.get("programHeader" + programHeaderNo)).entrySet(); it = entries.iterator(); Vector<String> v = new Vector<String>(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String bytesStr = ""; if (entry.getValue().getClass() == Short.class) { jStatusLabel.setText("Program header " + Long.toHexString((Short) entry.getValue())); bytesStr += "0x" + Long.toHexString((Short) entry.getValue()); } else if (entry.getValue().getClass() == Integer.class) { bytesStr += "0x" + Long.toHexString((Integer) entry.getValue()); } else if (entry.getValue().getClass() == Long.class) { bytesStr += "0x" + Long.toHexString((Long) entry.getValue()); } else if (entry.getValue().getClass() == String.class) { bytesStr += "0x" + entry.getValue(); } else { int b[] = (int[]) entry.getValue(); for (int x = 0; x < b.length; x++) { bytesStr += "0x" + Long.toHexString(b[x]) + " "; } } v.add(bytesStr); } model.addRow(v); programHeaderNo++; } // program header // symbol table int symbolTableNo = 0; while (map.get("symbolTable" + symbolTableNo) != null) { DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "st_name", "st_value", "st_size", "st_info", "st_other", "p_st_shndx" }); JTable tempTable = new JTable(); HashMap tempMap = (HashMap) map.get("symbolTable" + symbolTableNo); Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector"); for (int x = 0; x < v.size(); x++) { Vector tempV = new Vector(); jStatusLabel.setText("Symbol table " + x); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No."))); tempV.add(v.get(x).get("st_name")); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_value"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_size"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_info"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_other"))); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("p_st_shndx"))); tempTableModel.addRow(tempV); } tempTable.setModel(tempTableModel); JScrollPane tempScrollPane = new JScrollPane(); tempScrollPane.setViewportView(tempTable); jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null); symbolTableNo++; } // end symbol table // note int noteSectionNo = 0; while (map.get("note" + noteSectionNo) != null) { DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "namesz", "descsz", "type", "name", "desc" }); JTable tempTable = new JTable(); HashMap tempMap = (HashMap) map.get("note" + noteSectionNo); Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector"); for (int x = 0; x < v.size(); x++) { Vector tempV = new Vector(); jStatusLabel.setText("Note " + x); tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No."))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("namesz"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("descsz"))); tempV.add("0x" + Long.toHexString((Long) v.get(x).get("type"))); tempV.add(v.get(x).get("name")); tempV.add(v.get(x).get("desc")); tempTableModel.addRow(tempV); } tempTable.setModel(tempTableModel); JScrollPane tempScrollPane = new JScrollPane(); tempScrollPane.setViewportView(tempTable); jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null); noteSectionNo++; } // end note } try { jStatusLabel.setText("running objdump -DS"); Process process = Runtime.getRuntime().exec("objdump -DS " + elfFile.getAbsolutePath()); InputStream input = process.getInputStream(); String str = ""; byte b[] = new byte[102400]; int len; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } jEditorPane1.setText(str); jStatusLabel.setText("readelf -r"); process = Runtime.getRuntime().exec("readelf -r " + elfFile.getAbsolutePath()); input = process.getInputStream(); str = ""; b = new byte[102400]; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } jSearchRelPltEditorPane.setText(str); jStatusLabel.setText("readelf -d"); process = Runtime.getRuntime().exec("readelf -d " + elfFile.getAbsolutePath()); input = process.getInputStream(); str = ""; b = new byte[102400]; while ((len = input.read(b)) > 0) { str += new String(b, 0, len); } input.close(); jSearchDynamicEditorPane.setText(str); jStatusLabel.setText(""); } catch (IOException e) { e.printStackTrace(); } // end symbol table }
From source file:com.peterbochs.PeterBochsDebugger.java
public void updatePageTable(BigInteger pageDirectoryBaseAddress) { Vector<IA32PageDirectory> ia32_pageDirectories = new Vector<IA32PageDirectory>(); try {//from ww w.j a v a 2 s. co m commandReceiver.clearBuffer(); commandReceiver.shouldShow = false; jStatusLabel.setText("Updating page table"); // commandReceiver.setCommandNoOfLine(512); sendCommand("xp /4096bx " + pageDirectoryBaseAddress); float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr; String realStartAddressStr; BigInteger realStartAddress = pageDirectoryBaseAddress; realStartAddressStr = realStartAddress.toString(16); BigInteger realEndAddress = realStartAddress.add(BigInteger.valueOf(totalByte3 * 8)); realEndAddressStr = String.format("%08x", realEndAddress); String result = commandReceiver.getCommandResult(realStartAddressStr, realEndAddressStr, null); if (result != null) { String[] lines = result.split("\n"); DefaultTableModel model = (DefaultTableModel) jPageDirectoryTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0); } jStatusProgressBar.setMaximum(lines.length - 1); for (int y = 0; y < lines.length; y++) { jStatusProgressBar.setValue(y); String[] b = lines[y].replaceFirst("^.*:", "").trim().split("\t"); for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for (int x = 0; x < 4; x++) { bytes[x] = CommonLib.string2BigInteger(b[x + z * 4].substring(2).trim()).intValue(); } long value = CommonLib.getInt(bytes, 0); // "No.", "PT base", "AVL", "G", // "D", "A", "PCD", "PWT", // "U/S", "W/R", "P" long baseL = value & 0xfffff000; // if (baseL != 0) { String base = "0x" + Long.toHexString(baseL); String avl = String.valueOf((value >> 9) & 3); String g = String.valueOf((value >> 8) & 1); String d = String.valueOf((value >> 6) & 1); String a = String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value >> 1) & 1); String p = String.valueOf((value >> 0) & 1); ia32_pageDirectories .add(new IA32PageDirectory(base, avl, g, d, a, pcd, pwt, us, wr, p)); model.addRow(new String[] { String.valueOf(y * 2 + z), base, avl, g, d, a, pcd, pwt, us, wr, p }); // } } catch (Exception ex) { } } jStatusLabel.setText("Updating page table " + (y + 1) + "/" + lines.length); } jPageDirectoryTable.setModel(model); } } catch (Exception ex) { ex.printStackTrace(); } /* * if (false && Global.debug && * jAutoRefreshPageTableGraphCheckBox.isSelected()) { * System.out.println("aa"); GraphModel model = new DefaultGraphModel(); * GraphLayoutCache view = new GraphLayoutCache(model, new * DefaultCellViewFactory() { public CellView createView(GraphModel * model, Object cell) { CellView view = null; if (model.isPort(cell)) { * view = new PortView(cell); } else if (model.isEdge(cell)) { view = * new EdgeView(cell); } else { if (cell instanceof IA32PageDirectory) { * view = new PageDirectoryView(cell); } else if (cell instanceof * IA32PageTable) { view = new JButtonView(cell, 1); } else { view = new * VertexView(cell); } } return view; } }); JGraph graph = new * JGraph(model, view); * * // add cells * * // DefaultGraphCell[] cells = new // * DefaultGraphCell[ia32_pageDirectories.size() + 1]; * Vector<DefaultGraphCell> cells = new Vector<DefaultGraphCell>(); * DefaultGraphCell root = new DefaultGraphCell("cr3 " + * jRegisterPanel1.jCR3TextField.getText()); * GraphConstants.setGradientColor(root.getAttributes(), Color.red); * GraphConstants.setOpaque(root.getAttributes(), true); * GraphConstants.setBounds(root.getAttributes(), new * Rectangle2D.Double(0, 0, 140, 20)); root.add(new DefaultPort()); * cells.add(root); * * Vector<IA32PageDirectory> pageDirectoryCells = new * Vector<IA32PageDirectory>(); for (int x = 0; x < * ia32_pageDirectories.size(); x++) { IA32PageDirectory cell = * ia32_pageDirectories.get(x); * GraphConstants.setGradientColor(cell.getAttributes(), Color.orange); * GraphConstants.setOpaque(cell.getAttributes(), true); * GraphConstants.setBounds(cell.getAttributes(), new * Rectangle2D.Double(0, x * 20, 140, 20)); cell.add(new DefaultPort()); * pageDirectoryCells.add(cell); * * // page table String pageTableAddress = * ia32_pageDirectories.get(x).base; sendCommand("xp /4096bx " + * pageTableAddress); * * float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int * totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr; * String realStartAddressStr; String baseAddress = pageTableAddress; * long realStartAddress = CommonLib.string2BigInteger(baseAddress); * * realStartAddressStr = String.format("%08x", realStartAddress); long * realEndAddress = realStartAddress + totalByte3 * 8; realEndAddressStr * = String.format("%08x", realEndAddress); * * String result = commandReceiver.getCommandResult(realStartAddressStr, * realEndAddressStr); String[] lines = result.split("\n"); * * Vector<DefaultGraphCell> pageTables = new Vector<DefaultGraphCell>(); * for (int y = 1; y < 4; y++) { String[] b = * lines[y].replaceFirst(" cell.add(new DefaultPort());^.*:", * "").trim().split("\t"); * * for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for * (int x2 = 0; x2 < 4; x2++) { bytes[x2] = * CommonLib.string2BigInteger(b[x2 + z * * 4].substring(2).trim()).intValue(); } long value = * CommonLib.getInt(bytes, 0); * * String base = Long.toHexString(value & 0xfffff000); String avl = * String.valueOf((value >> 9) & 3); String g = String.valueOf((value >> * 8) & 1); String d = String.valueOf((value >> 6) & 1); String a = * String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value * >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us * = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value * >> 1) & 1); String p = String.valueOf((value >> 0) & 1); * IA32PageTable pageTableCell = new IA32PageTable(base, avl, g, d, a, * pcd, pwt, us, wr, p); * GraphConstants.setGradientColor(pageTableCell.getAttributes(), * Color.orange); * GraphConstants.setOpaque(pageTableCell.getAttributes(), true); * GraphConstants.setBounds(pageTableCell.getAttributes(), new * Rectangle2D.Double(0, (z + y) * 20, 140, 20)); pageTableCell.add(new * DefaultPort()); pageTables.add(pageTableCell); } catch (Exception ex) * { } } } * * // group it and link it DefaultGraphCell pt[] = * pageTables.toArray(new DefaultGraphCell[] {}); DefaultGraphCell * vertex1 = new DefaultGraphCell(new String("page table" + x), null, * pt); vertex1.add(new DefaultPort()); cells.add(vertex1); * * DefaultEdge edge = new DefaultEdge(); * edge.setSource(cell.getChildAt(0)); * edge.setTarget(vertex1.getLastChild()); * * GraphConstants.setLineStyle(edge.getAttributes(), * GraphConstants.STYLE_ORTHOGONAL); * GraphConstants.setRouting(edge.getAttributes(), * GraphConstants.ROUTING_DEFAULT); int arrow = * GraphConstants.ARROW_CLASSIC; * GraphConstants.setLineEnd(edge.getAttributes(), arrow); * GraphConstants.setEndFill(edge.getAttributes(), true); * * cells.add(edge); } * * if (pageDirectoryCells.toArray().length > 0) { IA32PageDirectory pt[] * = pageDirectoryCells.toArray(new IA32PageDirectory[] {}); * DefaultGraphCell vertex1 = new DefaultGraphCell(new * String("Vertex1"), null, pt); vertex1.add(new DefaultPort()); * cells.add(vertex1); * * DefaultEdge edge = new DefaultEdge(); * edge.setSource(root.getChildAt(0)); * edge.setTarget(vertex1.getLastChild()); int arrow = * GraphConstants.ARROW_CLASSIC; * GraphConstants.setLineEnd(edge.getAttributes(), arrow); * GraphConstants.setEndFill(edge.getAttributes(), true); * * // lastObj = cells[index]; cells.add(edge); } * * graph.getGraphLayoutCache().insert(cells.toArray()); * graph.setDisconnectable(false); * * JGraphFacade facade = new JGraphFacade(graph); JGraphLayout layout = * new JGraphTreeLayout(); ((JGraphTreeLayout) * layout).setOrientation(SwingConstants.WEST); // * ((JGraphHierarchicalLayout) layout).setNodeDistance(100); * layout.run(facade); Map nested = facade.createNestedMap(true, true); * graph.getGraphLayoutCache().edit(nested); * * // JGraphFacade facade = new JGraphFacade(graph); // JGraphLayout * layout = new JGraphFastOrganicLayout(); // layout.run(facade); // Map * nested = facade.createNestedMap(true, true); // * graph.getGraphLayoutCache().edit(nested); * * jPageTableGraphPanel.removeAll(); jPageTableGraphPanel.add(new * JScrollPane(graph), BorderLayout.CENTER); } */ }
From source file:interfaces.InterfazPrincipal.java
private void botonRegistrarAbonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonRegistrarAbonoActionPerformed // TODO add your handling code here: try {// w ww . j a v a 2 s. com String identificacionCliente = mostrarIdentificacionCliente.getText(); Double abono = Double.parseDouble(abonoClente.getText()); if (abono <= 0.0) { throw new Exception(); } ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); ControladorFactura controladorFactura = new ControladorFactura(); Calendar calendario = Calendar.getInstance(); String dia = Integer.toString(calendario.get(Calendar.DATE)); String mes = Integer.toString(calendario.get(Calendar.MONTH)); String annio = Integer.toString(calendario.get(Calendar.YEAR)); Date date = new Date(); DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss"); String hora = hourFormat.format(date); String fecha = annio + "-" + mes + "-" + dia + " " + hora; /* * -----------------Tomar el abono y los pagos----------------- * Procedimiento * 1 Tomar flujos de deuda de cada factura con estado fiado * 2 Tomar abonos de abono de cada factura con estado fiado * 3 Calcular la resta de estos dos para deteminar lo que se debe por factura * 4 Cancelar con el flujo la factura y si lo debido es 0 colocar estado pagado * 5 Mostrar una informacin en un JOptionPane y recalcular la deuda * */ DefaultTableModel modeloClientes = (DefaultTableModel) TablaDeSaldoClientes.getModel(); ArrayList<String> codigoFactura = new ArrayList<>(); ArrayList<Double> totalDebe = new ArrayList<>(); JTextArea area = new JTextArea(10, 30); String informe = "\t Registro flujo pago del abono \n\n"; informe += "Factura \t Pago \t Queda pagada? \n\n"; int numeroRegistros = -1; for (int i = 0; i < modeloClientes.getRowCount(); i++) { //System.out.println("Entro al for " + i); //Se necesita 0: Factura ID, 1 Tipo, 3 Valor // Codigofactura contiene los cogidos de las facturas // totalDebe contiene lo que debe de las facturas, la posicion coincide con la lista CodigoFactura String factura_id = String.valueOf(modeloClientes.getValueAt(i, 0)); String tipo_flujo = String.valueOf(modeloClientes.getValueAt(i, 1)); Double valor = Double.parseDouble(String.valueOf(modeloClientes.getValueAt(i, 3))); if (codigoFactura.contains(factura_id)) { if (tipo_flujo.equals("abono")) { totalDebe.set(numeroRegistros, totalDebe.get(numeroRegistros) - valor); } else { totalDebe.set(numeroRegistros, totalDebe.get(numeroRegistros) + valor); } } else { numeroRegistros++; codigoFactura.add(factura_id); if (tipo_flujo.equals("abono")) { totalDebe.add(-valor); } else { totalDebe.add(valor); } } } //System.out.println(Arrays.toString(codigoFactura.toArray())); //System.out.println(Arrays.toString(totalDebe.toArray())); Double debeTotal = 0d; for (int i = 0; i < totalDebe.size(); i++) { debeTotal += totalDebe.get(i); } if (debeTotal < abono) { JOptionPane.showMessageDialog(this, "El monto es superior a lo que debe el cliente, por favor indique otro monto", "Error", JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < totalDebe.size(); i++) { //Tomar flujos if (abono > 0.0) { Double pago = totalDebe.get(i) - abono; //Pago igual a 0 significa que se pag la factura if (pago == 0) { //Registrar flujo String[] value = { codigoFactura.get(i), "abono", fecha, String.valueOf(abono) }; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.insertFlujo_Factura(value); controladorFactura.cambiarEstadoFactura(codigoFactura.get(i), "pagada"); informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tSI\n"; //Romper el for break; } else { //Pago mayor que 0, es decir se queda debiendo if (pago > 0) { //Registrar flujo String[] value = { codigoFactura.get(i), "abono", fecha, String.valueOf(abono) }; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.insertFlujo_Factura(value); //Como el abono ahora es menor que 0 debe romperse el for informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tNO\n"; break; } else { //Caso final pago menor 0, es decir el abono paga la factura pero queda disponible para otras facturas //Registrar flujo String[] value = { codigoFactura.get(i), "abono", fecha, String.valueOf(totalDebe.get(i)) }; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.insertFlujo_Factura(value); controladorFactura.cambiarEstadoFactura(codigoFactura.get(i), "pagada"); //Ajustamos ahora el abono restando lo que debe la factura informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tSI\n"; abono -= totalDebe.get(i); } } } else { //Romper el for break; } } //Reordenar y volver a consultar for (int i = 0; i < modeloClientes.getRowCount(); i++) { modeloClientes.removeRow(i); } modeloClientes.setRowCount(0); //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506); ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura( " where factura_id in (select factura_id from Factura where cliente_id = " + String.valueOf(identificacionCliente) + " and estado=\"fiado\") order by factura_id"); double pago = 0.0; for (int i = 0; i < flujosCliente.size(); i++) { String[] datos = flujosCliente.get(i); Object[] rowData = { datos[1], datos[2], datos[3], datos[4] }; modeloClientes.addRow(rowData); if (datos[2].equals("deuda")) { pago += Double.parseDouble(datos[4]); } else { pago -= Double.parseDouble(datos[4]); } } textoTotalDebe.setText(String.valueOf(pago)); TablaDeSaldoClientes.setModel(modeloClientes); area.setText(informe); JScrollPane panelInformePago = new JScrollPane(area); JOptionPane.showMessageDialog(this, panelInformePago); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Debe ingresar un valor numrico mayor que 0 en el abono "); } }
From source file:interfaces.InterfazPrincipal.java
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed // TODO add your handling code here: try {//from ww w. j a v a 2 s.c o m String identificacionCliente = mostrarIDProveedor.getText(); Double abono = Double.parseDouble(jTextFieldAbonoProveedor.getText()); if (abono <= 0.0 || identificacionCliente.equals("")) { throw new Exception(); } ControladorFlujoCompras controladorFlujoFactura = new ControladorFlujoCompras(); ControladorCompraProveedor controladorCompraProveedor = new ControladorCompraProveedor(); Calendar calendario = Calendar.getInstance(); String dia = Integer.toString(calendario.get(Calendar.DATE)); String mes = Integer.toString(calendario.get(Calendar.MONTH)); String annio = Integer.toString(calendario.get(Calendar.YEAR)); Date date = new Date(); DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss"); String hora = hourFormat.format(date); String fecha = annio + "-" + mes + "-" + dia + " " + hora; /* * -----------------Tomar el abono y los pagos----------------- * Procedimiento * 1 Tomar flujos de deuda de cada factura con estado fiado * 2 Tomar abonos de abono de cada factura con estado fiado * 3 Calcular la resta de estos dos para deteminar lo que se debe por factura * 4 Cancelar con el flujo la factura y si lo debido es 0 colocar estado pagado * 5 Mostrar una informacin en un JOptionPane y recalcular la deuda * */ DefaultTableModel modeloClientes = (DefaultTableModel) TablaDeSaldoProveedor.getModel(); ArrayList<String> codigoFactura = new ArrayList<>(); ArrayList<Double> totalDebe = new ArrayList<>(); JTextArea area = new JTextArea(10, 30); String informe = "\t Registro flujo pago del abono \n\n"; informe += "Factura \t Pago \t Queda pagada? \n\n"; int numeroRegistros = -1; for (int i = 0; i < modeloClientes.getRowCount(); i++) { //System.out.println("Entro al for " + i); //Se necesita 0: Factura ID, 1 Tipo, 3 Valor // Codigofactura contiene los cogidos de las facturas // totalDebe contiene lo que debe de las facturas, la posicion coincide con la lista CodigoFactura String factura_id = String.valueOf(modeloClientes.getValueAt(i, 0)); String tipo_flujo = String.valueOf(modeloClientes.getValueAt(i, 1)); Double valor = Double.parseDouble(String.valueOf(modeloClientes.getValueAt(i, 3))); if (codigoFactura.contains(factura_id)) { if (tipo_flujo.equals("abono")) { totalDebe.set(numeroRegistros, totalDebe.get(numeroRegistros) - valor); } else { totalDebe.set(numeroRegistros, totalDebe.get(numeroRegistros) + valor); } } else { numeroRegistros++; codigoFactura.add(factura_id); if (tipo_flujo.equals("abono")) { totalDebe.add(-valor); } else { totalDebe.add(valor); } } } //System.out.println(Arrays.toString(codigoFactura.toArray())); //System.out.println(Arrays.toString(totalDebe.toArray())); System.out.println(totalDebe); double debeTotal = 0d; for (int i = 0; i < totalDebe.size(); i++) { debeTotal += totalDebe.get(i); } if (debeTotal < abono) { JOptionPane.showMessageDialog(this, "El monto a pagar no puede ser superior a lo que se debe", "Error del sistema", JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < totalDebe.size(); i++) { //Tomar flujos if (abono > 0.0) { Double pago = totalDebe.get(i) - abono; //Pago igual a 0 significa que se pag la factura if (pago == 0) { //Registrar flujo //String[] value = {codigoFactura.get(i), "abono", fecha, String.valueOf(abono)}; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.registrarFlujoAbono(codigoFactura.get(i), String.valueOf(abono)); //controladorFactura.cambiarEstadoFactura(codigoFactura.get(i), "pagada"); informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tSI\n"; //Romper el for break; } else { //Pago mayor que 0, es decir se queda debiendo if (pago > 0) { //Registrar flujo //String[] value = {codigoFactura.get(i), "abono", fecha, String.valueOf(abono)}; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.registrarFlujoAbono(codigoFactura.get(i), String.valueOf(abono)); //Como el abono ahora es menor que 0 debe romperse el for informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tNO\n"; break; } else { //Caso final pago menor 0, es decir el abono paga la factura pero queda disponible para otras facturas //Registrar flujo //String[] value = {codigoFactura.get(i), "abono", fecha, String.valueOf(totalDebe.get(i))}; //String [] selection = {"factura_id","tipo_flujo","fecha","valor"}; controladorFlujoFactura.registrarFlujoAbono(codigoFactura.get(i), String.valueOf(totalDebe.get(i))); //controladorFactura.cambiarEstadoFactura(codigoFactura.get(i), "pagada"); //Ajustamos ahora el abono restando lo que debe la factura informe += codigoFactura.get(i) + "\t" + String.valueOf(abono) + "\tSI\n"; abono -= totalDebe.get(i); } } } else { //Romper el for break; } } //Reordenar y volver a consultar for (int i = 0; i < modeloClientes.getRowCount(); i++) { modeloClientes.removeRow(i); } modeloClientes.setRowCount(0); //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506); ArrayList<Flujo_Compra> flujosProveedor = controladorFlujoFactura.obtenerFlujosCompras( " where ID_CompraProveedor in (select ID_CompraProveedor from Compra_Proveedores where IDProveedor = " + String.valueOf(identificacionCliente) + ") order by ID_CompraProveedor"); double pago = 0.0; for (int i = 0; i < flujosProveedor.size(); i++) { Flujo_Compra datos = flujosProveedor.get(i); Object[] rowData = { datos.getID_CompraProveedor(), datos.getTipo_flujo(), datos.getFecha(), datos.getMonto() }; if (datos.getTipo_flujo().equals("deuda")) { pago += Double.parseDouble(datos.getMonto() + ""); } else { pago -= Double.parseDouble(datos.getMonto() + ""); } modeloClientes.addRow(rowData); } TablaDeSaldoProveedor.setModel(modeloClientes); deudaActualProveedor.setText(String.valueOf(pago)); //Mostrar en table de clientes los datos botonRegistrarAbono.setEnabled(true); area.setText(informe); JScrollPane panelInformePago = new JScrollPane(area); JOptionPane.showMessageDialog(this, panelInformePago); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Debe ingresar un valor numrico mayor que 0 en el abono "); } }
From source file:net.ytbolg.mcxa.ForgeCheck.java
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable1.setColumnSelectionAllowed(false); jTable2.setColumnSelectionAllowed(false); jTable1.setRowSelectionAllowed(true); jTable2.setRowSelectionAllowed(true); setTitle(Lang.getLang("Forge_Window_Loading")); jButton1.setText(Lang.getLang("Forge_Button_Download")); jTabbedPane1.setTitleAt(0, Lang.getLang("Forge_TabledPanel_OlderVersion")); jTabbedPane1.setTitleAt(1, Lang.getLang("Forge_TabledPanel_NewerVersion")); DefaultTableModel newvm = (DefaultTableModel) jTable1.getModel(); DefaultTableModel oldvm = (DefaultTableModel) jTable2.getModel(); newvm.addColumn(Lang.getLang("Forge_Table_ForgeVer")); newvm.addColumn(Lang.getLang("Forge_Table_McVer")); newvm.addColumn(Lang.getLang("Forge_Table_RelTime")); oldvm.addColumn(Lang.getLang("Forge_Table_ForgeVer")); oldvm.addColumn(Lang.getLang("Forge_Table_McVer")); oldvm.addColumn(Lang.getLang("Forge_Table_RelTime")); jTable1.setSelectionMode(SINGLE_SELECTION); jTable2.setSelectionMode(SINGLE_SELECTION); JSONArray newv = null;//ww w . j a va 2 s . c o m try { newv = new JSONArray(downloadFile("http://bmclapi.bangbang93.com/forge/versionlist")); } catch (JSONException ex) { Logger.getLogger(ForgeCheck.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ForgeCheck.class.getName()).log(Level.SEVERE, null, ex); } JSONArray oldv = null; try { oldv = new JSONArray(downloadFile("http://bmclapi.bangbang93.com/forge/legacylist")); } catch (JSONException ex) { Logger.getLogger(ForgeCheck.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ForgeCheck.class.getName()).log(Level.SEVERE, null, ex); } for (int i = 0; i < newv.length(); i++) { try { JSONObject jo = newv.getJSONObject(i); newvm.addRow(new Object[] { jo.get("ver"), jo.get("mcver"), jo.get("releasetime") }); } catch (JSONException ex) { // Logger.getogger(ForgeDownloader.class.getName()).log(Level.SEVERE, null, ex); } } for (int i = 0; i < oldv.length(); i++) { try { JSONObject jo = oldv.getJSONObject(i); oldvm.addRow(new Object[] { jo.get("ver"), jo.get("mcver"), jo.get("releasetime") }); } catch (JSONException ex) { // Logger.getogger(ForgeDownloader.class.getName()).log(Level.SEVERE, null, ex); } } setTitle(Lang.getLang("Forge_Title"));// TODO add your handling code here: // TODO add your handling code here: }
From source file:net.ytbolg.mcxa.VersionCheck.java
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened setTitle(Lang.getLang("Version_Title")); DefaultTableModel zsbm = (DefaultTableModel) jTable1.getModel(); DefaultTableModel kzbm = (DefaultTableModel) jTable2.getModel(); DefaultTableModel jbbm = (DefaultTableModel) jTable3.getModel(); DefaultTableModel qbm = (DefaultTableModel) jTable4.getModel(); jButton1.setText(Lang.getLang("Version_Button_Download")); jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable1.setColumnSelectionAllowed(false); jTable2.setColumnSelectionAllowed(false); jTable3.setColumnSelectionAllowed(false); jTable4.setColumnSelectionAllowed(false); jTable1.setRowSelectionAllowed(true); jTable2.setRowSelectionAllowed(true); jTable3.setRowSelectionAllowed(true); jTable4.setRowSelectionAllowed(true); zsbm.addColumn(Lang.getLang("Version_Table_McVersion")); zsbm.addColumn(Lang.getLang("Version_Table_RelTime")); zsbm.addColumn(Lang.getLang("Version_Table_Type")); kzbm.addColumn(Lang.getLang("Version_Table_McVersion")); kzbm.addColumn(Lang.getLang("Version_Table_RelTime")); kzbm.addColumn(Lang.getLang("Version_Table_Type")); jbbm.addColumn(Lang.getLang("Version_Table_McVersion")); jbbm.addColumn(Lang.getLang("Version_Table_RelTime")); jbbm.addColumn(Lang.getLang("Version_Table_Type")); qbm.addColumn(Lang.getLang("Version_Table_McVersion")); qbm.addColumn(Lang.getLang("Version_Table_RelTime")); qbm.addColumn(Lang.getLang("Version_Table_Type")); jTabbedPane1.setTitleAt(0, Lang.getLang("Version_TabledPanel_Zsb")); jTabbedPane1.setTitleAt(1, Lang.getLang("Version_TabledPanel_Kzb")); jTabbedPane1.setTitleAt(2, Lang.getLang("Version_TabledPanel_jbb")); jTabbedPane1.setTitleAt(3, Lang.getLang("Version_TabledPanel_qb")); try {//from w w w .j a va 2s . co m JSONArray ja = (new JSONObject(downloadFile( DownLoadURL.getURL(DownLoadURL.VERSION_LIST, Integer.valueOf(Config.getConfig("DownSou"))))) .getJSONArray("versions")); for (int i = 0; i < ja.length(); i++) { JSONObject jo = ja.getJSONObject(i); if (jo.getString("type").equals("release")) { zsbm.addRow(new Object[] { jo.get("id"), jo.get("releaseTime"), jo.get("type") }); } if (jo.getString("type").equals("snapshot")) { kzbm.addRow(new Object[] { jo.get("id"), jo.get("releaseTime"), jo.get("type") }); } if (jo.getString("type").contains("old")) { jbbm.addRow(new Object[] { jo.get("id"), jo.get("releaseTime"), jo.get("type") }); } qbm.addRow(new Object[] { jo.get("id"), jo.get("releaseTime"), jo.get("type") }); } } catch (Exception e) { } // TODO add your handling code here: // TODO add your handling code here: }