|
From: Vos, J. R. <jv...@an...> - 2003-07-16 15:40:47
|
Ok, I understand that, but getSize could be useful if you wanted to find =
out how much area the TextDisplay was covering. For instance, if you =
want to customize the TextDisplay to have a certain background color, =
you could draw a rectangle underneath the TextDisplay the size of the =
TextDisplay's box. This could be done in a subclass's drawDisplay, after =
the TextDisplay.drawDisplay. I'm not sure if this made anymore sense so =
for instance:
TextDisplay td =3D new TextDisplay(0, 0, Color.black) {
public void drawDisplay(SimGraphics g) {
super.drawDisplay(g);
=09
Graphics2D graphics =3D g.getGraphics();
graphics.setColor(textDisplayBackgroundColor);
Dimension borderRectangleSize =3D getSize();
graphics.fillRect(
getX(),=20
getY(),=20
borderRectangleSize.getWidth(),
borderRectangleSize.getHeight());
}
};
=20
Something like this would draw all the text to the screen, and if =
boxVisible is set to true, the outer border TextDisplay border.
Then (in this code it would probably draw the background rectangle on =
top of the text, so this would need to be reordered, which if a line of =
text was added in between refreshes would cause the background to be a =
refresh behind, but....) would draw a background rectangle the same size =
as the TextDisplay.=20
I hope that is clearer, if not I would be glad to rephrase the question.
I would think all this would require is a=20
this.height =3D height;
this.width =3D width;
at the end of TextDisplay.drawDisplay
Thanks
Jerry Vos
ANL
-----Original Message-----
From: Nick Collier [mailto:nic...@ve...]=20
Sent: Wednesday, July 16, 2003 9:38 AM
To: Vos, Jerry R.
Cc: repast-developer
Subject: Re: [Repast-developer] TextDisplay height/width
I'm not absolutely sure I understand your question, but getSize()
returns the size of the display window itself, not the actual visible
box around the text you are displaying. The size of the display is used
to coordinate with the DisplaySurface and other displays, I think.
getSize() fulfills part of the requirements of the Displayable
interface. In the case, of TextDisplay, getSize() doesn't make as much
sense as it does in the case of a grid display, but it needs be there.
Nick
On Wed, 2003-07-16 at 10:20, Vos, Jerry R. wrote:
> The TextDisplay has getSize() which would seem to be the function to
> get the displayed size of the display (specifically I would think of
> the box around it), the getSize returns the height and width field.=20
> Is there a reason that the TextDisplay has the height and width field,
> but when drawDisplay runs it creates its own height and width
> variables and never stores those into the actual display?
>=20
> I would imagine this would be so that you can set custom box sizes,
> but it doesn=FFt appear to me that drawDisplay ever references the two
> fields, even indirectly.
>=20
> =20
>=20
> Jerry Vos
> ANL
--=20
Nick Collier <nic...@ve...>
|