You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2006/04/22 14:56:16 UTC
svn commit: r396119 [1/2] - in
/xmlgraphics/batik/branches/svg11/sources/org/apache/batik:
apps/svgbrowser/ bridge/ css/dom/ css/engine/ css/engine/value/ dom/svg/
ext/awt/image/codec/ extension/ swing/gvt/ xml/
Author: deweese
Date: Sat Apr 22 05:56:13 2006
New Revision: 396119
URL: http://svn.apache.org/viewcvs?rev=396119&view=rev
Log:
1) Applied patch from 25428 (Thanks Dieter)
2) Applied patch from 29552 (Thanks Dieter)
Modified:
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/apps/svgbrowser/LocalHistory.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/CSSUtilities.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/engine/CSSEngine.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/engine/value/AbstractColorManager.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/dom/svg/SVGOMStyleElement.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/dom/svg/SVGStylableElement.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/codec/PNGRed.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/StylableExtensionElement.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java
xmlgraphics/batik/branches/svg11/sources/org/apache/batik/xml/XMLScanner.java
Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/apps/svgbrowser/LocalHistory.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/apps/svgbrowser/LocalHistory.java?rev=396119&r1=396118&r2=396119&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/apps/svgbrowser/LocalHistory.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/apps/svgbrowser/LocalHistory.java Sat Apr 22 05:56:13 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
+ Copyright 2001-2003 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@
/**
* The frame to manage.
*/
- protected JSVGViewerFrame svgFrame;
+ protected JSVGViewerFrame svgFrame;
/**
* The menu which contains the history.
@@ -85,7 +85,7 @@
/**
* Creates a new local history.
* @param mb The menubar used to display the history. It must
- * contains one '@@@' item used as marker to place the
+ * contain one '@@@' item used as marker to place the
* history items.
* @param svgFrame The frame to manage.
*/
@@ -164,7 +164,7 @@
*/
public void update(String uri) {
if (currentURI < -1) {
- throw new InternalError();
+ throw new IllegalStateException("Unexpected currentURI:" + currentURI );
}
state = STABLE_STATE;
if (++currentURI < visitedURIs.size()) {
@@ -194,9 +194,9 @@
// Computes the button text.
String text = uri;
- int i = uri.lastIndexOf("/");
+ int i = uri.lastIndexOf('/');
if (i == -1) {
- i = uri.lastIndexOf("\\");
+ i = uri.lastIndexOf('\\' );
if (i != -1) {
text = uri.substring(i + 1);
}
@@ -222,7 +222,9 @@
break;
case RELOAD_PENDING_STATE:
currentURI++;
+ break;
case FORWARD_PENDING_STATE:
+ // fall-through intended
case STABLE_STATE:
}
}
@@ -230,21 +232,26 @@
/**
* To listen to the radio buttons.
*/
- protected class RadioListener implements ActionListener {
- public RadioListener() {}
- public void actionPerformed(ActionEvent e) {
- String uri = e.getActionCommand();
- currentURI = getItemIndex((JMenuItem)e.getSource()) - 1;
- svgFrame.showSVGDocument(uri);
- }
- public int getItemIndex(JMenuItem item) {
+ protected class RadioListener
+ implements ActionListener {
+
+ protected RadioListener() {
+ }
+
+ public void actionPerformed( ActionEvent e ) {
+ String uri = e.getActionCommand();
+ currentURI = getItemIndex( (JMenuItem)e.getSource() ) - 1;
+ svgFrame.showSVGDocument( uri );
+ }
+
+ public int getItemIndex( JMenuItem item ) {
int ic = menu.getItemCount();
- for (int i = index; i < ic; i++) {
- if (menu.getItem(i) == item) {
+ for ( int i = index; i < ic; i++ ) {
+ if ( menu.getItem( i ) == item ) {
return i - index;
}
}
- throw new InternalError();
+ throw new IllegalArgumentException("MenuItem is not from my menu!" );
}
}
}
Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/CSSUtilities.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/CSSUtilities.java?rev=396119&r1=396118&r2=396119&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/CSSUtilities.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/CSSUtilities.java Sat Apr 22 05:56:13 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
+ Copyright 2001-2003,2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@
public static Value getComputedStyle(Element e, int property) {
CSSEngine engine = getCSSEngine(e);
if (engine == null) return null;
- return engine.getComputedStyle((CSSStylableElement)e,
+ return engine.getComputedStyle((CSSStylableElement)e,
null, property);
}
@@ -115,7 +115,8 @@
case 's':
return GraphicsNode.VISIBLE_STROKE;
default:
- throw new Error(); // can't be reached
+ // can't be reached
+ throw new IllegalStateException("unexpected event, must be one of (p,f,s) is:" + s.charAt(7) );
}
}
case 'p':
@@ -129,7 +130,8 @@
case 'n':
return GraphicsNode.NONE;
default:
- throw new Error(); // can't be reached
+ // can't be reached
+ throw new IllegalStateException("unexpected event, must be one of (v,p,f,s,a,n) is:" + s.charAt(0) );
}
}
@@ -162,7 +164,7 @@
return new Rectangle2D.Float(x, y, w, h);
default:
- throw new InternalError(); // Cannot happen
+ throw new IllegalStateException("Unexpected length:" + length ); // Cannot happen
}
}
@@ -209,8 +211,8 @@
* Checks if the cursor property on the input element is set to auto
*/
public static boolean isAutoCursor(Element e) {
- Value cursorValue =
- CSSUtilities.getComputedStyle(e,
+ Value cursorValue =
+ CSSUtilities.getComputedStyle(e,
SVGCSSEngine.CURSOR_INDEX);
boolean isAuto = false;
@@ -229,9 +231,9 @@
cursorValue.getLength() == 1) {
Value lValue = cursorValue.item(0);
if (lValue != null
- &&
+ &&
lValue.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE
- &&
+ &&
lValue.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT
&&
lValue.getStringValue().charAt(0) == 'a') {
@@ -306,7 +308,7 @@
if (hints == null)
hints = new RenderingHints(null);
-
+
switch(s.charAt(0)) {
case 'o': // optimizeSpeed
hints.put(RenderingHints.KEY_RENDERING,
@@ -626,7 +628,8 @@
*/
public static float[] convertClip(Element e) {
Value v = getComputedStyle(e, SVGCSSEngine.CLIP_INDEX);
- switch (v.getPrimitiveType()) {
+ int primitiveType = v.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_RECT:
float [] off = new float[4];
off[0] = v.getTop().getFloatValue();
@@ -637,7 +640,8 @@
case CSSPrimitiveValue.CSS_IDENT:
return null; // 'auto' means no offsets
default:
- throw new Error(); // can't be reached
+ // can't be reached
+ throw new IllegalStateException("Unexpected primitiveType:" + primitiveType );
}
}
@@ -659,7 +663,8 @@
GraphicsNode filteredNode,
BridgeContext ctx) {
Value v = getComputedStyle(filteredElement, SVGCSSEngine.FILTER_INDEX);
- switch (v.getPrimitiveType()) {
+ int primitiveType = v.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT:
return null; // 'filter:none'
@@ -677,8 +682,8 @@
filteredElement,
filteredNode);
default:
- throw new InternalError(); // can't be reached
-
+ throw new IllegalStateException("Unexpected primitive type:" + primitiveType ); // can't be reached
+
}
}
@@ -700,7 +705,8 @@
BridgeContext ctx) {
Value v = getComputedStyle(clippedElement,
SVGCSSEngine.CLIP_PATH_INDEX);
- switch (v.getPrimitiveType()) {
+ int primitiveType = v.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT:
return null; // 'clip-path:none'
@@ -718,8 +724,7 @@
clippedElement,
clippedNode);
default:
- throw new InternalError(); // can't be reached
-
+ throw new IllegalStateException("Unexpected primitive type:" + primitiveType ); // can't be reached
}
}
@@ -753,7 +758,8 @@
GraphicsNode maskedNode,
BridgeContext ctx) {
Value v = getComputedStyle(maskedElement, SVGCSSEngine.MASK_INDEX);
- switch (v.getPrimitiveType()) {
+ int primitiveType = v.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT:
return null; // 'mask:none'
@@ -771,8 +777,7 @@
maskedElement,
maskedNode);
default:
- throw new InternalError(); // can't be reached
-
+ throw new IllegalStateException("Unexpected primitive type:" + primitiveType ); // can't be reached
}
}
@@ -888,7 +893,7 @@
CSSEngine engine = CSSUtilities.getCSSEngine(localRefElement);
CSSEngine refEngine = CSSUtilities.getCSSEngine(refElement);
-
+
engine.importCascadedStyleMaps(refElement, refEngine, localRefElement);
}
Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java?rev=396119&r1=396118&r2=396119&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java Sat Apr 22 05:56:13 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2004 The Apache Software Foundation
+ Copyright 2001-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -86,43 +86,43 @@
* @author <a href="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
* @version $Id$
*/
-public class SVGTextElementBridge extends AbstractGraphicsNodeBridge
+public class SVGTextElementBridge extends AbstractGraphicsNodeBridge
implements SVGTextContent {
protected final static Integer ZERO = new Integer(0);
- public static final
+ public static final
AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER =
GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER;
- public static final
+ public static final
AttributedCharacterIterator.Attribute TEXT_COMPOUND_ID =
GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_ID;
public static final AttributedCharacterIterator.Attribute PAINT_INFO =
GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO;
- public static final
+ public static final
AttributedCharacterIterator.Attribute ALT_GLYPH_HANDLER =
GVTAttributedCharacterIterator.TextAttribute.ALT_GLYPH_HANDLER;
-
- public static final
+
+ public static final
AttributedCharacterIterator.Attribute TEXTPATH
= GVTAttributedCharacterIterator.TextAttribute.TEXTPATH;
- public static final
+ public static final
AttributedCharacterIterator.Attribute ANCHOR_TYPE
= GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE;
- public static final
+ public static final
AttributedCharacterIterator.Attribute GVT_FONT_FAMILIES
= GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES;
- public static final
+ public static final
AttributedCharacterIterator.Attribute GVT_FONTS
= GVTAttributedCharacterIterator.TextAttribute.GVT_FONTS;
- public static final
+ public static final
AttributedCharacterIterator.Attribute BASELINE_SHIFT
= GVTAttributedCharacterIterator.TextAttribute.BASELINE_SHIFT;
@@ -307,7 +307,7 @@
* Handles 'DOMNodeRemoved' event type.
*/
public void handleEvent(Event evt) {
- handleDOMChildNodeRemovedEvent((MutationEvent)evt);
+ handleDOMChildNodeRemovedEvent((MutationEvent)evt);
}
}
@@ -334,7 +334,7 @@
/**
* This method insures that any modification to a text
- * element and its children is going to be reflected
+ * element and its children is going to be reflected
* into the GVT tree.
*/
protected void initializeDynamicSupport(BridgeContext ctx,
@@ -348,21 +348,21 @@
EventTarget evtTarget = (EventTarget)e;
- //to be notified when a child is removed from the
- //<text> element.
+ // to be notified when a child is removed from the
+ // <text> element.
evtTarget.addEventListener
("DOMNodeRemoved", childNodeRemovedEventListener, true);
ctx.storeEventListener
(evtTarget, "DOMNodeRemoved", childNodeRemovedEventListener, true);
-
- //to be notified when the modification of the subtree
- //of the <text> element is done
+
+ // to be notified when the modification of the subtree
+ // of the <text> element is done
evtTarget.addEventListener
("DOMSubtreeModified", subtreeModifiedEventListener, false);
ctx.storeEventListener
(evtTarget, "DOMSubtreeModified", subtreeModifiedEventListener, false);
- // traverse the children to add context on
+ // traverse the children to add context on
// <tspan>, <tref> and <textPath>
Node child = e.getFirstChild();
while (child != null) {
@@ -413,12 +413,12 @@
*/
public void handleDOMNodeInsertedEvent(MutationEvent evt) {
Node childNode = (Node)evt.getTarget();
-
+
//check the type of the node inserted before discard the layout
//in the case of <title> or <desc> or <metadata>, the layout
//is unchanged
switch( childNode.getNodeType() ){
- case Node.TEXT_NODE:
+ case Node.TEXT_NODE: // fall-through is intended
case Node.CDATA_SECTION_NODE:
laidoutText = null;
break;
@@ -461,14 +461,14 @@
//in the case of <title> or <desc> or <metadata>, the layout
//is unchanged
switch (childNode.getNodeType()) {
- case Node.TEXT_NODE:
+ case Node.TEXT_NODE: // fall-through is intended
case Node.CDATA_SECTION_NODE:
//the parent has to be a displayed node
if (isParentDisplayed( childNode)) {
laidoutText = null;
}
break;
- case Node.ELEMENT_NODE:
+ case Node.ELEMENT_NODE:
if (isTextChild((Element)childNode)) {
laidoutText = null;
}
@@ -491,7 +491,7 @@
}
/**
- * Invoked when an MutationEvent of type 'DOMCharacterDataModified'
+ * Invoked when an MutationEvent of type 'DOMCharacterDataModified'
* is fired.
*/
public void handleDOMCharacterDataModified(MutationEvent evt){
@@ -508,7 +508,7 @@
* <title>, <desc> and <metadata>
* are non displayable elements.
*
- * @return true if the parent of the node is <text>,
+ * @return true if the parent of the node is <text>,
* <tspan>, <tref>, <textPath>, <a>,
* <altGlyph>
*/
@@ -525,7 +525,7 @@
* update <code>laidoutText</code> with the new
* value.
*/
- protected void computeLaidoutText(BridgeContext ctx,
+ protected void computeLaidoutText(BridgeContext ctx,
Element e,
GraphicsNode node) {
TextNode tn = (TextNode)node;
@@ -606,7 +606,7 @@
int [] properties = evt.getProperties();
// first try to find CSS properties that change the layout
for (int i=0; i < properties.length; ++i) {
- switch(properties[i]) {
+ switch(properties[i]) { // fall-through is intended
case SVGCSSEngine.BASELINE_SHIFT_INDEX:
case SVGCSSEngine.DIRECTION_INDEX:
case SVGCSSEngine.DISPLAY_INDEX:
@@ -617,7 +617,7 @@
case SVGCSSEngine.FONT_WEIGHT_INDEX:
case SVGCSSEngine.GLYPH_ORIENTATION_HORIZONTAL_INDEX:
case SVGCSSEngine.GLYPH_ORIENTATION_VERTICAL_INDEX:
- case SVGCSSEngine.KERNING_INDEX:
+ case SVGCSSEngine.KERNING_INDEX:
case SVGCSSEngine.LETTER_SPACING_INDEX:
case SVGCSSEngine.TEXT_ANCHOR_INDEX:
case SVGCSSEngine.UNICODE_BIDI_INDEX:
@@ -644,7 +644,7 @@
* Invoked for each CSS property that has changed.
*/
protected void handleCSSPropertyChanged(int property) {
- switch(property) {
+ switch(property) { // fall-through is intended
case SVGCSSEngine.FILL_INDEX:
case SVGCSSEngine.FILL_OPACITY_INDEX:
case SVGCSSEngine.STROKE_INDEX:
@@ -658,8 +658,8 @@
case SVGCSSEngine.TEXT_DECORATION_INDEX:
rebuildACI();
break;
-
- case SVGCSSEngine.VISIBILITY_INDEX:
+
+ case SVGCSSEngine.VISIBILITY_INDEX:
rebuildACI();
super.handleCSSPropertyChanged(property);
break;
@@ -678,7 +678,7 @@
node.setRenderingHints(hints);
}
break;
- }
+ }
default:
super.handleCSSPropertyChanged(property);
}
@@ -711,7 +711,7 @@
if (oldPI == null) return;
tn.swapTextPaintInfo(pi, oldPI);
- if (usingComplexSVGFont)
+ if (usingComplexSVGFont)
// Force Complex SVG fonts to be recreated
tn.setAttributedCharacterIterator
(tn.getAttributedCharacterIterator());
@@ -743,7 +743,7 @@
*/
protected AttributedString buildAttributedString(BridgeContext ctx,
Element element) {
-
+
AttributedStringBuffer asb = new AttributedStringBuffer();
fillAttributedStringBuffer(ctx, element, true, null, null, asb);
return asb.toAttributedString();
@@ -773,7 +773,7 @@
(!CSSUtilities.convertDisplay(element))) {
return;
}
-
+
String s = XMLSupport.getXMLSpace(element);
boolean preserve = s.equals(SVG_PRESERVE_VALUE);
boolean prevEndsWithSpace;
@@ -784,7 +784,7 @@
endLimit = 0;
if (preserve)
endLimit = asb.length();
-
+
Map map = getAttributeMap(ctx, element, textPath, bidiLevel);
Object o = map.get(TextAttribute.BIDI_EMBEDDING);
Integer subBidiLevel = bidiLevel;
@@ -798,7 +798,7 @@
if (preserve) {
prevEndsWithSpace = false;
} else {
- if (asb.length() == 0)
+ if (asb.length() == 0)
prevEndsWithSpace = true;
else
prevEndsWithSpace = (asb.getLastChar() == ' ');
@@ -808,11 +808,11 @@
case Node.ELEMENT_NODE:
if (!SVG_NAMESPACE_URI.equals(n.getNamespaceURI()))
break;
-
+
nodeElement = (Element)n;
String ln = n.getLocalName();
-
+
if (ln.equals(SVG_TSPAN_TAG) ||
ln.equals(SVG_ALT_GLYPH_TAG)) {
fillAttributedStringBuffer(ctx,
@@ -841,7 +841,7 @@
s = normalizeString(s, preserve, prevEndsWithSpace);
if (s != null) {
int trefStart = asb.length();
- Map m = getAttributeMap(ctx, nodeElement,
+ Map m = getAttributeMap(ctx, nodeElement,
textPath, bidiLevel);
asb.append(s, m);
int trefEnd = asb.length()-1;
@@ -856,7 +856,7 @@
EventListener l = new SVGAElementBridge.AnchorListener(ua);
target.addEventListener(SVG_EVENT_CLICK, l, false);
ctx.storeEventListener(target, SVG_EVENT_CLICK, l, false);
-
+
fillAttributedStringBuffer(ctx,
nodeElement,
false,
@@ -865,7 +865,7 @@
asb);
}
break;
- case Node.TEXT_NODE:
+ case Node.TEXT_NODE: // fall-through is intended
case Node.CDATA_SECTION_NODE:
s = n.getNodeValue();
s = normalizeString(s, preserve, prevEndsWithSpace);
@@ -909,7 +909,7 @@
if (preserve) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
- switch (c) {
+ switch (c) { // fall-through is intended
case 10:
case 13:
case '\t':
@@ -928,7 +928,7 @@
switch (s.charAt(idx)) {
default:
break loop;
- case 10:
+ case 10: // fall-through is intended
case 13:
case ' ':
case '\t':
@@ -941,10 +941,10 @@
for (int i = idx; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
- case 10:
+ case 10: // fall-through is intended
case 13:
break;
- case ' ':
+ case ' ': // fall-through is intended
case '\t':
if (!space) {
sb.append(' ');
@@ -974,7 +974,7 @@
* The attributes.
*/
protected List attributes;
-
+
/**
* The number of items.
*/
@@ -984,7 +984,7 @@
* The length of the attributed string.
*/
protected int length;
-
+
/**
* Creates a new empty AttributedStringBuffer.
*/
@@ -1001,7 +1001,7 @@
public boolean isEmpty() {
return count == 0;
}
-
+
/**
* Returns the length in chars of the current Attributed String
*/
@@ -1036,7 +1036,7 @@
*/
public void stripFirst() {
String s = (String)strings.get(0);
- if (s.charAt(s.length() - 1) != ' ')
+ if (s.charAt(s.length() - 1) != ' ')
return;
length--;
@@ -1056,7 +1056,7 @@
*/
public void stripLast() {
String s = (String)strings.get(count - 1);
- if (s.charAt(s.length() - 1) != ' ')
+ if (s.charAt(s.length() - 1) != ' ')
return;
length--;
@@ -1331,8 +1331,8 @@
* This method adds all the font related properties to <tt>result</tt>
* It also builds a List of the GVTFonts and returns it.
*/
- protected List getFontList(BridgeContext ctx,
- Element element,
+ protected List getFontList(BridgeContext ctx,
+ Element element,
Map result) {
// Unique value for text element - used for run identification.
@@ -1344,15 +1344,15 @@
result.put(TextAttribute.SIZE, fsFloat);
// Font stretch
- result.put(TextAttribute.WIDTH,
+ result.put(TextAttribute.WIDTH,
TextUtilities.convertFontStretch(element));
// Font style
- result.put(TextAttribute.POSTURE,
+ result.put(TextAttribute.POSTURE,
TextUtilities.convertFontStyle(element));
// Font weight
- result.put(TextAttribute.WEIGHT,
+ result.put(TextAttribute.WEIGHT,
TextUtilities.convertFontWeight(element));
// Font weight
@@ -1397,7 +1397,7 @@
fontList.add(ft);
}
- // Eventually this will need to go for SVG fonts it
+ // Eventually this will need to go for SVG fonts it
// holds hard ref to DOM.
result.put(GVT_FONT_FAMILIES, fontFamilyList);
@@ -1422,10 +1422,10 @@
Map result = new HashMap();
String s;
float f;
-
+
if (SVG_NAMESPACE_URI.equals(element.getNamespaceURI()) &&
element.getLocalName().equals(SVG_ALT_GLYPH_TAG)) {
- result.put(ALT_GLYPH_HANDLER,
+ result.put(ALT_GLYPH_HANDLER,
new SVGAltGlyphHandler(ctx, element));
}
@@ -1433,7 +1433,7 @@
// Text we will swap in the correct values.
TextPaintInfo pi = new TextPaintInfo();
// Set some basic props so we can get bounds info for complex paints.
- pi.visible = true;
+ pi.visible = true;
pi.fillPaint = Color.black;
result.put(PAINT_INFO, pi);
elemTPI.put(element, pi);
@@ -1500,7 +1500,7 @@
else cbidi++; // was even now odd
break;
}
-
+
switch (s.charAt(0)) {
case 'b': // bidi-override
cbidi = -cbidi; // For bidi-override we want a negative number.
@@ -1540,7 +1540,8 @@
val = CSSUtilities.getComputedStyle
(element, SVGCSSEngine.GLYPH_ORIENTATION_VERTICAL_INDEX);
- switch (val.getPrimitiveType()) {
+ int primitiveType = val.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT: // auto
result.put(GVTAttributedCharacterIterator.
TextAttribute.VERTICAL_ORIENTATION,
@@ -1576,14 +1577,15 @@
break;
default:
// Cannot happen
- throw new InternalError();
+ throw new IllegalStateException("unexpected primitiveType (V):" + primitiveType );
}
// glyph-orientation-horizontal
val = CSSUtilities.getComputedStyle
(element, SVGCSSEngine.GLYPH_ORIENTATION_HORIZONTAL_INDEX);
- switch (val.getPrimitiveType()) {
+ primitiveType = val.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_DEG:
result.put(GVTAttributedCharacterIterator.
TextAttribute.HORIZONTAL_ORIENTATION_ANGLE,
@@ -1601,7 +1603,7 @@
break;
default:
// Cannot happen
- throw new InternalError();
+ throw new IllegalStateException("unexpected primitiveType (H):" + primitiveType );
}
// text spacing properties...
@@ -1674,7 +1676,6 @@
* of the node 'child' and extract the text decorations
* of the parent.
*
- * @param aci an <code>AttributedCharacterIterator</code> value
* @param child an <code>Element</code> value
* @return a <code>TextDecoration</code> value
*/
@@ -1789,11 +1790,11 @@
pi.underlinePaint = null;
pi.underlineStrokePaint = null;
pi.underlineStroke = null;
-
+
pi.overlinePaint = null;
pi.overlineStrokePaint = null;
pi.overlineStroke = null;
-
+
pi.strikethroughPaint = null;
pi.strikethroughStrokePaint = null;
pi.strikethroughStroke = null;
@@ -1805,7 +1806,7 @@
* Implementation of <ode>SVGContext</code> for
* the children of <text>
*/
- public abstract class AbstractTextChildSVGContext
+ public abstract class AbstractTextChildSVGContext
implements SVGContext {
/** Bridge Context */
@@ -1831,7 +1832,7 @@
}
public SVGTextElementBridge getTextBridge() { return textBridge; }
-
+
/**
* Returns the size of a px CSS unit in millimeters.
*/
@@ -1846,7 +1847,7 @@
*/
public float getPixelToMM() {
return getPixelUnitToMillimeter();
-
+
}
/**
* Returns the tight bounding box in current user space (i.e.,
@@ -1905,7 +1906,7 @@
public float getViewportWidth() {
return ctx.getBlockWidth(e);
}
-
+
/**
* Returns the height of the viewport which directly contains the
* given element.
@@ -1913,7 +1914,7 @@
public float getViewportHeight() {
return ctx.getBlockHeight(e);
}
-
+
/**
* Returns the font-size on the associated element.
*/
@@ -1933,13 +1934,13 @@
* <code>SVGTextElementBridge</code> which can determine
* the impact of a change of one of its children for the others.
*/
- protected abstract class AbstractTextChildBridgeUpdateHandler
+ protected abstract class AbstractTextChildBridgeUpdateHandler
extends AbstractTextChildSVGContext implements BridgeUpdateHandler {
/**
* Initialize the BridgeUpdateHandler implementation.
*/
- public AbstractTextChildBridgeUpdateHandler
+ protected AbstractTextChildBridgeUpdateHandler
(BridgeContext ctx,
SVGTextElementBridge parent,
Element e) {
@@ -1969,7 +1970,7 @@
}
/**
- * Invoked when an MutationEvent of type 'DOMCharacterDataModified'
+ * Invoked when an MutationEvent of type 'DOMCharacterDataModified'
* is fired.
*/
public void handleDOMCharacterDataModified(MutationEvent evt) {
@@ -1992,14 +1993,14 @@
}
}
- protected class AbstractTextChildTextContent
+ protected class AbstractTextChildTextContent
extends AbstractTextChildBridgeUpdateHandler
implements SVGTextContent{
/**
* Initialize the AbstractTextChildBridgeUpdateHandler implementation.
*/
- public AbstractTextChildTextContent
+ protected AbstractTextChildTextContent
(BridgeContext ctx,
SVGTextElementBridge parent,
Element e) {
@@ -2012,7 +2013,7 @@
public int getNumberOfChars(){
return textBridge.getNumberOfChars(e);
}
-
+
public Rectangle2D getExtentOfChar(int charnum ){
return textBridge.getExtentOfChar(e,charnum);
}
@@ -2036,7 +2037,7 @@
public float getComputedTextLength(){
return textBridge.getComputedTextLength(e);
}
-
+
public float getSubStringLength(int charnum, int nchars){
return textBridge.getSubStringLength(e,charnum,nchars);
}
@@ -2049,17 +2050,17 @@
/**
* BridgeUpdateHandle for <tref> element.
*/
- protected class TRefBridge
+ protected class TRefBridge
extends AbstractTextChildTextContent {
- public TRefBridge(BridgeContext ctx,
+ protected TRefBridge(BridgeContext ctx,
SVGTextElementBridge parent,
Element e) {
super(ctx,parent,e);
}
/**
- * Handle the dynamic update for the attributes of
+ * Handle the dynamic update for the attributes of
* <tspan> : 'x', 'y', 'dx', 'dy' and 'rotate'.
*/
public void handleDOMAttrModifiedEvent(MutationEvent evt){
@@ -2070,19 +2071,19 @@
attrName.equals(SVG_DY_ATTRIBUTE) ||
attrName.equals(SVG_ROTATE_ATTRIBUTE)) {
//recompute the layout of the text node
- textBridge.computeLaidoutText(ctx, textBridge.e,
+ textBridge.computeLaidoutText(ctx, textBridge.e,
textBridge.node);
}
- }
+ }
}
/**
* BridgeUpdateHandle for <textPath> element.
*/
- protected class TextPathBridge
+ protected class TextPathBridge
extends AbstractTextChildTextContent{
- public TextPathBridge(BridgeContext ctx,
+ protected TextPathBridge(BridgeContext ctx,
SVGTextElementBridge parent,
Element e){
super(ctx,parent,e);
@@ -2092,17 +2093,17 @@
/**
* BridgeUpdateHandle for <tspan> element.
*/
- protected class TspanBridge
+ protected class TspanBridge
extends AbstractTextChildTextContent {
- public TspanBridge(BridgeContext ctx,
+ protected TspanBridge(BridgeContext ctx,
SVGTextElementBridge parent,
Element e){
super(ctx,parent,e);
}
-
+
/**
- * Handle the dynamic update for the attributes of
+ * Handle the dynamic update for the attributes of
* <tspan> : 'x', 'y', 'dx', 'dy' and 'rotate'.
*/
public void handleDOMAttrModifiedEvent(MutationEvent evt){
@@ -2113,10 +2114,10 @@
attrName.equals(SVG_DY_ATTRIBUTE) ||
attrName.equals(SVG_ROTATE_ATTRIBUTE)) {
//recompute the layout of the text node
- textBridge.computeLaidoutText(ctx, textBridge.e,
+ textBridge.computeLaidoutText(ctx, textBridge.e,
textBridge.node);
}
- }
+ }
}
//Implementation of TextContent
@@ -2135,7 +2136,7 @@
public Point2D getEndPositionOfChar(int charnum){
return getEndPositionOfChar(e,charnum);
}
-
+
public void selectSubString(int charnum, int nchars){
selectSubString(e,charnum,nchars);
}
@@ -2201,7 +2202,7 @@
//find the character 'charnum' in the text run
CharacterInformation info;
info = getCharacterInformation(list, firstChar,charnum, aci);
-
+
if ( info == null )
return null;
@@ -2216,11 +2217,11 @@
b = it.getGlyphOutline(info.glyphIndexStart);
} else {
GeneralPath path = null;
- for( int k = info.glyphIndexStart ;
+ for( int k = info.glyphIndexStart ;
k <= info.glyphIndexEnd;
k++){
if (it.isGlyphVisible(k)) {
- if (path == null)
+ if (path == null)
path = new GeneralPath(it.getGlyphOutline(k));
else
path.append(it.getGlyphOutline(k),false);
@@ -2229,9 +2230,9 @@
b = path;
}
- if (b == null)
+ if (b == null)
return null;
-
+
//return the bounding box of the outline
return b.getBounds2D();
}
@@ -2245,7 +2246,7 @@
AttributedCharacterIterator aci;
aci = ((TextNode)node).getAttributedCharacterIterator();
- if (aci == null)
+ if (aci == null)
return null;
int firstChar = getElementStartIndex(element);
@@ -2261,8 +2262,8 @@
if ( info == null )
return null;
-
- return getStartPoint( info );
+
+ return getStartPoint( info );
}
protected Point2D getStartPoint(CharacterInformation info){
@@ -2309,7 +2310,7 @@
//find the glyph information for the character 'charnum'
CharacterInformation info;
info = getCharacterInformation(list, firstChar,charnum, aci);
-
+
if ( info == null )
return null;
return getEndPoint(info);
@@ -2320,18 +2321,18 @@
GVTGlyphVector it = info.layout.getGlyphVector();
if (!it.isGlyphVisible(info.glyphIndexEnd))
return null;
-
+
Point2D b = it.getGlyphPosition(info.glyphIndexEnd);
-
+
AffineTransform glyphTransform;
glyphTransform = it.getGlyphTransform(info.glyphIndexEnd);
-
+
GVTGlyphMetrics metrics = it.getGlyphMetrics(info.glyphIndexEnd);
-
-
+
+
Point2D.Float result = new Point2D.Float
(metrics.getHorizontalAdvance(), 0);
-
+
if ( glyphTransform != null )
glyphTransform.transform(result,result);
@@ -2362,7 +2363,7 @@
//find the glyph information for the character 'charnum'
CharacterInformation info;
info = getCharacterInformation(list, firstChar,charnum, aci);
-
+
double angle = 0.0;
int nbGlyphs = 0;
@@ -2375,7 +2376,7 @@
if (!it.isGlyphVisible(k)) continue;
nbGlyphs++;
-
+
//the glyph transform contains only a scale and a rotate.
AffineTransform glyphTransform = it.getGlyphTransform(k);
if ( glyphTransform == null ) continue;
@@ -2383,7 +2384,7 @@
double glyphAngle = 0.0;
double cosTheta = glyphTransform.getScaleX();
double sinTheta = glyphTransform.getShearX();
-
+
//extract the angle
if ( cosTheta == 0.0 ){
if ( sinTheta > 0 ) glyphAngle = Math.PI;
@@ -2394,10 +2395,10 @@
glyphAngle += Math.PI;
}
//get a degrees value for the angle
- //SVG angle are clock wise java anticlockwise
-
+ //SVG angle are clock wise java anticlockwise
+
glyphAngle = (Math.toDegrees( - glyphAngle ) ) % 360.0;
-
+
//remove the orientation from the value
angle += glyphAngle - info.getComputedOrientationAngle();
}
@@ -2419,7 +2420,7 @@
* org.w3c.dom.svg.SVGTextContentElement#getSubStringLength(int charnum,int nchars)}.
*/
protected float getSubStringLength(Element element,
- int charnum,
+ int charnum,
int nchars){
if (nchars == 0) {
return 0;
@@ -2474,7 +2475,7 @@
lastCharacterInRunInfo = getCharacterInformation
(list,firstChar,k-1,aci);
- //if the text run change compute the distance between the
+ //if the text run change compute the distance between the
//first character of the run and the last
length += distanceFirstLastCharacterInRun
(currentInfo,lastCharacterInRunInfo);
@@ -2511,9 +2512,9 @@
protected float distanceFirstLastCharacterInRun
(CharacterInformation first, CharacterInformation last){
-
+
float [] advs = first.layout.getGlyphAdvances();
-
+
int firstStart = first.glyphIndexStart;
int firstEnd = first.glyphIndexEnd;
int lastStart = last.glyphIndexStart;
@@ -2526,7 +2527,7 @@
protected float distanceBetweenRun
(CharacterInformation last, CharacterInformation first){
-
+
float distance;
Point2D startPoint;
Point2D endPoint;
@@ -2551,10 +2552,10 @@
else{
distance = (float)(endPoint.getX() - startPoint.getX());
}
-
+
return distance;
}
-
+
/**
* Select an ensemble of characters for that element.
@@ -2581,7 +2582,7 @@
CharacterInformation firstInfo, lastInfo;
firstInfo = getCharacterInformation(list, firstChar,charnum,aci);
lastInfo = getCharacterInformation(list, firstChar,charnum+nchars-1,aci);
-
+
Mark firstMark, lastMark;
firstMark = textNode.getMarkerForChar(firstInfo.characterIndex,true);
@@ -2596,7 +2597,7 @@
}
protected int getCharNumAtPosition(Element e, float x, float y){
-
+
TextNode textNode = (TextNode)node;
AttributedCharacterIterator aci;
aci = textNode.getAttributedCharacterIterator();
@@ -2633,7 +2634,7 @@
}
/**
- * Retrieve the list of layout for the
+ * Retrieve the list of layout for the
* text node.
*/
protected List getTextRuns(TextNode node){
@@ -2651,20 +2652,20 @@
* Retrieve the information about a character
* of en element. The element first character in
* the ACI is 'firstChar' and the character
- * look for is the charnum th character in the
+ * look for is the charnum th character in the
* element
*
* @param list list of the layouts
* @param startIndex index in the ACI of the first
* character for the element
- * @param charnum index of the character (among the
+ * @param charnum index of the character (among the
* characters of the element) looked for.
*
* @return information about the glyph representing the
* character
*/
protected CharacterInformation getCharacterInformation
- (List list,int startIndex, int charnum,
+ (List list,int startIndex, int charnum,
AttributedCharacterIterator aci)
{
CharacterInformation info = new CharacterInformation();
@@ -2678,9 +2679,9 @@
continue;
info.layout = run.getLayout();
-
+
aci.setIndex(info.characterIndex);
-
+
//check is it is a altGlyph
if (aci.getAttribute(ALT_GLYPH_HANDLER) != null){
info.glyphIndexStart = 0;
@@ -2688,7 +2689,7 @@
} else {
info.glyphIndexStart = info.layout.getGlyphIndex
(info.characterIndex);
-
+
//special case when the glyph does not have a unicode
//associated to it, it will return -1
if ( info.glyphIndexStart == -1 ){
@@ -2802,7 +2803,7 @@
reject.add(elem);
continue;
}
-
+
Rectangle2D glBounds = layout.getBounds2D();
if (glBounds != null)
glBounds = at.createTransformedShape
@@ -2825,12 +2826,12 @@
Rectangle2D rect,
boolean checkSensitivity) {
SVGContext svgCtx = null;
- if (elem instanceof SVGOMElement)
+ if (elem instanceof SVGOMElement)
svgCtx = ((SVGOMElement)elem).getSVGContext();
if (svgCtx == null) return false;
SVGTextElementBridge txtBridge = null;
- if (svgCtx instanceof SVGTextElementBridge)
+ if (svgCtx instanceof SVGTextElementBridge)
txtBridge = (SVGTextElementBridge)svgCtx;
else if (svgCtx instanceof AbstractTextChildSVGContext) {
AbstractTextChildSVGContext childCtx;
@@ -2841,7 +2842,7 @@
TextNode tn = (TextNode)txtBridge.node;
List list = tn.getTextRuns();
- if (list == null)
+ if (list == null)
return false;
Element txtElem = txtBridge.e;
@@ -2879,7 +2880,7 @@
if (glBounds == null) continue;
glBounds = at.createTransformedShape(glBounds).getBounds2D();
if (!rect.intersects(glBounds)) continue;
-
+
GVTGlyphVector gv = layout.getGlyphVector();
for (int g = 0; g < gv.getNumGlyphs(); g++) {
Shape gBounds = gv.getGlyphLogicalBounds(g);
@@ -2897,12 +2898,12 @@
public static Rectangle2D getTextBounds(BridgeContext ctx, Element elem,
boolean checkSensitivity) {
SVGContext svgCtx = null;
- if (elem instanceof SVGOMElement)
+ if (elem instanceof SVGOMElement)
svgCtx = ((SVGOMElement)elem).getSVGContext();
if (svgCtx == null) return null;
SVGTextElementBridge txtBridge = null;
- if (svgCtx instanceof SVGTextElementBridge)
+ if (svgCtx instanceof SVGTextElementBridge)
txtBridge = (SVGTextElementBridge)svgCtx;
else if (svgCtx instanceof AbstractTextChildSVGContext) {
AbstractTextChildSVGContext childCtx;
@@ -2913,7 +2914,7 @@
TextNode tn = (TextNode)txtBridge.node;
List list = tn.getTextRuns();
- if (list == null)
+ if (list == null)
return null;
Element txtElem = txtBridge.e;
@@ -2948,18 +2949,18 @@
}
return ret;
}
-
+
public static boolean isTextSensitive(Element e) {
int ptrEvts = CSSUtilities.convertPointerEvents(e);
switch (ptrEvts) {
- case GraphicsNode.VISIBLE_PAINTED:
+ case GraphicsNode.VISIBLE_PAINTED: // fall-through is intended
case GraphicsNode.VISIBLE_FILL:
case GraphicsNode.VISIBLE_STROKE:
case GraphicsNode.VISIBLE:
return CSSUtilities.convertVisibility(e);
case GraphicsNode.PAINTED:
- case GraphicsNode.FILL:
+ case GraphicsNode.FILL: // fall-through is intended
case GraphicsNode.STROKE:
case GraphicsNode.ALL:
return true;
Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java?rev=396119&r1=396118&r2=396119&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java Sat Apr 22 05:56:13 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2002-2003 The Apache Software Foundation
+ Copyright 2002-2003 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@
RGBColor,
SVGICCColor,
SVGNumberList {
-
+
/**
* The associated value.
*/
@@ -126,9 +126,11 @@
*/
public short getColorType() {
Value value = valueProvider.getValue();
- switch (value.getCssValueType()) {
+ int cssValueType = value.getCssValueType();
+ switch ( cssValueType ) {
case CSSValue.CSS_PRIMITIVE_VALUE:
- switch (value.getPrimitiveType()) {
+ int primitiveType = value.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT: {
if (value.getStringValue().equalsIgnoreCase
(CSSConstants.CSS_CURRENTCOLOR_VALUE))
@@ -138,12 +140,14 @@
case CSSPrimitiveValue.CSS_RGBCOLOR:
return SVG_COLORTYPE_RGBCOLOR;
}
- break;
+ // there was no case for this primitiveType, prevent throwing the other exception
+ throw new IllegalStateException("Found unexpected PrimitiveType:" + primitiveType );
case CSSValue.CSS_VALUE_LIST:
return SVG_COLORTYPE_RGBCOLOR_ICCCOLOR;
}
- throw new InternalError();
+ // should not happen
+ throw new IllegalStateException("Found unexpected CssValueType:" + cssValueType );
}
/**
@@ -213,7 +217,7 @@
if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
iccColors = null;
handler.colorChanged(type, rgb, icc);
}
@@ -513,7 +517,7 @@
}
/**
- * To provides the actual value.
+ * To provide the actual value.
*/
public interface ValueProvider {
@@ -565,7 +569,7 @@
*/
void blueFloatValueChanged(short unit, float value)
throws DOMException;
-
+
/**
* Called when the RGBColor text has changed.
*/
@@ -635,24 +639,25 @@
*/
public void redTextChanged(String text) throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
sb.append(text); sb.append(',');
- sb.append(getValue().getGreen().getCssText()); sb.append(',');
- sb.append(getValue().getBlue().getCssText()); sb.append(')');
+ sb.append( value.getGreen().getCssText()); sb.append(',');
+ sb.append( value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
sb.append(text); sb.append(',');
- sb.append(getValue().item(0).getGreen().getCssText());
+ sb.append(value.item(0).getGreen().getCssText());
sb.append(',');
- sb.append(getValue().item(0).getBlue().getCssText());
+ sb.append(value.item(0).getBlue().getCssText());
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
-
+
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
@@ -663,26 +668,27 @@
/**
* Called when the red float value has changed.
*/
- public void redFloatValueChanged(short unit, float value)
+ public void redFloatValueChanged(short unit, float fValue)
throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
- sb.append(FloatValue.getCssText(unit, value)); sb.append(',');
- sb.append(getValue().getGreen().getCssText()); sb.append(',');
- sb.append(getValue().getBlue().getCssText()); sb.append(')');
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
- sb.append(FloatValue.getCssText(unit, value));
+ sb.append(FloatValue.getCssText(unit, fValue));
sb.append(',');
- sb.append(getValue().item(0).getGreen().getCssText());
+ sb.append(value.item(0).getGreen().getCssText());
sb.append(',');
- sb.append(getValue().item(0).getBlue().getCssText());
+ sb.append(value.item(0).getBlue().getCssText());
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
default:
@@ -697,23 +703,24 @@
*/
public void greenTextChanged(String text) throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
- sb.append(getValue().getRed().getCssText()); sb.append(',');
+ sb.append(value.getRed().getCssText()); sb.append(',');
sb.append(text); sb.append(',');
- sb.append(getValue().getBlue().getCssText()); sb.append(')');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
- sb.append(getValue().item(0).getRed().getCssText());
+ sb.append(value.item(0).getRed().getCssText());
sb.append(',');
- sb.append(text);
+ sb.append(text);
sb.append(',');
- sb.append(getValue().item(0).getBlue().getCssText());
+ sb.append(value.item(0).getBlue().getCssText());
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
default:
@@ -726,26 +733,27 @@
/**
* Called when the green float value has changed.
*/
- public void greenFloatValueChanged(short unit, float value)
+ public void greenFloatValueChanged(short unit, float fValue)
throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
- sb.append(getValue().getRed().getCssText()); sb.append(',');
- sb.append(FloatValue.getCssText(unit, value)); sb.append(',');
- sb.append(getValue().getBlue().getCssText()); sb.append(')');
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(',');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
- sb.append(getValue().item(0).getRed().getCssText());
+ sb.append(value.item(0).getRed().getCssText());
sb.append(',');
- sb.append(FloatValue.getCssText(unit, value));
+ sb.append(FloatValue.getCssText(unit, fValue));
sb.append(',');
- sb.append(getValue().item(0).getBlue().getCssText());
+ sb.append(value.item(0).getBlue().getCssText());
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
default:
@@ -760,23 +768,24 @@
*/
public void blueTextChanged(String text) throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
- sb.append(getValue().getRed().getCssText()); sb.append(',');
- sb.append(getValue().getGreen().getCssText()); sb.append(',');
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
sb.append(text); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
- sb.append(getValue().item(0).getRed().getCssText());
+ sb.append(value.item(0).getRed().getCssText());
sb.append(',');
- sb.append(getValue().item(0).getGreen().getCssText());
+ sb.append(value.item(0).getGreen().getCssText());
sb.append(',');
- sb.append(text);
+ sb.append(text);
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
default:
@@ -789,26 +798,27 @@
/**
* Called when the blue float value has changed.
*/
- public void blueFloatValueChanged(short unit, float value)
+ public void blueFloatValueChanged(short unit, float fValue)
throws DOMException {
StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
sb.append("rgb(");
- sb.append(getValue().getRed().getCssText()); sb.append(',');
- sb.append(getValue().getGreen().getCssText()); sb.append(',');
- sb.append(FloatValue.getCssText(unit, value)); sb.append(')');
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
sb.append("rgb(");
- sb.append(getValue().item(0).getRed().getCssText());
+ sb.append(value.item(0).getRed().getCssText());
sb.append(',');
- sb.append(getValue().item(0).getGreen().getCssText());
+ sb.append(value.item(0).getGreen().getCssText());
sb.append(',');
- sb.append(FloatValue.getCssText(unit, value));
+ sb.append(FloatValue.getCssText(unit, fValue));
sb.append(')');
- sb.append(getValue().item(1).getCssText());
+ sb.append(value.item(1).getCssText());
break;
default:
@@ -817,7 +827,7 @@
}
textChanged(sb.toString());
}
-
+
/**
* Called when the RGBColor text has changed.
*/
@@ -844,7 +854,7 @@
throws DOMException {
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- textChanged(rgb + " " + icc);
+ textChanged(rgb + ' ' + icc);
break;
default:
@@ -868,7 +878,7 @@
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- textChanged(rgb + " " + icc);
+ textChanged(rgb + ' ' + icc);
break;
default:
@@ -880,13 +890,14 @@
* Called when the ICC color profile has changed.
*/
public void colorProfileChanged(String cp) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
sb.append(cp);
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
for (int i = 0; i < iccc.getLength(); i++) {
sb.append(',');
sb.append(iccc.getColor(i));
@@ -905,12 +916,13 @@
* Called when the ICC colors has changed.
*/
public void colorsCleared() throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
sb.append(')');
textChanged(sb.toString());
@@ -926,12 +938,13 @@
* Called when the ICC colors has been initialized.
*/
public void colorsInitialized(float f) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
sb.append(',');
sb.append(f);
@@ -949,12 +962,13 @@
* Called when the ICC color has been inserted.
*/
public void colorInsertedBefore(float f, int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
sb.append(',');
@@ -980,12 +994,13 @@
* Called when the ICC color has been replaced.
*/
public void colorReplaced(float f, int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
sb.append(',');
@@ -1011,12 +1026,13 @@
* Called when the ICC color has been removed.
*/
public void colorRemoved(int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
sb.append(',');
@@ -1040,12 +1056,13 @@
* Called when the ICC color has been append.
*/
public void colorAppend(float f) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < iccc.getLength(); i++) {
sb.append(',');
@@ -1113,7 +1130,7 @@
public String getStringValue() throws DOMException {
return valueProvider.getValue().getStringValue();
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSPrimitiveValue#getCounterValue()}.
@@ -1121,7 +1138,7 @@
public Counter getCounterValue() throws DOMException {
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSPrimitiveValue#getRectValue()}.
@@ -1147,7 +1164,7 @@
public int getLength() {
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSValueList#item(int)}.
@@ -1176,7 +1193,7 @@
* To represents a red component.
*/
protected class RedComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/
@@ -1220,7 +1237,7 @@
* To represents a green component.
*/
protected class GreenComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/
@@ -1263,7 +1280,7 @@
* To represents a blue component.
*/
protected class BlueComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/