From: dadar <iam...@ya...> - 2009-11-01 15:36:12
|
Michael, I have some problem about my function. when I try to getScaleX() i have an error java.lang.NullPointerException I try to make zoom in function right after i set my style. am I wrong about that? or is there any other way to getScaleX?? I change the function where I found in ZoomInTool.java so I don't need to click the mouse to zoom in public void finalizestyle(){ Rule otherRule = createRule(LINE_COLOUR, FILL_COLOUR,false); otherRule.setElseFilter(true); fixfts.rules().add(otherRule); stylefinal.featureTypeStyles().add(fixfts); mapFrame.getMapContext().getLayer(0).setStyle(stylefinal); mapFrame.getMapPane().repaint(); Rectangle paneArea = mapFrame.getMapPane().getVisibleRect(); double scale = mapFrame.getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale * 5; DirectPosition2D corner = new DirectPosition2D( posisix[0] - 0.5d * paneArea.getWidth() / newScale, posisiy[0] + 0.5d * paneArea.getHeight() / newScale); DirectPosition2D mapPos = null; mapPos.x=posisix[0]; mapPos.y=posisiy[0]; Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); mapFrame.getMapPane().setDisplayArea(newMapArea); } Darmawan mbedward wrote: > > Hi Darmawan, > > Really all that happens with the zoom in and zoom out cursor tools is > that they work out the new map bounds (as a ReferencedEnvelope) and > then call JMapPane.setDisplayArea. > > Perhaps the easiest thing for you to do is look at the source code for > ZoomInTool, ZoomOutTool, and their base class AbstractZoomTool. You > can find them all here... > > http://svn.osgeo.org/geotools/tags/2.6.0/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/ > > When using ZoomInTool you can draw a box on the map pane with the > mouse to define the area to zoom in to. The code that draws the box is > part of the JMapPane class so you don't need to implement that > yourself. > > Michael > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > -- View this message in context: http://n2.nabble.com/need-help-for-zoom-function-tp3917169p3927270.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |