hello everybody, 

i am trying to give a nice look to my window (meaning that i am dealing with 
Layout) but it seems that it's not easily easy!!
from the conversation here bottom mentioned,  i want to use a border layout (or 
any other appropriate layout) to have :

the toolbar (zoomin,zoomout, pan, info,...) on NORTH, 
the mappane in CENTER, 
the LayerTable in WEST CENTER,
and the Status Bar in SOUTH.

just like the default behavior of the JMapFrame with a MapContext.


problem is:

i don't have any idea to get the layer table, and the status bar to use them 
later adding them to the panel to their specific places.
when i use the JMapPane as the content pane of the JMapFrame, i can't apply the 
toolbar buttons to the map anymore!!
when i use another classic JPanel from javax.swing, it appears a bit more good 
but still, like there is no events listeners to JPanel or JMapPanel for the 
zoomin/out or pan buttons.

how do i activate them event listeners??


Date: Mon, 23 May 2011 04:46:57 -0700
From: [email protected]
To: [email protected]
Subject: Re: need to perform zoomin actions



        Hi Robert,


The problem there is that the AffineTransform used by the map pane to

convert from world to screen coordinates is not created until the pane

is actually displayed on screen. I think you'll also find that your

call to getVisibleRect has returned an empty Rectangle.


I'm not sure, but perhaps you are trying to do too much in your own

code when you could let the map pane just do it for you ? If you just

want a particular map area displayed in the centre of the map pane

when it is first displayed you can do this:


ReferencedEnvelope initialArea = new ReferencedEnvelope(minX, maxX,

minY, maxY, myCRS)

mapPane.setDisplayArea(initialArea)


// and later...

mapFrame.setVisible(true);


In this case the map pane will store the envelope and then use it to

calculate the AffineTransforms etc when it is first displayed.


Michael


On 23 May 2011 21:07, robert benjamin shimirwa <[hidden email]> wrote:

>

>  thanks Michael,

>

>  now i'm having this null pointer exception, i don't know where it comes

> from!! it can be a simple thing that i have omitted,or that i can't see

> right now, but as i see the code, it is supposed to work !! :(

>

>

> map = new DefaultMapContext();

> Style rasterStyle = createmapRGBStyle();

> map.addLayer(reader, rasterStyle);

> mapPane = new JMapPane();

> mapPane.setRenderer(new StreamingRenderer());

> mapPane.setMapContext(map);

>

> Rectangle paneArea = mapPane.getVisibleRect();

> DirectPosition2D mapPos = new DirectPosition2D(35.703517777777778,-0.6396);

> here is the exception: ---> double scale =

> mapPane.getWorldToScreenTransform().getScaleX();

> double newScale = scale * 2;

> DirectPosition2D corner = new DirectPosition2D(

> mapPos.getX() - 0.5d * paneArea.getWidth() / newScale,

> mapPos.getY() + 0.5d * paneArea.getHeight() / newScale);

> Envelope2D newMapArea = new Envelope2D();

> newMapArea.setFrameFromCenter(mapPos, corner);

> mapPane.setDisplayArea(newMapArea);

> maframe = new JMapFrame();

> maframe.setContentPane(mapPane);

> maframe.setSize(800, 700);

> maframe.enableToolBar(true);

> maframe.enableLayerTable(true);

> maframe.enableStatusBar(true);

> maframe.setVisible(true);

>

> ________________________________

> Date: Sun, 22 May 2011 20:03:11 -0700

> From: [hidden email]

> To: [hidden email]

> Subject: Re: need to perform zoomin actions

>

> Hello Robert,

>

>> exactly, i was interaction directly with the mapcontext, saw some results,

>> but couldn't do no pan.

>

> You didn't mention panning in your original question :)

>

> If you are trying to alter the display programmatically you will

> almost always interact with JMapPane, not the MapContext instance.

>

>> idea is that from the entire mapcontext, i do some zoom-in on a small

>> specific area just like the zoom-in button from the toolbar does. i just

>> have to specify the coordinates of the position i want to make the zoom.

>

> Yes. So if you have a look at the code for the zoom tool you will see

> that it is just using the JMapPane.setDisplayArea method:

>

> http://svn.osgeo.org/geotools/tags/2.7.1/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/ZoomInTool.java
>

> In particular, if you study the onMouseReleased and onMouseClicked

> methods it should be obvious how to do the same thing in your own

> program. But if you get stuck, please feel free to ask here again.

>

> Michael

>

> ------------------------------------------------------------------------------

> What Every C/C++ and Fortran developer Should Know!

> Read this article and learn how Intel has extended the reach of its

> next-generation tools to help Windows* and Linux* C/C++ and Fortran

> developers boost performance applications - including clusters.

> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________

> Geotools-gt2-users mailing list

> [hidden email]

> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

>

> ________________________________

> If you reply to this email, your message will be added to the discussion

> below:

> http://osgeo-org.1803224.n2.nabble.com/Double-buffering-bufferstrategy-etc-tp6391216p6392928.html
> To start a new topic under geotools-gt2-users, email

> [hidden email]

> To unsubscribe from geotools-gt2-users, click here.

> ------------------------------------------------------------------------------

> What Every C/C++ and Fortran developer Should Know!

> Read this article and learn how Intel has extended the reach of its

> next-generation tools to help Windows* and Linux* C/C++ and Fortran

> developers boost performance applications - including clusters.

> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________

> Geotools-gt2-users mailing list

> [hidden email]

> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

>

------------------------------------------------------------------------------

What Every C/C++ and Fortran developer Should Know!

Read this article and learn how Intel has extended the reach of its 

next-generation tools to help Windows* and Linux* C/C++ and Fortran 

developers boost performance applications - including clusters. 

http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________

Geotools-gt2-users mailing list

[hidden email]

https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

        
        

        

        
        
                If you reply to this email, your message will be added to the 
discussion below:
                
http://osgeo-org.1803224.n2.nabble.com/Double-buffering-bufferstrategy-etc-tp6391216p6394064.html
        
        
                To start a new topic under geotools-gt2-users, email 
[email protected] 

                To unsubscribe from geotools-gt2-users, click here.
                                                  

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Double-buffering-bufferstrategy-etc-tp6391216p6442203.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to