MASON-INTEREST-L Archives

November 2008

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Wed, 12 Nov 2008 18:30:01 -0500
MIME-version:
1.0
Reply-To:
Content-type:
text/plain; charset=ISO-8859-1; format=flowed
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Content-transfer-encoding:
7bit
Comments:
To: MASON Multiagent Simulation Toolkit <[log in to unmask]>
Parts/Attachments:
text/plain (89 lines)
I'm looking at the code and can't see how this can happen unless the 
grid is larger than the resolution of the drawing area.  MASON uses AWT 
graphics, and so cuts things down to integers.  If you scale down to the 
point that, for example, the width of your sparse grid is less than the 
pixels in your drawing area, some of those cut-downs will be to zero width.


But if this is not the case, then I'm stumped. Here's the relevant code 
(in SparseGridPortrayal2D.java):

newinfo.draw.x = (int)(info.draw.x + (xScale) * loc.x);
newinfo.draw.y = (int)(info.draw.y + (yScale) * loc.y);
newinfo.draw.width = (int)(info.draw.x + (xScale) * (loc.x+1)) - 
newinfo.draw.x;
newinfo.draw.height = (int)(info.draw.y + (yScale) * (loc.y+1)) - 
newinfo.draw.y;

info.draw.x and y are the <x,y> coordinates of the top-left position of 
the drawing area in your window.  loc.x and loc.y are the location of 
the grid item to draw.  They're integers.  xScale and yScale are the 
width or height of the drawing area divided by the maximum extent of the 
grid (field.getWidth() etc.).  They're doubles.

If xScale is a value >= 1.0, then I believe width *must* be a number 
larger than 1.0, and thus cut down to an integer > 1, except for huge 
numbers which your screen resolution can't display anyway.  I think the 
math is right.

Sean

Pelle Evensen wrote:
> Sean Luke wrote:
>> Now that's interesting.  Is the problem just that you're seeing 0 
>> width and 0 height, or that this triggers something which freaks out?
>>
>> In any case, could you create a stack trace when this occurs?
> 
> If it's any help, the width is at most off by one, so if I have scale 1 
> => width = 0.0 or 1.0, scale 16 => width = 15.0 or 16.0. Like I said 
> earlier, this is only for *some* calls to draw. The version of MASON is 
> the CVS version from Monday some time and the JRE is 6_0_7.
> 
> Naughtiness; DrawInfo2D: DrawInfo2D[ Draw: 
> java.awt.geom.Rectangle2D$Double[x=88.0,y=9.0,w=0.0,h=0.0] Clip: 
> java.awt.geom.Rectangle2D$Double[x=0.0,y=0.0,w=500.0,h=400.0]]
> java.lang.Exception: Stack trace
>    at java.lang.Thread.dumpStack(Thread.java:1206)
>    at barterBugs.BasicAgentPortrayal.draw(BasicAgentPortrayal.java:99)
>    at 
> sim.portrayal.grid.SparseGridPortrayal2D.hitOrDraw(SparseGridPortrayal2D.java:229) 
> 
>    at sim.portrayal.FieldPortrayal2D.draw(FieldPortrayal2D.java:55)
>    at 
> sim.display.Display2D$InnerDisplay2D.paintUnbuffered(Display2D.java:513)
>    at sim.display.Display2D$InnerDisplay2D.paint(Display2D.java:395)
>    at 
> sim.display.Display2D$InnerDisplay2D.paintComponent(Display2D.java:328)
>    at 
> sim.display.Display2D$InnerDisplay2D.paintComponent(Display2D.java:304)
>    at javax.swing.JComponent.paint(JComponent.java:1027)
>    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
>    at 
> javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:277) 
> 
>    at javax.swing.RepaintManager.paint(RepaintManager.java:1217)
>    at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
>    at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
>    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)
>    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
>    at 
> javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
>    at 
> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128) 
> 
>    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
>    at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) 
> 
>    at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) 
> 
>    at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) 
> 
>    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
>    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
>    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

ATOM RSS1 RSS2