From 6025b6016517c6d898d8957d1d7e03ba71431912 Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 1 Dec 2006 12:20:24 +0000 Subject: Initial import of release 2.2. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@4 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/table/Table.java | 215 +++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java b/src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java new file mode 100644 index 0000000..ceea1f3 --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2006 by Know-Center, Graz, Austria + * + * This software is the confidential and proprietary information of Know-Center, + * Graz, Austria. You shall not disclose such Confidential Information and shall + * use it only in accordance with the terms of the license agreement you entered + * into with Know-Center. + * + * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY + * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. + * + * $Id: Table.java,v 1.2 2006/08/25 17:08:19 wprinz Exp $ + */ +package at.knowcenter.wag.egov.egiz.table; + +import java.io.Serializable; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; + +/** + * This class implements an abstract table definition. The table contains table + * rows and the table rows contains the table entries. A table can be styled and + * a relative column width can be set. + * + * @author wlackner + * @see at.knowcenter.wag.egov.egiz.table.Style + * @see at.knowcenter.wag.egov.egiz.table.Entry + */ +public class Table implements Serializable +{ + + /** + * SVUID. + */ + private static final long serialVersionUID = 8488947943674086618L; + + /** + * The table column settings. + */ + private float[] colsRelativeWith_ = null; + + /** + * The row definitions. + */ + private Map rows_ = new HashMap(); + + /** + * The table width. + */ + private float width_ = 100; + + /** + * The table style. + */ + private Style style_ = null; + + /** + * Number of columns that are defined for the current table. + */ + private int maxCols_ = 0; + + /** + * A table name. + */ + private String name_ = null; + + /** + * The table constructor init by a table name. + * + * @param name + * the name for the table. + */ + public Table(String name) + { + name_ = name; + } + + /** + * The width of the columns are relative to each other. This means the values + * are summarized and divided into portions of columns used.
+ * Example: [1,4] means the second column is four times wider + * than the first column. + * + * @return Returns the relative width of the columns + */ + public float[] getColsRelativeWith() + { + return colsRelativeWith_; + } + + /** + * The width of the columns are relative to each other. This means the values + * are summarized and divided into portions of columns used.
+ * Example: [10,90] means the first colum consumes 10% and the + * second column consumes 90% of the table width.
+ * The relative width of the columns to set. + */ + public void setColsRelativeWith(float[] cols) + { + colsRelativeWith_ = cols; + } + + /** + * @return Returns the style. + */ + public Style getStyle() + { + return style_; + } + + /** + * @param style + * The style to set. + */ + public void setStyle(Style style) + { + style_ = style; + } + + /** + * @return Returns the width. + */ + public float getWidth() + { + return width_; + } + + /** + * @param width + * The width to set. + */ + public void setWidth(float width) + { + width_ = width; + } + + /** + * @return Returns the maxCols. + */ + public int getMaxCols() + { + return maxCols_; + } + + /** + * @return Returns the name. + */ + public String getName() + { + return name_; + } + + /** + * This method returns a sorted row list beginning with the row number 1. The + * entrys in a row also stored in a {@link ArrayList}. + * + * @return Returns the sorted (by row number) table rows. + */ + public ArrayList getRows() + { + ArrayList rows = new ArrayList(); + for (int row_idx = 1; row_idx <= rows_.size(); row_idx++) + { + ArrayList row = (ArrayList) rows_.get("" + row_idx); + rows.add(row); + } + return rows; + } + + /** + * Add a comlete table row to the current table. Be carefull usding the + * correct row number because no check is done if a row with the given row + * number does exist! In that case the stored row would be replaced! + * + * @param rowNumber + * the row number to store the row entries + * @param row + * the entry list to store + */ + public void addRow(String rowNumber, ArrayList row) + { + rows_.put(rowNumber, row); + if (row.size() > maxCols_) + { + maxCols_ = row.size(); + } + } + + /** + * The toString method, used for tests or debugging. + */ + public String toString() + { + String the_string = "\n#### TABLE " + name_ + " BEGIN #####"; + the_string += " Width:" + width_ + " max cols:" + maxCols_ + " cols:" + colsRelativeWith_; + the_string += "\nStyle:" + style_; + ArrayList rows = getRows(); + for (int row_idx = 0; row_idx < rows.size(); row_idx++) + { + ArrayList row = (ArrayList) rows.get(row_idx); + String row_prefix = "\n ++ ROW " + row_idx + " ++ "; + for (int entry_idx = 0; entry_idx < row.size(); entry_idx++) + { + the_string += row_prefix + ((Entry) row.get(entry_idx)).toString(); + } + } + the_string += "\n#### TABLE " + name_ + " END #####"; + return the_string; + } +} \ No newline at end of file -- cgit v1.2.3