rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
colModel.setSelectionInterval(colLead,colLead);
|
colModel.setSelectionInterval(colLead, colLead);
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead);
|
Math.min(rowLead - 1, 0)); colModel.setSelectionInterval(colLead, colLead);
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
rowModel.setSelectionInterval(rowLead,rowLead);
|
rowModel.setSelectionInterval(rowLead, rowLead);
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
rowModel.setSelectionInterval(rowLead,rowLead);
|
rowModel.setSelectionInterval(rowLead, rowLead);
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false));
|
table.scrollRectToVisible(table.getCellRect( rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false));
|
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin,
|
void advanceMultipleSelection(JTable table, ListSelectionModel firstModel, int firstMin,
|
void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin, int firstMax, ListSelectionModel secondModel, int secondMin, int secondMax, boolean reverse, boolean eventIsTab) { // If eventIsTab, all the "firsts" correspond to columns, otherwise, to rows // "seconds" correspond to the opposite int firstLead = firstModel.getLeadSelectionIndex(); int secondLead = secondModel.getLeadSelectionIndex(); int numFirsts = eventIsTab ? table.getModel().getColumnCount() : table.getModel().getRowCount(); int numSeconds = eventIsTab ? table.getModel().getRowCount() : table.getModel().getColumnCount(); // check if we have to wrap the "firsts" around, going to the other side if ((firstLead == firstMax && !reverse) || (reverse && firstLead == firstMin)) { firstModel.addSelectionInterval(reverse ? firstMax : firstMin, reverse ? firstMax : firstMin); // check if we have to wrap the "seconds" if ((secondLead == secondMax && !reverse) || (reverse && secondLead == secondMin)) secondModel.addSelectionInterval(reverse ? secondMax : secondMin, reverse ? secondMax : secondMin); // if we're not wrapping the seconds, we have to find out where we // are within the secondModel and advance to the next cell (or // go back to the previous cell if reverse == true) else { int[] secondsSelected; if (eventIsTab && table.getRowSelectionAllowed() || !eventIsTab && table.getColumnSelectionAllowed()) secondsSelected = eventIsTab ? table.getSelectedRows() : table.getSelectedColumns(); else { // if row selection is not allowed, then the entire column gets // selected when you click on it, so consider ALL rows selected secondsSelected = new int[numSeconds]; for (int i = 0; i < numSeconds; i++) secondsSelected[i] = i; } // and now find the "next" index within the model int secondIndex = reverse ? secondsSelected.length - 1 : 0; if (!reverse) while (secondsSelected[secondIndex] <= secondLead) secondIndex++; else while (secondsSelected[secondIndex] >= secondLead) secondIndex--; // and select it - updating the lead selection index secondModel.addSelectionInterval(secondsSelected[secondIndex], secondsSelected[secondIndex]); } } // We didn't have to wrap the firsts, so just find the "next" first // and select it, we don't have to change "seconds" else { int[] firstsSelected; if (eventIsTab && table.getColumnSelectionAllowed() || !eventIsTab && table.getRowSelectionAllowed()) firstsSelected = eventIsTab ? table.getSelectedColumns() : table.getSelectedRows(); else { // if selection not allowed, consider ALL firsts to be selected firstsSelected = new int[numFirsts]; for (int i = 0; i < numFirsts; i++) firstsSelected[i] = i; } int firstIndex = reverse ? firstsSelected.length - 1 : 0; if (!reverse) while (firstsSelected[firstIndex] <= firstLead) firstIndex++; else while (firstsSelected[firstIndex] >= firstLead) firstIndex--; firstModel.addSelectionInterval(firstsSelected[firstIndex], firstsSelected[firstIndex]); secondModel.addSelectionInterval(secondLead, secondLead); } }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin, int firstMax, ListSelectionModel secondModel, int secondMin, int secondMax, boolean reverse, boolean eventIsTab) { // If eventIsTab, all the "firsts" correspond to columns, otherwise, to rows // "seconds" correspond to the opposite int firstLead = firstModel.getLeadSelectionIndex(); int secondLead = secondModel.getLeadSelectionIndex(); int numFirsts = eventIsTab ? table.getModel().getColumnCount() : table.getModel().getRowCount(); int numSeconds = eventIsTab ? table.getModel().getRowCount() : table.getModel().getColumnCount(); // check if we have to wrap the "firsts" around, going to the other side if ((firstLead == firstMax && !reverse) || (reverse && firstLead == firstMin)) { firstModel.addSelectionInterval(reverse ? firstMax : firstMin, reverse ? firstMax : firstMin); // check if we have to wrap the "seconds" if ((secondLead == secondMax && !reverse) || (reverse && secondLead == secondMin)) secondModel.addSelectionInterval(reverse ? secondMax : secondMin, reverse ? secondMax : secondMin); // if we're not wrapping the seconds, we have to find out where we // are within the secondModel and advance to the next cell (or // go back to the previous cell if reverse == true) else { int[] secondsSelected; if (eventIsTab && table.getRowSelectionAllowed() || !eventIsTab && table.getColumnSelectionAllowed()) secondsSelected = eventIsTab ? table.getSelectedRows() : table.getSelectedColumns(); else { // if row selection is not allowed, then the entire column gets // selected when you click on it, so consider ALL rows selected secondsSelected = new int[numSeconds]; for (int i = 0; i < numSeconds; i++) secondsSelected[i] = i; } // and now find the "next" index within the model int secondIndex = reverse ? secondsSelected.length - 1 : 0; if (!reverse) while (secondsSelected[secondIndex] <= secondLead) secondIndex++; else while (secondsSelected[secondIndex] >= secondLead) secondIndex--; // and select it - updating the lead selection index secondModel.addSelectionInterval(secondsSelected[secondIndex], secondsSelected[secondIndex]); } } // We didn't have to wrap the firsts, so just find the "next" first // and select it, we don't have to change "seconds" else { int[] firstsSelected; if (eventIsTab && table.getColumnSelectionAllowed() || !eventIsTab && table.getRowSelectionAllowed()) firstsSelected = eventIsTab ? table.getSelectedColumns() : table.getSelectedRows(); else { // if selection not allowed, consider ALL firsts to be selected firstsSelected = new int[numFirsts]; for (int i = 0; i < numFirsts; i++) firstsSelected[i] = i; } int firstIndex = reverse ? firstsSelected.length - 1 : 0; if (!reverse) while (firstsSelected[firstIndex] <= firstLead) firstIndex++; else while (firstsSelected[firstIndex] >= firstLead) firstIndex--; firstModel.addSelectionInterval(firstsSelected[firstIndex], firstsSelected[firstIndex]); secondModel.addSelectionInterval(secondLead, secondLead); } }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
||
void advanceSingleSelection (ListSelectionModel firstModel, int firstMax,
|
void advanceSingleSelection(ListSelectionModel firstModel, int firstMax,
|
void advanceSingleSelection (ListSelectionModel firstModel, int firstMax, ListSelectionModel secondModel, int secondMax, boolean reverse) { // for TABs, "first" corresponds to columns and "seconds" to rows. // the opposite is true for ENTERs int firstLead = firstModel.getLeadSelectionIndex(); int secondLead = secondModel.getLeadSelectionIndex(); // if we are going backwards subtract 2 because we later add 1 // for a net change of -1 if (reverse && (firstLead == 0)) { // check if we have to wrap around if (secondLead == 0) secondLead += secondMax + 1; secondLead -= 2; } // do we have to wrap the "seconds"? if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax)) secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1), (secondLead + 1)%(secondMax + 1)); // if not, just reselect the current lead else secondModel.setSelectionInterval(secondLead, secondLead); // if we are going backwards, subtract 2 because we add 1 later // for net change of -1 if (reverse) { // check for wraparound if (firstLead == 0) firstLead += firstMax + 1; firstLead -= 2; } // select the next "first" firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1), (firstLead + 1)%(firstMax + 1)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1), (secondLead + 1)%(secondMax + 1));
|
secondModel.setSelectionInterval((secondLead + 1) % (secondMax + 1), (secondLead + 1) % (secondMax + 1));
|
void advanceSingleSelection (ListSelectionModel firstModel, int firstMax, ListSelectionModel secondModel, int secondMax, boolean reverse) { // for TABs, "first" corresponds to columns and "seconds" to rows. // the opposite is true for ENTERs int firstLead = firstModel.getLeadSelectionIndex(); int secondLead = secondModel.getLeadSelectionIndex(); // if we are going backwards subtract 2 because we later add 1 // for a net change of -1 if (reverse && (firstLead == 0)) { // check if we have to wrap around if (secondLead == 0) secondLead += secondMax + 1; secondLead -= 2; } // do we have to wrap the "seconds"? if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax)) secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1), (secondLead + 1)%(secondMax + 1)); // if not, just reselect the current lead else secondModel.setSelectionInterval(secondLead, secondLead); // if we are going backwards, subtract 2 because we add 1 later // for net change of -1 if (reverse) { // check for wraparound if (firstLead == 0) firstLead += firstMax + 1; firstLead -= 2; } // select the next "first" firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1), (firstLead + 1)%(firstMax + 1)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1), (firstLead + 1)%(firstMax + 1));
|
firstModel.setSelectionInterval((firstLead + 1) % (firstMax + 1), (firstLead + 1) % (firstMax + 1));
|
void advanceSingleSelection (ListSelectionModel firstModel, int firstMax, ListSelectionModel secondModel, int secondMax, boolean reverse) { // for TABs, "first" corresponds to columns and "seconds" to rows. // the opposite is true for ENTERs int firstLead = firstModel.getLeadSelectionIndex(); int secondLead = secondModel.getLeadSelectionIndex(); // if we are going backwards subtract 2 because we later add 1 // for a net change of -1 if (reverse && (firstLead == 0)) { // check if we have to wrap around if (secondLead == 0) secondLead += secondMax + 1; secondLead -= 2; } // do we have to wrap the "seconds"? if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax)) secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1), (secondLead + 1)%(secondMax + 1)); // if not, just reselect the current lead else secondModel.setSelectionInterval(secondLead, secondLead); // if we are going backwards, subtract 2 because we add 1 later // for net change of -1 if (reverse) { // check for wraparound if (firstLead == 0) firstLead += firstMax + 1; firstLead -= 2; } // select the next "first" firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1), (firstLead + 1)%(firstMax + 1)); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
int getFirstVisibleColumnIndex()
|
int getFirstVisibleColumnIndex(JTable table)
|
int getFirstVisibleColumnIndex() { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); if (!or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); return table.columnAtPoint(r.getLocation()); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
int getFirstVisibleRowIndex()
|
int getFirstVisibleRowIndex(JTable table)
|
int getFirstVisibleRowIndex() { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); if (!or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); return table.rowAtPoint(r.getLocation()); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
int getLastVisibleColumnIndex()
|
int getLastVisibleColumnIndex(JTable table)
|
int getLastVisibleColumnIndex() { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); if (or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); return table.columnAtPoint(r.getLocation()); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
int getLastVisibleRowIndex()
|
int getLastVisibleRowIndex(JTable table)
|
int getLastVisibleRowIndex() { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); r.translate(0, (int) r.getHeight() - 1); if (or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); // The next if makes sure that we don't return -1 simply because // there is white space at the bottom of the table (ie, the display // area is larger than the table) if (table.rowAtPoint(r.getLocation()) == -1) { if (getFirstVisibleRowIndex() == -1) return -1; else return table.getModel().getRowCount() - 1; } return table.rowAtPoint(r.getLocation()); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
if (getFirstVisibleRowIndex() == -1)
|
if (getFirstVisibleRowIndex(table) == -1)
|
int getLastVisibleRowIndex() { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); r.translate(0, (int) r.getHeight() - 1); if (or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); // The next if makes sure that we don't return -1 simply because // there is white space at the bottom of the table (ie, the display // area is larger than the table) if (table.rowAtPoint(r.getLocation()) == -1) { if (getFirstVisibleRowIndex() == -1) return -1; else return table.getModel().getRowCount() - 1; } return table.rowAtPoint(r.getLocation()); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource();
|
InputMap inputMap = (InputMap) SharedUIDefaults.get("Table.ancestorInputMap"); SwingUtilities.replaceUIInputMap(table, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
|
protected void installKeyboardActions() { InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMapUIResource(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair for (int i = 0; i < keys.length; i++) { KeyStroke stroke = (KeyStroke)keys[i]; String actionString = (String) ancestorMap.get(stroke); parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString); parentActionMap.put (actionString, new ActionListenerProxy (action, actionString)); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
ActionMap parentActionMap = new ActionMapUIResource(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); for (int i = 0; i < keys.length; i++) { KeyStroke stroke = (KeyStroke)keys[i]; String actionString = (String) ancestorMap.get(stroke);
|
SwingUtilities.replaceUIActionMap(table, getActionMap());
|
protected void installKeyboardActions() { InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMapUIResource(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair for (int i = 0; i < keys.length; i++) { KeyStroke stroke = (KeyStroke)keys[i]; String actionString = (String) ancestorMap.get(stroke); parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString); parentActionMap.put (actionString, new ActionListenerProxy (action, actionString)); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString); parentActionMap.put (actionString, new ActionListenerProxy (action, actionString)); } parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap);
|
protected void installKeyboardActions() { InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMapUIResource(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair for (int i = 0; i < keys.length; i++) { KeyStroke stroke = (KeyStroke)keys[i]; String actionString = (String) ancestorMap.get(stroke); parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString); parentActionMap.put (actionString, new ActionListenerProxy (action, actionString)); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
|
table = (JTable)comp;
|
table = (JTable) comp;
|
public void installUI(JComponent comp) { table = (JTable)comp; rendererPane = new CellRendererPane(); table.add(rendererPane); installDefaults(); installKeyboardActions(); installListeners(); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
int [] widths = new int[cn+1]; for (int i = c0; i <=cn ; i++)
|
int[] widths = new int[cn + 1]; for (int i = c0; i <= cn; i++)
|
public void paint(Graphics gfx, JComponent ignored) { int ncols = table.getColumnCount(); int nrows = table.getRowCount(); if (nrows == 0 || ncols == 0) return; Rectangle clip = gfx.getClipBounds(); // Determine the range of cells that are within the clip bounds. Point p1 = new Point(clip.x, clip.y); int c0 = table.columnAtPoint(p1); if (c0 == -1) c0 = 0; int r0 = table.rowAtPoint(p1); if (r0 == -1) r0 = 0; Point p2 = new Point(clip.x + clip.width, clip.y + clip.height); int cn = table.columnAtPoint(p2); if (cn == -1) cn = table.getColumnCount() - 1; int rn = table.rowAtPoint(p2); if (rn == -1) rn = table.getRowCount() - 1; int columnMargin = table.getColumnModel().getColumnMargin(); int rowMargin = table.getRowMargin(); TableColumnModel cmodel = table.getColumnModel(); int [] widths = new int[cn+1]; for (int i = c0; i <=cn ; i++) { widths[i] = cmodel.getColumn(i).getWidth() - columnMargin; } Rectangle bounds = table.getCellRect(r0, c0, false); // The left boundary of the area being repainted. int left = bounds.x; // The top boundary of the area being repainted. int top = bounds.y; // The bottom boundary of the area being repainted. int bottom; // paint the cell contents Color grid = table.getGridColor(); for (int r = r0; r <= rn; ++r) { for (int c = c0; c <= cn; ++c) { bounds.width = widths[c]; paintCell(gfx, r, c, bounds, table.getCellRenderer(r, c)); bounds.x += widths[c] + columnMargin; } bounds.x = left; bounds.y += table.getRowHeight(r); // Update row height for tables with custom heights. bounds.height = table.getRowHeight(r + 1) - rowMargin; } bottom = bounds.y - rowMargin; // paint vertical grid lines if (grid != null && table.getShowVerticalLines()) { Color save = gfx.getColor(); gfx.setColor(grid); int x = left - columnMargin; for (int c = c0; c <= cn; ++c) { // The vertical grid is draw right from the cells, so we // add before drawing. x += widths[c] + columnMargin; gfx.drawLine(x, top, x, bottom); } gfx.setColor(save); } // paint horizontal grid lines if (grid != null && table.getShowHorizontalLines()) { Color save = gfx.getColor(); gfx.setColor(grid); int y = top - rowMargin; for (int r = r0; r <= rn; ++r) { // The horizontal grid is draw below the cells, so we // add before drawing. y += table.getRowHeight(r); gfx.drawLine(left, y, p2.x, y); } gfx.setColor(save); } }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
protected void uninstallDefaults() { // TODO: this method used to do the following which is not // quite right (at least it breaks apps that run fine with the // JDK): // // table.setFont(null); // table.setGridColor(null); // table.setForeground(null); // table.setBackground(null); // table.setSelectionForeground(null); // table.setSelectionBackground(null); // // This would leave the component in a corrupt state, which is // not acceptable. A possible solution would be to have component // level defaults installed, that get overridden by the UI defaults // and get restored in this method. I am not quite sure about this // though. / Roman Kennke }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
||
throws NotImplementedException
|
protected void uninstallKeyboardActions() throws NotImplementedException { // TODO: Implement this properly. }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
|
SwingUtilities.replaceUIInputMap(table, JComponent. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIActionMap(table, null);
|
protected void uninstallKeyboardActions() throws NotImplementedException { // TODO: Implement this properly. }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
|
|
ScrollPane(int scrollbarDisplayPolicy)
|
ScrollPane()
|
ScrollPane(int scrollbarDisplayPolicy){ if (GraphicsEnvironment.isHeadless ()) throw new HeadlessException (); this.scrollbarDisplayPolicy = scrollbarDisplayPolicy; if (scrollbarDisplayPolicy != SCROLLBARS_ALWAYS && scrollbarDisplayPolicy != SCROLLBARS_AS_NEEDED && scrollbarDisplayPolicy != SCROLLBARS_NEVER) throw new IllegalArgumentException("Bad scrollbarDisplayPolicy: " + scrollbarDisplayPolicy); if (scrollbarDisplayPolicy != SCROLLBARS_NEVER) { hAdjustable = new ScrollPaneAdjustable (this, Scrollbar.HORIZONTAL); vAdjustable = new ScrollPaneAdjustable (this, Scrollbar.VERTICAL); } wheelScrollingEnabled = true; // Default size. setSize(100,100);}
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c0997df57feec0722568b1f1cc390b475c418086/ScrollPane.java/clean/core/src/classpath/java/java/awt/ScrollPane.java
|
if (GraphicsEnvironment.isHeadless ()) throw new HeadlessException (); this.scrollbarDisplayPolicy = scrollbarDisplayPolicy; if (scrollbarDisplayPolicy != SCROLLBARS_ALWAYS && scrollbarDisplayPolicy != SCROLLBARS_AS_NEEDED && scrollbarDisplayPolicy != SCROLLBARS_NEVER) throw new IllegalArgumentException("Bad scrollbarDisplayPolicy: " + scrollbarDisplayPolicy); if (scrollbarDisplayPolicy != SCROLLBARS_NEVER) { hAdjustable = new ScrollPaneAdjustable (this, Scrollbar.HORIZONTAL); vAdjustable = new ScrollPaneAdjustable (this, Scrollbar.VERTICAL); } wheelScrollingEnabled = true; setSize(100,100);
|
this(SCROLLBARS_AS_NEEDED);
|
ScrollPane(int scrollbarDisplayPolicy){ if (GraphicsEnvironment.isHeadless ()) throw new HeadlessException (); this.scrollbarDisplayPolicy = scrollbarDisplayPolicy; if (scrollbarDisplayPolicy != SCROLLBARS_ALWAYS && scrollbarDisplayPolicy != SCROLLBARS_AS_NEEDED && scrollbarDisplayPolicy != SCROLLBARS_NEVER) throw new IllegalArgumentException("Bad scrollbarDisplayPolicy: " + scrollbarDisplayPolicy); if (scrollbarDisplayPolicy != SCROLLBARS_NEVER) { hAdjustable = new ScrollPaneAdjustable (this, Scrollbar.HORIZONTAL); vAdjustable = new ScrollPaneAdjustable (this, Scrollbar.VERTICAL); } wheelScrollingEnabled = true; // Default size. setSize(100,100);}
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c0997df57feec0722568b1f1cc390b475c418086/ScrollPane.java/clean/core/src/classpath/java/java/awt/ScrollPane.java
|
if (!isDisplayable ())
|
if (peer != null)
|
addNotify(){ if (!isDisplayable ()) return; setPeer((ComponentPeer)getToolkit().createScrollPane(this)); super.addNotify(); Component[] list = getComponents(); if (list != null && list.length > 0 && ! (list[0] instanceof Panel)) { Panel panel = new Panel(); panel.setLayout(new BorderLayout()); panel.add(list[0], BorderLayout.CENTER); add(panel); }}
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c0997df57feec0722568b1f1cc390b475c418086/ScrollPane.java/clean/core/src/classpath/java/java/awt/ScrollPane.java
|
setScrollPosition(int x, int y)
|
setScrollPosition(Point scrollPosition) throws IllegalArgumentException
|
setScrollPosition(int x, int y){ Adjustable h = getHAdjustable(); Adjustable v = getVAdjustable(); if (h != null) h.setValue(x); if (v != null) v.setValue(y); ScrollPanePeer spp = (ScrollPanePeer)getPeer(); if (spp != null) spp.setScrollPosition(x, y);}
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c0997df57feec0722568b1f1cc390b475c418086/ScrollPane.java/clean/core/src/classpath/java/java/awt/ScrollPane.java
|
Adjustable h = getHAdjustable(); Adjustable v = getVAdjustable(); if (h != null) h.setValue(x); if (v != null) v.setValue(y); ScrollPanePeer spp = (ScrollPanePeer)getPeer(); if (spp != null) spp.setScrollPosition(x, y);
|
setScrollPosition(scrollPosition.x, scrollPosition.y);
|
setScrollPosition(int x, int y){ Adjustable h = getHAdjustable(); Adjustable v = getVAdjustable(); if (h != null) h.setValue(x); if (v != null) v.setValue(y); ScrollPanePeer spp = (ScrollPanePeer)getPeer(); if (spp != null) spp.setScrollPosition(x, y);}
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c0997df57feec0722568b1f1cc390b475c418086/ScrollPane.java/clean/core/src/classpath/java/java/awt/ScrollPane.java
|
return defaults.getIcon("RadioButton.icon");
|
return defaults.getIcon(getPropertyPrefix() + ".icon");
|
public Icon getDefaultIcon() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); return defaults.getIcon("RadioButton.icon"); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c4eda97e6e5feb8e7650d83d5066d85580f1249c/BasicRadioButtonUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicRadioButtonUI.java
|
Package( String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, URL sealed) {
|
Package(String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, URL sealed) {
|
Package( String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, URL sealed) { if (name == null) throw new IllegalArgumentException("null Package name"); this.name = name; this.implTitle = implTitle; this.implVendor = implVendor; this.implVersion = implVersion; this.specTitle = specTitle; this.specVendor = specVendor; this.specVersion = specVersion; this.sealed = sealed; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
Package( String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, URL sealed) { if (name == null) throw new IllegalArgumentException("null Package name"); this.name = name; this.implTitle = implTitle; this.implVendor = implVendor; this.implVersion = implVersion; this.specTitle = specTitle; this.specVendor = specVendor; this.specVersion = specVersion; this.sealed = sealed; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
||
public String getImplementationTitle() {
|
public String getImplementationTitle() {
|
public String getImplementationTitle() { return implTitle; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String getImplementationVendor() {
|
public String getImplementationVendor() {
|
public String getImplementationVendor() { return implVendor; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String getImplementationVersion() {
|
public String getImplementationVersion() {
|
public String getImplementationVersion() { return implVersion; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String getName() {
|
public String getName() {
|
public String getName() { return name; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public static Package getPackage(String name) {
|
public static Package getPackage(String name) {
|
public static Package getPackage(String name) { // Get the caller's classloader/* Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); return cl != null ? cl.getPackage(name) : null;*/ return null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
/* Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); return cl != null ? cl.getPackage(name) : null;*/ return null;
|
ClassLoader cl = VMSecurityManager.currentClassLoader(); return cl != null ? cl.getPackage(name) : null;
|
public static Package getPackage(String name) { // Get the caller's classloader/* Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); return cl != null ? cl.getPackage(name) : null;*/ return null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public static Package[] getPackages() {
|
public static Package[] getPackages() {
|
public static Package[] getPackages() { // Get the caller's classloader /*Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); // Sun's implementation returns the packages loaded by the bootstrap // classloader if cl is null, but right now our bootstrap classloader // does not create any Packages. return cl != null ? cl.getPackages() : new Package[0]; */ return null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
/*Class c = VMSecurityManager.getClassContext()[1];
|
Class c = VMSecurityManager.getClassContext()[1];
|
public static Package[] getPackages() { // Get the caller's classloader /*Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); // Sun's implementation returns the packages loaded by the bootstrap // classloader if cl is null, but right now our bootstrap classloader // does not create any Packages. return cl != null ? cl.getPackages() : new Package[0]; */ return null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
*/ return null;
|
public static Package[] getPackages() { // Get the caller's classloader /*Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); // Sun's implementation returns the packages loaded by the bootstrap // classloader if cl is null, but right now our bootstrap classloader // does not create any Packages. return cl != null ? cl.getPackages() : new Package[0]; */ return null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
|
public String getSpecificationTitle() {
|
public String getSpecificationTitle() {
|
public String getSpecificationTitle() { return specTitle; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String getSpecificationVendor() {
|
public String getSpecificationVendor() {
|
public String getSpecificationVendor() { return specVendor; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String getSpecificationVersion() {
|
public String getSpecificationVersion() {
|
public String getSpecificationVersion() { return specVersion; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public int hashCode() {
|
public int hashCode() {
|
public int hashCode() { return name.hashCode(); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public boolean isCompatibleWith(String version) {
|
public boolean isCompatibleWith(String version) {
|
public boolean isCompatibleWith(String version) { StringTokenizer versionTokens = new StringTokenizer(version, "."); StringTokenizer specTokens = new StringTokenizer(specVersion, "."); try { while (versionTokens.hasMoreElements()) { int vers = Integer.parseInt(versionTokens.nextToken()); int spec = Integer.parseInt(specTokens.nextToken()); if (spec < vers) return false; else if (spec > vers) return true; // They must be equal, next Token please! } } catch (NoSuchElementException e) { // This must have been thrown by spec.nextToken() so return false. return false; } // They must have been exactly the same version. // Or the specVersion has more subversions. That is also good. return true; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
try { while (versionTokens.hasMoreElements()) {
|
try { while (versionTokens.hasMoreElements()) {
|
public boolean isCompatibleWith(String version) { StringTokenizer versionTokens = new StringTokenizer(version, "."); StringTokenizer specTokens = new StringTokenizer(specVersion, "."); try { while (versionTokens.hasMoreElements()) { int vers = Integer.parseInt(versionTokens.nextToken()); int spec = Integer.parseInt(specTokens.nextToken()); if (spec < vers) return false; else if (spec > vers) return true; // They must be equal, next Token please! } } catch (NoSuchElementException e) { // This must have been thrown by spec.nextToken() so return false. return false; } // They must have been exactly the same version. // Or the specVersion has more subversions. That is also good. return true; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
public boolean isCompatibleWith(String version) { StringTokenizer versionTokens = new StringTokenizer(version, "."); StringTokenizer specTokens = new StringTokenizer(specVersion, "."); try { while (versionTokens.hasMoreElements()) { int vers = Integer.parseInt(versionTokens.nextToken()); int spec = Integer.parseInt(specTokens.nextToken()); if (spec < vers) return false; else if (spec > vers) return true; // They must be equal, next Token please! } } catch (NoSuchElementException e) { // This must have been thrown by spec.nextToken() so return false. return false; } // They must have been exactly the same version. // Or the specVersion has more subversions. That is also good. return true; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public boolean isSealed() {
|
public boolean isSealed() {
|
public boolean isSealed() { return sealed != null; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
public String toString() { return "package " + name + (specTitle == null ? "" : ", " + specTitle) + (specVersion == null ? "" : ", version " + specVersion);
|
public String toString() { return ("package " + name + (specTitle == null ? "" : ", " + specTitle) + (specVersion == null ? "" : ", version " + specVersion));
|
public String toString() { return "package " + name + (specTitle == null ? "" : ", " + specTitle) + (specVersion == null ? "" : ", version " + specVersion); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b2ed890086e708f00d163f3e8514bfa8b353f662/Package.java/buggy/core/src/classpath/java/java/lang/Package.java
|
this.parentArray = parentArray; init(); }
|
this.parentArray = parentArray; init(); }
|
public DataCube(Array parentArray) { this.parentArray = parentArray; init(); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
Log.error("in DataCube, addData(), function body empty, returning 0"); return 0; }
|
Log.error("in DataCube, addData(), function body empty, returning 0"); return 0; }
|
public double addData (Locator locator, double numValue) { Log.error("in DataCube, addData(), function body empty, returning 0"); return 0; }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
Number dim = getDimension(); if (dim == null) { Log.error(" in DataCube, incrementDimentsion, the dimension is undef"); return null; } else return setDimension(new Integer(dim.intValue()-1));
|
Number dim = getDimension(); if (dim == null) { Log.error(" in DataCube, incrementDimentsion, the dimension is undef"); return null;
|
public Number decrementDimension() { Number dim = getDimension(); if (dim == null) { Log.error(" in DataCube, incrementDimentsion, the dimension is undef"); return null; } else return setDimension(new Integer(dim.intValue()-1)); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
else return setDimension(new Integer(dim.intValue()-1)); }
|
public Number decrementDimension() { Number dim = getDimension(); if (dim == null) { Log.error(" in DataCube, incrementDimentsion, the dimension is undef"); return null; } else return setDimension(new Integer(dim.intValue()-1)); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
return (Number) ((XMLAttribute) attribHash.get("dimension")).getAttribValue(); }
|
return (Number) ((XMLAttribute) attribHash.get("dimension")).getAttribValue(); }
|
public Number getDimension() { return (Number) ((XMLAttribute) attribHash.get("dimension")).getAttribValue(); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
public double getDoubleData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
return java.lang.reflect.Array.getDouble(data.get(1), index); } catch (Exception e) { throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1);
|
return java.lang.reflect.Array.getDouble(data.get(1), index);
|
public double getDoubleData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
public double getDoubleData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
||
int index0 = locator.getAxisLocation((Axis) axisList.get(1)); int index1 = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1); } catch (Exception e) { throw new NoDataException(); } }
|
public double getDoubleData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getDouble(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
public int getIntData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
return java.lang.reflect.Array.getInt(data.get(1), index); } catch (Exception e) { throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1);
|
return java.lang.reflect.Array.getInt(data.get(1), index);
|
public int getIntData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
public int getIntData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
||
int index0 = locator.getAxisLocation((Axis) axisList.get(1)); int index1 = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1); } catch (Exception e) { throw new NoDataException(); } }
|
public int getIntData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.getInt(data.get(1), index); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(current.get(2*index0+1), index1); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
public List getMaxDataIndex() { Log.debug("in DataCube, getMaxDataIndex(), function body empty, returning null now"); return null;
|
public int[] getMaxDataIndex() { List axes = parentArray.getAxisList(); int[] maxDataIndices = new int[axes.size()]; for(int i = 0; i < axes.size(); i++) { maxDataIndices[i]=((Axis) axes.get(i)).getLength();
|
public List getMaxDataIndex() { Log.debug("in DataCube, getMaxDataIndex(), function body empty, returning null now"); return null; }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
attribHash.put("maxDimensionIndex", maxDataIndices); return maxDataIndices; }
|
public List getMaxDataIndex() { Log.debug("in DataCube, getMaxDataIndex(), function body empty, returning null now"); return null; }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
return parentArray; }
|
return parentArray; }
|
public Array getParentArray() { return parentArray; }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1)
|
public String getStringData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(data.get(1), index).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
return java.lang.reflect.Array.get(data.get(1), index).toString(); } catch (Exception e) { throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString();
|
return java.lang.reflect.Array.get(data.get(1), index).toString();
|
public String getStringData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(data.get(1), index).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
public String getStringData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(data.get(1), index).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
||
int index0 = locator.getAxisLocation((Axis) axisList.get(1)); int index1 = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString(); } catch (Exception e) { throw new NoDataException(); } }
|
public String getStringData(Locator locator) throws NoDataException{ List axisList = parentArray.getAxisList(); List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { int index = locator.getAxisLocation((Axis) axisList.get(0)); try { if (java.lang.reflect.Array.getByte(data.get(0), index) !=1) throw new NoDataException(); return java.lang.reflect.Array.get(data.get(1), index).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); current = (List) current.get(index); if (current == null) { //the location we try to access is not allocated, no data throw new NoDataException(); } } int index0 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-2)); int index1 = locator.getAxisLocation((Axis) axisList.get(numOfAxis-1)); try { if (java.lang.reflect.Array.getByte(current.get(2*index0), index1) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(current.get(2*index0+1), index1).toString(); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
Number dim = getDimension(); if (dim.intValue()==0) { data.add(null); data.add(null); return setDimension(new Integer(1)); }
|
Number dim = getDimension(); if (dim.intValue()==0) { data.add(null); data.add(null); return setDimension(new Integer(1)); }
|
public Number incrementDimension(Axis axis) { Number dim = getDimension(); if (dim.intValue()==0) { //add first dimension data.add(null); data.add(null); return setDimension(new Integer(1)); } if (dim.intValue() == 1) { //add second dimension int length = axis.getLength(); for (int i = 2; i < 2*length; i++) data.add(i,null); } else{ //dimension >= 2 List oldData = data; int length = axis.getLength(); data = Collections.synchronizedList(new ArrayList(length)); data.add(0,oldData); for (int i = 1; i < length; i++) data.add(i,null); } return setDimension(new Integer(dim.intValue()+1)); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
if (dim.intValue() == 1) { int length = axis.getLength(); for (int i = 2; i < 2*length; i++) data.add(i,null); } else{ List oldData = data; int length = axis.getLength(); data = Collections.synchronizedList(new ArrayList(length)); data.add(0,oldData); for (int i = 1; i < length; i++) data.add(i,null); } return setDimension(new Integer(dim.intValue()+1));
|
if (dim.intValue() == 1) { int length = axis.getLength(); for (int i = 2; i < 2*length; i++) data.add(i,null);
|
public Number incrementDimension(Axis axis) { Number dim = getDimension(); if (dim.intValue()==0) { //add first dimension data.add(null); data.add(null); return setDimension(new Integer(1)); } if (dim.intValue() == 1) { //add second dimension int length = axis.getLength(); for (int i = 2; i < 2*length; i++) data.add(i,null); } else{ //dimension >= 2 List oldData = data; int length = axis.getLength(); data = Collections.synchronizedList(new ArrayList(length)); data.add(0,oldData); for (int i = 1; i < length; i++) data.add(i,null); } return setDimension(new Integer(dim.intValue()+1)); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
else{ List oldData = data; int length = axis.getLength(); data = Collections.synchronizedList(new ArrayList(length)); data.add(0,oldData); for (int i = 1; i < length; i++) data.add(i,null); } return setDimension(new Integer(dim.intValue()+1)); }
|
public Number incrementDimension(Axis axis) { Number dim = getDimension(); if (dim.intValue()==0) { //add first dimension data.add(null); data.add(null); return setDimension(new Integer(1)); } if (dim.intValue() == 1) { //add second dimension int length = axis.getLength(); for (int i = 2; i < 2*length; i++) data.add(i,null); } else{ //dimension >= 2 List oldData = data; int length = axis.getLength(); data = Collections.synchronizedList(new ArrayList(length)); data.add(0,oldData); for (int i = 1; i < length; i++) data.add(i,null); } return setDimension(new Integer(dim.intValue()+1)); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
private void init() { classXDFNodeName = "data"; // order matters! these are in *reverse* order of their // occurence in the XDF DTD attribOrder.add(0,"maxDimensionIndex"); attribOrder.add(0,"dimension"); attribOrder.add(0,"compression"); attribOrder.add(0,"checksum"); attribOrder.add(0,"href"); //set up the attribute hashtable key with the default initial value attribHash.put("maxDimensionIndex", new XMLAttribute(Collections.synchronizedList(new ArrayList()), Constants.LIST_TYPE)); attribHash.put("dimension", new XMLAttribute(new Integer(0), Constants.NUMBER_TYPE)); attribHash.put("compression", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("checksum", new XMLAttribute(new Double(0), Constants.NUMBER_TYPE)); //double check attribHash.put("href", new XMLAttribute(null, Constants.STRING_TYPE)); };
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
||
attribHash.put("compression", new XMLAttribute(null, Constants.STRING_TYPE));
|
attribHash.put("compression", new XMLAttribute(null, Constants.STRING_TYPE));
|
private void init() { classXDFNodeName = "data"; // order matters! these are in *reverse* order of their // occurence in the XDF DTD attribOrder.add(0,"maxDimensionIndex"); attribOrder.add(0,"dimension"); attribOrder.add(0,"compression"); attribOrder.add(0,"checksum"); attribOrder.add(0,"href"); //set up the attribute hashtable key with the default initial value attribHash.put("maxDimensionIndex", new XMLAttribute(Collections.synchronizedList(new ArrayList()), Constants.LIST_TYPE)); attribHash.put("dimension", new XMLAttribute(new Integer(0), Constants.NUMBER_TYPE)); attribHash.put("compression", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("checksum", new XMLAttribute(new Double(0), Constants.NUMBER_TYPE)); //double check attribHash.put("href", new XMLAttribute(null, Constants.STRING_TYPE)); };
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
Log.error("in DataCube, removeData(), function body empty, returning 0"); return 0; }
|
Log.error("in DataCube, removeData(), function body empty, returning 0"); return 0; }
|
public double removeData (Locator locator, double numValue) { Log.error("in DataCube, removeData(), function body empty, returning 0"); return 0; }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis);
|
List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
if (data.get(0) == null) { data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]);
|
if (data.get(0) == null) { data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index) { toExpandLength = index+1;
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index) { toExpandLength = index+1; } byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; } try { java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) prev.add(null); current = (List) prev.get(index); if (current == null) { int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { current.add(null); } int newCoordinate = 2*index0; if (current.get(newCoordinate) == null) { current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } byte[] oldByteArray = (byte[]) current.get(newCoordinate);
|
byte[] oldByteArray = (byte[]) current.get(0);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray);
|
newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
double[] oldArray = (double[]) current.get(newCoordinate+1);
|
double[] oldArray = (double[]) current.get(1);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray);
|
newArray[k]=oldArray[k]; current.set(1, newArray);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
try { byte realValue = 1; java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue);
|
try { byte b = 1; java.lang.reflect.Array.setByte(current.get(0), index, b); java.lang.reflect.Array.setDouble(current.get(1), index, numValue);
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
Axis secondAxis = (Axis) axisList.get(1); Axis firstAxis = (Axis) axisList.get(0); int index0 = locator.getAxisLocation(secondAxis ); int index1 = locator.getAxisLocation(firstAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { current.add(null); } int newCoordinate = 2*index0; if (current.get(newCoordinate) == null) { current.set(newCoordinate, new byte[firstAxis.getLength()]); current.set(newCoordinate+1, new double[firstAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; } try { byte realValue = 1; java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
public double setData (Locator locator, double numValue) throws SetDataException{ List axisList = parentArray.getAxisList(); List prev = data; List current = data; int numOfAxis = axisList.size(); if (numOfAxis == 1) { Axis axis = (Axis) axisList.get(0); int index = locator.getAxisLocation(axis); if (data.get(0) == null) { //used to track if the corresponding cell stores valid data data.set(0,new byte[axis.getLength()]); data.set(1,new double[axis.getLength()]); } int arrayLength = ((byte[]) data.get(0)).length; if ( arrayLength< index+1) { //have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; //use 1.3 as the size multiplier if (toExpandLength < index) { //expand to the size of index (index > arrayLength*1.3) toExpandLength = index+1; } //copy the old byte array into the expanded one byte[] oldByteArray = (byte[]) current.get(0); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(0, newByteArray); oldByteArray = null; //force garbage collection //copy the old int array into the expanded one double[] oldArray = (double[]) current.get(1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(1, newArray); oldArray = null; //force garbage collection } try { //indicates its corresponding data cell holds vaid data java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1")); //put the data into the requested data cell java.lang.reflect.Array.setDouble(current.get(1), index, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } } // end of if (numOfAxis == 1) //contructs arraylist of arraylist to represent the multi-dimension for (int i = 0; i < numOfAxis-2; i++) { Axis axis = (Axis) axisList.get(i); int index = locator.getAxisLocation(axis); int end = axis.getLength() - prev.size(); for (i = 0; i < end ; i++) //expand it if prev.size < index+1 prev.add(null); current = (List) prev.get(index); if (current == null) { //expand the datacube int length = ((Axis) axisList.get(i+1)).getLength(); current = new ArrayList(length); for (int j = 0; j < length; j++) current.add(null); prev.set(index, current); } prev = current; } //special handling of the inner most two dimensions Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2); Axis lastAxis = (Axis) axisList.get(numOfAxis-1); int index0 = locator.getAxisLocation(lastTo2ndAxis ); int index1 = locator.getAxisLocation(lastAxis ); int stop = 2*(index0+1)-current.size(); for (int i = 0; i<stop; i++) { //expand it if current.size < 2*(index0+1) current.add(null); } int newCoordinate = 2*index0; //internal index = 2*index0 if (current.get(newCoordinate) == null) { //expand array of byte and int current.set(newCoordinate, new byte[lastAxis.getLength()]); current.set(newCoordinate+1, new double[lastAxis.getLength()]); } int arrayLength = ((double[]) current.get(newCoordinate+1)).length; if ( arrayLength< index1+1) { ////have to expand the array int toExpandLength = (int) (arrayLength*1.3)+1; if (toExpandLength < index1) { toExpandLength = index1+1; } //copy old byte array to the expanded new one byte[] oldByteArray = (byte[]) current.get(newCoordinate); byte[] newByteArray = new byte[toExpandLength]; for (int k = 0; k <oldByteArray.length; k++) newByteArray[k]=oldByteArray[k]; current.set(newCoordinate, newByteArray); oldByteArray = null; //force garbage collection //copy old int array to the expanded new one double[] oldArray = (double[]) current.get(newCoordinate+1); double[] newArray = new double[toExpandLength]; for (int k = 0; k <oldArray.length; k++) newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray); oldArray = null; //force garbage collection } try { //set data byte realValue = 1; //indicate its corresponding datacell holds valid data java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue); //put data into the requested datacell java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue); return numValue; } catch (Exception e) { throw new SetDataException(); } }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
|
return (Number) ((XMLAttribute)attribHash.get("dimension")).setAttribValue(dimension); }
|
return (Number) ((XMLAttribute)attribHash.get("dimension")).setAttribValue(dimension); }
|
private Number setDimension(Number dimension) { return (Number) ((XMLAttribute)attribHash.get("dimension")).setAttribValue(dimension); }
|
4483 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/4483/c4ac2dbbec64b548fdd0d495ae09a5a2e8b76a11/DataCube.java/clean/src/gov/nasa/gsfc/adc/xdf/DataCube.java
|
y0 += epsilon;
|
y0 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0))
|
y1 -= epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, epsilon, 0.0, distance, 0.0))
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y0 += epsilon;
|
y0 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0))
|
y1 -= epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, epsilon, 0.0, distance, 0.0))
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y0 += epsilon;
|
y0 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0))
|
y1 -= epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, epsilon, 0.0, distance, 0.0))
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y0 += epsilon;
|
y0 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y2 += epsilon;
|
y2 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y0 += epsilon;
|
y0 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
y3 += epsilon;
|
y3 -= epsilon;
|
private int evaluateCrossings(double x, double y, boolean neg, boolean useYaxis, double distance) { float cx = 0.0f; float cy = 0.0f; float firstx = 0.0f; float firsty = 0.0f; int negative = (neg) ? -1 : 1; double x0; double x1; double x2; double x3; double y0; double y1; double y2; double y3; double[] r = new double[4]; int nRoots; double epsilon = 0.0; int pos = 0; int windingNumber = 0; boolean pathStarted = false; if (index == 0) return (0); if (useYaxis) { float[] swap1; swap1 = ypoints; ypoints = xpoints; xpoints = swap1; double swap2; swap2 = y; y = x; x = swap2; } /* Get a value which is hopefully small but not insignificant relative the path. */ epsilon = ypoints[0] * 1E-9; pos = 0; while (pos < index) { switch (types[pos]) { case PathIterator.SEG_MOVETO: if (pathStarted) // close old path { x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; } cx = firstx = xpoints[pos] - (float) x; cy = firsty = ypoints[pos++] - (float) y; pathStarted = true; break; case PathIterator.SEG_CLOSE: x0 = cx; y0 = cy; x1 = firstx; y1 = firsty; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = firstx; cy = firsty; pos++; pathStarted = false; break; case PathIterator.SEG_LINETO: x0 = cx; y0 = cy; x1 = xpoints[pos] - (float) x; y1 = ypoints[pos++] - (float) y; if (y0 == 0.0) y0 += epsilon; if (y1 == 0.0) y1 += epsilon; if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) windingNumber += (y1 < y0) ? 1 : negative; cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_QUADTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y2 == 0.0) y2 += epsilon; r[0] = y0; r[1] = 2 * (y1 - y0); r[2] = (y2 - 2 * y1 + y0); /* degenerate roots (=tangent points) do not contribute to the winding number. */ if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0f && t < 1.0f) { double crossing = t * t * (x2 - 2 * x1 + x0) + 2 * t * (x1 - x0) + x0; if (crossing >= 0.0 && crossing <= distance) windingNumber += (2 * t * (y2 - 2 * y1 + y0) + 2 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; case PathIterator.SEG_CUBICTO: x0 = cx; y0 = cy; x1 = xpoints[pos] - x; y1 = ypoints[pos++] - y; x2 = xpoints[pos] - x; y2 = ypoints[pos++] - y; x3 = xpoints[pos] - x; y3 = ypoints[pos++] - y; /* check if curve may intersect X+ axis. */ if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) { if (y0 == 0.0) y0 += epsilon; if (y3 == 0.0) y3 += epsilon; r[0] = y0; r[1] = 3 * (y1 - y0); r[2] = 3 * (y2 + y0 - 2 * y1); r[3] = y3 - 3 * y2 + 3 * y1 - y0; if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { float t = (float) r[i]; if (t > 0.0 && t < 1.0) { double crossing = -(t * t * t) * (x0 - 3 * x1 + 3 * x2 - x3) + 3 * t * t * (x0 - 2 * x1 + x2) + 3 * t * (x1 - x0) + x0; if (crossing >= 0 && crossing <= distance) windingNumber += (3 * t * t * (y3 + 3 * y1 - 3 * y2 - y0) + 6 * t * (y0 - 2 * y1 + y2) + 3 * (y1 - y0) < 0) ? 1 : negative; } } } cx = xpoints[pos - 1] - (float) x; cy = ypoints[pos - 1] - (float) y; break; } } // swap coordinates back if (useYaxis) { float[] swap; swap = ypoints; ypoints = xpoints; xpoints = swap; } return (windingNumber); }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/560cf787ab92cba97cf57ce7b258e72947e5efbc/GeneralPath.java/buggy/core/src/classpath/java/java/awt/geom/GeneralPath.java
|
requestBodyNegotiationThreshold = 4096;
|
protected Request(HTTPConnection connection, String method, String path) { this.connection = connection; this.method = method; this.path = path; requestHeaders = new Headers(); responseHeaderHandlers = new HashMap(); requestBodyNegotiationThreshold = 4096; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/792415b1783f5e8798e64529a3048ed049193e55/Request.java/buggy/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java
|
|
if (contentLength > requestBodyNegotiationThreshold)
|
String expect = getHeader("Expect"); if (expect != null && expect.equals("100-continue"))
|
public Response dispatch() throws IOException { if (dispatched) { throw new ProtocolException("request already dispatched"); } final String CRLF = "\r\n"; final String HEADER_SEP = ": "; final String US_ASCII = "US-ASCII"; final String version = connection.getVersion(); Response response; int contentLength = -1; boolean retry = false; int attempts = 0; boolean expectingContinue = false; if (requestBodyWriter != null) { contentLength = requestBodyWriter.getContentLength(); if (contentLength > requestBodyNegotiationThreshold) { expectingContinue = true; setHeader("Expect", "100-continue"); } else { setHeader("Content-Length", Integer.toString(contentLength)); } } try { // Loop while authentication fails or continue do { retry = false; // Get socket output and input streams OutputStream out = connection.getOutputStream(); // Request line String requestUri = path; if (connection.isUsingProxy() && !"*".equals(requestUri) && !"CONNECT".equals(method)) { requestUri = getRequestURI(); } String line = method + ' ' + requestUri + ' ' + version + CRLF; out.write(line.getBytes(US_ASCII)); // Request headers for (Iterator i = requestHeaders.keySet().iterator(); i.hasNext(); ) { String name =(String) i.next(); String value =(String) requestHeaders.get(name); line = name + HEADER_SEP + value + CRLF; out.write(line.getBytes(US_ASCII)); } out.write(CRLF.getBytes(US_ASCII)); // Request body if (requestBodyWriter != null && !expectingContinue) { byte[] buffer = new byte[4096]; int len; int count = 0; requestBodyWriter.reset(); do { len = requestBodyWriter.write(buffer); if (len > 0) { out.write(buffer, 0, len); } count += len; } while (len > -1 && count < contentLength); } out.flush(); // Get response while(true) { response = readResponse(connection.getInputStream()); int sc = response.getCode(); if (sc == 401 && authenticator != null) { if (authenticate(response, attempts++)) { retry = true; } } else if (sc == 100) { if (expectingContinue) { requestHeaders.remove("Expect"); setHeader("Content-Length", Integer.toString(contentLength)); expectingContinue = false; retry = true; } else { // A conforming server can send an unsoliceted // Continue response but *should* not (RFC 2616 // sec 8.2.3). Ignore the bogus Continue // response and get the real response that // should follow continue; } } break; } } while (retry); } catch (IOException e) { connection.close(); throw e; } return response; }
|
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/792415b1783f5e8798e64529a3048ed049193e55/Request.java/buggy/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.