Skip to content

Commit

Permalink
fixed files form Chart #22
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 102647a commit 0298b7d
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions projects/Chart/22/org/jfree/data/KeyedObjects2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ public Object getObject(Comparable rowKey, Comparable columnKey) {
throw new UnknownKeyException("Column key (" + columnKey
+ ") not recognised.");
}
if (row >= 0) {
KeyedObjects rowData = (KeyedObjects) this.rows.get(row);
return rowData.getObject(columnKey);
int index = rowData.getIndex(columnKey);
if (index >= 0) {
return rowData.getObject(index);
}
else {
return null;
Expand Down Expand Up @@ -315,8 +316,29 @@ public void removeObject(Comparable rowKey, Comparable columnKey) {
}

// 2. check whether the column is now empty.
allNull = true;

for (int item = 0, itemCount = this.rows.size(); item < itemCount;
item++) {
row = (KeyedObjects) this.rows.get(item);
int columnIndex = row.getIndex(columnKey);
if (columnIndex >= 0 && row.getObject(columnIndex) != null) {
allNull = false;
break;
}
}

if (allNull) {
for (int item = 0, itemCount = this.rows.size(); item < itemCount;
item++) {
row = (KeyedObjects) this.rows.get(item);
int columnIndex = row.getIndex(columnKey);
if (columnIndex >= 0) {
row.removeValue(columnIndex);
}
}
this.columnKeys.remove(columnKey);
}
}

/**
Expand All @@ -342,6 +364,10 @@ public void removeRow(int rowIndex) {
*/
public void removeRow(Comparable rowKey) {
int index = getRowIndex(rowKey);
if (index < 0) {
throw new UnknownKeyException("Row key (" + rowKey
+ ") not recognised.");
}
removeRow(index);
}

Expand Down Expand Up @@ -375,7 +401,10 @@ public void removeColumn(Comparable columnKey) {
Iterator iterator = this.rows.iterator();
while (iterator.hasNext()) {
KeyedObjects rowData = (KeyedObjects) iterator.next();
rowData.removeValue(columnKey);
int i = rowData.getIndex(columnKey);
if (i >= 0) {
rowData.removeValue(i);
}
}
this.columnKeys.remove(columnKey);
}
Expand Down

0 comments on commit 0298b7d

Please sign in to comment.