Skip to main content

[JAVA2D] Java 2D Api Graphics by Vincent Hardy

10 replies [Last post]
Anonymous

Reply viewing options

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

----- Original Message -----
From: "Vincent Hardy"

> On Mac OS, it looks like there is a path issue. The DemoRunner code
invokes a script that is not found. I suggest you try to run: runsnippet
ColorTransparency for example and see if that works from the command line.
>
On OS X,

I can manually type in "runsnippet ColorTransparency " and that works fine.
(I copied the new demo.properties file you provided over to the Mac as
well, just in case.) I also added the current directory (ie, './') to the
CLASS_PATH variable in the runsnippet shell script.

However, I still get this error if I try to run the demorunner script and
double-click a demo, such as ColorTransparency:

"Could not start demo : runsnippet: not found".

I wonder, in the DemoRunner class, could it be that you're assuming a
relative path the that file, i.e, 'runsnippet' and not an explicit path such
as "./runsnippet"? If I had the source code for DemoRunner I could check
this myself on OS X.

Rob

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Vincent Hardy

[att1.html]

Rob Ross

Hello again.

On my Mac OS X (10.2.6) the os.name propery has the value "Mac OS X",
with spaces in the name. I've tried adding a line in demos.properties
for both "script.Mac_OS_X=./runsnippet" and "script.Mac OS
X=./runsnippet", but I still can't get the demorunner.sh to launch a
code snippet. I still get the error dialog saying "Could not start demo
: runsippet: not found" with any of the demos I try to run.

Any other ideas?

Thanks,

Rob

I wonder, in the DemoRunner class, could it be that you're assuming a
relative path the that file, i.e, 'runsnippet' and not an explicit path
such
as "./runsnippet"? If I had the source code for DemoRunner I could check
this myself on OS X.
That's correct. What I suggest you do is edit the demos.properties file
and add an entry:

script.=./runsnippet

where should be replaced with what System.getProperty("os.name")
returns on OS X (I do not have an OS X box handy to tell you).

Vincent.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Vincent Hardy

[att1.html]

Andrei Kouznetsov

After some trying (I have WinXP) I found that:

this don't work:

public static void main(String[] args) throws IOException {
Process process = Runtime.getRuntime().exec("runsnippet
HelloRenderingModel");
}

and this works:

public static void main(String[] args) throws IOException {
Process process = Runtime.getRuntime().exec("runsnippet.bat
HelloRenderingModel");
}

glf.jar must be in classpath, and must be in path

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Vincent Hardy

Hi Rob,

The following should fix your problem on XP.

I have attached a file that you should put in the
directory where your have demorunner.bat and add '.' to your classpath
or modify demoRunner.bat to add '.' in the classpath. I have attached
a sample demorunner.bat that does that.

This should take care of the issue on XP. Let me know if it does not work.

On Mac OS, it looks like there is a path issue. The DemoRunner code invokes a script that is not found. I suggest you try to run: runsnippet ColorTransparency for example and see if that works from the command line.

I'll work with Prentice Hall to make the updated versions of the attached files available on the web.

Thanks.
Vincent.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
script.Windows_2000=runsnippet.bat
script.Windows_NT=runsnippet.bat
script.Windows_95=runsnippet.bat
script.Windows_98=runsnippet.bat
script.Windows_Me=runsnippet.bat
script.Windows_XP=runsnippet.bat

All_Demos=Part_I Part_II Part_III

Part_I=Chapter_01 Chapter_02 Chapter_03 Chapter_04 Chapter_05

Chapter_01=HelloRenderingModel

Chapter_02=ShapeRendering SimpleTextRendering SimpleTextLayoutRendering ImageLoad FontAttribute CompositeAttribute AffineTransformAttribute StrokeAttribute PaintAttribute RenderingHintsAttribute ClipAttribute

Chapter_03=ScreenRendering PrinterRendering OffscreenBufferRendering

Chapter_04=ShapeUsage ShapeClasses DukeShapeDemo CMYKSave ImageFilters StyledTextRendering JustifiedTextBlock CustomGlyphLayout

Chapter_05=AffineTransformTypes BasicStrokeControls PaintTypes ColorTransparency TexturePaintControls FontLister FontFlip AlphaCompositeRules ClippingUsage

Part_II=Chapter_06 Chapter_07 Chapter_08 Chapter_09

Chapter_06=HelloLayers

Chapter_07=UsingLayers LayerMarginsUsage AnchorPlacement AdjustedAnchorPlacement AnchorPlacementTransform EiffelFill EiffelStroke EiffelComposite TextLayerControls ImagePlacement HelloLayersReuse CombiningLayers

Chapter_08=UsingCompositionComponent

Chapter_09=GradientPaintExtUsage RadialGradientPaintUsage RadialGradientPaintExtUsage CompositeStrokeUsage ControlStrokeUsage ShapeStrokeUsage WaveStrokeUsage TextStrokeUsage ColorCompositeUsage LightOpUsage1 LightOpUsage2 LightOpUsage3 SpotLightUsage LightOpUsage4 ElevationMapUsage LightOpUsage5 GetSunLightUsage GetSpotLightUsage GetLightRampUsage GetHotSpotLightRampUsage ToneAdjustmentOpUsage WaveTransformUsage BumpTransformUsage

Part_III=Chapter_11 Chapter_12 Chapter_13 Chapter_14 Chapter_15 Chapter_16 Chapter_17

Chapter_11=ImageDropShadowComposition ShadowsComposition ShapeCastShadowComposition TextRecessedShadowComposition

Chapter_12=BacklitGlowMenuComposition BacklitGlowMenuCompositionOff NeonGlowMenuComposition NeonGlowMenuCompositionCold

Chapter_13=LightPaintingComposition

Chapter_14=CircularLayoutComposition TriangularLayoutComposition ShapeLayoutComposition GlyphDecorationComposition

Chapter_15=PostCardComposition

Chapter_16=BarComposition CylinderComposition SphereComposition VolumeComposition

Chapter_17=BrushedMetal RecessedShadow ShadowStandOut GLFWebDemoTwo GLFWebDemoOne TextFlowers SoftFocus SunSet ShapeSplatter LookupParts Lights

AffineTransformAttribute.exec=imageSnippet
AffineTransformTypes.exec=noArguments
AlphaCompositeRules.exec=noArguments
BasicStrokeControls.exec=noArguments
ClipAttribute.exec=noArguments
ClippingUsage.exec=imageSnippet
CMYKSave.exec=cmykSave
CMYKSave.params=vango09CMYK.jpg true
ColorTransparency.exec=colorTransparency
CompositeAttribute.exec=imageSnippet
CustomGlyphLayout.exec=glyphLayoutSnippet
DukeShapeDemo.exec=noArguments
FontAttribute.exec=noArguments
FontFlip.exec=noArguments
FontLister.exec=noArguments
FontTransform.exec=noArguments
HelloRenderingModel.exec=noArguments
ImageFilters.exec=imageSnippet
ImageLoad.exec=imageSnippet
JustifiedTextBlock.exec=textBlock
OffscreenBufferRendering.exec=offscreenSnippet
OffscreenBufferRendering.params=vangoWithBorder.jpg
PaintAttribute.exec=noArguments
PaintTypes.exec=imageSnippet
PrinterRendering.exec=imageSnippet
RenderingHintsAttribute.exec=noArguments
ScreenRendering.exec=imageSnippet
ShapeClasses.exec=noArguments
ShapeRendering.exec=noArguments
ShapeUsage.exec=noArguments
SimpleTextLayoutRendering.exec=noArguments
SimpleTextRendering.exec=noArguments
StrokeAttribute.exec=noArguments
StyledTextRendering.exec=fontSnippet
TexturePaintControls.exec=textureSnippet

rem
rem Part II code samples
rem

rem Chapter 1
HelloLayers.exec=compositionFactory

rem Chapter 2
UsingLayers.exec=textCompositionFactory
LayerMarginsUsage.exec=compositionFactory
AnchorPlacement.exec=anchorPlacement
AdjustedAnchorPlacement.exec=anchorPlacement
AnchorPlacementTransform.exec=anchorPlacement
EiffelFill.exec=noArguments
EiffelStroke.exec=noArguments
EiffelComposite.exec=noArguments
TextLayerControls.exec=textCompositionFactory
ImagePlacement.exec=textCompositionFactory
HelloLayersReuse.exec=compositionFactory
CombiningLayers.exec=textCompositionFactory

rem Chapter 3
UsingCompositionComponent.exec=noArguments

rem Chapter 4
GradientPaintExtUsage.exec=noArguments
RadialGradientPaintUsage.exec=noArguments
RadialGradientPaintExtUsage.exec=noArguments
CompositeStrokeUsage.exec=noArguments
ControlStrokeUsage.exec=noArguments
ShapeStrokeUsage.exec=noArguments
WaveStrokeUsage.exec=noArguments
TextStrokeUsage.exec=noArguments
ColorCompositeUsage.exec=colorCompositeUsage
LightOpUsage1.exec=imageSnippet
LightOpUsage2.exec=imageSnippet
LightOpUsage3.exec=lightOpUsage3
SpotLightUsage.exec=compositionFactory
LightOpUsage4.exec=lightOpUsage4
ElevationMapUsage.exec=textCompositionFactory
LightOpUsage5.exec=lightOpUsage5
GetSunLightUsage.exec=textCompositionFactory
GetSpotLightUsage.exec=textCompositionFactory
GetLightRampUsage.exec=textCompositionFactory
GetHotSpotLightRampUsage.exec=textCompositionFactory
ToneAdjustmentOpUsage.exec=textCompositionFactory
WaveTransformUsage.exec=noArguments
BumpTransformUsage.exec=noArguments

rem
rem Part III code samples
rem

rem Chapter 2
ImageDropShadowComposition.exec=ch2TextCompositionFactory
ShadowsComposition.exec=ch2TextCompositionFactory
ShapeCastShadowComposition.exec=ch2TextCompositionFactory
TextRecessedShadowComposition.exec=ch2TextCompositionFactory

rem Chapter 3
BacklitGlowMenuComposition.exec=ch3TextCompositionFactory
BacklitGlowMenuCompositionOff.exec=ch3TextCompositionFactory
NeonGlowMenuComposition.exec=ch3TextCompositionFactory
NeonGlowMenuCompositionCold.exec=ch3TextCompositionFactory

rem Chapter 4
LightPaintingComposition.exec=ch4TextCompositionFactory

rem Chapter 5
CircularLayoutComposition.exec=ch5TextCompositionFactory
TriangularLayoutComposition.exec=ch5TextCompositionFactory
ShapeLayoutComposition.exec=ch5TextCompositionFactory
GlyphDecorationComposition.exec=ch5TextCompositionFactory

rem Chapter 6
PostCardComposition.exec=ch6TextCompositionFactory

rem Chapter 7
BarComposition.exec=ch7TextCompositionFactory
CylinderComposition.exec=ch7TextCompositionFactory
SphereComposition.exec=ch7TextCompositionFactory
VolumeComposition.exec=ch7TextCompositionFactory

noArguments=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET%

offscreenSnippet=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/vango09.jpg %2%

imageSnippet=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/vango09.jpg

textureSnippet=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/texture.jpg

colorTransparency=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/syberia30.jpg

cmykSave=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.CMYKSave res/misc/cmyk.pf res/images/snippets/vango09.jpg %2% true

fontSnippet=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% serif 30

glyphLayoutSnippet=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% serif CrossWords

textBlock=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.JustifiedTextBlock res/text/apidoc.txt serif 30 500

ch2TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch2/%SNIPPET%.ser.txt

ch3TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch3/%SNIPPET%.ser.txt

ch4TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch4/%SNIPPET%.ser.txt

ch5TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch5/%SNIPPET%.ser.txt

ch6TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch6/%SNIPPET%.ser.txt

ch7TextCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/ch7/%SNIPPET%.ser.txt

textCompositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio res/com/sun/glf/beans/%SNIPPET%.ser.txt

compositionFactory=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.util.CompositionStudio com.sun.glf.snippets.%SNIPPET%

anchorPlacement=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/syberia84.jpg

colorCompositeUsage=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/vango09.jpg 255 0 0

lightOpUsage3=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/vango09.jpg 1.5 res/images/snippets/elevationMap.jpg

lightOpUsage4=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% doNotUseFile 4 res/images/snippets/elevationMap.jpg

lightOpUsage5=java -Dcom.sun.glf.getAllFonts=true com.sun.glf.snippets.%SNIPPET% res/images/snippets/elevationMap.jpg

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
java -classpath .;glf.jar DemoRunner

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Rob Ross

Thanks for the quick response Vincent. I can now get the demos running, at
least on Windows XP.

I wasn't sure where I was supposed to place the "demos.properties" file, as
I couldn't find an existing file with that name. I placed it in the root
directory of the examples folder, at the same level where I copied the new
demorunner.bat file.

So, I am now trying out the various demos as I read through the book. (Great
book btw!) But I have run into a new problem/question with the FontAttribute
example.

I can't seem to get the demo to use the custom fonts as described in the
book or in the sample source code. Here are the fonts being used:
...
Font scriptFont = new Font("French Script MT", Font.PLAIN, 40);
Font funFont = new Font("Curlz MT", Font.PLAIN, 40);
...

But I just get regular plain boring text showing up. The first thing to
point out is there are no font files with these names anywhere in the
example code. In the res/fonts folder, the closest files with these names
are "crl_____.ttf" and "frs_____.ttf". So I don't know if that's a problem,
or if there is some logical mapping that takes the label "Curlz MT" and
knows to use the "crl______.ttf" file for that font.

I have copied all the files in the res/fonts directory to just about
anywhere I could find a font folder. (I started out with the jre/lib/fonts
folder as the readme file instructs, but since that didn't seem to do
anything,even after I rebooted the machine, I have since copied all the
files to my %JAVA_HOME%\jre\lib\fonts folder as well, and that didn't make a
difference.

Am I missing something simple here?

Thanks!

Rob

----- Original Message -----
From: "Vincent Hardy"
To:
Sent: Monday, January 05, 2004 11:37 PM
Subject: Re: [JAVA2D] Java 2D Api Graphics by Vincent Hardy

> Hi Rob,
>
> The following should fix your problem on XP.
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Vincent Hardy

Rob Ross wrote:

>Thanks for the quick response Vincent. I can now get the demos running, at
>least on Windows XP.
>
>
Good.

>I wasn't sure where I was supposed to place the "demos.properties" file, as
>I couldn't find an existing file with that name. I placed it in the root
>directory of the examples folder, at the same level where I copied the new
>demorunner.bat file.
>
>
This is the right place.

>So, I am now trying out the various demos as I read through the book. (Great
>book btw!)
>
Thanks!

>But I have run into a new problem/question with the FontAttribute
>example.
>
>I can't seem to get the demo to use the custom fonts as described in the
>book or in the sample source code. Here are the fonts being used:
>...
> Font scriptFont = new Font("French Script MT", Font.PLAIN, 40);
> Font funFont = new Font("Curlz MT", Font.PLAIN, 40);
>...
>
>But I just get regular plain boring text showing up. The first thing to
>point out is there are no font files with these names anywhere in the
>example code. In the res/fonts folder, the closest files with these names
>are "crl_____.ttf" and "frs_____.ttf". So I don't know if that's a problem,
>or if there is some logical mapping that takes the label "Curlz MT" and
>knows to use the "crl______.ttf" file for that font.
>
>I have copied all the files in the res/fonts directory to just about
>anywhere I could find a font folder. (I started out with the jre/lib/fonts
>folder as the readme file instructs, but since that didn't seem to do
>anything,even after I rebooted the machine, I have since copied all the
>files to my %JAVA_HOME%\jre\lib\fonts folder as well, and that didn't make a
>difference.
>
>Am I missing something simple here?
>
>
I am not sure. The instructions in the readme should work on Mac OS X as
well which means that copying the fonts in /jre/lib/fonts
should be enough to make the fonts visible. One thing you can do is
check the list of available fonts is to run the FontLister demo in Part
I, Chapter 5. Also, is there any chance you would run a different VM
with the 'java' command than when you start demorunner? In that case, it
might be that you copied the fonts in the wrong jre, but that is a wild
guess.

Vincent.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Rob Ross

I just bought this book and can't get the demorunner or scriptrunner java
apps to work on either Mac OS X 10.2.6, or WinXP. Both are running some
version of JDK 1.4 (1.4.2 on windows, 1.4.1 on OS X).

On the Mac, if I double-click the demorunner script file (I've chmod'ed it
to be executable) OR if I manually invoke it via a terminal shell with
"demorunner", I do get the demo browser window to come up, but anything I
try to double click results in an error dialog that states "Could not start
demo : runsnippet: not found".

(I had to place the glf.jar file in the /Library/Java/Extensions directory
to even get this far - including it in the classpath in the demorunner
script wasn't working.).

On Windows XP, if I double-click the demorunner.bat file, I do get the demo
browser window, but double-clicking any actual demo in the tree gives me an
error dialog such as: "Could not start demo: CreateProcess: runsnippet
HelloRenderingModel error=2".

If I had the source code to the Main class object (DemoRunner) I could try
to debug this myself, but the source is NOT included for the demo runner
classes (just for the GLF), and I can't find an updated version on either
the Prentice Hall, java.net, or java.sun.com sites.

One thing that is immediately apparent is that the DemoRunner class is in
the default package, and that's problematic in JDK version 1.3 and greater.
But again, if I had the source code for this class I could figure out what
the problem is.

Any pointers to the source code, or an updated version of the source
code/examples CD for the Java 2D API Graphics book? (It IS, after all, the
'official' Sun Microsystems Press.)

Thanks!

Rob

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Ho Han Keng

Same problems here: JDK1.4.2(with net beans), Fedora Core 1.
I can run Demorunner and then take note of the Chapter demos and then runsnippetit.
i had PATH and CLASSPATH exported previously.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".