1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.svg;
\r
14 //import static org.apache.batik.util.SVGConstants.SVG_NONE_VALUE;
\r
16 //import org.apache.batik.util.CSSConstants;
\r
19 * @author Tuukka Lehtonen
\r
21 public class FillDesc {
\r
23 // public static final FillDesc NO_FILL = new FillDesc(SVG_NONE_VALUE) {
\r
25 // public String toStyleString() {
\r
26 // return "fill:none;";
\r
29 // public void setFillRule(FillRule rule) {
\r
30 // throw new UnsupportedOperationException("immutable object");
\r
33 // public void setOpacity(double opacity) {
\r
34 // throw new UnsupportedOperationException("immutable object");
\r
37 // public void setPaint(String paint) {
\r
38 // throw new UnsupportedOperationException("immutable object");
\r
43 //private static final String[] ruleConv = { "nonzero", "evenodd" };
\r
48 private String paint;
\r
53 private double opacity;
\r
56 * nonzero | evenodd | inherit
\r
58 private FillRule fillRule;
\r
62 this(StyleConstants.INHERIT, 1, FillRule.nonzero);
\r
65 public FillDesc(String paint) {
\r
66 this(paint, 1, FillRule.nonzero);
\r
69 public FillDesc(String paint, double opacity) {
\r
70 this(paint, opacity, FillRule.nonzero);
\r
73 public FillDesc(String paint, double opacity, FillRule fillRule) {
\r
75 this.opacity = opacity;
\r
76 this.fillRule = fillRule != null ? fillRule : FillRule.nonzero;
\r
79 public String getPaint() {
\r
83 public void setPaint(String paint) {
\r
87 public double getOpacity() {
\r
91 public void setOpacity(double opacity) {
\r
92 this.opacity = opacity;
\r
95 public FillRule getFillRule() {
\r
99 public void setFillRule(FillRule rule) {
\r
100 this.fillRule = rule;
\r
104 * Returns the hashcode for this stroke.
\r
106 * @return a hash code for this stroke.
\r
108 public int hashCode() {
\r
109 int hash = paint.hashCode();
\r
110 hash = hash * 31 + (int) Double.doubleToLongBits(opacity);
\r
111 hash = hash * 31 + fillRule.hashCode();
\r
116 * Returns true if this BasicStroke represents the same stroking operation
\r
117 * as the given argument.
\r
120 * Tests if a specified object is equal to this <code>Stroke</code> by
\r
121 * first testing if it is a <code>BasicStroke</code> and then comparing
\r
122 * its width, join, cap, miter limit, dash, and dash phase attributes with
\r
123 * those of this <code>Stroke</code>.
\r
125 * @param obj the specified object to compare to this <code>Stroke</code>
\r
126 * @return <code>true</code> if the width, join, cap, miter limit, dash,
\r
127 * and dash phase are the same for both objects; <code>false</code>
\r
130 public boolean equals(Object obj) {
\r
131 if (!(obj instanceof FillDesc)) {
\r
135 FillDesc fd = (FillDesc) obj;
\r
136 if (opacity != fd.opacity) {
\r
139 if (!fillRule.equals(fd.fillRule)) {
\r
145 // public String toStyleString() {
\r
146 // StringBuilder s = new StringBuilder(64);
\r
148 // s.append(CSSConstants.CSS_FILL_PROPERTY);
\r
150 // s.append(paint);
\r
152 // if (!paint.equals(CSSConstants.CSS_NONE_VALUE)) {
\r
153 // s.append(CSSConstants.CSS_FILL_OPACITY_PROPERTY);
\r
155 // s.append(opacity);
\r
157 // s.append(CSSConstants.CSS_FILL_RULE_PROPERTY);
\r
159 // s.append(fillRule);
\r
163 // return s.toString();
\r