-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
css: make css constants non-modifiable, bridge: use float color compo…
…nents
- Loading branch information
Showing
14 changed files
with
1,040 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ImmutableIdentValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
See the NOTICE file distributed with this work for additional | ||
information regarding copyright ownership. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package io.sf.carte.echosvg.css.engine.value; | ||
|
||
import org.w3c.api.DOMTypeException; | ||
import org.w3c.dom.DOMException; | ||
|
||
/** | ||
* Immutable identifier values. | ||
* | ||
* @author See Git history. | ||
* @version $Id$ | ||
*/ | ||
class ImmutableIdentValue extends IdentValue { | ||
|
||
/** | ||
* Creates a new immutable IdentValue. | ||
*/ | ||
public ImmutableIdentValue(String s) { | ||
super(s); | ||
} | ||
|
||
@Override | ||
public void setValue(String value) throws DOMTypeException { | ||
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Immutable value."); | ||
} | ||
|
||
@Override | ||
public IdentValue clone() { | ||
return new IdentValue(value); | ||
} | ||
|
||
} |
105 changes: 105 additions & 0 deletions
105
echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ImmutableRGBColorValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
See the NOTICE file distributed with this work for additional | ||
information regarding copyright ownership. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package io.sf.carte.echosvg.css.engine.value; | ||
|
||
import org.w3c.api.DOMSyntaxException; | ||
import org.w3c.css.om.typed.CSSNumericValue; | ||
import org.w3c.dom.DOMException; | ||
|
||
/** | ||
* Immutable RGB colors. | ||
* | ||
* @author See Git history. | ||
* @version $Id$ | ||
*/ | ||
class ImmutableRGBColorValue extends RGBColorValue { | ||
|
||
/** | ||
* Creates a new, opaque RGBColorValue. | ||
* | ||
* @throws DOMSyntaxException if a supplied component is invalid. | ||
*/ | ||
public ImmutableRGBColorValue(NumericValue r, NumericValue g, NumericValue b) | ||
throws DOMSyntaxException { | ||
super(r, g, b); | ||
} | ||
|
||
/** | ||
* Creates a new RGBColorValue. | ||
* | ||
* @throws DOMSyntaxException if a supplied component is invalid. | ||
*/ | ||
public ImmutableRGBColorValue(NumericValue r, NumericValue g, NumericValue b, NumericValue a) | ||
throws DOMSyntaxException { | ||
super(r, g, b, a); | ||
} | ||
|
||
@Override | ||
void setRGB(NumericValue r, NumericValue g, NumericValue b) { | ||
red = r; | ||
green = g; | ||
blue = b; | ||
} | ||
|
||
@Override | ||
public void setR(double r) { | ||
immutable(); | ||
} | ||
|
||
private void immutable() { | ||
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Immutable value."); | ||
} | ||
|
||
@Override | ||
public void setR(CSSNumericValue r) throws DOMSyntaxException { | ||
immutable(); | ||
} | ||
|
||
@Override | ||
public void setG(double g) { | ||
immutable(); | ||
} | ||
|
||
@Override | ||
public void setG(CSSNumericValue g) throws DOMSyntaxException { | ||
immutable(); | ||
} | ||
|
||
@Override | ||
public void setB(double b) { | ||
immutable(); | ||
} | ||
|
||
@Override | ||
public void setB(CSSNumericValue b) throws DOMSyntaxException { | ||
immutable(); | ||
} | ||
|
||
@Override | ||
public RGBColorValue clone() { | ||
RGBColorValue clon; | ||
try { | ||
clon = new RGBColorValue(getR().clone(), getG().clone(), getB().clone(), getAlpha().clone()); | ||
} catch (DOMSyntaxException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
return clon; | ||
} | ||
|
||
} |
Oops, something went wrong.