|
From: Nick C. <nic...@ve...> - 2003-07-16 16:26:45
|
Ah. I think I see. TextDisplay contains an inner class Box that contains
the dimensions and the location of the text box. There is also a private
field box of this type. It sounds like it would be enough if this field
was protected and there was a method like getTextBox that returned the
box itself.
Nick
On Wed, 2003-07-16 at 11:02, Vos, Jerry R. wrote:
> 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 = new TextDisplay(0, 0, Color.black) {
> public void drawDisplay(SimGraphics g) {
> super.drawDisplay(g);
>
> Graphics2D graphics = g.getGraphics();
> graphics.setColor(textDisplayBackgroundColor);
> Dimension borderRectangleSize = getSize();
> graphics.fillRect(
> getX(),
> getY(),
> borderRectangleSize.getWidth(),
> borderRectangleSize.getHeight());
> }
> };
>
> 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.
>
> I hope that is clearer, if not I would be glad to rephrase the question.
>
> I would think all this would require is a
> this.height = height;
> this.width = width;
>
> at the end of TextDisplay.drawDisplay
>
> Thanks
> Jerry Vos
> ANL
>
>
> -----Original Message-----
> From: Nick Collier [mailto:nic...@ve...]
> 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.
> > 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?
> >
> > I would imagine this would be so that you can set custom box sizes,
> > but it doesnÿt appear to me that drawDisplay ever references the two
> > fields, even indirectly.
> >
> >
> >
> > Jerry Vos
> > ANL
--
Nick Collier <nic...@ve...>
|