com.anrisoftware.globalpom.spreadsheetimport.DefaultSpreadsheetDataTableModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of globalpomutils-data Show documentation
Show all versions of globalpomutils-data Show documentation
Arbitrary data for mathematical calculations.
/*
* Copyright 2016 Erwin Müller
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.anrisoftware.globalpom.spreadsheetimport;
import java.util.List;
import javax.inject.Inject;
import javax.swing.event.TableModelListener;
import com.anrisoftware.globalpom.data.Data;
import com.google.inject.assistedinject.Assisted;
/**
* Makes the data available as a table model.
*
* @author Erwin Müller, [email protected]
* @since 2.14
*/
public class DefaultSpreadsheetDataTableModel implements
SpreadsheetDataTableModel {
private final Data data;
private final List columnNames;
/**
* @see DefaultSpreadsheetDataTableModelFactory#create(Data)
*/
@Inject
DefaultSpreadsheetDataTableModel(@Assisted Data data,
@Assisted List columnNames) {
this.data = data;
this.columnNames = columnNames;
}
@Override
public int getRowCount() {
return data.getNumRows();
}
@Override
public int getColumnCount() {
return data.getNumCols();
}
@Override
public String getColumnName(int columnIndex) {
int size = columnNames.size();
if (size == 0) {
return null;
} else if (columnIndex >= size) {
return columnNames.get(size - 1);
} else {
return columnNames.get(columnIndex);
}
}
@Override
public Class> getColumnClass(int columnIndex) {
return Double.class;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return data.get(rowIndex, columnIndex);
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
}
@Override
public void addTableModelListener(TableModelListener l) {
}
@Override
public void removeTableModelListener(TableModelListener l) {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy