[prev in list] [next in list] [prev in thread] [next in thread]
List: icu4j-support
Subject: (1) TextAttributes, (2) Swing, (3) doDrawText - AffineTransform
From: Nick Betteridge <n.betteridge () syntactics ! com>
Date: 2002-11-29 20:59:28
[Download RAW message or body]
Hi
I'm currently trying to integrate richtext into a swing environment and I've hit a \
number of problems, and I'm pretty sure that they are due to my inexperience with \
TextAttributes.
The current distribution has a swingdemo package with which I tried to get an initial \
handle on the code. The swing version also differs from the awt version in that one \
cannot modify the styles. I modified the swingdemo and tried to change the font \
family and size, nothing changed - the font always remained the same and the size \
never changed.
I then wrote a dump method to throw out all of the data from StyledText and I \
discovered that doing an action like :
StyleModifier modifier = \
StyleModifier.createAddModifier(TextAttribute.FAMILY, fontName); \
textPanel.modifyCharacterStyleOnSelection(modifier);
.... will add the modifier to the appropriate stylebuffer, but doing a subsequent
StyleModifier modifier = \
StyleModifier.createAddModifier(TextAttribute.SIZE, new Float(someSize)); \
textPanel.modifyCharacterStyleOnSelection(modifier);
... will cause the original font attribute to disappear, replacing it with the size \
attribute. Does anyone know of a TextAttibute primer I could use to get up to speed \
on this? I still can't work out why the awt version works like a dream and the swing \
version is stubborn (I'm developing on windows xp and sun java 1.4.1)
A final issue I've hit is that I have added a magnification AffineTransform to the \
doDrawText method in TextComponent (DocumentView) in order to scale up the text - my \
property editor needs to deal with text of any size and when the user has set a size \
of 0.25 it's impossible to see in the text area. If I apply a transform of anyting \
but 1.0 to the Graphics2D, nothing is visible in the text area of the frame.
Nevertheless, this is a very nice piece of code.
Very grateful for any input.
Thanks
Nick
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm currently trying to integrate richtext into a
swing environment and I've hit a number of problems, and I'm pretty sure that
they are due to my inexperience with TextAttributes.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The current distribution has a swingdemo package
with which I tried to get an initial handle on the code. The swing version also
differs from the awt version in that one cannot modify the styles. I modified
the swingdemo and tried to change the font family and size, nothing changed -
the font always remained the same and the size never changed.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I then wrote a dump method to throw out all of the
data from StyledText and I discovered that doing an action like
:</FONT></DIV><FONT face=Arial size=2>
<DIV><BR>
StyleModifier modifier = StyleModifier.createAddModifier(TextAttribute.FAMILY,
fontName);<BR>
textPanel.modifyCharacterStyleOnSelection(modifier);</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>.... will add the modifier to the appropriate stylebuffer, but doing a
subsequent </DIV>
<DIV><BR>
StyleModifier modifier = StyleModifier.createAddModifier(TextAttribute.SIZE, new
Float(someSize));<BR>
textPanel.modifyCharacterStyleOnSelection(modifier);</DIV>
<DIV> </DIV>
<DIV>... will cause the original font attribute to disappear, replacing it with
the size attribute. Does anyone know of a TextAttibute primer I could use to get
up to speed on this? I still can't work out why the awt version works like a
dream and the swing version is stubborn (I'm developing on windows xp and sun
java 1.4.1)</DIV>
<DIV> </DIV>
<DIV>A final issue I've hit is that I have added a magnification AffineTransform
to the doDrawText method in TextComponent (DocumentView) in order to scale
up the text - my property editor needs to deal with text of any size and when
the user has set a size of 0.25 it's impossible to see in the text area. If I
apply a transform of anyting but 1.0 to the Graphics2D, nothing is visible in
the text area of the frame.</DIV>
<DIV> </DIV>
<DIV>Nevertheless, this is a very nice piece of code.</DIV>
<DIV> </DIV>
<DIV>Very grateful for any input.</DIV>
<DIV> </DIV>
<DIV>Thanks </DIV>
<DIV> </DIV>
<DIV>Nick</FONT></DIV></BODY></HTML>
_______________________________________________
icu4j-support mailing list
icu4j-support@oss.software.ibm.com
http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu4j-support
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic