Re: [JAVA2D] Using GlyphVectors

2006-06-16 Thread Chris Nokleberg
On Sat, Jun 17, 2006 at 12:46:17AM +0100, Peter B. West wrote:
> This is the fly in the ointment. It seems to me that this limitation is
> recognized as being serious in the Java2D "white paper".  The exit path
> offered is GlyphVectors. They are adjustable, where TextLayouts are
> immutable.

Not sure how helpful this is, but you can "extract" the GlyphVectors
from a TextLayout by drawing it onto a "proxy" Graphics2D which serves
only to capture or modify the GlyphVectors as they come in. I've had to
do this in order to customize the TextLayout rendering, for example to
support shadowed and embossed text.

You have to be a little careful because the implementation of TextLayout
may vary platform to platform. For example the Apple impl uses
drawString instead of drawGlyphVector.

Chris

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Using GlyphVectors

2006-06-16 Thread Peter B. West

Phil Race wrote:

Peter B. West wrote:


On Thu, 2006-06-15 at 17:24 +0100, Peter B. West wrote:



David,

Thanks for the response.  I did look at LineBreakMeasurer, but in looks
as though the most powerful layout mechanism available is
Font.layoutGlyphVector. The docs say:




its not 'the most powerful'


"Returns a new GlyphVector object, performing full layout of the text if
possible. Full layout is required for complex text, such as Arabic or
Hindi."

It was that flexibility and power I was after. You have to do your own
Bidi which is a complicationg factor, but you get everything else, as
far as I can tell.




as you say it doesn't do Bidi and as David Kavanagh as trying to remember
AttributedString can handle text in multiple fonts (ie suppose you wnat
to style
one word in italics,) and with various stylings (have a word in red or
have it underlined)
AttributedString together with LineBreakMeasurer can handle that. It
will also handle Bidi


I'm using AttributedString as well, with subclasses of
AttributedCharacterIterator.Attribute for hyphenation markers and
character replacement graphics.

Full layout is an expensive process, so I would like to be able to work
off the GlyphVectors I have, if possible, to retrieve the broken lines.







you get most of the same benefit by caching the TextLayout objects that
LineBreakMeasurer
returns. Mostly apps should avoid GlyphVector unless you know you can
make some
simplifying assumptions about the text you will be handling.

So my feeling is you are digging into the guts rather than using the
higher level APIs
that have been designed for this sort of purpose.

I am not sure if you are also wanting to somehow break at hyphens or
have some
special behaviour associated with them. LineBreakMeasurer could also do
that
by telling calling the overload of LBM.nextLayout() that takes offSetLimit.

-phil.


Thanks for the input Phil. Now I'm more confused. I would love to use
LineBreakMeasurer.  However, the best conclusion I could draw from the
documentation available was that it made a few simplifying assumptions
itself.

What does layoutGlyphVector do, if anything, that LineBreakMeasurer and
TextLayout do not. I'm assuming that the full layout of complex scripts,
including kerning, ligatures and context-dependent text shaping are
being performed in both. Is this the case?

If so, that's great. However, "LineBreakMeasurer implements the most
commonly used line-breaking policy: Every word that fits within the
wrapping width is placed on the line. If the first word does not fit,
then all of the characters that fit within the wrapping width are placed
on the line. At least one character is placed on each line."

This is the fly in the ointment. It seems to me that this limitation is
recognized as being serious in the Java2D "white paper".  The exit path
offered is GlyphVectors. They are adjustable, where TextLayouts are
immutable.

I am performing paragraph layout with complex Knuth/Plass style
line-breaking and adjustment. Given this requirement, and the
requirement to support complex scripts, how do you suggest I go about this?

Peter


--
Peter B. West 
Folio 

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


[JAVA2D] loading imageicons fails once and then works

2006-06-16 Thread Thomas Busey
I'm having problems loading images when using JLabels in conjunction with a JViewport. The following code demonstrates the problem. It will create a frame that displays one of two images. The user cycles between the two images by clicking within the frame, so that the second image is effectively a zoom of the first. The first JLabel loads fine, and is the first displayed. The first time the images are cycled (after a user clicks), the second image comes up as invalid. Subsequent cycling results in normal behavior. I've tried utilizing the built in Mediatracker, as well as explicitly setting the JViewport's view to try to explicitly load the second image. It seems like the second image doesn't load the first time, although changing the image loading order doesn't change the behavior; the image that is shown after the click is never valid the first time, but is the second time.I'd appreciate any insights people might have. Below is a complete program that isolates the issue.Thanks,Tom// Begin Code import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Test implements MouseListener { int view = 1; JViewport viewport; /* REPLACE WITH YOUR OWN IMAGES */ String p1 =  "C:/Documents and Settings/dwyatte/Desktop/fingerzoom/Img/ABLF1.jpg"; String p2 =  "C:/Documents and Settings/dwyatte/Desktop/fingerzoom/Img/ABLF2.jpg"; JLabel jl1, jl2; ImageIcon ii1, ii2; JFrame frame; /* creates a frame with two images. cycle between them by clicking within the frame.  * first click will result in an invalid second image, but subsequent clicks result  * in normal behavior */ public Test() {   ii1 = new ImageIcon(p1);   ii2 = new ImageIcon(p2);   jl1 = new JLabel(ii1);   jl2 = new JLabel(ii2);   frame = new JFrame("Test");   frame.setSize(800, 600);   frame.getContentPane().setLayout(new BorderLayout());   viewport = new JViewport();   viewport.setView(jl1);   frame.getContentPane().add(viewport, BorderLayout.CENTER);   frame.addMouseListener(this);   frame.setVisible(true); } public void mouseReleased(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseClicked(MouseEvent e) {   System.out.println("jl1 is " + jl1);   System.out.println();   /* Here, you can see that the size of jl2    * is invalid on the first click */   System.out.println("jl2 is " + jl2);   System.out.println();   if(view == 1) {     viewport.setView(jl2);     movePanel(0,0);     view = 2;   }   else {     viewport.setView(jl1);     movePanel(0,0);     view = 1;   } } public void movePanel(int xmove, int ymove) {   Point pt = new Point(xmove, ymove);  /* getMaxXExtent and getMaxYExtent will systematically   * fail on the first click because jl2's size is invalid */   pt.x = Math.max(0, pt.x);   pt.x = Math.min(getMaxXExtent(), pt.x);   pt.y = Math.max(0, pt.y);   pt.y = Math.min(getMaxYExtent(), pt.y);   viewport.setViewPosition(pt); } /* viewport.getView().getWidth is image width  * viewport.getWidth() is frame width. */ public int getMaxXExtent() {   return viewport.getView().getWidth() - viewport.getWidth(); } public int getMaxYExtent() {   return viewport.getView().getHeight() - viewport.getHeight(); } public static void main(String args[]) {   new Test(); }} Thomas Busey, PhDAssociate ProfessorDepartment of Psychological and Brain SciencesProgram in Cognitive ScienceIndiana University, Bloomington1101 E. 10th StBloomington, IN, 47405(812) 855-4261[EMAIL PROTECTED]www.indiana.edu/~buseyAIM / IChat AV:  [EMAIL PROTECTED] (video feed) ===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Using GlyphVectors

2006-06-16 Thread Phil Race

Peter B. West wrote:


On Thu, 2006-06-15 at 17:24 +0100, Peter B. West wrote:



David,

Thanks for the response.  I did look at LineBreakMeasurer, but in looks
as though the most powerful layout mechanism available is
Font.layoutGlyphVector. The docs say:




its not 'the most powerful'


"Returns a new GlyphVector object, performing full layout of the text if
possible. Full layout is required for complex text, such as Arabic or
Hindi."

It was that flexibility and power I was after. You have to do your own
Bidi which is a complicationg factor, but you get everything else, as
far as I can tell.




as you say it doesn't do Bidi and as David Kavanagh as trying to remember
AttributedString can handle text in multiple fonts (ie suppose you wnat
to style
one word in italics,) and with various stylings (have a word in red or
have it underlined)
AttributedString together with LineBreakMeasurer can handle that. It
will also handle Bidi


I'm using AttributedString as well, with subclasses of
AttributedCharacterIterator.Attribute for hyphenation markers and
character replacement graphics.

Full layout is an expensive process, so I would like to be able to work
off the GlyphVectors I have, if possible, to retrieve the broken lines.







you get most of the same benefit by caching the TextLayout objects that
LineBreakMeasurer
returns. Mostly apps should avoid GlyphVector unless you know you can
make some
simplifying assumptions about the text you will be handling.

So my feeling is you are digging into the guts rather than using the
higher level APIs
that have been designed for this sort of purpose.

I am not sure if you are also wanting to somehow break at hyphens or
have some
special behaviour associated with them. LineBreakMeasurer could also do that
by telling calling the overload of LBM.nextLayout() that takes offSetLimit.

-phil.


This seems to be a silly idea on reflection.  The whole point of doing
complex layout is that it accounts for all sorts of context
dependencies. This would show up most glaringly when hyphenation occurs.
It seems to me now that I may need to perform GlyphVector layout on a
word-by-word basis, and to get separate GlyphVectors or the hyphenated
components of words.

Any other suggestions?

Peter

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".




===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Full Screen Mode on Linux

2006-06-16 Thread Chris Campbell

Hi,

Although the GraphicsDevice docs aren't perfectly clear about this
(we're working on that), you need to be in fullscreen mode first before
you can query whether display mode changing is possible.  If you go into
fullscreen mode and then print the list of available display modes
(GD.getDisplayModes()), does it report more than one?

Also, you can look at your xorg.conf file to figure out what display
modes *should be* available.

I've never heard about GDM preventing display mode changing.  If you can
find any docs on the matter, I'd be interested to know.

Thanks,
Chris

[EMAIL PROTECTED] wrote:

Hi Chris thanks for your quick response.

I have made some progress with my problem since this morning.

It was a rather silly mistake on my behalf. I forgot to change the eclipse JRE 
to 1.6 so it was still running 1.5.

After changing the jre to 1.6 the program enters fullscreen mode without 
problems.

Anyway that was not the only problem.
I was now able to go into fullscreenmode but not change the display mode.

It seems using a login manager(GDM in my case) prevents the program from 
changing the display mode.

If I don't run the GDM and just use $startx to begin my gnome session the java 
program can also change display modes.

There is just one more thing I'm wondering about.
The test program that I run now states that FSEM is possible but it still says 
the displaymode can't be changed,altough it can.
I'm wondering what could be causing it to give a false report?
[Message sent by forum member 'tersius' (tersius)]

http://forums.java.net/jive/thread.jspa?messageID=123986

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Full Screen Mode on Linux

2006-06-16 Thread java2d
Hi Chris thanks for your quick response.

I have made some progress with my problem since this morning.

It was a rather silly mistake on my behalf. I forgot to change the eclipse JRE 
to 1.6 so it was still running 1.5.

After changing the jre to 1.6 the program enters fullscreen mode without 
problems.

Anyway that was not the only problem.
I was now able to go into fullscreenmode but not change the display mode.

It seems using a login manager(GDM in my case) prevents the program from 
changing the display mode.

If I don't run the GDM and just use $startx to begin my gnome session the java 
program can also change display modes.

There is just one more thing I'm wondering about.
The test program that I run now states that FSEM is possible but it still says 
the displaymode can't be changed,altough it can.
I'm wondering what could be causing it to give a false report?
[Message sent by forum member 'tersius' (tersius)]

http://forums.java.net/jive/thread.jspa?messageID=123986

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Full Screen Mode on Linux

2006-06-16 Thread Chris Campbell

Hi there,

Could you post the output of xdpyinfo?

What is the output of:
% ls -l /usr/lib/Xrandr*

What happens if you set the following before running your test:
% export J2D_TRACE_LEVEL=4

Thanks,
Chris


[EMAIL PROTECTED] wrote:

I'm having trouble to get fullscreen working.

When I run
--
public class FSETest {
public static void main(String[] args) {
GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for (int i = 0; i < devices.length; i++) {
GraphicsDevice device = devices[i];
System.out.println("Device " + i + ": ID string=" +
device.getIDstring());
System.out.println("  Available accelerated memory: " +
device.getAvailableAcceleratedMemory());
System.out.println("  Fullscreen supported: " +
device.isFullScreenSupported());
System.out.println("  Display change supported: " +
device.isDisplayChangeSupported());
System.out.println();
}
}
}
-
I get this output.
--
Device 0: ID string=:0.0
  Available accelerated memory: -1
  Fullscreen supported: false
  Display change supported: false
-

I'm running gentoo linux with xorg 7.0 and 
jdk-6-rc-bin-b88-linux-i586-15_jun_2006
[Message sent by forum member 'tersius' (tersius)]

http://forums.java.net/jive/thread.jspa?messageID=123929

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Full Screen Mode on Linux

2006-06-16 Thread java2d
I'm having trouble to get fullscreen working.

When I run
--
public class FSETest {
public static void main(String[] args) {
GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for (int i = 0; i < devices.length; i++) {
GraphicsDevice device = devices[i];
System.out.println("Device " + i + ": ID string=" +
device.getIDstring());
System.out.println("  Available accelerated memory: " +
device.getAvailableAcceleratedMemory());
System.out.println("  Fullscreen supported: " +
device.isFullScreenSupported());
System.out.println("  Display change supported: " +
device.isDisplayChangeSupported());
System.out.println();
}
}
}
-
I get this output.
--
Device 0: ID string=:0.0
  Available accelerated memory: -1
  Fullscreen supported: false
  Display change supported: false
-

I'm running gentoo linux with xorg 7.0 and 
jdk-6-rc-bin-b88-linux-i586-15_jun_2006
[Message sent by forum member 'tersius' (tersius)]

http://forums.java.net/jive/thread.jspa?messageID=123929

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


[JAVA2D] Stacking height of GlyphVectors

2006-06-16 Thread Peter B. West
How do I determine the leading for GlyphVectors stacked in the block
progression direction? Do the logical dimensions include leading, or
must I add it. I don't seem to be able to getLeading() directly from a
GV. I can from a LineMetrics object derived from the same text.

Peter

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Using GlyphVectors

2006-06-16 Thread Peter B. West
On Thu, 2006-06-15 at 17:24 +0100, Peter B. West wrote:
> David,
>
> Thanks for the response.  I did look at LineBreakMeasurer, but in looks
> as though the most powerful layout mechanism available is
> Font.layoutGlyphVector. The docs say:
>
> "Returns a new GlyphVector object, performing full layout of the text if
> possible. Full layout is required for complex text, such as Arabic or
> Hindi."
>
> It was that flexibility and power I was after. You have to do your own
> Bidi which is a complicationg factor, but you get everything else, as
> far as I can tell.
>
> I'm using AttributedString as well, with subclasses of
> AttributedCharacterIterator.Attribute for hyphenation markers and
> character replacement graphics.
>
> Full layout is an expensive process, so I would like to be able to work
> off the GlyphVectors I have, if possible, to retrieve the broken lines.

This seems to be a silly idea on reflection.  The whole point of doing
complex layout is that it accounts for all sorts of context
dependencies. This would show up most glaringly when hyphenation occurs.
It seems to me now that I may need to perform GlyphVector layout on a
word-by-word basis, and to get separate GlyphVectors or the hyphenated
components of words.

Any other suggestions?

Peter

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".