+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.svg;\r
+\r
+//import static org.apache.batik.util.SVGConstants.SVG_NONE_VALUE;\r
+//\r
+//import org.apache.batik.util.CSSConstants;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class FillDesc {\r
+\r
+// public static final FillDesc NO_FILL = new FillDesc(SVG_NONE_VALUE) {\r
+// @Override\r
+// public String toStyleString() {\r
+// return "fill:none;";\r
+// }\r
+// @Override\r
+// public void setFillRule(FillRule rule) {\r
+// throw new UnsupportedOperationException("immutable object");\r
+// }\r
+// @Override\r
+// public void setOpacity(double opacity) {\r
+// throw new UnsupportedOperationException("immutable object");\r
+// }\r
+// @Override\r
+// public void setPaint(String paint) {\r
+// throw new UnsupportedOperationException("immutable object");\r
+// }\r
+// };\r
+\r
+\r
+ //private static final String[] ruleConv = { "nonzero", "evenodd" };\r
+\r
+ /**\r
+ * paint | inherit\r
+ */\r
+ private String paint;\r
+\r
+ /**\r
+ * [0,1] | "inherit"\r
+ */\r
+ private double opacity;\r
+\r
+ /**\r
+ * nonzero | evenodd | inherit\r
+ */\r
+ private FillRule fillRule;\r
+\r
+ \r
+ public FillDesc() {\r
+ this(StyleConstants.INHERIT, 1, FillRule.nonzero);\r
+ }\r
+ \r
+ public FillDesc(String paint) {\r
+ this(paint, 1, FillRule.nonzero);\r
+ }\r
+ \r
+ public FillDesc(String paint, double opacity) {\r
+ this(paint, opacity, FillRule.nonzero);\r
+ }\r
+ \r
+ public FillDesc(String paint, double opacity, FillRule fillRule) {\r
+ this.paint = paint;\r
+ this.opacity = opacity;\r
+ this.fillRule = fillRule != null ? fillRule : FillRule.nonzero;\r
+ }\r
+\r
+ public String getPaint() {\r
+ return paint;\r
+ }\r
+ \r
+ public void setPaint(String paint) {\r
+ this.paint = paint;\r
+ }\r
+ \r
+ public double getOpacity() {\r
+ return opacity;\r
+ }\r
+ \r
+ public void setOpacity(double opacity) {\r
+ this.opacity = opacity;\r
+ }\r
+ \r
+ public FillRule getFillRule() {\r
+ return fillRule;\r
+ }\r
+ \r
+ public void setFillRule(FillRule rule) {\r
+ this.fillRule = rule;\r
+ }\r
+ \r
+ /**\r
+ * Returns the hashcode for this stroke.\r
+ * \r
+ * @return a hash code for this stroke.\r
+ */\r
+ public int hashCode() {\r
+ int hash = paint.hashCode();\r
+ hash = hash * 31 + (int) Double.doubleToLongBits(opacity);\r
+ hash = hash * 31 + fillRule.hashCode();\r
+ return hash;\r
+ }\r
+\r
+ /**\r
+ * Returns true if this BasicStroke represents the same stroking operation\r
+ * as the given argument.\r
+ * \r
+ * <p>\r
+ * Tests if a specified object is equal to this <code>Stroke</code> by\r
+ * first testing if it is a <code>BasicStroke</code> and then comparing\r
+ * its width, join, cap, miter limit, dash, and dash phase attributes with\r
+ * those of this <code>Stroke</code>.\r
+ * \r
+ * @param obj the specified object to compare to this <code>Stroke</code>\r
+ * @return <code>true</code> if the width, join, cap, miter limit, dash,\r
+ * and dash phase are the same for both objects; <code>false</code>\r
+ * otherwise.\r
+ */\r
+ public boolean equals(Object obj) {\r
+ if (!(obj instanceof FillDesc)) {\r
+ return false;\r
+ }\r
+\r
+ FillDesc fd = (FillDesc) obj;\r
+ if (opacity != fd.opacity) {\r
+ return false;\r
+ }\r
+ if (!fillRule.equals(fd.fillRule)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ \r
+// public String toStyleString() {\r
+// StringBuilder s = new StringBuilder(64);\r
+// \r
+// s.append(CSSConstants.CSS_FILL_PROPERTY);\r
+// s.append(':');\r
+// s.append(paint);\r
+// s.append(';');\r
+// if (!paint.equals(CSSConstants.CSS_NONE_VALUE)) {\r
+// s.append(CSSConstants.CSS_FILL_OPACITY_PROPERTY);\r
+// s.append(':');\r
+// s.append(opacity);\r
+// s.append(';');\r
+// s.append(CSSConstants.CSS_FILL_RULE_PROPERTY);\r
+// s.append(':');\r
+// s.append(fillRule);\r
+// s.append(';');\r
+// }\r
+// \r
+// return s.toString();\r
+// }\r
+ \r
+}\r