aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/table
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/table')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/table/Entry.java227
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java368
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/table/Table.java215
3 files changed, 810 insertions, 0 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/table/Entry.java b/src/main/java/at/knowcenter/wag/egov/egiz/table/Entry.java
new file mode 100644
index 0000000..3f2caa7
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/table/Entry.java
@@ -0,0 +1,227 @@
+/*
+ * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
+ *
+ * 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: Entry.java,v 1.3 2006/08/25 17:08:19 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.table;
+
+import java.io.Serializable;
+
+/**
+ * This class implements a table entry for different types. A table entry can be
+ * styled and setting there column dimensions. The default value for the column
+ * dimension is 1. To declare the type of the entry use the public
+ * <code>TYPE_</code> definitions.
+ *
+ * @author wlackner
+ */
+public class Entry implements Serializable
+{
+
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = -7952755200668528348L;
+
+ /**
+ * Type for a text entry.
+ */
+ public final static int TYPE_CAPTION = 0;
+
+ /**
+ * Type for a text entry.
+ */
+ public final static int TYPE_VALUE = 1;
+
+ /**
+ * Type for an image entry.
+ */
+ public final static int TYPE_IMAGE = 2;
+
+ /**
+ * Type for a table entry.
+ */
+ public final static int TYPE_TABLE = 3;
+
+ /**
+ * The type info holder, default value is 0!
+ */
+ private int type_ = 0;
+
+ /**
+ * The entry value.
+ */
+ private Object value_ = null;
+
+ /**
+ * The key value
+ */
+ private String key_ = null;
+
+ /**
+ * The entry style information.
+ */
+ private Style style_ = null;
+
+ /**
+ * The column dimension.
+ */
+ private int colSpan_ = 1;
+
+ /**
+ * Text wrap indicator, default is <code>false</code>.
+ */
+ private boolean noWrap_ = false;
+
+ /**
+ * The empty constructor.
+ */
+ public Entry()
+ {
+ }
+
+ /**
+ * A constructor setting the type and the value.
+ *
+ * @param type
+ * the entry type to set
+ * @param value
+ * the entry value to set
+ */
+ public Entry(int type, Object value, String key)
+ {
+ type_ = type;
+ value_ = value;
+ key_ = key;
+ }
+
+ /**
+ * @return Returns the entry style.
+ */
+ public Style getStyle()
+ {
+ return style_;
+ }
+
+ /**
+ * @param style
+ * The style to set.
+ */
+ public void setStyle(Style style)
+ {
+ style_ = style;
+ }
+
+ /**
+ * @return Returns the entry type.
+ */
+ public int getType()
+ {
+ return type_;
+ }
+
+ /**
+ * @param type
+ * The type to set.
+ */
+ public void setType(int type)
+ {
+ type_ = type;
+ }
+
+ /**
+ * @return Returns the entry value.
+ */
+ public Object getValue()
+ {
+ return value_;
+ }
+
+ /**
+ * @param value
+ * The value to set.
+ */
+ public void setValue(Object value)
+ {
+ value_ = value;
+ }
+
+ /**
+ * @return Returns the key.
+ */
+
+ public String getKey()
+ {
+ return key_;
+ }
+
+ /**
+ * @param key
+ * The key to set.
+ */
+ public void setKey(String key)
+ {
+ key_ = key;
+ }
+
+ /**
+ * @return Returns the colSpan.
+ */
+ public int getColSpan()
+ {
+ return colSpan_;
+ }
+
+ /**
+ * @param colSpan
+ * The colSpan to set.
+ */
+ public void setColSpan(int colSpan)
+ {
+ colSpan_ = colSpan;
+ }
+
+ /**
+ * @return Returns the wrap indicator.
+ */
+ public boolean isNoWrap()
+ {
+ return noWrap_;
+ }
+
+ /**
+ * @param noWrap
+ * The wrap indicator to set.
+ */
+ public void setNoWrap(boolean noWrap)
+ {
+ noWrap_ = noWrap;
+ }
+
+ /**
+ * The toString method, used for tests or debugging.
+ */
+ public String toString()
+ {
+ Object obj = getValue();
+ String value = null;
+ if (obj != null)
+ {
+ value = obj.toString();
+ }
+ return "Type:" + getType() + " Value:" + value + " ColSpan:" + getColSpan();
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java b/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
new file mode 100644
index 0000000..285361a
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
@@ -0,0 +1,368 @@
+/*
+ * <copyright>
+ * Copyright (c) 2006 by Know-Center, Graz, Austria
+ * </copyright>
+ *
+ * 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: Style.java,v 1.3 2006/08/25 17:08:19 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.table;
+
+import java.awt.Color;
+import java.io.Serializable;
+
+/**
+ * This class implements an abstract style definiton used in tables or table entrys. Predefined
+ * values exists for valign and halign. Color definitions uses the native awt color declarations.
+ * <br>
+ * The predefined keys are used in the setting definition file to style tables and table entries.
+ * <br>
+ * It provides an static method to inherit style informations from a given style object.
+ * {@link at.knowcenter.wag.egov.egiz.table.Style#doInherit}
+ *
+ *
+ * @author wlackner
+ * @see java.awt.Color
+ */
+public class Style implements Serializable {
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = 5855722896712428387L;
+
+ /**
+ * valign statement key top
+ */
+ public final static String TOP = "top";
+ /**
+ * valign statement key middle
+ */
+ public final static String MIDDLE = "middle";
+ /**
+ * valign statement key bottom
+ */
+ public final static String BOTTOM = "bottom";
+ /**
+ * halign statement key left
+ */
+ public final static String LEFT = "left";
+ /**
+ * halign statement key center
+ */
+ public final static String CENTER = "center";
+ /**
+ * halign statement key right
+ */
+ public final static String RIGHT = "right";
+
+ /**
+ * bgcolor key
+ */
+ public final static String BGCOLOR = "bgcolor";
+ /**
+ * halign key
+ */
+ public final static String HALIGN = "halign";
+ /**
+ * valign key
+ */
+ public final static String VALIGN = "valign";
+ /**
+ * padding key, default padding = 1
+ */
+ public final static String PADDING = "padding";
+ /**
+ * border key, default border = 1;<br>
+ * The border value is one value for all border lines of an entry or table! <br>
+ * No separte definitions for top, right, bottom or left are possible.
+ */
+ public final static String BORDER = "border";
+
+ /**
+ * Font key
+ */
+ public final static String FONT = "font";
+
+ /**
+ * The value font key.
+ */
+ public final static String VALUEFONT = "valuefont";
+
+ /**
+ * Font name HELVETICA
+ */
+ public final static String HELVETICA = "HELVETICA";
+ /**
+ * Font name TIMES_ROMAN
+ */
+ public final static String TIMES_ROMAN = "TIMES_ROMAN";
+ /**
+ * Font name COURIER
+ */
+ public final static String COURIER = "COURIER";
+ /**
+ * Font type NORMAL
+ */
+ public final static String NORMAL = "NORMAL";
+ /**
+ * Font type BOLD
+ */
+ public final static String BOLD = "BOLD";
+ /**
+ * Font type ITALIC
+ */
+ public final static String ITALIC = "ITALIC";
+ /**
+ * Font type BOLDITALIC
+ */
+ public final static String BOLDITALIC = "BOLDITALIC";
+ /**
+ * Font type UNDERLINE
+ */
+ public final static String UNDERLINE = "UNDERLINE";
+ /**
+ * Font type STRIKETHRU
+ */
+ public final static String STRIKETHRU = "STRIKETHRU";
+
+
+ /**
+ * all paddings initialized with the default padding value (1)
+ */
+ private static final float DEFAULT_PADDING = 1;
+ /**
+ * all borders initialized with the default border value (1)
+ */
+ private static final float DEFAULT_BORDER = 1;
+ /**
+ * The background color definition.
+ */
+ private Color bgColor_ = null;
+ /**
+ * The current padding value -> initialized with the default padding value
+ */
+ private float padding_ = DEFAULT_PADDING;
+ /**
+ * The current halign value -> initialized with left
+ */
+ private String hAlign_ = LEFT;
+ /**
+ * The current valign value -> initialized with top
+ */
+ private String vAlign_ = TOP;
+ /**
+ * The current border value -> initialized with the default border value
+ */
+ private float border_ = DEFAULT_BORDER;
+ /**
+ * The font string of the style definition
+ */
+ private String font_ = null;
+ /**
+ * The font string of the value font.
+ */
+ private String valuefont_ = null;
+
+ /**
+ * The empty constructor.
+ */
+ public Style() {
+ }
+
+ /**
+ * Set a style attribute. The style attribute must be one of the public definitions
+ *
+ * @param id the style attribute to set
+ * @param value the style value to set for the given attribute
+ */
+ public void setStyle(String id, String value) {
+ if (BGCOLOR.equals(id)) {
+ String[] col_strg = value.split(" ");
+ if (col_strg.length == 3) {
+ int r = Integer.parseInt(col_strg[0]);
+ int g = Integer.parseInt(col_strg[1]);
+ int b = Integer.parseInt(col_strg[2]);
+ if (r < 256 && g < 256 && b < 256 && r >= 0 && g >= 0 && b >= 0) {
+ bgColor_ = new Color(r, g, b);
+ }
+ }
+ }
+ if (HALIGN.equals(id)) {
+ if (LEFT.equals(value) || CENTER.equals(value) || RIGHT.equals(value)) {
+ hAlign_ = value;
+ }
+ }
+ if (VALIGN.equals(id)) {
+ if (TOP.equals(value) || MIDDLE.equals(value) || BOTTOM.equals(value)) {
+ vAlign_ = value;
+ }
+ }
+ if (PADDING.equals(id)) {
+ padding_ = Float.parseFloat(value);
+ }
+ if (BORDER.equals(id)) {
+ border_ = Float.parseFloat(value);
+ }
+ if (FONT.equals(id)) {
+ font_ = value;
+ }
+ if (VALUEFONT.equals(id)) {
+ valuefont_ = value;
+ }
+ }
+
+ /**
+ * @return Returns the bgColor.
+ */
+ public Color getBgColor() {
+ return bgColor_;
+ }
+
+ /**
+ * @param bgColor The bgColor to set.
+ */
+ public void setBgColor(Color bgColor) {
+ bgColor_ = bgColor;
+ }
+
+ /**
+ * @return Returns the hAlign.
+ */
+ public String getHAlign() {
+ return hAlign_;
+ }
+
+ /**
+ * @param align The hAlign to set.
+ */
+ public void setHAlign(String align) {
+ hAlign_ = align;
+ }
+
+ /**
+ * @return Returns the padding.
+ */
+ public float getPadding() {
+ return padding_;
+ }
+
+ /**
+ * @param padding The padding to set.
+ */
+ public void setPadding(float padding) {
+ padding_ = padding;
+ }
+
+ /**
+ * @return Returns the vAlign.
+ */
+ public String getVAlign() {
+ return vAlign_;
+ }
+
+ /**
+ * @param align The vAlign to set.
+ */
+ public void setVAlign(String align) {
+ vAlign_ = align;
+ }
+
+ /**
+ * @return Returns the border.
+ */
+ public float getBorder() {
+ return border_;
+ }
+
+ /**
+ * @param border The border to set.
+ */
+ public void setBorder(float border) {
+ border_ = border;
+ }
+
+
+ /**
+ * @return Returns the font.
+ */
+ public String getFont() {
+ return font_;
+ }
+
+ /**
+ * @param font The font to set.
+ */
+ public void setFont(String font) {
+ font_ = font;
+ }
+
+
+ /**
+ * Returns the value font.
+ * @return Returns the value font.
+ */
+ public String getValueFont()
+ {
+ return valuefont_;
+ }
+
+ /**
+ * Sets the value font.
+ * @param valuefont The value font to be set.
+ */
+ public void setValueFont(String valuefont)
+ {
+ this.valuefont_ = valuefont;
+ }
+
+ /**
+ * The toString method, used for tests or debugging.
+ */
+ public String toString() {
+ return "bgcolor:" + getBgColor() + " halign:" + getHAlign() + " valign:" + getVAlign() + " padding:" + getPadding() + " border:" + getBorder() + " font:" + getFont() + " valuefont:" + getValueFont();
+ }
+
+ /**
+ * This method inherits all style attributes (values) from a given style object. A new style
+ * object is created if the base style object is null. If a value is not defined in the
+ * <code>baseStyle</code> object it would be inhert from the <code>inheritStyle</code> object.
+ *
+ * @param baseStyle the base style object that should be enhanced
+ * @param inhertStyle the style values that could inherit from
+ * @return an inherit style object
+ */
+ public static Style doInherit(Style baseStyle, Style inhertStyle) {
+ if (baseStyle == null) {
+ baseStyle = new Style();
+ }
+ if (inhertStyle != null) {
+
+ if (baseStyle.getBgColor() == null)
+ baseStyle.setBgColor(inhertStyle.getBgColor());
+ if (baseStyle.getBorder() == DEFAULT_BORDER)
+ baseStyle.setBorder(inhertStyle.getBorder());
+ if (baseStyle.getHAlign() == null)
+ baseStyle.setHAlign(inhertStyle.getHAlign());
+ if (baseStyle.getVAlign() == null)
+ baseStyle.setVAlign(inhertStyle.getVAlign());
+ if (baseStyle.getPadding() == DEFAULT_PADDING)
+ baseStyle.setPadding(inhertStyle.getPadding());
+ if (baseStyle.getFont() == null)
+ baseStyle.setFont(inhertStyle.getFont());
+ if (baseStyle.getValueFont() == null)
+ baseStyle.setValueFont(inhertStyle.getValueFont());
+ }
+ return baseStyle;
+ }
+} \ No newline at end of file
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> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
+ *
+ * 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. <br>
+ * Example: <code>[1,4]</code> 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. <br>
+ * Example: <code>[10,90]</code> means the first colum consumes 10% and the
+ * second column consumes 90% of the table width. <br>
+ * 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 <code>{@link ArrayList}</code>.
+ *
+ * @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