ZoomIn,ZoomOut problem...

Hi. I have following problem:
addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void
stop();
addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOverHandler_0);
function fl_MouseOverHandler_0(event:MouseEvent):void
play();
a.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);
var myTextField:TextField = new TextField();
function fl_MouseOverHandler_2(event:MouseEvent):void
addChild(myTextField);
myTextField.text = "www.xxx.com";
myTextField.x = mouseX-50;
myTextField.y = mouseY-50;
  myTextField.selectable = false;
myTextField.border = true;
myTextField.background = true;
myTextField.autoSize = TextFieldAutoSize.LEFT;
var myFormat:TextFormat = new TextFormat();
myFormat.size = 20;
myTextField.setTextFormat(myFormat);
a.width = 418;
a.height = 160;
a.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage(event:MouseEvent):void
navigateToURL(new URLRequest("http://www.xxx.com"), "_blank");
a.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_a);
function fl_MouseOutHandler_a(event:MouseEvent):void
a.width = 380;
a.height = 150;
removeChild(myTextField);
I have an animation a few elements,they're move to the left and script must stop element on which user move mouse cursor and scale it to bigger size. After take mouse animation must play again with the original size. Almost everything works but when user take cursor image resize to original size and don't want to play . I took only part of script cos next elements have almost the same code. Can someone help me?? thanx for reply

It appears as though your play()/stop() functions have no relationship to the object that you say mousing over should cause things to play()/stop().  Why don't you try placing the play()/Stop() calls inside the object's mouse code instead of the stage?
a.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);
var myTextField:TextField = new TextField();
function fl_MouseOverHandler_2(event:MouseEvent):void
addChild(myTextField);
myTextField.text = "www.xxx.com";
myTextField.x = mouseX-50;
myTextField.y = mouseY-50;
  myTextField.selectable = false;
myTextField.border = true;
myTextField.background = true;
myTextField.autoSize = TextFieldAutoSize.LEFT;
var myFormat:TextFormat = new TextFormat();
myFormat.size = 20;
myTextField.setTextFormat(myFormat);
a.width = 418;
a.height = 160;
stop();
a.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage(event:MouseEvent):void
navigateToURL(new URLRequest("http://www.xxx.com"), "_blank");
a.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_a);
function fl_MouseOutHandler_a(event:MouseEvent):void
play();
a.width = 380;
a.height = 150;
removeChild(myTextField);

Similar Messages

  • Need Code For ZoomIn/ZoomOut Effect

    Dear Friends, I need a small help from you guys... I want to do a simple thing in Flash CS3, but some how i am unable to do it. Actually my requirement was....OnRollOver of a Button I want to slightly zoom it and OnRollOut i want to slightly zoom out the Button.
    And the conditions are I should not use TimeLines/Stage Assets etc. Every thing has to come dynamically. Including the Button creation/ZoomOut/ZoomIn effect etc. and mainly i need it in Flash Cs3/Flash Cs4. I need it little urgent. can you guys pls help me out on this. Rajesh

    Hello dmennenoh ,
    Thank you so much for your reply. i am still unclear with the suggestion made by you.
    can you please give me an example ie what exactly i am looking for.. i need it little urgent... i hope you understood my situation.
    pls pls reply me and give me a solution for this,
    Rajesh

  • Problem: Scalable canvas with affine transformation

    I'm trying to create a canvas that can be scrolled and is scalable through affine transformations. This, I'm trying to achieve by adding a control component to an existing Canvas that listens for MouseEvents and masks the area outside the area defined by the canvas when the control component is created. The base for this component was http://gasi.ch/blog/zooming-in-flash-flex/.
    Next I'm explain how the component is supposed to work and then on to the problem.
    This is how the canvas is created. In the constructor MouseListeners and a mask canvas is added to dragCanvas.
              var canvasControl:MatrixCanvasMouseControl = new MatrixCanvasMouseControl(dragCanvas);
    The listeners work pretty much the same way as in the link I mentioned earlier. So on to the scaling which is the problem.
    The scaling is done by first scaling the dragCanvas with method scaleAt(...):
    /** START OF MOUSE WHEEL LISTENER */
              // CUT
              // get the mouseevent position in stage
              var eventStagePoint:Point = new Point();
                        eventStagePoint.x = event.stageX;
                        eventStagePoint.y = event.stageY;         
              // scale dragCanvas at that point with scaleAt
              scaleAt(canvas, zoomIn, zoomIn, canvas.globalToLocal(eventStagePoint).x, canvas.globalToLocal(eventStagePoint).y);       
              // CUT
    /** END OF MOUSE WHEEL LISTENER  */
             * Scales the matrix through affine transformation.
            public static function scaleAt(sprite:Sprite, scaleX:Number, scaleY:Number, originX:Number, originY:Number):void
                var translateMatrix:Matrix = sprite.transform.matrix;
                // move to origo to preserve form
                translateMatrix.translate(-originX, -originY);
                // scale the matrix
                translateMatrix.scale(scaleX, scaleY);
                // move back to originX, originY
                translateMatrix.translate(originX, originY);
                sprite.transform.matrix = translateMatrix;
    This scales the maskCanvas also. Next I'm trying to scale the maskCanvas back to it's original position by:
              MatrixHelper.scaleAt(maskCanvas, (1 / zoomIn), (1 / zoomIn), maskCanvas.globalToLocal(eventStagePoint).x * (1 / zoomIn), maskCanvas.globalToLocal(eventStagePoint).y * (1 / zoomIn));
    The problem is that when the Canvas is scaled, the mask  changes it's position when I try to scale it back to it's original size and position (as it's size and position changed when dragCanvas was scaled because maskCanvas is a child of dragCanvas).
    This might not be the best way to achieve scrolling. I also thought about extending Canvas and creating a parent Canvas that would contain dragCanvas and maskCanvas as it's children. That way scaling one would not affect the other. The problem with this was that I didn't find a way to do that without overriding Canvas functionality. If anyone knows and could explain how this could be done effectively for example by "decorating" it would be great.
    I would really appreciate if anyone could help me with this. I've struggled with it for quite a few hours already.
    I know I haven't explained everything clearly, so, please, ask me to clarify things more, if this was not understandable.
    Message was edited by: Kimmo Jokinen
    Message was edited by: Kimmo Jokinen

    OK, I found a hacky solution to my problem by going through every rawChildren of the canvas and then scaling it if it's id didn't match with the one I created in the mouseControl component.
    This does not seem like a very elegant way but at least it works.
    I'm pretty sure that this should be done whole differently architecturally but I'm not experienced enough to find that way.
    So this is how I did it.
    for (i = 0; i < canvas.rawChildren.numChildren; i++) {
         child = canvas.rawChildren.getChildAt(i) as Object;
         if (!child is DisplayObject) {
              continue;
         transformAllowed = false;
         displayChild = DisplayObject(child);
         if (displayChild.hasOwnProperty("id") && (displayChild["id"] == "maskCanvas" || displayChild["id"] == "mouseControlArea")) {    
              transformAllowed = false;                                   
         } else {
              transformAllowed = true;
         if (transformAllowed) {
              MatrixHelper.scaleAt(displayChild, zoomOut, zoomOut, canvas.globalToLocal(eventStagePoint).x, canvas.globalToLocal(eventStagePoint).y);

  • Adding ZoomIn functionality to the Gantt menu Items

    Hi
    We have a requirement of adding ZoomIn/ZoomOut as MenuItem in Gantt.
    As ZoomIn/ ZoomOut is an implicit functionality of Gantt.Is there any way to do this?

    You can add a custom menu with zoom-in/zoom-out menu-items to Gantt's menubar. In the action listener of the new menu-item, you can update the scale attribute of the major/minor dvt:timeAxis to the new zoom level, and ppr gantt.
    This approach will not work in the older versions, but should work in the latest production release out on the OTN.

  • ScrollPane problem - scrollbars not updated after child rescaling

    Hi.
    Here is a simple application using a ScrollPane to display a large circle. Initially everything looks fine but when you use zoom in and zoom out buttons ScrollPane doesn't update the scrollbars. Scrollbars are only updated after you try to scroll. Even worse - if you zoom out a couple of times, scrollbars dissapear. If you then zoom in again scrollbars will only reappear if you resize the stage main window.
    Is there something else I should do in addition to rescaling the circle node?
    Thanks for your help.
    package test2;
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ScrollPane;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.transform.Scale;
    import javafx.stage.Stage;
    public class App2 extends Application {
         @Override
         public void start(Stage stage) throws Exception {
              final Scale scale = new Scale(1,1);
              final Circle circle = new Circle(100,100,500, Color.BLUEVIOLET);
              BorderPane border = new BorderPane();
              ScrollPane scroll = new ScrollPane();
              circle.getTransforms().add(scale);
              scroll.setNode(circle);
              Button zoomin = new Button("+");
              Button zoomout = new Button("-");
              zoomin.onActionProperty().set(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(ActionEvent arg0) {
                        scale.setX(scale.getX()*2);
                        scale.setY(scale.getY()*2);
              zoomout.onActionProperty().set(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(ActionEvent arg0) {
                        scale.setX(scale.getX()/2);
                        scale.setY(scale.getY()/2);
              HBox top = new HBox(5);          
              top.getChildren().addAll(zoomin, zoomout);
              border.setTop(top);
              border.setCenter(scroll);
              Scene s = new Scene(border,500,500);
              stage.setScene(s);
              stage.setVisible(true);
        public static void main(String[] args) {
            Application.launch(args);
    }

    Hi,
    see this thread maybe you find something helpful.
    javafx.scene.Group "auto-size" doesn't work in my case

  • JTextField keyEvent consume()

    This question is related to the keyEvent-architecture.
    The JTextField (or any JTextComponent for that matter) is designed to use the keyEvents but NOT consume it. Which means the JTextField modifies its internal Document-model and leaves the keyEvent to propagate further for any body (parent-component etc.) to use it.
    I dont really understand why the design leaves that event to be used by anybody with key-mapping for that keyEvent !?!
    In the specific problem that I have, I am putting JTextField in MainFrame which also has zoomIn/zoomOut Menu-actions attached to Minus(-) and Plus(+) keys respectively.
    What I notice is whenever I type, Minus(-) in JTextField, zoomIn is invoked !!
    Well, I was able to prevent that from happening by attaching a keyListener to my JTextField whose ONLY JOB is to consume() ALL keyevents. (ConsumeAllKeysListener)
    This preety much solves my problem. But I would like to know, is this the correct way to prevent STRAY keyEvent propagation ?
    Also until now, I thought that the JTextField uses InputMap/ActionMap to append all the regular keys that are typed. This assumption is does not seem to be true since even when I consume all the keyEvents by attaching the "ConsumeAllKeysListener" the keys actually end up being typed in the JTextField (although that is what I want).
    But, this behaviour makes me think that JTextField has its Document/model setup as keyListener to itself rather that handling the keyEvent using InputMap/ActionMap. Is this true ?
    Hope I am not confusing the matter !?!
    Thanks in anticipation,
    -sharad

    As mentioned above the correct way to do this is to use a Document to edit any characters as they are typed. The reason for this is that this approach will work whether data is 'typed' or 'pasted' into the text field. Check out this section from the Swing tutorial for more information on Documents and examples:
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation
    I do not recommend using a KeyListener, but here is the reason why it doesn't work.
    Three events are generated every time you type a character into a text field:
    1) key pressed
    2) key typed
    3) key released
    The key typed event seems to be the important event for adding text to the text field so you could add code in the keyTyped(..) method:
    if (e.getKeyChar() == ',')
        e.consume();

  • Inconsistent results for zoom/pan operation:

    We have multiple MapViewer servers to test our application against. When running against one of those machines we get the following error occurring on the client.
    Exception occurred during event dispatching:
    java.lang.ExceptionInInitializerError: java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at oracle.sdovis.CoordArray.getAll(JSDOGeometry.java:2755)
         at oracle.sdovis.ProjAzEd.createBG(ProjAzEd.java:507)
         at oracle.sdovis.ProjAzEd.&lt;clinit&gt;(ProjAzEd.java:63)
         at oracle.lbs.mapclient.MapViewer.getUserPoint(MapViewer.java:1914)
         at oracle.lbs.mapclient.MapViewer.pan(MapViewer.java:1871)
         at com.ups.upi.delegates.BasicMapNavigationDelegate.pan(BasicMapNavigationDelegate.java:84)
         at com.ups.upi.client.BasicMapNavigationController.propertyChange(BasicMapNavigationController.java:237)
         at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
         at com.ups.upi.gui.ImagePanel$ImageMouseListener.mouseClicked(ImagePanel.java:317)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    This error occurs on the client during either a zoomIn, zoomOut or pan operation. However when running against other servers or our locally running MapViewer service then these operations are successful.
    We started seeing this problem after we updated all of our geometries and the associated metadata to an srid of 8307. As part of this we re-built all of our spatial indexes. In addition we disabled caching on the machine with the error as part of some other testing.
    We do not see any errors in the log that could help us debug this problem.
    MapViewer versions:
    SERVER WITH ERROR: Build: Ver9_0_4_B031104
    LOCALLY RUNNING: Build: Ver9_0_4_B030811
    SUCCESSFUL SERVER: Build: Ver9_0_4_B031104
    We re-cycled both servers after updating our geometry data and the results were the same before and after the recycle.
    Any help would be appreciated.
    Derek

    Hi, the cause of the error might be that the mvclient.jar used by your client is not the same version as the server in question. You can check the version of the mvclient.jar by executing the following command:
    jar tvf mvclient.jar
    and it should show a class named like Ver10_1_2_B041013.class, which shows the version number for the jar library.
    Your application should always use the mvclient.jar from the server that you are testing against.
    hope this helps.

  • When I export a MC from flash that has a .png in it, it shows up in all browsers except iPad.

    This is working in safari on Mac and firefox. The image will not load on the Ipad. Any Ideas?
    Here is the code:
    var canvas, stage, exportRoot, offset, zoomIn, zoomOut, image, schematic;
    function init() {
              canvas = document.getElementById("canvas");
              stage = new createjs.Stage(canvas);
              createjs.Touch.enable(stage);
              images = images||{};
              var manifest = [
                        {src:"images/schematic.png", id:"_95Z7FanBrakeHydDiagramColored"}
              var loader = new createjs.PreloadJS(false);
              loader.onFileLoad = handleFileLoad;
              loader.onComplete = handleComplete;
              loader.loadManifest(manifest);
    function handleFileLoad(o) {
              if (o.type == "image") { images[o.id] = o.result; }
    function handleComplete() {
              schematic = new lib.Schematic();
              stage.addChild(schematic);
              createjs.Ticker.setFPS(60);
              createjs.Ticker.addListener(stage);
              zoomIn = new lib.ZoomIn();
              zoomIn.x=10;
              zoomIn.y=10;
              stage.addChild(zoomIn);
              zoomOut = new lib.ZoomOut();
              zoomOut.x=10;
              zoomOut.y=70;
              stage.addChild(zoomOut);
              addListeners();
              stage.update();

    I'm not sure if that is the problem, but when compiling for iOS you have to include external files in the publishing window.
    And maybe that will change the URL you are using too.

  • Continuous MouseDown

    I am trying to develope a custom Numeric Stepper using ZoomIn/ZoomOut images as scroller.
    Now I want to handle continuos MouseDown event. The problem is that the MouseDown event is triggered only once. But, I want a behaviour of MouseDown to be similar of  Flex NumericStepper. The longer we press and hold the scroller, the faster the numbers are increased. I tried using timer which starts on mouseDown and stops on MouseUp. But the problem is that, timer ticks at constant intervals and I cannot achieve the behavious of NumericStepper.
    Can anybody please help me out on this issue.

    On mouseDown, add 3 event listeners: (A) mouseup, (B) rollOut, and (C) enterframe.
    Until the user triggers the (A) mouseup, or (B) rollOut event, you can consider the mousebutton to be down and over the component.  While the button is down you can listen to the enterFrame event firing on each frame, or alternatively, you could use a timer to continously call a function.

  • Display image in full screen canvas

    Hi frndz
    I have an Image, which either bigger in size of a canvas or small
    I want to give an option of a full screen view
    So its a kind of zoomIn/ zoomOut function in one method
    how can I convert such small/big images into full screen canvas size
    thanks
    alpesh

    This question has been asked already several times here: http://onesearch.sun.com/search/onesearch/index.jsp?qt=resizing+image&subCat=siteforumid%3Ajava76&site=dev&dftab=siteforumid%3Ajava76&chooseCat=javaall&col=developer-forums
    There is no method in MIDP which rescales a picture for you, so you have to write it on your on (or use existing code). But usually this would be pretty slow. Mostly it is better to offer different versions of your application for different devices (screen resolutions) where the images have already the appropriate size within your jar-file.

  • Script to Zoom In and Out at specific increments

    I have dabbled with javascript in the past, but I'm a total newb at scripting Photoshop.
    What I need is a script I can use to zoom in at specific intervals and another to zoom out at the same intervals.  I plan to use these two scripts in conjunction with Configurator to make a couple buttons for doing the tasks.
    Example...
    Current zoom is 30%.  The Zoom In Script has a an array of zoom levels: 12.5%, 25%, 50%, 100%, 200%, 300%, 400%.  The script would detect current zoome level and find the next higher zoom level, 50%, and set the window to that new zoom.
    Likewise, Zoom Out would do the same operation selecting the next lower zoom level, 25%.
    This is all in an effort to get back some of the functionality moving from CS5 to CS6.  I used the zoom menu at the top of the screen a LOT to move to preset zoom levels when drawing on my Wacom Cintiq. This Configurator panel would give most of that functionality back.
    Can one of you coding gurus help me with that?  Or at least give me a hint as to how to manipulate zoom percentage in Photoshop using javascript?
    Thanks!!!
    Matt

    This should do it...
    main();
    function main(){
    Use either
    zoomIn();
    zoomOut();
    if(!documents.length) return;
    var zoomLevels=[12.5, 25, 50, 100, 200, 300, 400];
    zoomIn();
    //zoomOut();
    function zoomIn(){
    var zoomLevel = getZoomLevel();
    for(var z in zoomLevels){
        if(Number(zoomLevels[z]) > Number(zoomLevel)){
            setZoomLevel(zoomLevels[z]);
            break;
    function zoomOut(){
    var zoomLevel = getZoomLevel();
    zoomLevels.reverse();
    for(var z in zoomLevels){
        if(Number(zoomLevels[z]) < zoomLevel){
            setZoomLevel(zoomLevels[z]);
            break;
    function getZoomLevel(){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref);
    return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);
    function setZoomLevel( zoom ) {
        if(zoom < 1 ) zoom =1;
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
       var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;
       var docRes = activeDocument.resolution;
       activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );
       var desc = new ActionDescriptor();
       ref = null;
       ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );
       desc.putReference( charIDToTypeID( "null" ), ref );
       executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
       activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );

  • Coordinate of map in identify?

    HI,,,,
    today in my application I use the coordinate of screen in method identify, would like to know if it is possible to use coordinate of map in the method of identify, zoomIn, zoomOut and pan?

    Hi Junior,
    the identify methods use values in screen coordinates. But with the AffineTransformation of the MapResponse class you may be able to handle the map coordinate on your application. You can convert it to screen before calling the identify, zoomIn, and other methods.
    This post may help:
    Re: MapViewer and getScreenCoordinate
    Joao

  • Easy ways to implement Zoom functionality

    Hello,
    I have written a small object orientated graph editor that is made of a custom JPanel and custom JComponents. At the moment, device coordinates and user coordinates are the same, - they correspond. Drawing is done via Graphics2D objects.
    Is there an easy way to implement a zoom functionality so that device coordinates and user coordinates remain idetically, by just configuring the device (for example via class GraphicsConfiguration ) - so that MouseEvents and all other coordinates are being calculated and converted automatically (Maybe by changing the devices virtual resolution of 72 dpi to another resolution?)
    Any help appreciated!
    Thanks in advance!
    alex

    You have to do much work to implement this. Here is the main method that I coded to implement zoom. The whole package is just too large to post here.
    * Implements the zoom in, zoom out or zoom functionality according to
    * the string <code>command</code> passed in.
    * @param command     the command string, one of the three: zoomin,
    *     zoomout, zoom
    public void zoom(String command) {        
         if(command.equalsIgnoreCase("zoomin")) {
         if(zoomMultiplier+deltZoom > maxZoomMultiplier) return;
              zoomMultiplier = zoomMultiplier+deltZoom;
         } else if(command.equalsIgnoreCase("zoomout")) {
              zoomMultiplier = zoomMultiplier-deltZoom;
              if(zoomMultiplier < minZoomMultiplier)
              zoomMultiplier = minZoomMultiplier;
         } else if(command.equalsIgnoreCase("zoom")) {
              zoomMultiplier = 1.0;
         //Gets the currently visible rectangle's width & height, calculates the new
         //bounds's width & height
         Rectangle rect = getVisibleRect();
         //System.out.println("Contour.zoom getVisibleRect() = "+rect.x+", "+rect.y);
         int newW = (int)((double)rect.width* zoomMultiplier);
         int newH = (int)((double)rect.height* zoomMultiplier);
         //System.out.println("Contour.zoom setBounds = "+newW+", "+newH);
         * Enlarges the component's bounds here & Graph2D.paint() will
         * use this bounds to redraw the contour.
         setBounds(new Rectangle(0, 0, newW, newH));
         //Focuses the currently contents as much as possible
         this.scrollRectToVisible(rect);
         * Changing the size of a scroll pane's client is a two-step process.
         * First, set the client's preferred size. Then, call revalidate on the
         * client to let the scroll pane know that it should update itself and
         * its scroll bars.
         //Update client's preferred size because the area taken up
         //by the graphics has gotten larger or smaller.
         //this.setPreferredSize(new Dimension(rect.width, rect.height));
         this.setPreferredSize(new Dimension(newW, newH));
         //Let the scroll pane know to update itself and its scrollbars.
    this.revalidate();                     
    Here is some fields used in the method above and the class the method belongs to:
    * The multiplier when the zoom in functionality should be carried out.
    public double zoomMultiplier = 1.0;
    * The increment for each zoom in or out action.
    public double deltZoom = 0.2;
    * The maximum multiplier in zoom in functionality.
    public double maxZoomMultiplier = 20.0;
    * The minimum multiplier in zoom in functionality, and
    * the currently used value is 1.0.
    public double minZoomMultiplier = 1.0;
    * The threshold to pan the contour after the PanTo(move)
    * button or menu item is activated.
    private double deltDistanceToPan = 10.0;
    You have to code your method paint() or other methods carrying out the actual painting carefully to make it work with this method harmoniously. It's a too long story to let you know the details here. If you need more discussion, please email me([email protected] or [email protected]. The former address cannot work recently though I pay for it yearly. The latter address is more stable thought it's a free one. You'd better use it.)
    Hope this can help.

  • Getting incorrect values while using getLineMetrics()

    following e.g. finding x position of word "Adobe flex".
    if container of TextArea is not scaled then its giving
    correct value
    but after doing zoomin/zoomout its giving incorrect value
    Plz help me to figure out this.
    Thanks
    Kaushal
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    private function onClick():void{
    cnvs.scaleX = cnvs.scaleY = 1;
    cnvs.validateNow();
    var obj:TextLineMetrics = ta.getLineMetrics(0);
    lbl.text = "X: " + String(obj.x);
    private function onZoom(val:Number):void{
    cnvs.scaleX = cnvs.scaleY += (0.25 * val);
    ]]>
    </mx:Script>
    <mx:Button x="75" y="285" label="Find X"
    click="onClick()"/>
    <mx:Canvas x="75" y="10" width="382" height="201"
    id="cnvs">
    <mx:TextArea x="4" y="46" color="#000000" id="ta"
    borderStyle="none" textDecoration="underline" text="adobe
    flex"
    fontSize="28" width="361" height="54" textAlign="center"/>
    </mx:Canvas>
    <mx:Button x="75" y="219" label="-"
    click="onZoom(-1)"/>
    <mx:Button x="123" y="219" label="+"
    click="onZoom(1)"/>
    <mx:Label x="159" y="287" text="" fontSize="13"
    fontWeight="bold"
    id="lbl"/>
    </mx:Application>

    Yes number of pages are correct even though the values are different
    If I drilldown these reports for week 04.2008 – 09.2008 by Sales office only – and add the totals in Excel to double check then they are more or less the same.  Then I drilldown by Sales Office, ASM, Week & Sub Trade Channel.  Then export this into excel and add the totals to double check but then I get totally different amounts as to what they are supposed to be.
    Please waiting for help
    Thanks
    S
    Edited by: Shiva on Mar 6, 2008 12:52 PM

  • Problem with drawing in a scrollpane using clipbounds

    Hello
    Setup is a JFrame containing a splitpane with on the left just some config buttons and on the right a scrollpane.
    Inside the scrollpane I want to draw big waveforms.
    This is represented by a long array of 1's and 0's for the Y coordinates.
    On drawing in paintComponents method I allways reconstruct a GeneralPath, based on the Clipbouns returned by the Graphics variable.
    I have to reconstruct the GeneralPath polygon because my data can be millions long. And therefor I have to limit the points that are drawn.
    When I allways reconstruct this GeneralPath, upon scrolling the polygon is shown scrappy, as in the line connecting the points will only be half shown or almost not.
    Resizing the window or just minimize maximize and it is shown ok.
    I do not have this problem when the GeneralPath I construct is only once made upfront and never remade in the paintComponent method.
    But as I need the clipbounds to know which part to construct I need to rebuild this polygon over and over again.
    I have tried to draw it with Line2D.Double but I get almost the same effect, parts of the lines not being drawn ok.
    Below is the code of the Panel inside the ScrollPane responsible for this drawing.
    public class Usr_Test_L extends JPanel
      final static Color bg   = Color.black;
      final static Color fg   = Color.white;
      final static Color wave = Color.red;
      final static Color txt  = Color.green;
      final static Color grid = Color.lightGray;
      private static final BasicStroke SOLID = new BasicStroke(1.0f);
      private static final BasicStroke BOLD  = new BasicStroke(3.0f);
      private double maxX = 0.0;
      private double maxY = 0.0;
      private double gridWidth;
      private double gridHeight;
      private int panelWidth;
      private int panelHeight;
      boolean firstTime = true;
      private double[] xPoints = null;
      private double[] yPoints = null;
      GeneralPath polygon;
      boolean polyOk = false;
      private double waveHeight = 0;
      private boolean gridOn = true;
      private Usr_Test_R scrollPane = null;
      Usr_Test_L(Usr_Test_R scrollPane)
        super(true);
        this.scrollPane = scrollPane;
        buildGui();
      void buildGui()
        setBackground(bg);
        setForeground(fg);
        //Let the user scroll by dragging to outside the window.
        setAutoscrolls(true); //enable synthetic drag events
    //    addMouseMotionListener(this); //handle mouse drags
        repaint();
      private void generateWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        Random r = new Random();
        for ( int i = 0; i < cycles; i++ )
          xPoints[i] = i;
          yPoints[i] = (int)( Math.pow(-1.0,i) ) * ( r.nextInt(2) );
    //      if ( ( i % 10 ) == 0 ) yPoints[i] = height;
    //      else                   yPoints[i] = height + gridHeight;
    //      System.err.println("P"+i+"("+xPoints[i]+","+yPoints[i]+")");
      private void generateSineWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        double j, xval, yval;
        j = 0;
        int i = 0;
        while (i < cycles)
          xval = j;
          yval = Math.sin(j) * 10.0 + 20;
          xPoints[i] = xval;
          yPoints[i] = yval;
          i++;
          j += 0.01;
      public Dimension getPreferredSize()  // <== used because of revalidate, parent scrollpane asks preferredsize ..., so we overruled the method
        return new Dimension(panelWidth, panelHeight);
      public void drawLine(int cycles, int height)
        generateWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void drawSine(int cycles, int height)
        generateSineWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void zoomIn()
        gridWidth  *= 2;
        gridHeight *= 2;
        repaint();
      public void zoomOut()
        gridWidth  /= 2;
        gridHeight /= 2;
        repaint();
      private void initPanel()
        Dimension d = getSize();
        panelWidth = d.width;
        panelHeight = d.height;
        maxX = panelWidth;
        maxY = panelHeight;
        gridWidth  = panelWidth / 8;
        gridHeight = panelHeight / 8;
        scrollPane.getHorBar().setUnitIncrement((int)(gridWidth*3));           // times 2 otherwise no clipbounds are allways too small
        scrollPane.getHorBar().setBlockIncrement((int)(gridWidth*3));
        scrollPane.getVerBar().setUnitIncrement((int)(gridHeight*3));
        scrollPane.getVerBar().setBlockIncrement((int)(gridHeight*3));
      public void grid()
        if ( gridOn ) gridOn = false;
        else          gridOn = true;
      private void drawGrid(Graphics2D g2, Rectangle clip)
        if ( ! gridOn ) return;
        // draw grid
        g2.setPaint(grid);
        // new good grid
        double startX = clip.getX() + ( gridWidth - ( clip.getX() % gridWidth ) );
        double endX   = clip.getX() + clip.getWidth();
        double startY = clip.getY() + ( gridHeight - ( clip.getY() % gridHeight ) );
        double endY   = clip.getY() + clip.getHeight();
        double y = startY;
        while ( startX < endX )
          while ( y < endY )
            g2.draw(new Rectangle2D.Double( startX - 0.5, y - 0.5, 1.0, 1.0 ));
            y += gridHeight;
          y = startY;
          startX += gridWidth;
      private boolean buildPolygon(Rectangle clip)
        if ( xPoints != null && yPoints != null )
          polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,xPoints.length);
        else
          return false;
        double x = xPoints[0] * gridWidth;
        double y = waveHeight;
        polygon.moveTo((float)xPoints[0], (float)yPoints[0]);
        for ( int index = 0; index < xPoints.length; index++ )
          x = xPoints[index] * gridWidth;
          y = waveHeight + ( yPoints[index] * gridHeight );
          if ( x > ( clip.getX() + clip.getWidth() ) ) break;
          if ( y < clip.getY() || y > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( x < clip.getX() || x > ( clip.getX() + clip.getWidth()  ) ) continue;
          polygon.lineTo((float)x, (float)y);
        return true;
      private boolean drawLines(Graphics2D g2, Rectangle clip)
        if ( xPoints == null || yPoints == null ) return false;
        double x1 = xPoints[0] * gridWidth;
        double y1 = waveHeight;
        double x2, y2;
        boolean cont = false;
        for ( int index = 0; index < xPoints.length; index++ )
          x2 = xPoints[index] * gridWidth;
          y2 = waveHeight + ( yPoints[index] * gridHeight );
          if ( x1 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( x2 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( y2 < clip.getY() || y2 > ( clip.getY() + clip.getHeight() ) )
            cont = true;
          if ( x2 < clip.getX() || x2 > ( clip.getX() + clip.getWidth()  ) )
            cont = true;
          if ( ! cont ) g2.draw(new Line2D.Double(x1,y1,x2,y2));
          x1 = x2;
          y1 = y2;
          cont = false;
        return true;
      public void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        if ( firstTime )
          initPanel();
          firstTime = false;
        // get clip bounds
        Rectangle clip = new Rectangle();
        clip = g2.getClipBounds(clip);
        // draw grid
        drawGrid(g2,clip);
        // draw waveform
        g2.setPaint(wave);
        g2.setStroke(SOLID);
        if ( buildPolygon(clip) ) g2.draw(polygon);
    //    if ( polyOk ) g2.draw(polygon);
    //    drawLines(g2,clip);
      }

    I have added a standalone testcase for ease.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.*;
    public class Scrolling {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(new DrawPanel()));
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    class DrawPanel extends JPanel {
        private GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
        private int[] coords;
        public DrawPanel() {
            setBackground(Color.white);
            buildPolygon();
        private void buildPolygon() {
         coords = new int[2000];
            Random r = new Random();
            int height = 80;
            int gridHeight = 10;
            int gridWidth = 10;
         int j = 0;       
            for (int i=0, dir=-1; i<1000; i++, dir=-dir) {
                coords[j++] = i * gridWidth;
                coords[j++] = height + dir*gridHeight*r.nextInt(2);
        private void drawPolygonClipped(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
           polygon.moveTo(0,80);
           for ( int i = 0; i < 2000; i++ )
          if ( coords[i] > ( clip.getX() + clip.getWidth() ) ) break;
          if ( coords[i+1] < clip.getY() || coords[i+1] > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( coords[i] < clip.getX() || coords[i] > ( clip.getX() + clip.getWidth()  ) ) continue;
                polygon.lineTo(coords[i++],coords);
    private void drawPolygon(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
         polygon.moveTo(0,80);
         for ( int i = 0; i < 2000; i++ )
              polygon.lineTo(coords[i++],coords[i]);
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
         Rectangle clip = new Rectangle();
         g.getClipBounds(clip);
         drawPolygonClipped(clip);
         //drawPolygon(clip);
    g2.draw(polygon);
    public Dimension getPreferredSize() {
    return new Dimension(1500,500);

Maybe you are looking for

  • Any solutions for "Export process terminated unexpectedly [11]" problem?

    Hey guys, I'm trying to simply use Quicktime Pro (Version 7.6.6 Build 1632) to enable the "Fast Internet Start" feature of a 640 x 480 video H.264 video. It uses 16-bit Little Endian for audio, if that's of any help. Anyway, like lots of other users

  • Re: NOKIA 7210 Supernova Connectivity Problem

    Hi Can anyone help me regarding My Nokia 7210. Im having prob in playing music files as it is showing the msg of "not enough memory" Seconndly Im unable to connect my phone to pc. i have tried pc suite 7.1 and 6.6. None of them are able to recognize

  • Low image quality when working

    When I am working in Photoshop and zoom out on the image it gets really noisy at quality gets quite low but when you zoom in enough to work it smooths its out get back's to normal quality. I was looking at preferences settings to find the reason but

  • DVD Encore 2.0   my first thoughts

    Having completed my first major project in Encore 2.0 I thought I would share some of my experiences. My project was basically a family album DVD I had been meaning to do for years. The content for this DVD consisted of About 350 scanned photographs

  • RETURNCODE fail in samrtfroms.

    Hi All , i have developed a custom smartform and a custom Pritprogram . while executing form the transaction it is showing the form but in the OUTPUT type it is showing redbutton . in the processinglog it is giving message "Processing routine ENTRY i