Skip to main content

Default font for SGText?

5 replies [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shannon Hickey

Hi Jim,

Nice to see a default font on SGText. Just a question - how did you
arrive at what to use for the default font? In particular, the "Serif"
attribute?

The reason I ask is that in Hans/my GUI library, the default font in the
Font class and the wrapper for SGText is "Default",Plain,12. I chose
this to match what you get with java.awt.Font if you don't specify a
name. Wondering if I should use "Serif" instead.

Thanks!
Shannon

flar@dev.java.net wrote:
> Author: flar
> Date: 2008-02-21 10:36:31+0000
> New Revision: 147
>
> Added:
> trunk/test/bug6664048/
> trunk/test/bug6664048/bug6664048Test.java
> Modified:
> trunk/src/com/sun/scenario/scenegraph/SGText.java
>
> Log:
> Fix 6664048 - No default font for SGText
> plus regression test for all other SGLeaf attributes...
>
> Modified: trunk/src/com/sun/scenario/scenegraph/SGText.java
> Url: https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/src/com/s...
> ==============================================================================
> --- trunk/src/com/sun/scenario/scenegraph/SGText.java (original)
> +++ trunk/src/com/sun/scenario/scenegraph/SGText.java 2008-02-21 10:36:31+0000
> @@ -42,10 +42,11 @@
> * @author Hans Muller
> */
> public class SGText extends SGAbstractShape {
> -
> + private static Font defaultFont = new Font("Serif", Font.PLAIN, 12);
> +
> public enum VAlign { BASELINE, TOP, BOTTOM }
> -
> - private Font font;
> +
> + private Font font = defaultFont;
> private String text;
> private Object antialiasingHint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
> private final Point2D.Float location = new Point2D.Float();
>
> Added: trunk/test/bug6664048/bug6664048Test.java
> Url: https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/test/bug6...
> ==============================================================================
> --- (empty file)
> +++ trunk/test/bug6664048/bug6664048Test.java 2008-02-21 10:36:31+0000
> @@ -0,0 +1,85 @@
> +/*
> + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * - Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + *
> + * - Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in the
> + * documentation and/or other materials provided with the distribution.
> + *
> + * - Neither the name of Sun Microsystems nor the names of its
> + * contributors may be used to endorse or promote products derived
> + * from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
> + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
> + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
> + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
> + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +package bug6664048;
> +
> +import com.sun.scenario.scenegraph.SGAbstractShape;
> +import com.sun.scenario.scenegraph.SGImage;
> +import com.sun.scenario.scenegraph.SGNode;
> +import com.sun.scenario.scenegraph.SGShape;
> +import com.sun.scenario.scenegraph.SGText;
> +import org.junit.Assert;
> +import org.junit.Test;
> +
> +/**
> + * Regression test for
> + * 6664048 - No default font for SGText
> + *
> + * Tests that various rendering attributes of the SGLeaf nodes have
> + * non-null default values.
> + */
> +public class bug6664048Test {
> + @Test(timeout=1000 * 10)
> + public void testSGText() throws Exception {
> + SGText sgt = new SGText();
> + testAbstractShape(sgt);
> + checkNonNull(sgt.getAntialiasingHint(), "antialias hint", sgt);
> + checkNonNull(sgt.getFont(), "font", sgt);
> + checkNonNull(sgt.getLocation(), "location", sgt);
> + checkNonNull(sgt.getVerticalAlignment(), "vertical alignment", sgt);
> + }
> +
> + @Test(timeout=1000 * 10)
> + public void testSGShape() throws Exception {
> + SGShape sgs = new SGShape();
> + testAbstractShape(sgs);
> + checkNonNull(sgs.getAntialiasingHint(), "antialias hint", sgs);
> + }
> +
> + @Test(timeout=1000 * 10)
> + public void testSGImage() throws Exception {
> + SGImage sgi = new SGImage();
> + checkNonNull(sgi.getInterpolationHint(), "interpolation hint", sgi);
> + checkNonNull(sgi.getLocation(), "location", sgi);
> + }
> +
> + private void testAbstractShape(SGAbstractShape sgas) {
> + checkNonNull(sgas.getDrawPaint(), "draw paint", sgas);
> + checkNonNull(sgas.getDrawStroke(), "stroke", sgas);
> + checkNonNull(sgas.getFillPaint(), "fill paint", sgas);
> + checkNonNull(sgas.getMode(), "mode", sgas);
> + }
> +
> + public void checkNonNull(Object o, String attrname, SGNode node) {
> + Assert.assertNotNull("No default for "+attrname+" on "+
> + node.getClass().getName(), o);
> + }
> +}
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: commits-help@scenegraph.dev.java.net
>

--
Shannon Hickey
shannon.hickey@sun.com
Swing Team - Sun Microsystems, Inc.
http://java.sun.com/javase/technologies/desktop

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Jim Graham

Good point - when I added it I had a brief thought that I should bring
this up for discussion, but then I got distracted trying to write a
regression test for all SGLeaf attributes and never got back to that.

Another idea is to instantiate "new Font(null)" since that is defined to
create a font with defaults for all attributes. I haven't checked it to
see what you end up with, but that is about as "default" as you could get.

Another idea would be to somehow match the font that the UI is using -
perhaps instantiate a Swing component and query it for its font?

...jim

Shannon Hickey wrote:
> Hi Jim,
>
> Nice to see a default font on SGText. Just a question - how did you
> arrive at what to use for the default font? In particular, the "Serif"
> attribute?
>
> The reason I ask is that in Hans/my GUI library, the default font in the
> Font class and the wrapper for SGText is "Default",Plain,12. I chose
> this to match what you get with java.awt.Font if you don't specify a
> name. Wondering if I should use "Serif" instead.
>
> Thanks!
> Shannon
>
> flar@dev.java.net wrote:
>> Author: flar
>> Date: 2008-02-21 10:36:31+0000
>> New Revision: 147
>>
>> Added:
>> trunk/test/bug6664048/
>> trunk/test/bug6664048/bug6664048Test.java
>> Modified:
>> trunk/src/com/sun/scenario/scenegraph/SGText.java
>>
>> Log:
>> Fix 6664048 - No default font for SGText
>> plus regression test for all other SGLeaf attributes...
>>
>> Modified: trunk/src/com/sun/scenario/scenegraph/SGText.java
>> Url:
>> https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/src/com/s...
>>
>> ==============================================================================
>>
>> --- trunk/src/com/sun/scenario/scenegraph/SGText.java (original)
>> +++ trunk/src/com/sun/scenario/scenegraph/SGText.java 2008-02-21
>> 10:36:31+0000
>> @@ -42,10 +42,11 @@
>> * @author Hans Muller
>> */
>> public class SGText extends SGAbstractShape {
>> - + private static Font defaultFont = new Font("Serif",
>> Font.PLAIN, 12);
>> +
>> public enum VAlign { BASELINE, TOP, BOTTOM }
>> - - private Font font;
>> +
>> + private Font font = defaultFont;
>> private String text;
>> private Object antialiasingHint =
>> RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
>> private final Point2D.Float location = new Point2D.Float();
>>
>> Added: trunk/test/bug6664048/bug6664048Test.java
>> Url:
>> https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/test/bug6...
>>
>> ==============================================================================
>>
>> --- (empty file)
>> +++ trunk/test/bug6664048/bug6664048Test.java 2008-02-21 10:36:31+0000
>> @@ -0,0 +1,85 @@
>> +/*
>> + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * - Redistributions of source code must retain the above copyright
>> + * notice, this list of conditions and the following disclaimer.
>> + *
>> + * - Redistributions in binary form must reproduce the above copyright
>> + * notice, this list of conditions and the following disclaimer
>> in the
>> + * documentation and/or other materials provided with the
>> distribution.
>> + *
>> + * - Neither the name of Sun Microsystems nor the names of its
>> + * contributors may be used to endorse or promote products derived
>> + * from this software without specific prior written permission.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
>> CONTRIBUTORS "AS
>> + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>> LIMITED TO,
>> + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
>> PARTICULAR
>> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
>> + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>> + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
>> + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
>> + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>> THEORY OF
>> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
>> + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
>> + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + */
>> +
>> +package bug6664048;
>> +
>> +import com.sun.scenario.scenegraph.SGAbstractShape;
>> +import com.sun.scenario.scenegraph.SGImage;
>> +import com.sun.scenario.scenegraph.SGNode;
>> +import com.sun.scenario.scenegraph.SGShape;
>> +import com.sun.scenario.scenegraph.SGText;
>> +import org.junit.Assert;
>> +import org.junit.Test;
>> +
>> +/**
>> + * Regression test for
>> + * 6664048 - No default font for SGText
>> + * + * Tests that various rendering attributes of the SGLeaf nodes have
>> + * non-null default values.
>> + */
>> +public class bug6664048Test {
>> + @Test(timeout=1000 * 10)
>> + public void testSGText() throws Exception {
>> + SGText sgt = new SGText();
>> + testAbstractShape(sgt);
>> + checkNonNull(sgt.getAntialiasingHint(), "antialias hint", sgt);
>> + checkNonNull(sgt.getFont(), "font", sgt);
>> + checkNonNull(sgt.getLocation(), "location", sgt);
>> + checkNonNull(sgt.getVerticalAlignment(), "vertical
>> alignment", sgt);
>> + }
>> +
>> + @Test(timeout=1000 * 10)
>> + public void testSGShape() throws Exception {
>> + SGShape sgs = new SGShape();
>> + testAbstractShape(sgs);
>> + checkNonNull(sgs.getAntialiasingHint(), "antialias hint", sgs);
>> + }
>> +
>> + @Test(timeout=1000 * 10)
>> + public void testSGImage() throws Exception {
>> + SGImage sgi = new SGImage();
>> + checkNonNull(sgi.getInterpolationHint(), "interpolation
>> hint", sgi);
>> + checkNonNull(sgi.getLocation(), "location", sgi);
>> + }
>> +
>> + private void testAbstractShape(SGAbstractShape sgas) {
>> + checkNonNull(sgas.getDrawPaint(), "draw paint", sgas);
>> + checkNonNull(sgas.getDrawStroke(), "stroke", sgas);
>> + checkNonNull(sgas.getFillPaint(), "fill paint", sgas);
>> + checkNonNull(sgas.getMode(), "mode", sgas);
>> + }
>> +
>> + public void checkNonNull(Object o, String attrname, SGNode node) {
>> + Assert.assertNotNull("No default for "+attrname+" on "+
>> + node.getClass().getName(), o);
>> + }
>> +}
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commits-unsubscribe@scenegraph.dev.java.net
>> For additional commands, e-mail: commits-help@scenegraph.dev.java.net
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Shannon Hickey

Jim Graham wrote:
> Good point - when I added it I had a brief thought that I should bring
> this up for discussion, but then I got distracted trying to write a
> regression test for all SGLeaf attributes and never got back to that.

Funny...when I was in SCA I did bring it up for discussion with Hans and
he wanted NO default. So I'm happy to see you put one in.

>
> Another idea is to instantiate "new Font(null)" since that is defined to
> create a font with defaults for all attributes. I haven't checked it to
> see what you end up with, but that is about as "default" as you could get.

So there is no Font(null), but you can pass null for the name, in which
case it uses "Default" for the name. I mimicked this in JavaFX code,
using "Default",Plain,12. Would be great if this, java.awt.Font, and
SGText.defaultFont were consistent.

>
> Another idea would be to somehow match the font that the UI is using -
> perhaps instantiate a Swing component and query it for its font?

Interesting idea. Probably best not to do that in Scenegraph though and
consider it for the JavaFX layer.

Thanks,
Shannon

>
> ...jim
>
> Shannon Hickey wrote:
>> Hi Jim,
>>
>> Nice to see a default font on SGText. Just a question - how did you
>> arrive at what to use for the default font? In particular, the "Serif"
>> attribute?
>>
>> The reason I ask is that in Hans/my GUI library, the default font in
>> the Font class and the wrapper for SGText is "Default",Plain,12. I
>> chose this to match what you get with java.awt.Font if you don't
>> specify a name. Wondering if I should use "Serif" instead.
>>
>> Thanks!
>> Shannon
>>
>> flar@dev.java.net wrote:
>>> Author: flar
>>> Date: 2008-02-21 10:36:31+0000
>>> New Revision: 147
>>>
>>> Added:
>>> trunk/test/bug6664048/
>>> trunk/test/bug6664048/bug6664048Test.java
>>> Modified:
>>> trunk/src/com/sun/scenario/scenegraph/SGText.java
>>>
>>> Log:
>>> Fix 6664048 - No default font for SGText
>>> plus regression test for all other SGLeaf attributes...
>>>
>>> Modified: trunk/src/com/sun/scenario/scenegraph/SGText.java
>>> Url:
>>> https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/src/com/s...
>>>
>>> ==============================================================================
>>>
>>> --- trunk/src/com/sun/scenario/scenegraph/SGText.java (original)
>>> +++ trunk/src/com/sun/scenario/scenegraph/SGText.java 2008-02-21
>>> 10:36:31+0000
>>> @@ -42,10 +42,11 @@
>>> * @author Hans Muller
>>> */
>>> public class SGText extends SGAbstractShape {
>>> - + private static Font defaultFont = new Font("Serif",
>>> Font.PLAIN, 12);
>>> +
>>> public enum VAlign { BASELINE, TOP, BOTTOM }
>>> - - private Font font;
>>> +
>>> + private Font font = defaultFont;
>>> private String text;
>>> private Object antialiasingHint =
>>> RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
>>> private final Point2D.Float location = new Point2D.Float();
>>>
>>> Added: trunk/test/bug6664048/bug6664048Test.java
>>> Url:
>>> https://scenegraph.dev.java.net/source/browse/scenegraph/trunk/test/bug6...
>>>
>>> ==============================================================================
>>>
>>> --- (empty file)
>>> +++ trunk/test/bug6664048/bug6664048Test.java 2008-02-21
>>> 10:36:31+0000
>>> @@ -0,0 +1,85 @@
>>> +/*
>>> + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
>>> + *
>>> + * Redistribution and use in source and binary forms, with or without
>>> + * modification, are permitted provided that the following conditions
>>> + * are met:
>>> + *
>>> + * - Redistributions of source code must retain the above copyright
>>> + * notice, this list of conditions and the following disclaimer.
>>> + *
>>> + * - Redistributions in binary form must reproduce the above
>>> copyright
>>> + * notice, this list of conditions and the following disclaimer
>>> in the
>>> + * documentation and/or other materials provided with the
>>> distribution.
>>> + *
>>> + * - Neither the name of Sun Microsystems nor the names of its
>>> + * contributors may be used to endorse or promote products derived
>>> + * from this software without specific prior written permission.
>>> + *
>>> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
>>> CONTRIBUTORS "AS
>>> + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>>> LIMITED TO,
>>> + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
>>> PARTICULAR
>>> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
>>> + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>>> SPECIAL,
>>> + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
>>> + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
>>> + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>>> THEORY OF
>>> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
>>> + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
>>> + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>> + */
>>> +
>>> +package bug6664048;
>>> +
>>> +import com.sun.scenario.scenegraph.SGAbstractShape;
>>> +import com.sun.scenario.scenegraph.SGImage;
>>> +import com.sun.scenario.scenegraph.SGNode;
>>> +import com.sun.scenario.scenegraph.SGShape;
>>> +import com.sun.scenario.scenegraph.SGText;
>>> +import org.junit.Assert;
>>> +import org.junit.Test;
>>> +
>>> +/**
>>> + * Regression test for
>>> + * 6664048 - No default font for SGText
>>> + * + * Tests that various rendering attributes of the SGLeaf nodes have
>>> + * non-null default values.
>>> + */
>>> +public class bug6664048Test {
>>> + @Test(timeout=1000 * 10)
>>> + public void testSGText() throws Exception {
>>> + SGText sgt = new SGText();
>>> + testAbstractShape(sgt);
>>> + checkNonNull(sgt.getAntialiasingHint(), "antialias hint", sgt);
>>> + checkNonNull(sgt.getFont(), "font", sgt);
>>> + checkNonNull(sgt.getLocation(), "location", sgt);
>>> + checkNonNull(sgt.getVerticalAlignment(), "vertical
>>> alignment", sgt);
>>> + }
>>> +
>>> + @Test(timeout=1000 * 10)
>>> + public void testSGShape() throws Exception {
>>> + SGShape sgs = new SGShape();
>>> + testAbstractShape(sgs);
>>> + checkNonNull(sgs.getAntialiasingHint(), "antialias hint", sgs);
>>> + }
>>> +
>>> + @Test(timeout=1000 * 10)
>>> + public void testSGImage() throws Exception {
>>> + SGImage sgi = new SGImage();
>>> + checkNonNull(sgi.getInterpolationHint(), "interpolation
>>> hint", sgi);
>>> + checkNonNull(sgi.getLocation(), "location", sgi);
>>> + }
>>> +
>>> + private void testAbstractShape(SGAbstractShape sgas) {
>>> + checkNonNull(sgas.getDrawPaint(), "draw paint", sgas);
>>> + checkNonNull(sgas.getDrawStroke(), "stroke", sgas);
>>> + checkNonNull(sgas.getFillPaint(), "fill paint", sgas);
>>> + checkNonNull(sgas.getMode(), "mode", sgas);
>>> + }
>>> +
>>> + public void checkNonNull(Object o, String attrname, SGNode node) {
>>> + Assert.assertNotNull("No default for "+attrname+" on "+
>>> + node.getClass().getName(), o);
>>> + }
>>> +}
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commits-unsubscribe@scenegraph.dev.java.net
>>> For additional commands, e-mail: commits-help@scenegraph.dev.java.net
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

--
Shannon Hickey
shannon.hickey@sun.com
Swing Team - Sun Microsystems, Inc.
http://java.sun.com/javase/technologies/desktop

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Jim Graham

>> Another idea is to instantiate "new Font(null)" since that is defined
>> to create a font with defaults for all attributes. I haven't checked
>> it to see what you end up with, but that is about as "default" as you
>> could get.
>
> So there is no Font(null), but you can pass null for the name, in which
> case it uses "Default" for the name. I mimicked this in JavaFX code,
> using "Default",Plain,12. Would be great if this, java.awt.Font, and
> SGText.defaultFont were consistent.

No Font(null)? I was looking at this:

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Font.html#Font(java.util.Map)

When I use that constructor I get the following font:

java.awt.Font[family=Dialog,name=Default,style=plain,size=12]

>> Another idea would be to somehow match the font that the UI is using -
>> perhaps instantiate a Swing component and query it for its font?
>
> Interesting idea. Probably best not to do that in Scenegraph though and
> consider it for the JavaFX layer.

The JSGPanel that is used to display these graphs is a Swing component
which might suggest some integration of defaults for Scenegraph itself
as well...

...jim

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Shannon Hickey

Jim Graham wrote:
>>> Another idea is to instantiate "new Font(null)" since that is defined
>>> to create a font with defaults for all attributes. I haven't checked
>>> it to see what you end up with, but that is about as "default" as you
>>> could get.
>>
>> So there is no Font(null), but you can pass null for the name, in
>> which case it uses "Default" for the name. I mimicked this in JavaFX
>> code, using "Default",Plain,12. Would be great if this, java.awt.Font,
>> and SGText.defaultFont were consistent.
>
> No Font(null)? I was looking at this:
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Font.html#Font(java.util.Map)
>
>
> When I use that constructor I get the following font:
>
> java.awt.Font[family=Dialog,name=Default,style=plain,size=12]

Whoops - sorry I missed that. And, in fact, it does the same as what you
get with:

new Font(null, Font.PLAIN, 12)

Which is what I'm using in FX. So new Font(null) is perfect then for SGText.

>
>>> Another idea would be to somehow match the font that the UI is using
>>> - perhaps instantiate a Swing component and query it for its font?
>>
>> Interesting idea. Probably best not to do that in Scenegraph though
>> and consider it for the JavaFX layer.
>
> The JSGPanel that is used to display these graphs is a Swing component
> which might suggest some integration of defaults for Scenegraph itself
> as well...

Interesting. Will let you guys discuss this more on the Scenegraph team.

Thanks,
Shannon

>
> ...jim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

--
Shannon Hickey
shannon.hickey@sun.com
Swing Team - Sun Microsystems, Inc.
http://java.sun.com/javase/technologies/desktop

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net