aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwprinz <wprinz@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-05-30 09:58:11 +0000
committerwprinz <wprinz@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-05-30 09:58:11 +0000
commit6187c5538a87cdd03472d4eabfe92745e68b3ed5 (patch)
treefcb2b745fd4a0bd111f11fb0b3b285b4073e2155
parentee8b49fc0b85730d90e34a1fe81e4dbef49b36f7 (diff)
downloadpdf-as-3-6187c5538a87cdd03472d4eabfe92745e68b3ed5.tar.gz
pdf-as-3-6187c5538a87cdd03472d4eabfe92745e68b3ed5.tar.bz2
pdf-as-3-6187c5538a87cdd03472d4eabfe92745e68b3ed5.zip
CR Unsichtbare Felder
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@266 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java182
1 files changed, 156 insertions, 26 deletions
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
index 285361a..f5881e5 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
@@ -100,6 +100,11 @@ public class Style implements Serializable {
public final static String VALUEFONT = "valuefont";
/**
+ * The imageScaleToFit key.
+ */
+ public final static String IMAGE_SCALE_TO_FIT = "imagescaletofit";
+
+ /**
* Font name HELVETICA
*/
public final static String HELVETICA = "HELVETICA";
@@ -173,6 +178,10 @@ public class Style implements Serializable {
* The font string of the value font.
*/
private String valuefont_ = null;
+ /**
+ * The scaleToFit dimensions to be applied for image-cells.
+ */
+ private ImageScaleToFit imageScaleToFit_ = null;
/**
* The empty constructor.
@@ -220,6 +229,10 @@ public class Style implements Serializable {
if (VALUEFONT.equals(id)) {
valuefont_ = value;
}
+ if (IMAGE_SCALE_TO_FIT.equals(id))
+ {
+ imageScaleToFit_ = parseImageScaleToFit(value);
+ }
}
/**
@@ -325,44 +338,161 @@ public class Style implements Serializable {
{
this.valuefont_ = valuefont;
}
+
+
+
+ /**
+ * Returns the scaleToFit dimensions to be applied for image-cells.
+ * @return Returns the scaleToFit dimensions to be applied for image-cells.
+ */
+ public ImageScaleToFit getImageScaleToFit()
+ {
+ return this.imageScaleToFit_;
+ }
+
+ /**
+ * Sets the scaleToFit dimensions to be applied for image-cells.
+ * @param imageScaleToFit_ The scaleToFit dimensions to be applied for image-cells.
+ */
+ public void setImageScaleToFit(ImageScaleToFit imageScaleToFit)
+ {
+ this.imageScaleToFit_ = imageScaleToFit;
+ }
/**
* 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();
+ return "bgcolor:" + getBgColor() + " halign:" + getHAlign() + " valign:" + getVAlign() + " padding:" + getPadding() + " border:" + getBorder() + " font:" + getFont() + " valuefont:" + getValueFont() + " imageScaleToFit:" + getImageScaleToFit();
}
/**
- * 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.
+ * This method inherits all style attributes (values) from a given style object.
+ *
+ * <p>
+ * A new style object is created that receives the properly inherited styles.
+ * </p>
+ * <p>
+ * If a value is not defined in the <code>baseStyle</code> object it would be inhert from the <code>inheritStyle</code> object.
+ * </p>
*
- * @param baseStyle the base style object that should be enhanced
- * @param inhertStyle the style values that could inherit from
- * @return an inherit style object
+ * @param baseStyle the style object that serves as a primary style source.
+ * @param inheritStyle the style object that serves as a secondary style source in case a style attribute is not defined on the primary style source.
+ * @return Returns a new Style object being fully equipped with styles.
+ */
+ public static Style doInherit(Style baseStyle, Style inheritStyle) {
+ Style newStyle = new Style();
+
+ if (baseStyle != null)
+ {
+ newStyle.setBgColor(baseStyle.getBgColor());
+ newStyle.setBorder(baseStyle.getBorder());
+ newStyle.setFont(baseStyle.getFont());
+ newStyle.setHAlign(baseStyle.getHAlign());
+ newStyle.setPadding(baseStyle.getPadding());
+ newStyle.setVAlign(baseStyle.getVAlign());
+ newStyle.setValueFont(baseStyle.getValueFont());
+ newStyle.setImageScaleToFit(baseStyle.getImageScaleToFit());
+ }
+
+ if (inheritStyle != null)
+ {
+ if (newStyle.getBgColor() == null) { newStyle.setBgColor(inheritStyle.getBgColor()); }
+ if (newStyle.getBorder() == DEFAULT_BORDER) { newStyle.setBorder(inheritStyle.getBorder()); }
+ if (newStyle.getFont() == null) { newStyle.setFont(inheritStyle.getFont()); }
+ if (newStyle.getHAlign() == null) { newStyle.setHAlign(inheritStyle.getHAlign()); }
+ if (newStyle.getPadding() == DEFAULT_PADDING) { newStyle.setPadding(inheritStyle.getPadding()); }
+ if (newStyle.getVAlign() == null) { newStyle.setVAlign(inheritStyle.getVAlign()); }
+ if (newStyle.getValueFont() == null) { newStyle.setValueFont(inheritStyle.getValueFont()); }
+ if (newStyle.getImageScaleToFit() == null) { newStyle.setImageScaleToFit(inheritStyle.getImageScaleToFit()); }
+ }
+
+ return newStyle;
+ }
+
+ protected static ImageScaleToFit parseImageScaleToFit (String imageScaleToFit)
+ {
+ if (imageScaleToFit == null || imageScaleToFit.length() == 0 || imageScaleToFit.trim().length() == 0)
+ {
+ return null;
+ }
+
+ String [] dimensions = imageScaleToFit.split(";");
+ if (dimensions.length != 2)
+ {
+ return null;
+ }
+
+ float width = Float.parseFloat(dimensions[0]);
+ float height = Float.parseFloat(dimensions[0]);
+
+ return new ImageScaleToFit(width, height);
+ }
+
+ /**
+ * Holds the width and the height an image can be scaled to fit.
+ *
+ * @author wprinz
*/
- public static Style doInherit(Style baseStyle, Style inhertStyle) {
- if (baseStyle == null) {
- baseStyle = new Style();
+ public static class ImageScaleToFit
+ {
+ /**
+ * The width.
+ */
+ protected float width;
+
+ /**
+ * The height.
+ */
+ protected float height;
+
+ /**
+ * Constructor.
+ *
+ * @param width The width.
+ * @param height The height.
+ */
+ public ImageScaleToFit(float width, float height)
+ {
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Returns the width.
+ * @return Returns the width.
+ */
+ public float getWidth()
+ {
+ return this.width;
+ }
+
+ /**
+ * Sets the width.
+ * @param width The width to set.
+ */
+ public void setWidth(float width)
+ {
+ this.width = width;
+ }
+
+ /**
+ * Returns the height.
+ * @return Returns the height.
+ */
+ public float getHeight()
+ {
+ return this.height;
}
- 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());
+ /**
+ * Sets the height.
+ * @param height The height to set.
+ */
+ public void setHeight(float height)
+ {
+ this.height = height;
}
- return baseStyle;
+
}
} \ No newline at end of file