You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by hi...@apache.org on 2002/09/05 14:58:19 UTC
cvs commit: xml-batik/sources/org/apache/batik/swing/svg JSVGComponent.java SVGUserAgent.java
hillion 2002/09/05 05:58:19
Modified: sources/org/apache/batik/apps/svgbrowser
JSVGViewerFrame.java
sources/org/apache/batik/bridge BridgeContext.java
UserAgent.java UserAgentAdapter.java
sources/org/apache/batik/css/engine CSSContext.java
sources/org/apache/batik/css/engine/value/css2
FontFamilyManager.java
sources/org/apache/batik/swing/svg JSVGComponent.java
SVGUserAgent.java
Log:
Added SVGUserAgent.getDefaultFontFamily().
Revision Changes Path
1.86 +8 -1 xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
Index: JSVGViewerFrame.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- JSVGViewerFrame.java 14 Aug 2002 14:12:21 -0000 1.85
+++ JSVGViewerFrame.java 5 Sep 2002 12:58:18 -0000 1.86
@@ -2238,6 +2238,13 @@
}
+ /**
+ * Returns the default font family.
+ */
+ public String getDefaultFontFamily() {
+ return "Arial, Helvetica, sans-serif";
+ }
+
/**
* Returns the medium font size.
*/
1.52 +14 -1 xml-batik/sources/org/apache/batik/bridge/BridgeContext.java
Index: BridgeContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- BridgeContext.java 31 Jul 2002 16:00:07 -0000 1.51
+++ BridgeContext.java 5 Sep 2002 12:58:18 -0000 1.52
@@ -994,6 +994,19 @@
}
/**
+ * Returns the value corresponding to the default font.
+ */
+ public Value getDefaultFontFamily() {
+ // No cache needed since the default font family is asked only
+ // one time on the root element (only if it does not have its
+ // own font-family).
+ SVGOMDocument doc = (SVGOMDocument)document;
+ String str = userAgent.getDefaultFontFamily();
+ return doc.getCSSEngine().parsePropertyValue
+ (SVGConstants.CSS_FONT_FAMILY_PROPERTY, str);
+ }
+
+ /**
* Returns a lighter font-weight.
*/
public float getLighterFontWeight(float f) {
1.24 +6 -1 xml-batik/sources/org/apache/batik/bridge/UserAgent.java
Index: UserAgent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UserAgent.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- UserAgent.java 13 Jun 2002 11:19:37 -0000 1.23
+++ UserAgent.java 5 Sep 2002 12:58:18 -0000 1.24
@@ -98,6 +98,11 @@
float getBolderFontWeight(float f);
/**
+ * Returns the default font family.
+ */
+ String getDefaultFontFamily();
+
+ /**
* Returns the language settings.
*/
String getLanguages();
1.11 +9 -2 xml-batik/sources/org/apache/batik/bridge/UserAgentAdapter.java
Index: UserAgentAdapter.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UserAgentAdapter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- UserAgentAdapter.java 13 Jun 2002 11:19:37 -0000 1.10
+++ UserAgentAdapter.java 5 Sep 2002 12:58:18 -0000 1.11
@@ -119,11 +119,18 @@
}
+ /**
+ * Returns the default font family.
+ */
+ public String getDefaultFontFamily() {
+ return "Arial, Helvetica, sans-serif";
+ }
+
/**
* Returns the medium font size.
*/
public float getMediumFontSize() {
- // <!> FIXME: Should that 72 be 96?
+ // 9pt (72pt = 1in)
return 9f * 25.4f / (72f * getPixelUnitToMillimeter());
}
1.4 +6 -1 xml-batik/sources/org/apache/batik/css/engine/CSSContext.java
Index: CSSContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CSSContext.java 13 Jun 2002 11:19:38 -0000 1.3
+++ CSSContext.java 5 Sep 2002 12:58:19 -0000 1.4
@@ -29,6 +29,11 @@
Value getSystemColor(String ident);
/**
+ * Returns the value corresponding to the default font-family.
+ */
+ Value getDefaultFontFamily();
+
+ /**
* Returns a lighter font-weight.
*/
float getLighterFontWeight(float f);
1.2 +21 -2 xml-batik/sources/org/apache/batik/css/engine/value/css2/FontFamilyManager.java
Index: FontFamilyManager.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/value/css2/FontFamilyManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FontFamilyManager.java 18 Mar 2002 10:28:23 -0000 1.1
+++ FontFamilyManager.java 5 Sep 2002 12:58:19 -0000 1.2
@@ -8,7 +8,10 @@
package org.apache.batik.css.engine.value.css2;
+import org.apache.batik.css.engine.CSSContext;
import org.apache.batik.css.engine.CSSEngine;
+import org.apache.batik.css.engine.CSSStylableElement;
+import org.apache.batik.css.engine.StyleMap;
import org.apache.batik.css.engine.value.AbstractValueManager;
import org.apache.batik.css.engine.value.ListValue;
@@ -39,7 +42,6 @@
*/
protected final static ListValue DEFAULT_VALUE = new ListValue();
static {
- // !!! TODO: Move it to the context.
DEFAULT_VALUE.append
(new StringValue(CSSPrimitiveValue.CSS_STRING,
"Arial"));
@@ -149,5 +151,22 @@
throw createMalformedLexicalUnitDOMException();
}
}
+ }
+
+ /**
+ * Implements {@link
+ * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
+ */
+ public Value computeValue(CSSStylableElement elt,
+ String pseudo,
+ CSSEngine engine,
+ int idx,
+ StyleMap sm,
+ Value value) {
+ if (value == DEFAULT_VALUE) {
+ CSSContext ctx = engine.getCSSContext();
+ value = ctx.getDefaultFontFamily();
+ }
+ return value;
}
}
1.59 +31 -2 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
Index: JSVGComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- JSVGComponent.java 28 Aug 2002 20:14:51 -0000 1.58
+++ JSVGComponent.java 5 Sep 2002 12:58:19 -0000 1.59
@@ -1743,6 +1743,25 @@
public float getPixelToMM() { return getPixelUnitToMillimeter(); }
+ /**
+ * Returns the default font family.
+ */
+ public String getDefaultFontFamily() {
+ if (EventQueue.isDispatchThread()) {
+ return userAgent.getDefaultFontFamily();
+ } else {
+ class Query implements Runnable {
+ String result;
+ public void run() {
+ result = userAgent.getDefaultFontFamily();
+ }
+ }
+ Query q = new Query();
+ invokeAndWait(q);
+ return q.result;
+ }
+ }
+
public float getMediumFontSize() {
if (EventQueue.isDispatchThread()) {
return userAgent.getMediumFontSize();
@@ -2340,6 +2359,16 @@
*/
public float getPixelToMM() { return getPixelUnitToMillimeter(); }
+ /**
+ * Returns the default font family.
+ */
+ public String getDefaultFontFamily() {
+ if (svgUserAgent != null) {
+ return svgUserAgent.getDefaultFontFamily();
+ }
+ return "Arial, Helvetica, sans-serif";
+ }
+
/**
* Returns the medium font size.
*/
@@ -2347,7 +2376,7 @@
if (svgUserAgent != null) {
return svgUserAgent.getMediumFontSize();
}
- // <!> FIXME: Should that 72 be 96?
+ // 9pt (72pt = 1in)
return 9f * 25.4f / (72f * getPixelUnitToMillimeter());
}
1.12 +6 -1 xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java
Index: SVGUserAgent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SVGUserAgent.java 13 Jun 2002 11:19:38 -0000 1.11
+++ SVGUserAgent.java 5 Sep 2002 12:58:19 -0000 1.12
@@ -72,6 +72,11 @@
*/
float getPixelToMM();
+ /**
+ * Returns the default font family.
+ */
+ String getDefaultFontFamily();
+
/**
* Returns the medium font size.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org